Cope with demangling function names that include a double underscore.
authorNick Clifton <nickc@redhat.com>
Fri, 16 Aug 2002 11:44:03 +0000 (11:44 +0000)
committerNick Clifton <nickc@redhat.com>
Fri, 16 Aug 2002 11:44:03 +0000 (11:44 +0000)
binutils/ChangeLog
binutils/stabs.c

index de9c5716db0a881ced6d54c0d4f9e9e3c2087e62..9b0a306f9fdf70b8f0ff7778eaab2c088e19d28b 100644 (file)
@@ -1,3 +1,13 @@
+2002-08-16  Sivaguru Sankaridurg  <siva@eternal-systems.com>
+
+       * stabs.c (parse_stab_argtype): Pass length of physname to
+       stab_demangle_argtypes.
+       (stab_demangle_argtypes): Add new parameter - length of physname.
+       Pass length of physname on to stab_demangle_prefix.
+       (stab_demangle_prefix): Add new parameter - length of physname.
+       Use length of physname (if supplied) to compute end of function
+       name.
+
 2002-08-15  Alan Modra  <amodra@bigpond.net.au>
 
        * readelf.c: Include elf/i370.h.
index 087358289261e202cb7993096d707f7dbeaa13e2..d3efdf1fde8332a30c70e009145c1860ace80d9d 100644 (file)
@@ -1,5 +1,5 @@
 /* stabs.c -- Parse stabs debugging information
-   Copyright 1995, 1996, 1997, 1998, 1999, 2000, 2001
+   Copyright 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002
    Free Software Foundation, Inc.
    Written by Ian Lance Taylor <ian@cygnus.com>.
 
@@ -213,7 +213,7 @@ static debug_type stab_find_tagged_type
   PARAMS ((PTR, struct stab_handle *, const char *, int,
           enum debug_type_kind));
 static debug_type *stab_demangle_argtypes
-  PARAMS ((PTR, struct stab_handle *, const char *, boolean *));
+  PARAMS ((PTR, struct stab_handle *, const char *, boolean *, unsigned int));
 
 /* Save a string in memory.  */
 
@@ -2908,6 +2908,7 @@ parse_stab_argtypes (dhandle, info, class_type, fieldname, tagname,
   boolean is_destructor;
   debug_type *args;
   boolean varargs;
+  unsigned int physname_len = 0;
 
   /* Constructors are sometimes handled specially.  */
   is_full_physname_constructor = ((argtypes[0] == '_'
@@ -2984,6 +2985,7 @@ parse_stab_argtypes (dhandle, info, class_type, fieldname, tagname,
            strcpy (physname, fieldname);
        }
 
+      physname_len = strlen (physname);
       strcat (physname, buf);
       if (tagname != NULL)
        strcat (physname, tagname);
@@ -3000,7 +3002,7 @@ parse_stab_argtypes (dhandle, info, class_type, fieldname, tagname,
                                     false);
     }
 
-  args = stab_demangle_argtypes (dhandle, info, *pphysname, &varargs);
+  args = stab_demangle_argtypes (dhandle, info, *pphysname, &varargs, physname_len);
   if (args == NULL)
     return DEBUG_TYPE_NULL;
 
@@ -3729,7 +3731,7 @@ static unsigned int stab_demangle_count PARAMS ((const char **));
 static boolean stab_demangle_get_count
   PARAMS ((const char **, unsigned int *));
 static boolean stab_demangle_prefix
-  PARAMS ((struct stab_demangle_info *, const char **));
+  PARAMS ((struct stab_demangle_info *, const char **, unsigned int));
 static boolean stab_demangle_function_name
   PARAMS ((struct stab_demangle_info *, const char **, const char *));
 static boolean stab_demangle_signature
@@ -3821,11 +3823,12 @@ stab_demangle_get_count (pp, pi)
    terminated array of argument types.  */
 
 static debug_type *
-stab_demangle_argtypes (dhandle, info, physname, pvarargs)
+stab_demangle_argtypes (dhandle, info, physname, pvarargs, physname_len)
      PTR dhandle;
      struct stab_handle *info;
      const char *physname;
      boolean *pvarargs;
+     unsigned int physname_len;
 {
   struct stab_demangle_info minfo;
 
@@ -3842,7 +3845,7 @@ stab_demangle_argtypes (dhandle, info, physname, pvarargs)
   /* cplus_demangle checks for special GNU mangled forms, but we can't
      see any of them in mangled method argument types.  */
 
-  if (! stab_demangle_prefix (&minfo, &physname))
+  if (! stab_demangle_prefix (&minfo, &physname, physname_len))
     goto error_return;
 
   if (*physname != '\0')
@@ -3869,9 +3872,10 @@ stab_demangle_argtypes (dhandle, info, physname, pvarargs)
 /* Demangle the prefix of the mangled name.  */
 
 static boolean
-stab_demangle_prefix (minfo, pp)
+stab_demangle_prefix (minfo, pp, physname_len)
      struct stab_demangle_info *minfo;
      const char **pp;
+     unsigned int physname_len;
 {
   const char *scan;
   unsigned int i;
@@ -3879,26 +3883,29 @@ stab_demangle_prefix (minfo, pp)
   /* cplus_demangle checks for global constructors and destructors,
      but we can't see them in mangled argument types.  */
 
-  /* Look for `__'.  */
-  scan = *pp;
-  do
+  if (physname_len)
+    scan = *pp + physname_len;
+  else
     {
-      scan = strchr (scan, '_');
-    }
-  while (scan != NULL && *++scan != '_');
+      /* Look for `__'.  */
+      scan = *pp;
+      do
+       scan = strchr (scan, '_');
+      while (scan != NULL && *++scan != '_');
 
-  if (scan == NULL)
-    {
-      stab_bad_demangle (*pp);
-      return false;
-    }
+      if (scan == NULL)
+       {
+         stab_bad_demangle (*pp);
+         return false;
+       }
 
-  --scan;
+      --scan;
 
-  /* We found `__'; move ahead to the last contiguous `__' pair.  */
-  i = strspn (scan, "_");
-  if (i > 2)
-    scan += i - 2;
+      /* We found `__'; move ahead to the last contiguous `__' pair.  */
+      i = strspn (scan, "_");
+      if (i > 2)
+       scan += i - 2;
+    }
 
   if (scan == *pp
       && (ISDIGIT (scan[2])
This page took 0.031309 seconds and 4 git commands to generate.