From: Dejan Jevtic Date: Fri, 4 Apr 2014 10:20:03 +0000 (+0000) Subject: mips32/64: According to DWARF version 4 in DW_TAG_structure_type we can X-Git-Tag: svn/VALGRIND_3_10_0~545 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6cb9b78f0d55a8ea60fafdabdd2adbbd5d068815;p=thirdparty%2Fvalgrind.git mips32/64: According to DWARF version 4 in DW_TAG_structure_type we can 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 --- diff --git a/coregrind/m_debuginfo/priv_tytypes.h b/coregrind/m_debuginfo/priv_tytypes.h index e79f7de871..255090e41e 100644 --- a/coregrind/m_debuginfo/priv_tytypes.h +++ b/coregrind/m_debuginfo/priv_tytypes.h @@ -116,6 +116,7 @@ typedef struct { HChar* name; /* in mallocville */ UWord szB; + UWord typeR; XArray* /* of UWord */ fieldRs; Bool complete; Bool isStruct; diff --git a/coregrind/m_debuginfo/readdwarf3.c b/coregrind/m_debuginfo/readdwarf3.c index f64a97b0a9..1ca7c91db5 100644 --- a/coregrind/m_debuginfo/readdwarf3.c +++ b/coregrind/m_debuginfo/readdwarf3.c @@ -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)) { diff --git a/coregrind/m_debuginfo/tytypes.c b/coregrind/m_debuginfo/tytypes.c index 0fde46bdf0..30f431d3b7 100644 --- a/coregrind/m_debuginfo/tytypes.c +++ b/coregrind/m_debuginfo/tytypes.c @@ -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;