|
From: <sv...@va...> - 2014-04-04 10:20:28
|
Author: dejanj
Date: Fri Apr 4 10:20:03 2014
New Revision: 13891
Log:
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.
Modified:
trunk/coregrind/m_debuginfo/priv_tytypes.h
trunk/coregrind/m_debuginfo/readdwarf3.c
trunk/coregrind/m_debuginfo/tytypes.c
Modified: trunk/coregrind/m_debuginfo/priv_tytypes.h
==============================================================================
--- trunk/coregrind/m_debuginfo/priv_tytypes.h (original)
+++ trunk/coregrind/m_debuginfo/priv_tytypes.h Fri Apr 4 10:20:03 2014
@@ -116,6 +116,7 @@
struct {
HChar* name; /* in mallocville */
UWord szB;
+ UWord typeR;
XArray* /* of UWord */ fieldRs;
Bool complete;
Bool isStruct;
Modified: trunk/coregrind/m_debuginfo/readdwarf3.c
==============================================================================
--- trunk/coregrind/m_debuginfo/readdwarf3.c (original)
+++ trunk/coregrind/m_debuginfo/readdwarf3.c Fri Apr 4 10:20:03 2014
@@ -2632,6 +2632,7 @@
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 @@
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)) {
Modified: trunk/coregrind/m_debuginfo/tytypes.c
==============================================================================
--- trunk/coregrind/m_debuginfo/tytypes.c (original)
+++ trunk/coregrind/m_debuginfo/tytypes.c Fri Apr 4 10:20:03 2014
@@ -785,7 +785,8 @@
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 @@
}
/* 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;
|