Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/external/cddl/osnet/dist/tools/ctf/cvt - Add processing for ...



details:   https://anonhg.NetBSD.org/src/rev/a14108ba5cb4
branches:  trunk
changeset: 344259:a14108ba5cb4
user:      christos <christos%NetBSD.org@localhost>
date:      Fri Mar 18 14:55:34 2016 +0000

description:
- Add processing for c++ references.
- Make sure we load the DIE that contains the types of array elements so
  we can resolve them later.
- Print t_id (die offsets) in hex.

diffstat:

 external/cddl/osnet/dist/tools/ctf/cvt/ctftools.h |   1 +
 external/cddl/osnet/dist/tools/ctf/cvt/dwarf.c    |  51 ++++++++++++++++++----
 external/cddl/osnet/dist/tools/ctf/cvt/merge.c    |   5 ++
 external/cddl/osnet/dist/tools/ctf/cvt/traverse.c |   2 +
 4 files changed, 49 insertions(+), 10 deletions(-)

diffs (259 lines):

diff -r 984f61b4a31a -r a14108ba5cb4 external/cddl/osnet/dist/tools/ctf/cvt/ctftools.h
--- a/external/cddl/osnet/dist/tools/ctf/cvt/ctftools.h Fri Mar 18 13:23:00 2016 +0000
+++ b/external/cddl/osnet/dist/tools/ctf/cvt/ctftools.h Fri Mar 18 14:55:34 2016 +0000
@@ -137,6 +137,7 @@
        STABTYPE_FIRST, /* do not use */
        INTRINSIC,
        POINTER,
+       REFERENCE,
        ARRAY,
        FUNCTION,
        STRUCT,
diff -r 984f61b4a31a -r a14108ba5cb4 external/cddl/osnet/dist/tools/ctf/cvt/dwarf.c
--- a/external/cddl/osnet/dist/tools/ctf/cvt/dwarf.c    Fri Mar 18 13:23:00 2016 +0000
+++ b/external/cddl/osnet/dist/tools/ctf/cvt/dwarf.c    Fri Mar 18 14:55:34 2016 +0000
@@ -181,6 +181,7 @@
                switch (tdp->t_type) {
                case INTRINSIC:
                case POINTER:
+               case REFERENCE:
                case ARRAY:
                case FUNCTION:
                case STRUCT:
@@ -189,6 +190,7 @@
                        return (tdp->t_size);
 
                case FORWARD:
+                       debug(3, "type is forward for %#x\n", tdp->t_id);
                        return (0);
 
                case TYPEDEF:
@@ -199,10 +201,11 @@
                        continue;
 
                case 0: /* not yet defined */
+                       debug(3, "type is undefined for %#x\n", tdp->t_id);
                        return (0);
 
                default:
-                       terminate("tdp %u: tdesc_size on unknown type %d\n",
+                       terminate("tdp %u: tdesc_size on unknown type %#x\n",
                            tdp->t_id, tdp->t_type);
                }
        }
@@ -222,9 +225,11 @@
                case UNION:
                case ENUM:
                case POINTER:
+               case REFERENCE:
                        return (tdp->t_size * NBBY);
 
                case FORWARD:
+                       debug(3, "bitsize is forward for %d\n", tdp->t_id);
                        return (0);
 
                case TYPEDEF:
@@ -235,6 +240,7 @@
                        continue;
 
                case 0: /* not yet defined */
+                       debug(3, "bitsize is undefined for %d\n", tdp->t_id);
                        return (0);
 
                default:
