www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - mangle

reply Ellery Newcomer <ellery-newcomer utulsa.edu> writes:
test.o: In function 
`_D3std6random156__T11RandomCoverTAiTS3std6random98__T21MersenneTwisterEngineTkVi32Vi624Vi397Vi31Vk2567483615Vi11Vi7Vk2636928640Vi15Vk4022730752Vi18Z21MersenneTwisterEngineZ11RandomCover4saveMFNdZS3std6random156__T11RandomCoverTAiTS3std6random98__T21MersenneTwisterEngineTkVi32Vi624Vi397Vi31Vk2567483615Vi11Vi7Vk2636928640Vi15Vk4022730752Vi18Z21MersenneTwisterEngineZ11RandomCover':
test.d:(.text._D3std6random156__T11RandomCoverTAiTS3std6random98__T21MersenneTwisterEngineTkVi32Vi624Vi397Vi31Vk2567483615Vi11Vi7Vk2636928640Vi15Vk4022730752Vi18Z21MersenneTwisterEngineZ11RandomCover4saveMFNdZS3std6random156__T11RandomCoverTAiTS3std6random98__T21MersenneTwisterEngineTkVi32Vi624Vi397Vi31Vk2567483615Vi11Vi7Vk2636928640Vi15Vk4022730752Vi18Z21MersenneTwisterEngineZ
1RandomCover+0x69): 
undefined reference to 
`_D3std6random98__T21MersenneTwisterEngineTkVi32Vi624Vi397Vi31Vk2567483615Vi11Vi7Vk2636928640Vi15Vk4022730752Vi18Z21MersenneTwisterEngine4saveMFNdZS3std6random98__T21MersenneTwisterEngineTkVi32Vi624Vi397Vi31Vk2567483615Vi11Vi7Vk2636928640Vi15Vk4022730752Vi18Z21MersenneTwisterEngine'
collect2: ld returned 1 exit status
--- errorlevel 1


err, could someone point me to a decent demangler?
Jul 01 2010
next sibling parent reply Adam Ruppe <destructionator gmail.com> writes:
http://dpldocs.info/std.demangle
Jul 01 2010
parent reply Ellery Newcomer <ellery-newcomer utulsa.edu> writes:
On 07/01/2010 08:16 PM, Adam Ruppe wrote:
 http://dpldocs.info/std.demangle

import std.demangle; import std.stdio; void main(){ writeln(demangle("_D3std6random156__T11RandomCoverTAiTS3std6random98__T21MersenneTwisterEngineTkVi32Vi624Vi397Vi31Vk2567483615Vi11Vi7Vk2636928640Vi15Vk4022730752Vi18Z21MersenneTwisterEngineZ11RandomCover4saveMFNdZS3std6random156__T11RandomCoverTAiTS3std6random98__T21MersenneTwisterEngineTkVi32Vi624Vi397Vi31Vk2567483615Vi11Vi7Vk2636928640Vi15Vk4022730752Vi18Z21MersenneTwisterEngineZ11RandomCover")); } gives _D3std6random156__T11RandomCoverTAiTS3std6random98__T21MersenneTwisterEngineTkVi32Vi624Vi397Vi31Vk2567483615Vi11Vi7Vk2636928640Vi15Vk4022730752Vi18Z21MersenneTwisterEngineZ11RandomCover4saveMFNdZS3std6random156__T11RandomCoverTAiTS3std6random98__T21MersenneTwisterEngineTkVi32Vi624Vi397Vi31Vk2567483615Vi11Vi7Vk2636928640Vi15Vk4022730752Vi18Z21MersenneTwisterEngineZ11RandomCover There wouldn't happen to be any other demanglers about, would there?
Jul 02 2010
next sibling parent reply Jacob Carlborg <doob me.com> writes:
On 2010-07-02 18.17, Ellery Newcomer wrote:
 On 07/01/2010 08:16 PM, Adam Ruppe wrote:
 http://dpldocs.info/std.demangle

import std.demangle; import std.stdio; void main(){ writeln(demangle("_D3std6random156__T11RandomCoverTAiTS3std6random98__T21MersenneTwisterEngineTkVi32Vi624Vi397Vi31Vk2567483615Vi11Vi7Vk2636928640Vi15Vk4022730752Vi18Z21MersenneTwisterEngineZ11RandomCover4saveMFNdZS3std6random156__T11RandomCoverTAiTS3std6random98__T21MersenneTwisterEngineTkVi32Vi624Vi397Vi31Vk2567483615Vi11Vi7Vk2636928640Vi15Vk4022730752Vi18Z21MersenneTwisterEngineZ11RandomCover")); } gives _D3std6random156__T11RandomCoverTAiTS3std6random98__T21MersenneTwisterEngineTkVi32Vi624Vi397Vi31Vk2567483615Vi11Vi7Vk2636928640Vi15Vk4022730752Vi18Z21MersenneTwisterEngineZ11RandomCover4saveMFNdZS3std6random156__T11RandomCoverTAiTS3std6random98__T21MersenneTwisterEngineTkVi32Vi624Vi397Vi31Vk2567483615Vi11Vi7Vk2636928640Vi15Vk4022730752Vi18Z21MersenneTwisterEngineZ11RandomCover

std.demangle is incomplete, missing newer D2 features like return by reference, and incorrectly handles floating point numbers in tempaltes. If it encounters something it can't demangle it will just return the original mangled name.
 There wouldn't happen to be any other demanglers about, would there?

You could try the one in tango but I wouldn't think you have any more luck with that one. -- Jacob Carlborg
Jul 03 2010
parent Jacob Carlborg <doob me.com> writes:
On 2010-07-06 07.21, Brad Roberts wrote:
 On 7/3/2010 11:34 AM, Jacob Carlborg wrote:
 On 2010-07-02 18.17, Ellery Newcomer wrote:
 On 07/01/2010 08:16 PM, Adam Ruppe wrote:
 http://dpldocs.info/std.demangle

import std.demangle; import std.stdio; void main(){ writeln(demangle("_D3std6random156__T11RandomCoverTAiTS3std6random98__T21MersenneTwisterEngineTkVi32Vi624Vi397Vi31Vk2567483615Vi11Vi7Vk2636928640Vi15Vk4022730752Vi18Z21MersenneTwisterEngineZ11RandomCover4saveMFNdZS3std6random156__T11RandomCoverTAiTS3std6random98__T21MersenneTwisterEngineTkVi32Vi624Vi397Vi31Vk2567483615Vi11Vi7Vk2636928640Vi15Vk4022730752Vi18Z21MersenneTwisterEngineZ11RandomCover")); } gives _D3std6random156__T11RandomCoverTAiTS3std6random98__T21MersenneTwisterEngineTkVi32Vi624Vi397Vi31Vk2567483615Vi11Vi7Vk2636928640Vi15Vk4022730752Vi18Z21MersenneTwisterEngineZ11RandomCover4saveMFNdZS3std6random156__T11RandomCoverTAiTS3std6random98__T21MersenneTwisterEngineTkVi32Vi624Vi397Vi31Vk2567483615Vi11Vi7Vk2636928640Vi15Vk4022730752Vi18Z21MersenneTwisterEngineZ11RandomCover

std.demangle is incomplete, missing newer D2 features like return by reference, and incorrectly handles floating point numbers in tempaltes. If it encounters something it can't demangle it will just return the original mangled name.

Obviously any failures to demangle symbols produced by the compiler is a bug and should be treated as such.. so.. please file 'em. Thanks, Brad

Already filed, issue 4323 and 3334. -- Jacob Carlborg
Jul 06 2010
prev sibling parent Brad Roberts <braddr puremagic.com> writes:
On 7/3/2010 11:34 AM, Jacob Carlborg wrote:
 On 2010-07-02 18.17, Ellery Newcomer wrote:
 On 07/01/2010 08:16 PM, Adam Ruppe wrote:
 http://dpldocs.info/std.demangle

import std.demangle; import std.stdio; void main(){ writeln(demangle("_D3std6random156__T11RandomCoverTAiTS3std6random98__T21MersenneTwisterEngineTkVi32Vi624Vi397Vi31Vk2567483615Vi11Vi7Vk2636928640Vi15Vk4022730752Vi18Z21MersenneTwisterEngineZ11RandomCover4saveMFNdZS3std6random156__T11RandomCoverTAiTS3std6random98__T21MersenneTwisterEngineTkVi32Vi624Vi397Vi31Vk2567483615Vi11Vi7Vk2636928640Vi15Vk4022730752Vi18Z21MersenneTwisterEngineZ11RandomCover")); } gives _D3std6random156__T11RandomCoverTAiTS3std6random98__T21MersenneTwisterEngineTkVi32Vi624Vi397Vi31Vk2567483615Vi11Vi7Vk2636928640Vi15Vk4022730752Vi18Z21MersenneTwisterEngineZ11RandomCover4saveMFNdZS3std6random156__T11RandomCoverTAiTS3std6random98__T21MersenneTwisterEngineTkVi32Vi624Vi397Vi31Vk2567483615Vi11Vi7Vk2636928640Vi15Vk4022730752Vi18Z21MersenneTwisterEngineZ11RandomCover

