www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - D demangling filter tool?

reply David Nadlinger <see klickverbot.at> writes:
Does anybody have a tool lying around which reads in some text (from a 
file or stdin) and replaces all mangled D names it comes across with the 
demangled text? I thought I would ask before quickly whipping together a 
short program myself…

David
Jun 22 2011
parent reply Michel Fortin <michel.fortin michelf.com> writes:
On 2011-06-22 18:58:44 -0400, David Nadlinger <see klickverbot.at> said:

 Does anybody have a tool lying around which reads in some text (from a 
 file or stdin) and replaces all mangled D names it comes across with 
 the demangled text? I thought I would ask before quickly whipping 
 together a short program myself…
I made one a few months ago, but I can't seem to find it back now... Ah! found it: <http://www.digitalmars.com/pnews/read.php?server=news.digitalmars.com&group=digitalmars.D&artnum=129673&header> -- Michel Fortin michel.fortin michelf.com http://michelf.com/
Jun 22 2011
next sibling parent reply Robert Clipsham <robert octarineparrot.com> writes:
On 23/06/2011 02:16, Michel Fortin wrote:
 On 2011-06-22 18:58:44 -0400, David Nadlinger <see klickverbot.at> said:

 Does anybody have a tool lying around which reads in some text (from a
 file or stdin) and replaces all mangled D names it comes across with
 the demangled text? I thought I would ask before quickly whipping
 together a short program myself…
I made one a few months ago, but I can't seem to find it back now... Ah! found it: <http://www.digitalmars.com/pnews/read.php?server=news.digitalmars.com&group=digitalmars.D&artnum=129673&header>
I don't suppose you could repaste the code, I can't seem to copy/paste the above, the web news reader just takes me back to its home page when I try D; -- Robert http://octarineparrot.com/
Jun 23 2011
next sibling parent reply David Nadlinger <see klickverbot.at> writes:
On 6/23/11 12:57 PM, Robert Clipsham wrote:
 On 23/06/2011 02:16, Michel Fortin wrote:
 I made one a few months ago, but I can't seem to find it back now... Ah!
 found it:
 <http://www.digitalmars.com/pnews/read.php?server=news.digitalmars.com&group=digitalmars.D&artnum=129673&header>
I don't suppose you could repaste the code, I can't seem to copy/paste the above, the web news reader just takes me back to its home page when I try D;
https://gist.github.com/1042363 David
Jun 23 2011
parent reply Robert Clipsham <robert octarineparrot.com> writes:
On 23/06/2011 12:13, David Nadlinger wrote:
 On 6/23/11 12:57 PM, Robert Clipsham wrote:
 On 23/06/2011 02:16, Michel Fortin wrote:
 I made one a few months ago, but I can't seem to find it back now... Ah!
 found it:
 <http://www.digitalmars.com/pnews/read.php?server=news.digitalmars.com&group=digitalmars.D&artnum=129673&header>
I don't suppose you could repaste the code, I can't seem to copy/paste the above, the web news reader just takes me back to its home page when I try D;
https://gist.github.com/1042363 David
Doesn't seem to work for me with the following: Undefined symbols for architecture i386: "__Dmain", referenced from: _D2rt6dmain24mainUiPPaZi7runMainMFZv in libphobos2.a(dmain2_2fa_1a5.o) ld: symbol(s) not found for architecture i386 collect2: ld returned 1 exit status --- errorlevel 1 Unless I manually pull out the symbols and send them through it. -- Robert http://octarineparrot.com/
Jun 23 2011
parent reply Michel Fortin <michel.fortin michelf.com> writes:
On 2011-06-23 07:25:45 -0400, Robert Clipsham <robert octarineparrot.com> said:

 On 23/06/2011 12:13, David Nadlinger wrote:
 On 6/23/11 12:57 PM, Robert Clipsham wrote:
 On 23/06/2011 02:16, Michel Fortin wrote:
 I made one a few months ago, but I can't seem to find it back now... Ah!
 found it:
 <http://www.digitalmars.com/pnews/read.php?server=news.digitalmars.com&group=digitalmars.D&artnum=129673&header>
I
 
don't suppose you could repaste the code, I can't seem to copy/paste the above, the web news reader just takes me back to its home page when I try D;
https://gist.github.com/1042363 David
Doesn't seem to work for me with the following: Undefined symbols for architecture i386: "__Dmain", referenced from: _D2rt6dmain24mainUiPPaZi7runMainMFZv in libphobos2.a(dmain2_2fa_1a5.o) ld: symbol(s) not found for architecture i386 collect2: ld returned 1 exit status --- errorlevel 1 Unless I manually pull out the symbols and send them through it.
Works for me. Note: make sure you're redirecting stderr to ddemangle's stdin using 2>&1. $ dmd u.d 2>&1 | ./ddemangle Undefined symbols for architecture i386: "__Dmain", referenced from: extern (C) int rt.dmain2.main(int, char**).void runMain() in libphobos2.a(dmain2_2f9_1a5.o) ld: symbol(s) not found for architecture i386 collect2: ld returned 1 exit status --- errorlevel 1 -- Michel Fortin michel.fortin michelf.com http://michelf.com/
Jun 23 2011
parent reply Robert Clipsham <robert octarineparrot.com> writes:
On 23/06/2011 12:54, Michel Fortin wrote:
 https://gist.github.com/1042363

 David
