www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - About demangling

reply Lubos Pintes <lubos.pintes gmail.com> writes:
Hi,
Can someone point me to some source with information about name 
demangling when compiling some D program and the famous linker error 42 
appears?
Thank
Oct 11 2012
next sibling parent Jacob Carlborg <doob me.com> writes:
On 2012-10-11 15:17, Lubos Pintes wrote:
 Hi,
 Can someone point me to some source with information about name
 demangling when compiling some D program and the famous linker error 42
 appears?
 Thank
This page contains the reference for the name mangling: http://dlang.org/abi.html -- /Jacob Carlborg
Oct 11 2012
prev sibling parent reply Sean Kelly <sean invisibleduck.org> writes:
On Oct 11, 2012, at 6:17 AM, Lubos Pintes <lubos.pintes gmail.com> =
wrote:

 Hi,
 Can someone point me to some source with information about name =
demangling when compiling some D program and the famous linker error 42 = appears? Filter the symbol names through core.demangle.
Oct 11 2012
parent reply =?UTF-8?B?QWxleCBSw7hubmUgUGV0ZXJzZW4=?= <alex lycus.org> writes:
On 11-10-2012 22:56, Sean Kelly wrote:
 On Oct 11, 2012, at 6:17 AM, Lubos Pintes <lubos.pintes gmail.com> wrote:

 Hi,
 Can someone point me to some source with information about name demangling
when compiling some D program and the famous linker error 42 appears?
Filter the symbol names through core.demangle.
We even have a tool for that: https://github.com/D-Programming-Language/tools/blob/master/ddemangle.d -- Alex Rønne Petersen alex lycus.org http://lycus.org
Oct 11 2012
parent reply "Dan" <dbdavidson yahoo.com> writes:
On Thursday, 11 October 2012 at 21:04:28 UTC, Alex Rønne 
Petersen wrote:
 On 11-10-2012 22:56, Sean Kelly wrote:
 On Oct 11, 2012, at 6:17 AM, Lubos Pintes 
 <lubos.pintes gmail.com> wrote:

 Hi,
 Can someone point me to some source with information about 
 name demangling when compiling some D program and the famous 
 linker error 42 appears?
Filter the symbol names through core.demangle.
We even have a tool for that: https://github.com/D-Programming-Language/tools/blob/master/ddemangle.d
Does this work and if so how? I've seen a thread about the demangling tool not working on types, just functions. The comment at top of this file says "Replaces *all* occurrences of mangled D symbols in the input..." so I assume it deals with types? The help says: 'If <inputfile> is a single dash '-', standard input is read.' I've tried: $ echo "this & _D56TypeInfo_xS8plusauri6bsheet13balance_sheet12BalanceSheet6__initZ unq & _D55TypeInfo_S8plusauri6bsheet13balance_sheet12BalanceSheet6__initZ"
 ./goo.txt
$ ./ddmangle ./goo.txt which just hangs, and this - which does not demangle: $ echo "this & _D56TypeInfo_xS8plusauri6bsheet13balance_sheet12BalanceSheet6__initZ unq & _D55TypeInfo_S8plusauri6bsheet13balance_sheet12BalanceSheet6__initZ" | ./ddmangle this & _D56TypeInfo_xS8plusauri6bsheet13balance_sheet12BalanceSheet6__initZ unq & _D55TypeInfo_S8plusauri6bsheet13balance_sheet12BalanceSheet6__initZ What is the correct way to do this? Thanks Dan
Nov 01 2012
next sibling parent reply "H. S. Teoh" <hsteoh quickfur.ath.cx> writes:
On Thu, Nov 01, 2012 at 03:16:25PM +0100, Dan wrote:
 On Thursday, 11 October 2012 at 21:04:28 UTC, Alex Rønne Petersen
 wrote:
On 11-10-2012 22:56, Sean Kelly wrote:
On Oct 11, 2012, at 6:17 AM, Lubos Pintes
<lubos.pintes gmail.com> wrote:

Hi,
Can someone point me to some source with information about
name demangling when compiling some D program and the famous
linker error 42 appears?
Filter the symbol names through core.demangle.
We even have a tool for that: https://github.com/D-Programming-Language/tools/blob/master/ddemangle.d
Does this work and if so how? I've seen a thread about the demangling tool not working on types, just functions. The comment at top of this file says "Replaces *all* occurrences of mangled D symbols in the input..." so I assume it deals with types? The help says: 'If <inputfile> is a single dash '-', standard input is read.'
[...] This program only calls the library core.demangle. So if core.demangle doesn't demangle something, then it won't get demangled. The problem is, there's a comment in core.demangle that seems to say that some mangled symbols are skipped because they are not pertinent to the ABI, or something to that effect. Meaning that *not* all symbols are getting demangled. I think this should be an enhancement request in the bugtracker. T -- Let's call it an accidental feature. -- Larry Wall
Nov 01 2012
next sibling parent "Regan Heath" <regan netmail.co.nz> writes:
On Thu, 01 Nov 2012 15:40:23 -0000, H. S. Teoh <hsteoh quickfur.ath.cx> =
 =

wrote:

 On Thu, Nov 01, 2012 at 03:16:25PM +0100, Dan wrote:
 On Thursday, 11 October 2012 at 21:04:28 UTC, Alex R=F8nne Petersen
 wrote:
On 11-10-2012 22:56, Sean Kelly wrote:
On Oct 11, 2012, at 6:17 AM, Lubos Pintes
<lubos.pintes gmail.com> wrote:

Hi,
Can someone point me to some source with information about
name demangling when compiling some D program and the famous
linker error 42 appears?
Filter the symbol names through core.demangle.
We even have a tool for that: https://github.com/D-Programming-Language/tools/blob/master/ddemangl=
e.d
 Does this work and if so how? I've seen a thread about the demangling=
 tool not working on types, just functions. The comment at top of this=
 file says "Replaces *all* occurrences of mangled D symbols in the
 input..." so I assume it deals with types? The help says: 'If
 <inputfile> is a single dash '-', standard input is read.'
[...] This program only calls the library core.demangle. So if core.demangle=
 doesn't demangle something, then it won't get demangled. The problem i=
s,
 there's a comment in core.demangle that seems to say that some mangled=
 symbols are skipped because they are not pertinent to the ABI, or
 something to that effect. Meaning that *not* all symbols are getting
 demangled.

 I think this should be an enhancement request in the bugtracker.
There is also a bug in demangle.d, line 55: foreach (line; stdin.byLine()) should read: foreach (line; f.byLine()) R -- = Using Opera's revolutionary email client: http://www.opera.com/mail/
Nov 01 2012
prev sibling parent reply "Regan Heath" <regan netmail.co.nz> writes:
On Thu, 01 Nov 2012 15:40:23 -0000, H. S. Teoh <hsteoh quickfur.ath.cx> =
 =

wrote:

 On Thu, Nov 01, 2012 at 03:16:25PM +0100, Dan wrote:
 On Thursday, 11 October 2012 at 21:04:28 UTC, Alex R=F8nne Petersen
 wrote:
On 11-10-2012 22:56, Sean Kelly wrote:
On Oct 11, 2012, at 6:17 AM, Lubos Pintes
<lubos.pintes gmail.com> wrote:

Hi,
Can someone point me to some source with information about
name demangling when compiling some D program and the famous
linker error 42 appears?
Filter the symbol names through core.demangle.
We even have a tool for that: https://github.com/D-Programming-Language/tools/blob/master/ddemangl=
e.d
 Does this work and if so how? I've seen a thread about the demangling=
 tool not working on types, just functions. The comment at top of this=
 file says "Replaces *all* occurrences of mangled D symbols in the
 input..." so I assume it deals with types? The help says: 'If
 <inputfile> is a single dash '-', standard input is read.'
[...] This program only calls the library core.demangle. So if core.demangle=
 doesn't demangle something, then it won't get demangled. The problem i=
s,
 there's a comment in core.demangle that seems to say that some mangled=
 symbols are skipped because they are not pertinent to the ABI, or
 something to that effect. Meaning that *not* all symbols are getting
 demangled.

 I think this should be an enhancement request in the bugtracker.
Also, running this: dmd test.d | demangle.exe - on windows, results in this: invalid UTF-8 sequence Usage: demangle.exe [options] <inputfile> Demangles all occurrences of mangled D symbols in the input and writes t= o standard output. If <inputfile> is a single dash '-', standard input is read. Options: --help, -h Show this help Adding writefln to demangle.d to debug the issue shows that args[1] is "= -" = and that getopt is throwing the exception "invalid UTF-8 sequence". Omitting the - works, and demangle reads stdin. R -- = Using Opera's revolutionary email client: http://www.opera.com/mail/
Nov 01 2012
next sibling parent reply "H. S. Teoh" <hsteoh quickfur.ath.cx> writes:
On Thu, Nov 01, 2012 at 04:25:56PM -0000, Regan Heath wrote:
 On Thu, 01 Nov 2012 15:40:23 -0000, H. S. Teoh
 <hsteoh quickfur.ath.cx> wrote:
 
