]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
mips32/64: According to DWARF version 4 in DW_TAG_structure_type we can
authorDejan Jevtic <dejan.jevtic@valgrind.org>
Fri, 4 Apr 2014 10:20:03 +0000 (10:20 +0000)
committerDejan Jevtic <dejan.jevtic@valgrind.org>
Fri, 4 Apr 2014 10:20:03 +0000 (10:20 +0000)
have DW_AT_signature attribute. That wasn't the case in DWARF version 3.

From DWARF version 4:
If the complete declaration of a type has been placed in a separate type unit,
an incomplete declaration of that type in the compilation unit may provide the
unique 64-bit signature of the type using a DW_AT_signature attribute.

This patch adds an extra field in TyStOrUn structure (typeR). This field is
reference to other TyEnt that is placed in separate type unit. Because of the new
field in TyStOrUn structure we need to add an extra case in parse_type_DIE
that will put the right reference to other TyEnt and an extra case in
ML_(describe_type) that will describe type when the ty->Te.TyStOrUn.typeR field
is used.

This patch is resolving the problem with memcheck/tests/dw4 test when it's
compiled with compiler that will emit DW_AT_signature under the DW_TAG_structure_type.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13891

coregrind/m_debuginfo/priv_tytypes.h
coregrind/m_debuginfo/readdwarf3.c
coregrind/m_debuginfo/tytypes.c

index e79f7de871d2bc24546b076e6a791f13a260d093..255090e41e7d8eeceaff79c71ab33dd298880e1f 100644 (file)
@@ -116,6 +116,7 @@ typedef
          struct {
             HChar*  name; /* in mallocville */
             UWord   szB;
+            UWord   typeR;
             XArray* /* of UWord */ fieldRs;
             Bool    complete;
             Bool    isStruct;
index f64a97b0a9e1fe1bc0d6f00ebcaa586fca8c69f6..1ca7c91db5c7756ffa9678ad771a61c4296920be 100644 (file)
@@ -2632,6 +2632,7 @@ static void parse_type_DIE ( /*MOD*/XArray* /* of TyEnt */ tyents,
       typeE.cuOff = posn;
       typeE.tag   = Te_TyStOrUn;
       typeE.Te.TyStOrUn.name = NULL;
+      typeE.Te.TyStOrUn.typeR = D3_INVALID_CUOFF;
       typeE.Te.TyStOrUn.fieldRs
          = VG_(newXA)( ML_(dinfo_zalloc), "di.readdwarf3.pTD.struct_type.1", 
                        ML_(dinfo_free),
@@ -2659,6 +2660,13 @@ static void parse_type_DIE ( /*MOD*/XArray* /* of TyEnt */ tyents,
          if (attr == DW_AT_specification && cts.szB > 0 && cts.u.val > 0) {
             is_spec = True;
          }
+         if (attr == DW_AT_signature && form == DW_FORM_ref_sig8
+             && cts.szB > 0) {
+            have_szB = True;
+            typeE.Te.TyStOrUn.szB = 8;
+            typeE.Te.TyStOrUn.typeR
+               = cook_die_using_form( cc, (UWord)cts.u.val, form );
+         }
       }
       /* Do we have something that looks sane? */
       if (is_decl && (!is_spec)) {
index 0fde46bdf04add690bcf69a65a8ebf8922f27757..30f431d3b717fad427bfe0ea560713dce0c8b2f3 100644 (file)
@@ -785,7 +785,8 @@ XArray* /*HChar*/ ML_(describe_type)( /*OUT*/PtrdiffT* residual_offset,
             PtrdiffT   offMin = 0, offMax1 = 0;
             if (!ty->Te.TyStOrUn.isStruct) goto done;
             fieldRs = ty->Te.TyStOrUn.fieldRs;
-            if ((!fieldRs) || VG_(sizeXA)(fieldRs) == 0) goto done;
+            if (((!fieldRs) || VG_(sizeXA)(fieldRs) == 0)
+                && (ty->Te.TyStOrUn.typeR == 0)) goto done;
             for (i = 0; i < VG_(sizeXA)( fieldRs ); i++ ) {
                fieldR = *(UWord*)VG_(indexXA)( fieldRs, i );
                field = ML_(TyEnts__index_by_cuOff)(tyents, NULL, fieldR);
@@ -831,8 +832,14 @@ XArray* /*HChar*/ ML_(describe_type)( /*OUT*/PtrdiffT* residual_offset,
             }
             /* Did we find a suitable field? */
             vg_assert(i >= 0 && i <= VG_(sizeXA)( fieldRs ));
-            if (i == VG_(sizeXA)( fieldRs ))
-               goto done; /* No.  Give up. */
+            if (i == VG_(sizeXA)( fieldRs )) {
+               ty = ML_(TyEnts__index_by_cuOff)(tyents, NULL,
+                                                   ty->Te.TyStOrUn.typeR);
+               vg_assert(ty);
+               if (ty->tag == Te_UNKNOWN) goto done;
+               vg_assert(ML_(TyEnt__is_type)(ty));
+               continue;
+            }
             /* Yes.  'field' is it. */
             vg_assert(field);
             if (!field->Te.Field.name) goto done;