std.demangle is incomplete, missing newer D2 features like return by reference, and incorrectly handles floating point numbers in tempaltes. If it encounters something it can't demangle it will just return the original mangled name.

Obviously any failures to demangle symbols produced by the compiler is a bug and should be treated as such.. so.. please file 'em. Thanks, Brad
Jul 05 2010
prev sibling next sibling parent reply Jonathan M Davis <jmdavisprog gmail.com> writes:
By the way, why _does_ D mangle its names? What's the advantage? I understood 
that C++ does it because it was forced to back in the days when it was 
transformed into C code during compilation but that it's now generally 
considered a legacy problem that we're stuck with rather than something that 
would still be considered a good design decision.

So, why did D go with name mangling? It certainly makes stuff like stack traces 
harder to deal with. I've never heard of any advantage to name mangling, only 
disadvantages.

- Jonathan M Davis
Jul 01 2010
parent reply Rainer Deyke <rainerd eldwood.com> writes:
On 7/1/2010 19:32, Jonathan M Davis wrote:
 By the way, why _does_ D mangle its names? What's the advantage? I understood 
 that C++ does it because it was forced to back in the days when it was 
 transformed into C code during compilation but that it's now generally 
 considered a legacy problem that we're stuck with rather than something that 
 would still be considered a good design decision.
 
 So, why did D go with name mangling? It certainly makes stuff like stack
traces 
 harder to deal with. I've never heard of any advantage to name mangling, only 
 disadvantages.

Because DMD is stuck with a C-age linker. -- Rainer Deyke - rainerd eldwood.com
Jul 01 2010
next sibling parent Rainer Deyke <rainerd eldwood.com> writes:
On 7/1/2010 20:34, Jonathan M Davis wrote:
 On Thursday, July 01, 2010 19:13:02 Rainer Deyke wrote:
 Because DMD is stuck with a C-age linker.

Well, I guess that it just goes to show how little I understand about exactly how linking works when I don't understand what that means. After all, C doesn't using name mangling. Does that mean that name mangling it meant as a namespacing tool to ensure that no D function could possibly have the same linking name as a C function?

That, and to allow for overloaded functions, functions with the same name in different modules, and member functions. Each symbol with external linkage must map to a single unique identifier. The concerns are exactly the same as those in C++. -- Rainer Deyke - rainerd eldwood.com
Jul 01 2010
prev sibling parent reply Justin Spahr-Summers <Justin.SpahrSummers gmail.com> writes:
On Thu, 1 Jul 2010 19:34:09 -0700, Jonathan M Davis 
<jmdavisprog gmail.com> wrote:
 
 On Thursday, July 01, 2010 19:13:02 Rainer Deyke wrote:
 On 7/1/2010 19:32, Jonathan M Davis wrote:
 By the way, why _does_ D mangle its names? What's the advantage? I
 understood that C++ does it because it was forced to back in the days
 when it was transformed into C code during compilation but that it's now
 generally considered a legacy problem that we're stuck with rather than
 something that would still be considered a good design decision.
 
 So, why did D go with name mangling? It certainly makes stuff like stack
 traces harder to deal with. I've never heard of any advantage to name
 mangling, only disadvantages.

Because DMD is stuck with a C-age linker.

Well, I guess that it just goes to show how little I understand about exactly how linking works when I don't understand what that means. After all, C doesn't using name mangling. Does that mean that name mangling it meant as a namespacing tool to ensure that no D function could possibly have the same linking name as a C function? - Jonathan M Davis

C doesn't require mangling because functions can't be overloaded. To make D (or C++) compatible with C linkers, symbol names need to be unique, so functions with identical names but different types need to be represented with different symbols.
Jul 01 2010
next sibling parent Norbert Nemec <Norbert Nemec-online.de> writes:
On 02/07/10 13:41, Steven Schveighoffer wrote:
 This isn't really the reason for "mangling". The issue is that the C
 linker requires symbols to be the same as source symbols. That is, made
 up only of A-Z,a-z,0-9 and _. I'd much rather see symbol names like this:

 foo(int,string)

 than

 fooIvS45whatever

