Print this page
rm code review
12259 CTF shouldn't assume enum size

Split Close
Expand all
Collapse all
          --- old/usr/src/common/ctf/ctf_types.c
          +++ new/usr/src/common/ctf/ctf_types.c
↓ open down ↓ 17 lines elided ↑ open up ↑
  18   18   * information: Portions Copyright [yyyy] [name of copyright owner]
  19   19   *
  20   20   * CDDL HEADER END
  21   21   */
  22   22  
  23   23  /*
  24   24   * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
  25   25   * Use is subject to license terms.
  26   26   */
  27   27  /*
  28      - * Copyright 2018 Joyent, Inc.
       28 + * Copyright 2020 Joyent, Inc.
  29   29   */
  30   30  
  31   31  #include <ctf_impl.h>
  32   32  #include <sys/debug.h>
  33   33  
  34   34  ssize_t
  35   35  ctf_get_ctt_size(const ctf_file_t *fp, const ctf_type_t *tp, ssize_t *sizep,
  36   36      ssize_t *incrementp)
  37   37  {
  38   38          ssize_t size, increment;
↓ open down ↓ 8 lines elided ↑ open up ↑
  47   47          }
  48   48  
  49   49          if (sizep)
  50   50                  *sizep = size;
  51   51          if (incrementp)
  52   52                  *incrementp = increment;
  53   53  
  54   54          return (size);
  55   55  }
  56   56  
       57 +void
       58 +ctf_set_ctt_size(ctf_type_t *tp, ssize_t size)
       59 +{
       60 +        if (size > CTF_MAX_SIZE) {
       61 +                tp->ctt_size = CTF_LSIZE_SENT;
       62 +                tp->ctt_lsizehi = CTF_SIZE_TO_LSIZE_HI(size);
       63 +                tp->ctt_lsizelo = CTF_SIZE_TO_LSIZE_LO(size);
       64 +        } else {
       65 +                tp->ctt_size = (ushort_t)size;
       66 +        }
       67 +}
       68 +
  57   69  /*
  58   70   * Iterate over the members of a STRUCT or UNION.  We pass the name, member
  59   71   * type, and offset of each member to the specified callback function.
  60   72   */
  61   73  int
  62   74  ctf_member_iter(ctf_file_t *fp, ctf_id_t type, ctf_member_f *func, void *arg)
  63   75  {
  64   76          ctf_file_t *ofp = fp;
  65   77          const ctf_type_t *tp;
  66   78          ssize_t size, increment;
↓ open down ↓ 407 lines elided ↑ open up ↑
 474  486          case CTF_K_POINTER:
 475  487                  return (fp->ctf_dmodel->ctd_pointer);
 476  488  
 477  489          case CTF_K_FUNCTION:
 478  490                  return (0); /* function size is only known by symtab */
 479  491  
 480  492          case CTF_K_FORWARD:
 481  493                  return (0);
 482  494  
 483  495          case CTF_K_ENUM:
 484      -                return (fp->ctf_dmodel->ctd_int);
      496 +                return (ctf_get_ctt_size(fp, tp, NULL, NULL));
 485  497  
 486  498          case CTF_K_ARRAY:
 487  499                  /*
 488  500                   * Array size is not directly returned by stabs data.  Instead,
 489  501                   * it defines the element type and requires the user to perform
 490  502                   * the multiplication.  If ctf_get_ctt_size() returns zero, the
 491  503                   * current version of ctfconvert does not compute member sizes
 492  504                   * and we compute the size here on its behalf.
 493  505                   */
 494  506                  if ((size = ctf_get_ctt_size(fp, tp, NULL, NULL)) > 0)
↓ open down ↓ 76 lines elided ↑ open up ↑
 571  583                          for (; n != 0; n--, lmp++) {
 572  584                                  ssize_t am = ctf_type_align(fp, lmp->ctlm_type);
 573  585                                  align = MAX(align, am);
 574  586                          }
 575  587                  }
 576  588  
 577  589                  return (align);
 578  590          }
 579  591  
 580  592          case CTF_K_ENUM:
 581      -                return (fp->ctf_dmodel->ctd_int);
 582      -
 583  593          default:
 584  594                  return (ctf_get_ctt_size(fp, tp, NULL, NULL));
 585  595          }
 586  596  }
 587  597  
 588  598  /*
 589  599   * Return the kind (CTF_K_* constant) for the specified type ID.
 590  600   */
 591  601  int
 592  602  ctf_type_kind(ctf_file_t *fp, ctf_id_t type)
↓ open down ↓ 718 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX