|
From: Rich C. <Ric...@me...> - 2005-07-13 12:34:14
|
Was having a problem with VG-2.4.0 parsing some old stabs debug info.
Below is my diff of vg_stabs.c from VG-2.2.1 into VG-2.4.0.
Also attached is the VG output which coredumps VG-2.4.0.
When I get a chance, I'll try VG-3.0.
R.
--
Rich Coe ric...@me...
General Electric Healthcare Technologies
Global Software Platforms, Computer Technology Team
==4089== Memcheck, a memory error detector for x86-linux.
==4089== Copyright (C) 2002-2005, and GNU GPL'd, by Julian Seward et al.
==4089== Using valgrind-2.4.0, a program supervision framework for x86-linux.
==4089== Copyright (C) 2000-2005, and GNU GPL'd, by Julian Seward et al.
==4089==
==4089== My PID = 4089, parent PID = 3566. Prog and args are:
==4089== ......
@@ don't know what type 'p' is
@@ parsing pair<char* const, Commentclass::_comment*>,std::allocator<std::pair<char* const, Commentclass::_comment*> >,true>:(903,6),0,256;; gave NULL type (air<char* const, Commentclass::_comment*>,std::allocator<std::pair<char* const, Commentclass::_comment*> >,true>:(903,6),0,256;; remains)
@@ expected ':' at struct method MANGLE-ARGS (remains="ir<char* const, Commentclass::_comment*>,std::allocator<std::pair<char* const, Commentclass::_comment*> >,true>:(903,6),0,256;;")
@@ parsing (903,9)=s4_Rb_tree_alloc_base<std::pair<char* const, Commentclass::_comment*>,std::allocator<std::pair<char* const, Commentclass::_comment*> >,true>:(903,6),0,256;; gave NULL type (s4_Rb_tree_alloc_base<std::pair<char* const, Commentclass::_comment*>,std::allocator<std::pair<char* const, Commentclass::_comment*> >,true>:(903,6),0,256;; remains)
--- valgrind-2.4.0/coregrind/vg_stabs.c.orig 2005-03-20 12:40:51.000000000 -0600
+++ valgrind-2.4.0/coregrind/vg_stabs.c 2005-07-13 06:26:00.000000000 -0500
@@ -413,12 +413,42 @@ 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)
+static Char *templ_name(Char *p, int exp)
{
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++;
@@ -435,13 +465,11 @@ static Char *templ_name(Char *p)
if (brac && p[0] == '\'' && p[2] == '\'')
p += 3;
- /* If we're within <>, then treat :: as part of the name (a single
- : still terminates) */
- if (*p == ':') {
- if (brac && p[1] == ':' && p[-1] != '<')
- p++;
- else
- break;
+ if (*p == ':') {
+ if (exp && !brac && p[1] == ':') break; /* expecting '::' */
+ /* p[2] is a disgusting exception */
+ if (p[1] == ':' && p[2] != '(' ) p++;
+ else break;
}
p++;
}
@@ -678,6 +706,8 @@ static SymType *stabtype_parser(SegInfo
EXPECT(';', "FP-TYPE");
bytes = atoi(&p, 0);
EXPECT(';', "FP-TYPE bytes");
+ atoi(&p, 0);
+ EXPECT(';', "FP-TYPE extra");
type = VG_(st_mkfloat)(def, bytes);
break;
@@ -737,7 +767,7 @@ static SymType *stabtype_parser(SegInfo
Char kind = *p++; /* get kind */
Char *name = p;
- p = templ_name(name);
+ p = templ_name(name, 1);
EXPECT(':', "struct/union/enum ref");
name = VG_(addStr)(si, name, p-1-name);
@@ -847,7 +877,7 @@ static SymType *stabtype_parser(SegInfo
UInt off, sz;
SymType *fieldty;
- end = SKIPPAST(p, ':', "method name") - 1;
+ end = templ_name(p, 1);
if (end[1] == ':') {
/* c++ method names end in :: */
@@ -1028,18 +1058,7 @@ static Bool initSym(SegInfo *si, Sym *sy
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);
- /* Find first ':' */
- ty = VG_(strchr)(name, ':');
-
- /* Skip '::' */
- while (ty && ty[1] == ':')
- ty = VG_(strchr)(ty + 2, ':');
-
- if (ty == NULL) {
- /* there was no ':' */
- *namep += VG_(strlen)(name);
- return True; /* skip */
- }
+ ty = templ_name(name, 0);
len = ty - name;
|
|
From: Tom H. <to...@co...> - 2005-07-23 12:39:06
|
In message <20050713073208.18731395@godzilla>
Rich Coe <Ric...@me...> wrote:
> Was having a problem with VG-2.4.0 parsing some old stabs debug info.
> Below is my diff of vg_stabs.c from VG-2.2.1 into VG-2.4.0.
I don't think I understand what that diff is... You say it's a diff
from 2.2.1 to 2.4.0 but as there wasn't a 2.2.1 that doesn't make
much sense. Plus the patch appears to be from 2.4.0 back to some
older version as it looks it is undoing a number of recent stabs
fixes.
I completely reworked the C++ name parsing in stabs for 2.4.0 to try
and fix a large number of open bugs. I spent some time analysing what
gdb does and trying to do the same thing. This is what I wrote in the
commit liog:
: r362575 | thughes | 2004-11-12 23:16:31 +0000 (Fri, 12 Nov 2004) | 18 lines
:
: Try and improve the parsing of C++ stabs that contain :: sequences. This
: 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.
I assume that you have a case which has actually been broken by this
but I need to understand which of the three cases it is and why the
above rules aren't working.
> Also attached is the VG output which coredumps VG-2.4.0.
Unfortunately what I really need is the input, not the output. The full
text of the stab that is causing the problem would be ideal.
> @@ -678,6 +706,8 @@ static SymType *stabtype_parser(SegInfo
> EXPECT(';', "FP-TYPE");
> bytes = atoi(&p, 0);
> EXPECT(';', "FP-TYPE bytes");
> + atoi(&p, 0);
> + EXPECT(';', "FP-TYPE extra");
>
> type = VG_(st_mkfloat)(def, bytes);
> break;
Was there a reason for including this chunk, which reverts another
recent fix? Do you have a compiler which is generating the extra
field for this stab (the 'specification' doesn't mention such an
extra field).
Tom
--
Tom Hughes (to...@co...)
http://www.compton.nu/
|