]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Try and improve the parsing of C++ stabs that contain :: sequences. This
authorTom Hughes <tom@compton.nu>
Fri, 12 Nov 2004 23:16:31 +0000 (23:16 +0000)
committerTom Hughes <tom@compton.nu>
Fri, 12 Nov 2004 23:16:31 +0000 (23:16 +0000)
patch attempts to follow the same rules that gdb uses and is based on the
fact that there appear to be three places where :: can appear:

  - In the name of a undefined struct/union/enum after an x type
    marker. In this case we follow a simplified version of the old
    rules and only allow :: inside <> characters.

  - In a method name. These are mangled so :: will never appear as
    part of the name but will always occurs as the terminator. We
    handle this by stopping at the first :: sequence.

  - In a symbol/type name. This can include :: but can only be ended
    by a single colon so we simply carry on until we see that.

I suspect this will resolve a number of bugs but I'm still waiting for
the submitters to confirm exactly which ones it resolves.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2981

coregrind/vg_stabs.c

index 47a1fa58cfeb1bfe5b4615a0f486f81736d70dec..1f08f681fbe83668c0a0d13ec4418e9d1f55faaf 100644 (file)
@@ -413,42 +413,12 @@ static UInt atou(Char **pp, Int base)
    return ret;
 }
 
-static Bool isoperator(Char op)
-{
-   switch(op) {
-   case 'a'...'z':
-   case 'A'...'Z':
-   case '0'...'9':
-   case '_':
-   case ':':
-   case '\'':
-   case '"':
-   case '$':
-      return False;
-      
-   default:
-      return True;
-   }
-}
-
 /* Skip a ':'-delimited name which may have ::, 'char' or other things in
    <> brackets */
 static Char *templ_name(Char *p)
 {
    Int brac = 0;
 
-   /* Special case: if the name is "operatorX", where X is not an
-      otherwise valid operator name, then just skip to the terminating
-      ':' and ignore the '<>' bracketing stuff.  That's because names
-      like "operator<" and "operator<=" can appear here, and it can be
-      terminated by ::. */
-   if (VG_(strncmp)(p, "operator", 8) == 0 && isoperator(p[8])) {
-      p += 8;
-      while(*p != ':')
-        p++;
-      return p;
-   }
-
    for(;;) {
       if (*p == '<')
         brac++;
@@ -879,7 +849,8 @@ static SymType *stabtype_parser(SegInfo *si, SymType *def, Char **pp)
         UInt off, sz;
         SymType *fieldty;
 
-        end = templ_name(p);
+         //     end = templ_name(p);
+         end = SKIPPAST(p, ':', "method name") - 1;
 
         if (end[1] == ':') {
            /* c++ method names end in :: */
@@ -1060,7 +1031,9 @@ static Bool initSym(SegInfo *si, Sym *sym, stab_types kind, Char **namep, Int va
       VG_(printf)("initSym(si=%p, tab=%p, sym=%p, kind=%d, name=%p \"%s\", val=%d)\n",
                  si, si->stab_typetab, sym, kind, name, name, val);
 
-   ty = templ_name(name);
+   //   ty = templ_name(name);
+   ty = VG_(strchr)(name, ':');
+   while (ty && ty[1] == ':') ty = VG_(strchr)(ty + 2, ':');
 
    len = ty - name;