www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.announce - GDB Symbol Demangling Patch

reply John Demme <me teqdruid.com> writes:
I've finally gotten my GDB patch working.  It's able to demangle most D symbols,
but a few weird ones still show up.  Anyway, the announcement (along with
directions) are here:
http://dsource.org/forums/viewtopic.php?t=734

Please report bugs on the dsource forum, instead of cluttering up this NG.

Walter, I'd like to do more with GDB, and expand the patch, but since the DWARF2
line number info is broke, I can't use GDB to do anything but stack traces on
segfaults.  I would appreciate if you would put a higher priority on this item.
Although there are still "show stopper" bugs, most of them aren't bugs people
run into on a daily basis.  Debugging is something that most people do on a
daily basis, so I would argue it should be of high importance.

John Demme
Apr 16 2005
next sibling parent "Charlie" <charles jwavro.com> writes:
 Walter, I'd like to do more with GDB, and expand the patch, but since the
DWARF2
 line number info is broke, I can't use GDB to do anything but stack traces
on
 segfaults.  I would appreciate if you would put a higher priority on this
item.
 Although there are still "show stopper" bugs, most of them aren't bugs
people
 run into on a daily basis.  Debugging is something that most people do on
a
 daily basis, so I would argue it should be of high importance.
We Win32 users would certainly like more debug info also :). I wonder why this wasn't the first thing to be developed, seems it would be enourmously helpful from the start. Charlie "John Demme" <me teqdruid.com> wrote in message news:d3sq2d$1094$1 digitaldaemon.com...
 I've finally gotten my GDB patch working.  It's able to demangle most D
symbols,
 but a few weird ones still show up.  Anyway, the announcement (along with
 directions) are here:
 http://dsource.org/forums/viewtopic.php?t=734

 Please report bugs on the dsource forum, instead of cluttering up this NG.

 Walter, I'd like to do more with GDB, and expand the patch, but since the
DWARF2
 line number info is broke, I can't use GDB to do anything but stack traces
on
 segfaults.  I would appreciate if you would put a higher priority on this
item.
 Although there are still "show stopper" bugs, most of them aren't bugs
people
 run into on a daily basis.  Debugging is something that most people do on
a
 daily basis, so I would argue it should be of high importance.

 John Demme
Apr 17 2005
prev sibling parent reply James Dunne <jdunne4 bradley.edu> writes:
I enjoyed looking at your patch.  Strange how I release a D symbol demangler
written in D and see some familiar programming constructs in your C patch =P.
My favorite is:

+  if (symbol == strstr(symbol, "_D")) {
+    mangled.pos += 2;
+    isFunc = 1;
+  } else if (symbol == strstr(symbol, "__Class_")) {
+    mangled.pos += 8;
+  } else if (symbol == strstr(symbol, "__init_")) {
+    mangled.pos += 7;
+  } else if (symbol == strstr(symbol, "__vtbl_")) {
+    mangled.pos += 7;
+  } else if (symbol == strstr(symbol, "__modctor_")) {
+    mangled.pos += 10;
+  } else if (symbol == strstr(symbol, "__moddtor_")) {
+    mangled.pos += 10;
+  } else if (symbol == strstr(symbol, "__ModuleInfo_")) {
+    mangled.pos += 13;
+  } else {
+    xfree(output.str);
+    //printf("NULL2\n");
+    return NULL;
+  }

which looks remarkably similar to something I wrote (demangle.d in bindings
project on dsource.org):

+ } else if (id[1 .. 6] == "Class") {
+ 	i = 7;
+ 	printf("class %.*s\n", extractidentifiers(id, i));
+ } else if (id[1 .. 5] == "init") {
+ 	i = 6;
+ 	printf("init %.*s\n", extractidentifiers(id, i));
+ } else if (id[1 .. 5] == "vtbl") {
+ 	i = 6;
+ 	printf("vtbl %.*s\n", extractidentifiers(id, i));
+ } else if (id[1 .. 8] == "modctor") {
+ 	i = 9;
+ 	printf("ctor %.*s\n", extractidentifiers(id, i));
+ } else if (id[1 .. 8] == "moddtor") {
+ 	i = 9;
+ 	printf("dtor %.*s\n", extractidentifiers(id, i));
+ } else if (id[1 .. 11] == "ModuleInfo") {
+ 	i = 12;
+ 	printf("module %.*s\n", extractidentifiers(id, i));
+ } else {
+ 	return false;
+ }

