From: Tom Hughes Date: Thu, 7 Oct 2004 08:33:08 +0000 (+0000) Subject: More fixes for stabs generated by the GNAT compiler. This patch X-Git-Tag: svn/VALGRIND_3_0_0~1554 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=588711ca620b13411188d8a63033e9ffd0d76e2a;p=thirdparty%2Fvalgrind.git More fixes for stabs generated by the GNAT compiler. This patch allows negative offsets in structure member definitions as well as improving the previous fix for names that are declared as both struct tags and typedefs. CCMAIL: 90128-done@bugs.kde.org git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2734 --- diff --git a/coregrind/vg_stabs.c b/coregrind/vg_stabs.c index f7ff516397..73455b212d 100644 --- a/coregrind/vg_stabs.c +++ b/coregrind/vg_stabs.c @@ -171,12 +171,22 @@ static SymType *structDef(StabTypeTab *tab, SymType *def, Bool isstruct, Char *n static const Bool debug = False || stabs_debug; SymType *ref = structRef(tab, NULL, isstruct, name); - if (debug) - VG_(printf)("defining %s ref for %s %p -> %p\n", - isstruct ? "struct" : "union", name, ref, def); + /* it seems that GNAT likes to declare names as both struct tags + and typedefs so check we aren't about to make a structure a + reference to itself as that will create a loop */ + if (ref == def) { + if (debug) + VG_(printf)("ignoring %s self ref for %s %p -> %p\n", + isstruct ? "struct" : "union", name, ref, def); + } + else { + if (debug) + VG_(printf)("defining %s ref for %s %p -> %p\n", + isstruct ? "struct" : "union", name, ref, def); - def = VG_(st_mktypedef)(ref, name, VG_(st_basetype)(def, False)); - VG_(st_setname)(def, name); + def = VG_(st_mktypedef)(ref, name, VG_(st_basetype)(def, False)); + VG_(st_setname)(def, name); + } return def; } @@ -940,7 +950,10 @@ static SymType *stabtype_parser(SegInfo *si, SymType *def, Char **pp) } else { EXPECT(',', "struct TYPE"); - off = atou(&p, 0); + /* logic dictates that the offset would always be + positive and that atou would work here but GNAT has + has other ideas - see bug 90128 for more details */ + off = atoi(&p, 0); if (*p == ',') { EXPECT(',', "struct OFFSET"); @@ -1091,7 +1104,6 @@ static Bool initSym(SegInfo *si, Sym *sym, stab_types kind, Char **namep, Int va } out: - if (isStruct && isTypedef) isStruct = False; sym->type = stabtype_parser(si, NULL, &ty); base = VG_(st_basetype)(sym->type, False); if (isStruct && (VG_(st_isstruct)(base) || VG_(st_isunion)(base))) {