@@ -664,10 +670,12 @@
 
        if ((dim2 = die_sibling(dw, dim)) == NULL) {
                ctdp = arrtdp;
+               debug(3, "die %ju: sibling type %#x for dimension\n",
+                   (uintmax_t)die_off(dw, dim), ctdp->t_id);
        } else if (die_tag(dw, dim2) == DW_TAG_subrange_type) {
                ctdp = xcalloc(sizeof (tdesc_t));
                ctdp->t_id = mfgtid_next(dw);
-               debug(3, "die %ju: creating new type %u for sub-dimension\n",
+               debug(3, "die %ju: creating new type %#x for sub-dimension\n",
                    (uintmax_t)die_off(dw, dim2), ctdp->t_id);
                tdesc_array_create(dw, dim2, arrtdp, ctdp);
        } else {
@@ -706,6 +714,8 @@
         */
        ar->ad_idxtype = tdesc_intr_long(dw);
        ar->ad_contents = ctdp;
+       debug(3, "die %ju: hi mom sibling type %#x for dimension\n",
+           (uintmax_t)die_off(dw, dim), ctdp->t_id);
 
        if (ar->ad_contents->t_size != 0) {
                dimtdp->t_size = ar->ad_contents->t_size * ar->ad_nelems;
@@ -733,6 +743,17 @@
                terminate("die %ju: failed to retrieve array bounds\n",
                    (uintmax_t)off);
 
+       if (arrtdp->t_type == 0) {
+               /*
+                * Add the die that contains the type of the array elements
+                * to the the ones we process; XXX: no public API for that?
+                */
+               extern Dwarf_Die _dwarf_die_find(Dwarf_Die, Dwarf_Unsigned);
+               Dwarf_Die elem = _dwarf_die_find(arr, arrtdp->t_id);
+               if (elem != NULL)
+                   die_create_one(dw, elem);
+       }
+
        tdesc_array_create(dw, dim, arrtdp, tdp);
 
        if (die_unsigned(dw, arr, DW_AT_byte_size, &uval, 0)) {
@@ -779,12 +800,13 @@
        if (tdp->t_flags & TDESC_F_RESOLVED)
                return (1);
 
-       debug(3, "trying to resolve array %d (cont %d)\n", tdp->t_id,
-           tdp->t_ardef->ad_contents->t_id);
+       debug(3, "trying to resolve array %#x (cont %#x/%zu)\n", tdp->t_id,
+           tdp->t_ardef->ad_contents->t_id,
+           tdp->t_ardef->ad_contents->t_size);
 
        if ((sz = tdesc_size(tdp->t_ardef->ad_contents)) == 0 &&
            (tdp->t_ardef->ad_contents->t_flags & TDESC_F_RESOLVED) == 0) {
-               debug(3, "unable to resolve array %s (%d) contents %d\n",
+               debug(3, "unable to resolve array %s (%#x) contents %#x\n",
                    tdesc_name(tdp), tdp->t_id,
                    tdp->t_ardef->ad_contents->t_id);
 
@@ -795,7 +817,7 @@
        tdp->t_size = sz * tdp->t_ardef->ad_nelems;
        tdp->t_flags |= TDESC_F_RESOLVED;
 
-       debug(3, "resolved array %d: %u bytes\n", tdp->t_id, tdp->t_size);
+       debug(3, "resolved array %#x: %u bytes\n", tdp->t_id, tdp->t_size);
 
        return (1);
 }
@@ -966,9 +988,9 @@
 
        tdp->t_type = (die_isdecl(dw, str) ? FORWARD : type);
 
-       debug(3, "die %ju: creating %s %s\n", (uintmax_t)off,
+       debug(3, "die %ju: creating %s %s <%d>\n", (uintmax_t)off,
            (tdp->t_type == FORWARD ? "forward decl" : typename),
-           tdesc_name(tdp));
+           tdesc_name(tdp), tdp->t_id);
 
        if (tdp->t_type == FORWARD) {
                hash_add(dw->dw_fwdhash, tdp);
@@ -1016,7 +1038,7 @@
                        ml->ml_name = NULL;
 
                ml->ml_type = die_lookup_pass1(dw, mem, DW_AT_type);
-               debug(3, "die_sou_create(): ml_type = %p t_id = %d\n",
+               debug(3, "die_sou_create(): ml_type = %p t_id = %#x\n",
                    ml->ml_type, ml->ml_type->t_id);
 
                if (die_mem_offset(dw, mem, DW_AT_data_member_location,
@@ -1578,7 +1600,7 @@
                tdp->t_tdesc = tdesc_intr_void(dw);
        }
 
-       if (type == POINTER)
+       if (type == POINTER || type == REFERENCE)
                tdp->t_size = dw->dw_ptrsz;
 
        tdp->t_flags |= TDESC_F_RESOLVED;
@@ -1612,6 +1634,12 @@
 }
 
 static void
+die_reference_create(dwarf_t *dw, Dwarf_Die die, Dwarf_Off off, tdesc_t *tdp)
+{
+       die_through_create(dw, die, off, tdp, REFERENCE, "reference");
+}
+
+static void
 die_restrict_create(dwarf_t *dw, Dwarf_Die die, Dwarf_Off off, tdesc_t *tdp)
 {
        die_through_create(dw, die, off, tdp, RESTRICT, "restrict");
@@ -1786,6 +1814,7 @@
        { DW_TAG_enumeration_type,      0,              die_enum_create },
        { DW_TAG_lexical_block,         DW_F_NOTDP,     die_lexblk_descend },
        { DW_TAG_pointer_type,          0,              die_pointer_create },
+       { DW_TAG_reference_type,        0,              die_reference_create },
        { DW_TAG_structure_type,        0,              die_struct_create },
        { DW_TAG_subroutine_type,       0,              die_funcptr_create },
        { DW_TAG_typedef,               0,              die_typedef_create },
@@ -1861,6 +1890,7 @@
        NULL,
        NULL,                   /* intrinsic */
        NULL,                   /* pointer */
+       NULL,                   /* reference */
        die_array_resolve,      /* array */
        NULL,                   /* function */
        die_sou_resolve,        /* struct */
@@ -1878,6 +1908,7 @@
        NULL,
        NULL,                   /* intrinsic */
        NULL,                   /* pointer */
+       NULL,                   /* reference */
        die_array_failed,       /* array */
        NULL,                   /* function */
        die_sou_failed,         /* struct */
diff -r 984f61b4a31a -r a14108ba5cb4 external/cddl/osnet/dist/tools/ctf/cvt/merge.c
--- a/external/cddl/osnet/dist/tools/ctf/cvt/merge.c    Fri Mar 18 13:23:00 2016 +0000
+++ b/external/cddl/osnet/dist/tools/ctf/cvt/merge.c    Fri Mar 18 14:55:34 2016 +0000
@@ -543,6 +543,7 @@
        NULL,
        map_td_tree_pre,        /* intrinsic */
        map_td_tree_pre,        /* pointer */
+       map_td_tree_pre,        /* reference */
        map_td_tree_pre,        /* array */
        map_td_tree_pre,        /* function */
        map_td_tree_pre,        /* struct */
@@ -560,6 +561,7 @@
        NULL,
        map_td_tree_post,       /* intrinsic */
        map_td_tree_post,       /* pointer */
+       map_td_tree_post,       /* reference */
        map_td_tree_post,       /* array */
        map_td_tree_post,       /* function */
        map_td_tree_post,       /* struct */
@@ -577,6 +579,7 @@
        NULL,
        map_td_tree_self_post,  /* intrinsic */
        map_td_tree_self_post,  /* pointer */
+       map_td_tree_self_post,  /* reference */
        map_td_tree_self_post,  /* array */
        map_td_tree_self_post,  /* function */
        map_td_tree_self_post,  /* struct */
@@ -893,6 +896,7 @@
        NULL,
        NULL,                   /* intrinsic */
        NULL,                   /* pointer */
+       NULL,                   /* reference */
        NULL,                   /* array */
        NULL,                   /* function */
        NULL,                   /* struct */
@@ -1134,6 +1138,7 @@
        { "ERROR! BAD tdesc TYPE", NULL, NULL },
        { "intrinsic",          equiv_intrinsic,        conjure_intrinsic },
        { "pointer",            equiv_plain,            conjure_plain },
+       { "reference",          equiv_plain,            conjure_plain },
        { "array",              equiv_array,            conjure_array },
        { "function",           equiv_function,         conjure_function },
        { "struct",             equiv_su,               conjure_su },
diff -r 984f61b4a31a -r a14108ba5cb4 external/cddl/osnet/dist/tools/ctf/cvt/traverse.c
--- a/external/cddl/osnet/dist/tools/ctf/cvt/traverse.c Fri Mar 18 13:23:00 2016 +0000
+++ b/external/cddl/osnet/dist/tools/ctf/cvt/traverse.c Fri Mar 18 14:55:34 2016 +0000
@@ -119,6 +119,7 @@
        NULL,
        NULL,                   /* intrinsic */
        NULL,                   /* pointer */
+       NULL,                   /* reference */
        NULL,                   /* array */
        NULL,                   /* function */
        NULL,                   /* struct */
@@ -136,6 +137,7 @@
        NULL,
        NULL,                   /* intrinsic */
        tdtrav_plain,           /* pointer */
+       tdtrav_plain,           /* reference */
        tdtrav_array,           /* array */
        tdtrav_func,            /* function */
        tdtrav_su,              /* struct */



Home | Main Index | Thread Index | Old Index