Print this page
12259 CTF shouldn't assume enum size

Split Close
Expand all
Collapse all
          --- old/usr/src/lib/libctf/common/ctf_merge.c
          +++ new/usr/src/lib/libctf/common/ctf_merge.c
↓ open down ↓ 2 lines elided ↑ open up ↑
   3    3   * Common Development and Distribution License ("CDDL"), version 1.0.
   4    4   * You may only use this file in accordance with the terms of version
   5    5   * 1.0 of the CDDL.
   6    6   *
   7    7   * A full copy of the text of the CDDL should have accompanied this
   8    8   * source.  A copy of the CDDL is also available via the Internet at
   9    9   * http://www.illumos.org/license/CDDL.
  10   10   */
  11   11  
  12   12  /*
  13      - * Copyright 2019, Joyent, Inc.
       13 + * Copyright 2020 Joyent, Inc.
  14   14   */
  15   15  
  16   16  /*
  17   17   * To perform a merge of two CTF containers, we first diff the two containers
  18   18   * types. For every type that's in the src container, but not in the dst
  19   19   * container, we note it and add it to dst container. If there are any objects
  20   20   * or functions associated with src, we go through and update the types that
  21   21   * they refer to such that they all refer to types in the dst container.
  22   22   *
  23   23   * The bulk of the logic for the merge, after we've run the diff, occurs in
↓ open down ↓ 309 lines elided ↑ open up ↑
 333  333  }
 334  334  
 335  335  static int
 336  336  ctf_merge_add_enum(ctf_merge_types_t *cmp, ctf_id_t id)
 337  337  {
 338  338          int flags;
 339  339          const ctf_type_t *tp;
 340  340          const char *name;
 341  341          ctf_id_t enumid;
 342  342          ctf_merge_enum_t cme;
      343 +        size_t size;
 343  344  
 344  345          tp = LCTF_INDEX_TO_TYPEPTR(cmp->cm_src, id);
 345      -        name = ctf_strraw(cmp->cm_src, tp->ctt_name);
 346  346          if (CTF_INFO_ISROOT(tp->ctt_info) != 0)
 347  347                  flags = CTF_ADD_ROOT;
 348  348          else
 349  349                  flags = CTF_ADD_NONROOT;
 350  350  
 351      -        enumid = ctf_add_enum(cmp->cm_out, flags, name);
      351 +        name = ctf_strraw(cmp->cm_src, tp->ctt_name);
      352 +        size = ctf_get_ctt_size(cmp->cm_src, tp, NULL, NULL);
      353 +
      354 +        enumid = ctf_add_enum(cmp->cm_out, flags, name, size);
 352  355          if (enumid == CTF_ERR)
 353  356                  return (enumid);
 354  357  
 355  358          cme.cme_fp = cmp->cm_out;
 356  359          cme.cme_id = enumid;
 357  360          if (ctf_enum_iter(cmp->cm_src, id, ctf_merge_add_enumerator,
 358  361              &cme) != 0)
 359  362                  return (CTF_ERR);
 360  363  
 361  364          VERIFY(cmp->cm_tmap[id].cmt_map == 0);
↓ open down ↓ 1317 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX