]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Fix some GNAT related stabs parsing problems.
authorTom Hughes <tom@compton.nu>
Thu, 4 Nov 2004 13:24:33 +0000 (13:24 +0000)
committerTom Hughes <tom@compton.nu>
Thu, 4 Nov 2004 13:24:33 +0000 (13:24 +0000)
MERGE TO STABLE

git-svn-id: svn://svn.valgrind.org/valgrind/branches/VALGRIND_2_2_0_BRANCH@2913

coregrind/vg_stabs.c

index a815f174fd58488a254bb35220833bc92de1ea6d..970a6bac319e6d6203361692398628bbd5034a04 100644 (file)
@@ -170,12 +170,22 @@ static SymType *structDef(StabTypeTab *tab, SymType *def, Bool isstruct, Char *n
    static const Bool debug = False;
    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);
-
-   def = VG_(st_mktypedef)(ref, name, VG_(st_basetype)(def, False));
-   VG_(st_setname)(def, name);
+   /* 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);
+   }
    return def;
 }
 
@@ -939,7 +949,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");