Perhaps this limitation could be removed in the C linker? Why not allow arbitrary strings as symbols in a modern implementation? I could well imagine that this could be realized in some extension of the standard?
Jul 02 2010
prev sibling parent reply Justin Spahr-Summers <Justin.SpahrSummers gmail.com> writes:
On Fri, 02 Jul 2010 08:41:45 -0400, Steven Schveighoffer 
<schveiguy yahoo.com> wrote:
 
 On Thu, 01 Jul 2010 23:03:31 -0400, Justin Spahr-Summers  
 <Justin.SpahrSummers gmail.com> wrote:
 
 On Thu, 1 Jul 2010 19:34:09 -0700, Jonathan M Davis
 <jmdavisprog gmail.com> wrote:
 On Thursday, July 01, 2010 19:13:02 Rainer Deyke wrote:
 On 7/1/2010 19:32, Jonathan M Davis wrote:
 By the way, why _does_ D mangle its names? What's the advantage? I
 understood that C++ does it because it was forced to back in the  


 when it was transformed into C code during compilation but that  


 generally considered a legacy problem that we're stuck with rather  


 something that would still be considered a good design decision.

 So, why did D go with name mangling? It certainly makes stuff like  


 traces harder to deal with. I've never heard of any advantage to  


 mangling, only disadvantages.

Because DMD is stuck with a C-age linker.

Well, I guess that it just goes to show how little I understand about exactly how linking works when I don't understand what that means. After all, C doesn't using name mangling. Does that mean that name mangling it meant as a namespacing tool to ensure that no D function could possibly have the same linking name as a C function? - Jonathan M Davis

C doesn't require mangling because functions can't be overloaded. To make D (or C++) compatible with C linkers, symbol names need to be unique, so functions with identical names but different types need to be represented with different symbols.

This isn't really the reason for "mangling". The issue is that the C linker requires symbols to be the same as source symbols. That is, made up only of A-Z,a-z,0-9 and _. I'd much rather see symbol names like this: foo(int,string) than fooIvS45whatever -Steve

Right, but that's only an issue because of overloaded types. C suffers no such problems because a symbol with a given name is guaranteed to be unique within the same translation unit.
Jul 04 2010
parent Don <nospam nospam.com> writes:
Leandro Lucarella wrote:
 What about including a demangling tool in the DMD distribution? That
 would be helpful and avoid the DIY status we have now...
 

Jul 11 2010
prev sibling next sibling parent Jonathan M Davis <jmdavisprog gmail.com> writes:
On Thursday, July 01, 2010 19:13:02 Rainer Deyke wrote:
 On 7/1/2010 19:32, Jonathan M Davis wrote:
 By the way, why _does_ D mangle its names? What's the advantage? I
 understood that C++ does it because it was forced to back in the days
 when it was transformed into C code during compilation but that it's now
 generally considered a legacy problem that we're stuck with rather than
 something that would still be considered a good design decision.
 
 So, why did D go with name mangling? It certainly makes stuff like stack
 traces harder to deal with. I've never heard of any advantage to name
 mangling, only disadvantages.

Because DMD is stuck with a C-age linker.

Well, I guess that it just goes to show how little I understand about exactly how linking works when I don't understand what that means. After all, C doesn't using name mangling. Does that mean that name mangling it meant as a namespacing tool to ensure that no D function could possibly have the same linking name as a C function? - Jonathan M Davis
Jul 01 2010
prev sibling next sibling parent "Steven Schveighoffer" <schveiguy yahoo.com> writes:
On Thu, 01 Jul 2010 23:03:31 -0400, Justin Spahr-Summers  
<Justin.SpahrSummers gmail.com> wrote:

 On Thu, 1 Jul 2010 19:34:09 -0700, Jonathan M Davis
 <jmdavisprog gmail.com> wrote:
 On Thursday, July 01, 2010 19:13:02 Rainer Deyke wrote:
 On 7/1/2010 19:32, Jonathan M Davis wrote:
 By the way, why _does_ D mangle its names? What's the advantage? I
 understood that C++ does it because it was forced to back in the  


 when it was transformed into C code during compilation but that  


 generally considered a legacy problem that we're stuck with rather  


 something that would still be considered a good design decision.

 So, why did D go with name mangling? It certainly makes stuff like  


 traces harder to deal with. I've never heard of any advantage to  


 mangling, only disadvantages.

Because DMD is stuck with a C-age linker.

Well, I guess that it just goes to show how little I understand about exactly how linking works when I don't understand what that means. After all, C doesn't using name mangling. Does that mean that name mangling it meant as a namespacing tool to ensure that no D function could possibly have the same linking name as a C function? - Jonathan M Davis