On Thu, Nov 01, 2012 at 03:16:25PM +0100, Dan wrote:
On Thursday, 11 October 2012 at 21:04:28 UTC, Alex Rønne Petersen
wrote:
On 11-10-2012 22:56, Sean Kelly wrote:
[...]
We even have a tool for that:
https://github.com/D-Programming-Language/tools/blob/master/ddemangle.d
[...]
 Also, running this:
 
 dmd test.d | demangle.exe -
 
 on windows, results in this:
 
 invalid UTF-8 sequence
[...]
 Omitting the - works, and demangle reads stdin.
[...] https://github.com/D-Programming-Language/tools/pull/35 T -- English has the lovely word "defenestrate", meaning "to execute by throwing someone out a window", or more recently "to remove Windows from a computer and replace it with something useful". :-) -- John Cowan
Nov 01 2012
parent "Regan Heath" <regan netmail.co.nz> writes:
On Thu, 01 Nov 2012 17:21:29 -0000, H. S. Teoh <hsteoh quickfur.ath.cx> =
 =

wrote:

 On Thu, Nov 01, 2012 at 04:25:56PM -0000, Regan Heath wrote:
 On Thu, 01 Nov 2012 15:40:23 -0000, H. S. Teoh
 <hsteoh quickfur.ath.cx> wrote:

On Thu, Nov 01, 2012 at 03:16:25PM +0100, Dan wrote:
On Thursday, 11 October 2012 at 21:04:28 UTC, Alex R=F8nne Petersen=
wrote:
On 11-10-2012 22:56, Sean Kelly wrote:
[...]
We even have a tool for that:
https://github.com/D-Programming-Language/tools/blob/master/ddeman=
gle.d
 [...]
 Also, running this:

 dmd test.d | demangle.exe -

 on windows, results in this:

 invalid UTF-8 sequence
[...]
 Omitting the - works, and demangle reads stdin.
[...] https://github.com/D-Programming-Language/tools/pull/35
Perfect, thanks. R -- = Using Opera's revolutionary email client: http://www.opera.com/mail/
Nov 01 2012
prev sibling parent "Regan Heath" <regan netmail.co.nz> writes:
On Thu, 01 Nov 2012 16:25:56 -0000, Regan Heath <regan netmail.co.nz>  
wrote:
 Adding writefln to demangle.d to debug the issue shows that args[1] is  
 "-" and that getopt is throwing the exception "invalid UTF-8 sequence".
I was wrong here, this line is the issue: stderr.writeln(e.msg); For some reason, when run from command prompt and passed "-" as an arg it errors. If I run it in debug mode in VisualD it works and outputs: Unrecognized option - R -- Using Opera's revolutionary email client: http://www.opera.com/mail/
Nov 01 2012
prev sibling parent "H. S. Teoh" <hsteoh quickfur.ath.cx> writes:
On Thu, Nov 01, 2012 at 08:40:23AM -0700, H. S. Teoh wrote:
 On Thu, Nov 01, 2012 at 03:16:25PM +0100, Dan wrote:
 On Thursday, 11 October 2012 at 21:04:28 UTC, Alex Rønne Petersen
 wrote:
[...]
We even have a tool for that:
https://github.com/D-Programming-Language/tools/blob/master/ddemangle.d
Does this work and if so how? I've seen a thread about the demangling tool not working on types, just functions. The comment at top of this file says "Replaces *all* occurrences of mangled D symbols in the input..." so I assume it deals with types? The help says: 'If <inputfile> is a single dash '-', standard input is read.'
[...] This program only calls the library core.demangle. So if core.demangle doesn't demangle something, then it won't get demangled. The problem is, there's a comment in core.demangle that seems to say that some mangled symbols are skipped because they are not pertinent to the ABI, or something to that effect. Meaning that *not* all symbols are getting demangled. I think this should be an enhancement request in the bugtracker.
[...] I just looked over core.demangle. Apparently only function names are demangled, everything else is currently not implemented. :-( I say, definitely file an enhancement request in the bugtracker. T -- The computer is only a tool. Unfortunately, so is the user. -- Armaphine, K5
Nov 01 2012