:).  If this is pure coincidence, then that's pretty strange!  If not, that's
cool too.  I'm not gonna get all up in arms about something as small and trivial
as a D symbol demangler.  I just thought it was funny and thought I should point
it out.  LOL

In article <d3sq2d$1094$1 digitaldaemon.com>, John Demme says...
I've finally gotten my GDB patch working.  It's able to demangle most D symbols,
but a few weird ones still show up.  Anyway, the announcement (along with
directions) are here:
http://dsource.org/forums/viewtopic.php?t=734
Regards, James Dunne
Apr 19 2005
parent reply James Dunne <jdunne4 bradley.edu> writes:
In article <d44esj$23kk$1 digitaldaemon.com>, James Dunne says...
I enjoyed looking at your patch.  Strange how I release a D symbol demangler
written in D and see some familiar programming constructs in your C patch =P.
My favorite is:

+  if (symbol == strstr(symbol, "_D")) {
+    mangled.pos += 2;
+    isFunc = 1;
+  } else if (symbol == strstr(symbol, "__Class_")) {
+    mangled.pos += 8;
+  } else if (symbol == strstr(symbol, "__init_")) {
+    mangled.pos += 7;
+  } else if (symbol == strstr(symbol, "__vtbl_")) {
+    mangled.pos += 7;
+  } else if (symbol == strstr(symbol, "__modctor_")) {
+    mangled.pos += 10;
+  } else if (symbol == strstr(symbol, "__moddtor_")) {
+    mangled.pos += 10;
+  } else if (symbol == strstr(symbol, "__ModuleInfo_")) {
+    mangled.pos += 13;
+  } else {
+    xfree(output.str);
+    //printf("NULL2\n");
+    return NULL;
+  }

which looks remarkably similar to something I wrote (demangle.d in bindings
project on dsource.org):

+ } else if (id[1 .. 6] == "Class") {
+ 	i = 7;
+ 	printf("class %.*s\n", extractidentifiers(id, i));
+ } else if (id[1 .. 5] == "init") {
+ 	i = 6;
+ 	printf("init %.*s\n", extractidentifiers(id, i));
+ } else if (id[1 .. 5] == "vtbl") {
+ 	i = 6;
+ 	printf("vtbl %.*s\n", extractidentifiers(id, i));
+ } else if (id[1 .. 8] == "modctor") {
+ 	i = 9;
+ 	printf("ctor %.*s\n", extractidentifiers(id, i));
+ } else if (id[1 .. 8] == "moddtor") {
+ 	i = 9;
+ 	printf("dtor %.*s\n", extractidentifiers(id, i));
+ } else if (id[1 .. 11] == "ModuleInfo") {
+ 	i = 12;
+ 	printf("module %.*s\n", extractidentifiers(id, i));
+ } else {
+ 	return false;
+ }

:).  If this is pure coincidence, then that's pretty strange!  If not, that's
cool too.  I'm not gonna get all up in arms about something as small and trivial
as a D symbol demangler.  I just thought it was funny and thought I should point
it out.  LOL

In article <d3sq2d$1094$1 digitaldaemon.com>, John Demme says...
I've finally gotten my GDB patch working.  It's able to demangle most D symbols,
but a few weird ones still show up.  Anyway, the announcement (along with
directions) are here:
http://dsource.org/forums/viewtopic.php?t=734
Regards, James Dunne
Upon closer inspection, you took the whole friggin' switch () statement block in my extracttypeinfo function too!! =P. Props to you for getting this stuff in GDB! I will actually drag down a source tree of GDB and compile this patch in. I've been waiting for something like this. I thank you. My dog thanks you. My wife thanks you. My appendix thanks you. My kids thank you. My boss thanks you. My professors thank you. Regards, James Dunne
Apr 19 2005
parent reply John Demme <me teqdruid.com> writes:
Yep.  It's your's.  The source that I found for your demangler didn't
include a license, so I just assumed public domain.

I'd apologize for not giving your credit in the credit section of the
code, but I neglected to include the credits section.  When I add it,
you'll be in there.  Sorry I neglected to mention your name in the
release announcement.