C doesn't require mangling because functions can't be overloaded. To make D (or C++) compatible with C linkers, symbol names need to be unique, so functions with identical names but different types need to be represented with different symbols.

This isn't really the reason for "mangling". The issue is that the C linker requires symbols to be the same as source symbols. That is, made up only of A-Z,a-z,0-9 and _. I'd much rather see symbol names like this: foo(int,string) than fooIvS45whatever -Steve
Jul 02 2010
prev sibling next sibling parent Leandro Lucarella <luca llucax.com.ar> writes:
Rainer Deyke, el  1 de julio a las 20:59 me escribiste:
 On 7/1/2010 20:34, Jonathan M Davis wrote:
 On Thursday, July 01, 2010 19:13:02 Rainer Deyke wrote:
 Because DMD is stuck with a C-age linker.

Well, I guess that it just goes to show how little I understand about exactly how linking works when I don't understand what that means. After all, C doesn't using name mangling. Does that mean that name mangling it meant as a namespacing tool to ensure that no D function could possibly have the same linking name as a C function?

That, and to allow for overloaded functions, functions with the same name in different modules, and member functions. Each symbol with external linkage must map to a single unique identifier. The concerns are exactly the same as those in C++.

You can use fully qualified names, like: p1.m1.f1(int, float) p1.m1.f1(charp[]) p2.m2.f1(int, float) I don't know if that names are supported by the linker. -- Leandro Lucarella (AKA luca) http://llucax.com.ar/ ---------------------------------------------------------------------- GPG Key: 5F5A8D05 (F8CD F9A7 BF00 5431 4145 104C 949E BFB6 5F5A 8D05) ---------------------------------------------------------------------- Come on, now, I hear you're feeling down. Well I can ease your pain Get you on your feet again.
Jul 02 2010
prev sibling next sibling parent "Rory McGuire" <rmcguire neonova.co.za> writes:
On Fri, 02 Jul 2010 18:17:03 +0200, Ellery Newcomer  
<ellery-newcomer utulsa.edu> wrote:

 On 07/01/2010 08:16 PM, Adam Ruppe wrote:
 http://dpldocs.info/std.demangle

import std.demangle; import std.stdio; void main(){ writeln(demangle("_D3std6random156__T11RandomCoverTAiTS3std6random98__T21MersenneTwisterEngineTkVi32Vi624Vi397Vi31Vk2567483615Vi11Vi7Vk2636928640Vi15Vk4022730752Vi18Z21MersenneTwisterEngineZ11RandomCover4saveMFNdZS3std6random156__T11RandomCoverTAiTS3std6random98__T21MersenneTwisterEngineTkVi32Vi624Vi397Vi31Vk2567483615Vi11Vi7Vk2636928640Vi15Vk4022730752Vi18Z21MersenneTwisterEngineZ11RandomCover")); } gives _D3std6random156__T11RandomCoverTAiTS3std6random98__T21MersenneTwisterEngineTkVi32Vi624Vi397Vi31Vk2567483615Vi11Vi7Vk2636928640Vi15Vk4022730752Vi18Z21MersenneTwisterEngineZ11RandomCover4saveMFNdZS3std6random156__T11RandomCoverTAiTS3std6random98__T21MersenneTwisterEngineTkVi32Vi624Vi397Vi31Vk2567483615Vi11Vi7Vk2636928640Vi15Vk4022730752Vi18Z21MersenneTwisterEngineZ11RandomCover There wouldn't happen to be any other demanglers about, would there?

Perhaps make one or fix the std one. The mangle definition seems to be in mtype.c:193 and in template.c:4480 there is genIdent which seems to generate the template identifier not sure though (Just had a quick look for the 'V' char in the mangled symbol you have here). -Rory
Jul 02 2010
prev sibling parent Leandro Lucarella <luca llucax.com.ar> writes:
What about including a demangling tool in the DMD distribution? That
would be helpful and avoid the DIY status we have now...

-- 
Leandro Lucarella (AKA luca)                     http://llucax.com.ar/
----------------------------------------------------------------------
GPG Key: 5F5A8D05 (F8CD F9A7 BF00 5431 4145  104C 949E BFB6 5F5A 8D05)
----------------------------------------------------------------------
¿Qué será lo que hace que una brújula siempre marque el norte?
- Ser aguja, nada más, y cumplir su misión.
	-- Ricardo Vaporeso
Jul 04 2010