Doesn't seem to work for me with the following: Undefined symbols for architecture i386: "__Dmain", referenced from: _D2rt6dmain24mainUiPPaZi7runMainMFZv in libphobos2.a(dmain2_2fa_1a5.o) ld: symbol(s) not found for architecture i386 collect2: ld returned 1 exit status --- errorlevel 1 Unless I manually pull out the symbols and send them through it.
Works for me. Note: make sure you're redirecting stderr to ddemangle's stdin using 2>&1. $ dmd u.d 2>&1 | ./ddemangle Undefined symbols for architecture i386: "__Dmain", referenced from: extern (C) int rt.dmain2.main(int, char**).void runMain() in libphobos2.a(dmain2_2f9_1a5.o) ld: symbol(s) not found for architecture i386 collect2: ld returned 1 exit status --- errorlevel 1
Shouldn't it also demangle __Dmain? In backtraces that's normally demangled as D main(). Also thanks, that's got it working :) -- Robert http://octarineparrot.com/
Jun 23 2011
parent Sean Kelly <sean invisibleduck.org> writes:
On Jun 23, 2011, at 5:26 AM, Robert Clipsham wrote:
=20
 Shouldn't it also demangle __Dmain? In backtraces that's normally =
demangled as D main(). Also thanks, that's got it working :) =20 The double underscore may be throwing it off.=
Jun 23 2011
prev sibling parent Michel Fortin <michel.fortin michelf.com> writes:
On 2011-06-23 06:57:39 -0400, Robert Clipsham <robert octarineparrot.com> said:

 On 23/06/2011 02:16, Michel Fortin wrote:
 On 2011-06-22 18:58:44 -0400, David Nadlinger <see klickverbot.at> said:
 
 Does anybody have a tool lying around which reads in some text (from a
 file or stdin) and replaces all mangled D names it comes across with
 the demangled text? I thought I would ask before quickly whipping
 together a short program myself…
I made one a few months ago, but I can't seem to find it back now... Ah! found it: <http://www.digitalmars.com/pnews/read.php?server=news.digitalmars.com&group=digitalmars.D&artnum=129673&header>
I
 
don't suppose you could repaste the code, I can't seem to copy/paste the above, the web news reader just takes me back to its home page when I try D;
import std.stdio; import core.demangle; void main() { foreach (line; stdin.byLine()) { size_t beginIdx, endIdx; enum State { searching_, searchingD, searchingEnd, done } State state; foreach (i, char c; line) { switch (state) { case State.searching_: if (c == '_') { beginIdx = i; state = State.searchingD; } break; case State.searchingD: if (c == 'D') state = State.searchingEnd; else if (c != '_') state = State.searching_; break; case State.searchingEnd: if (c == ' ' || c == '"' || c == '\'') { endIdx = i; state = State.done; } break; } if (state == State.done) break; } if (endIdx > beginIdx) writeln(line[0..beginIdx], demangle(line[beginIdx..endIdx]), line[endIdx..$]); else writeln(line); } } -- Michel Fortin michel.fortin michelf.com http://michelf.com/
Jun 23 2011
prev sibling parent reply KennyTM~ <kennytm gmail.com> writes:
On Jun 23, 11 09:16, Michel Fortin wrote:
 On 2011-06-22 18:58:44 -0400, David Nadlinger <see klickverbot.at> said:

 Does anybody have a tool lying around which reads in some text (from a
 file or stdin) and replaces all mangled D names it comes across with
 the demangled text? I thought I would ask before quickly whipping
 together a short program myself…
I made one a few months ago, but I can't seem to find it back now... Ah! found it: <http://www.digitalmars.com/pnews/read.php?server=news.digitalmars.com&group=digitalmars.D&artnum=129673&header>
This should be pulled to https://github.com/D-Programming-Language/tools, bundled with dmd, and be piped automatically in dmd/src/link.c.
Jun 23 2011
parent Michel Fortin <michel.fortin michelf.com> writes:
On 2011-06-23 09:36:43 -0400, KennyTM~ <kennytm gmail.com> said:

 On Jun 23, 11 09:16, Michel Fortin wrote:
 On 2011-06-22 18:58:44 -0400, David Nadlinger <see klickverbot.at> said:
 
 Does anybody have a tool lying around which reads in some text (from a
 file or stdin) and replaces all mangled D names it comes across with
 the demangled text? I thought I would ask before quickly whipping
 together a short program myself…
I made one a few months ago, but I can't seem to find it back now... Ah! found it: <http://www.digitalmars.com/pnews/read.php?server=news.digitalmars.com&group=digitalmars.D&artnum=129673&header>
This
 
should be pulled to https://github.com/D-Programming-Language/tools, bundled with dmd, and be piped automatically in dmd/src/link.c.
First step done: <https://github.com/D-Programming-Language/tools/pull/2> -- Michel Fortin michel.fortin michelf.com http://michelf.com/
Jun 23 2011