Anyway, weren't we discussing this on the forum and/or NG previously?  I
thought you knew that I was porting your code into GDB, and that that
was what you wrote it for.

John


hmmm.... Your boss thanks me?  He's welcome to hire me out to do this
work!

On Wed, 2005-04-20 at 02:34 +0000, James Dunne wrote:
 In article <d44esj$23kk$1 digitaldaemon.com>, James Dunne says...
I enjoyed looking at your patch.  Strange how I release a D symbol demangler
written in D and see some familiar programming constructs in your C patch =P.
My favorite is:

+  if (symbol == strstr(symbol, "_D")) {
+    mangled.pos += 2;
+    isFunc = 1;
+  } else if (symbol == strstr(symbol, "__Class_")) {
+    mangled.pos += 8;
+  } else if (symbol == strstr(symbol, "__init_")) {
+    mangled.pos += 7;
+  } else if (symbol == strstr(symbol, "__vtbl_")) {
+    mangled.pos += 7;
+  } else if (symbol == strstr(symbol, "__modctor_")) {
+    mangled.pos += 10;
+  } else if (symbol == strstr(symbol, "__moddtor_")) {
+    mangled.pos += 10;
+  } else if (symbol == strstr(symbol, "__ModuleInfo_")) {
+    mangled.pos += 13;
+  } else {
+    xfree(output.str);
+    //printf("NULL2\n");
+    return NULL;
+  }

which looks remarkably similar to something I wrote (demangle.d in bindings
project on dsource.org):

+ } else if (id[1 .. 6] == "Class") {
+ 	i = 7;
+ 	printf("class %.*s\n", extractidentifiers(id, i));
+ } else if (id[1 .. 5] == "init") {
+ 	i = 6;
+ 	printf("init %.*s\n", extractidentifiers(id, i));
+ } else if (id[1 .. 5] == "vtbl") {
+ 	i = 6;
+ 	printf("vtbl %.*s\n", extractidentifiers(id, i));
+ } else if (id[1 .. 8] == "modctor") {
+ 	i = 9;
+ 	printf("ctor %.*s\n", extractidentifiers(id, i));
+ } else if (id[1 .. 8] == "moddtor") {
+ 	i = 9;
+ 	printf("dtor %.*s\n", extractidentifiers(id, i));
+ } else if (id[1 .. 11] == "ModuleInfo") {
+ 	i = 12;
+ 	printf("module %.*s\n", extractidentifiers(id, i));
+ } else {
+ 	return false;
+ }

:).  If this is pure coincidence, then that's pretty strange!  If not, that's
cool too.  I'm not gonna get all up in arms about something as small and trivial
as a D symbol demangler.  I just thought it was funny and thought I should point
it out.  LOL

In article <d3sq2d$1094$1 digitaldaemon.com>, John Demme says...
I've finally gotten my GDB patch working.  It's able to demangle most D symbols,
but a few weird ones still show up.  Anyway, the announcement (along with
directions) are here:
http://dsource.org/forums/viewtopic.php?t=734
Regards, James Dunne
Upon closer inspection, you took the whole friggin' switch () statement block in my extracttypeinfo function too!! =P. Props to you for getting this stuff in GDB! I will actually drag down a source tree of GDB and compile this patch in. I've been waiting for something like this. I thank you. My dog thanks you. My wife thanks you. My appendix thanks you. My kids thank you. My boss thanks you. My professors thank you. Regards, James Dunne
Apr 19 2005
parent James Dunne <jdunne4 bradley.edu> writes:
Yeah, I never include any licenses with any of my work that I post online.  I
figure that if I can code it, someone else can too; so why should I be proud of
something I can do that someone else can do just as well??  It doesn't make any
sense to me.  It's in the public domain, along with everything else I have
posted into the bindings project on dsource.org, or have posted in the forums
here.

Of course, credit is always nice :)  I'm not gonna demand it, but it's always
fun to see your name on someone else's stuff.  =P  I see it as a gesture of good
character.  So thank you if you do decide to include my name in your credits.

And yes, I do recall discussing this earlier on the forums and it was my
intention that it would be included into gdb someday.  I wasn't sure how useful,
if at all, that code was going to be to you.  I guess it was just shock at first
when I saw real results!

