]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
More fixes for stabs generated by the GNAT compiler. This patch
authorTom Hughes <tom@compton.nu>
Thu, 7 Oct 2004 08:33:08 +0000 (08:33 +0000)
committerTom Hughes <tom@compton.nu>
Thu, 7 Oct 2004 08:33:08 +0000 (08:33 +0000)
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

coregrind/vg_stabs.c

index f7ff516397c58105ac55d6ebc076365319c4bf51..73455b212db98fe2a2ffb7c4292dcffbbc41d081 100644 (file)
@@ -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))) {