I have no boss at the moment, as I am still in school.  I just thought it'd be
funny to throw that in there.  Just as well, I'm not married nor have I any
offspring, yet.  I do have a dog, however!

BTW, I did patch up gdb and compile it with your patch and it met with immediate
success!  Great work.  What is the status on variables?  I haven't played with
it much yet.

In article <1113965238.21324.19.camel localhost.localdomain>, John Demme says...
Yep.  It's your's.  The source that I found for your demangler didn't
include a license, so I just assumed public domain.

I'd apologize for not giving your credit in the credit section of the
code, but I neglected to include the credits section.  When I add it,
you'll be in there.  Sorry I neglected to mention your name in the
release announcement.

Anyway, weren't we discussing this on the forum and/or NG previously?  I
thought you knew that I was porting your code into GDB, and that that
was what you wrote it for.

John


hmmm.... Your boss thanks me?  He's welcome to hire me out to do this
work!

On Wed, 2005-04-20 at 02:34 +0000, James Dunne wrote:
 In article <d44esj$23kk$1 digitaldaemon.com>, James Dunne says...
I enjoyed looking at your patch.  Strange how I release a D symbol demangler
written in D and see some familiar programming constructs in your C patch =P.
My favorite is:

+  if (symbol == strstr(symbol, "_D")) {
+    mangled.pos += 2;
+    isFunc = 1;
+  } else if (symbol == strstr(symbol, "__Class_")) {
+    mangled.pos += 8;
+  } else if (symbol == strstr(symbol, "__init_")) {
+    mangled.pos += 7;
+  } else if (symbol == strstr(symbol, "__vtbl_")) {
+    mangled.pos += 7;
+  } else if (symbol == strstr(symbol, "__modctor_")) {
+    mangled.pos += 10;
+  } else if (symbol == strstr(symbol, "__moddtor_")) {
+    mangled.pos += 10;
+  } else if (symbol == strstr(symbol, "__ModuleInfo_")) {
+    mangled.pos += 13;
+  } else {
+    xfree(output.str);
+    //printf("NULL2\n");
+    return NULL;
+  }

which looks remarkably similar to something I wrote (demangle.d in bindings
project on dsource.org):

+ } else if (id[1 .. 6] == "Class") {
+ 	i = 7;
+ 	printf("class %.*s\n", extractidentifiers(id, i));
+ } else if (id[1 .. 5] == "init") {
+ 	i = 6;
+ 	printf("init %.*s\n", extractidentifiers(id, i));
+ } else if (id[1 .. 5] == "vtbl") {
+ 	i = 6;
+ 	printf("vtbl %.*s\n", extractidentifiers(id, i));
+ } else if (id[1 .. 8] == "modctor") {
+ 	i = 9;
+ 	printf("ctor %.*s\n", extractidentifiers(id, i));
+ } else if (id[1 .. 8] == "moddtor") {
+ 	i = 9;
+ 	printf("dtor %.*s\n", extractidentifiers(id, i));
+ } else if (id[1 .. 11] == "ModuleInfo") {
+ 	i = 12;
+ 	printf("module %.*s\n", extractidentifiers(id, i));
+ } else {
+ 	return false;
+ }

:).  If this is pure coincidence, then that's pretty strange!  If not, that's
cool too.  I'm not gonna get all up in arms about something as small and trivial
as a D symbol demangler.  I just thought it was funny and thought I should point
it out.  LOL

In article <d3sq2d$1094$1 digitaldaemon.com>, John Demme says...
I've finally gotten my GDB patch working.  It's able to demangle most D symbols,
but a few weird ones still show up.  Anyway, the announcement (along with
directions) are here:
http://dsource.org/forums/viewtopic.php?t=734
Regards, James Dunne
Upon closer inspection, you took the whole friggin' switch () statement block in my extracttypeinfo function too!! =P. Props to you for getting this stuff in GDB! I will actually drag down a source tree of GDB and compile this patch in. I've been waiting for something like this. I thank you. My dog thanks you. My wife thanks you. My appendix thanks you. My kids thank you. My boss thanks you. My professors thank you. Regards, James Dunne
Regards, James Dunne
Apr 20 2005