www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Is std.demangle usable?

reply Andrej Mitrovic <none none.none> writes:
import std.stdio;
import std.demangle;
import std.traits;

void main()
{   
    void test()
    {
    }
    
    auto mystr = mangledName!(test); // -----------
demangle4mainFAAyaZv4testMFZv
    writeln(demangle(mystr));        // writes back
demangle4mainFAAyaZv4testMFZv
}

Also, the example code is broken in
http://www.digitalmars.com/d/2.0/phobos/std_demangle.html
Dec 22 2010
next sibling parent Andrej Mitrovic <andrej.mitrovich gmail.com> writes:
Okay, this works:

import std.stdio;
import std.demangle;
import std.traits;

void main()
{
    void test()
    {
    }

    auto mystr = "_D3std5stdio4File17LockingTextWriter11__T3putTAaZ3putMFAaZv";
    writeln(demangle(mystr)); // void
std.stdio.File.LockingTextWriter.put!(char[]).put(char[])
}

So maybe mangledName!() doesn't work properly.

On 12/23/10, Andrej Mitrovic <none none.none> wrote:
 import std.stdio;
 import std.demangle;
 import std.traits;

 void main()
 {
     void test()
     {
     }

     auto mystr = mangledName!(test); // -----------
 demangle4mainFAAyaZv4testMFZv
     writeln(demangle(mystr));        // writes back
 demangle4mainFAAyaZv4testMFZv
 }

 Also, the example code is broken in
 http://www.digitalmars.com/d/2.0/phobos/std_demangle.html
Dec 22 2010
prev sibling next sibling parent Andrej Mitrovic <andrej.mitrovich gmail.com> writes:
It's really weird though, because I can only demangle a few names from
a .log file when using -profile with DMD. Is this normal?
Dec 22 2010
prev sibling next sibling parent reply Sean Kelly <sean invisibleduck.org> writes:
std.demangle is moderately broken.  Use core.demangle instead.  I meant to have
std.demangle call core.demangle for this release, but forgot to make the change.
Dec 22 2010
parent reply Sean Kelly <sean invisibleduck.org> writes:
Sean Kelly Wrote:

 std.demangle is moderately broken.  Use core.demangle instead.  I meant to
have std.demangle call core.demangle for this release, but forgot to make the
change.
Okay, I'm about to check in this change. With it, demangle works on the string you supplied provided it's prefixed with "_D8" or "D8". Simply having "demangle4mainFAAyaZv4testMFZv" isn't a complete symbol.
Dec 22 2010
next sibling parent Andrej Mitrovic <andrej.mitrovich gmail.com> writes:
On 12/23/10, Sean Kelly <sean invisibleduck.org> wrote:
 Okay, I'm about to check in this change.  With it, demangle works on the
 string you supplied provided it's prefixed with "_D8" or "D8".  Simply
 having "demangle4mainFAAyaZv4testMFZv" isn't a complete symbol.
Thanks. It works for _D3 as well. But not all of them. I can demangle this: _D3std5stdio4File17LockingTextWriter12__T3putTAyaZ3putMFAyaZv
 void std.stdio.File.LockingTextWriter.put!(immutable(char)[]).put(immuta
ble(char)[]) but not this: _D3std9algorithm28__T6reduceVAyaa5_61202b2062Z255__T6reduceTS3std9algorithm221__T3MapS723std10fu1B89DCD92D22D288E31BD77EB8883277 That one's from a trace log. I don't know why this name is mangled like that, though.
Dec 22 2010
prev sibling next sibling parent Brad Roberts <braddr puremagic.com> writes:
Please file a bug against druntime with any symbols that it can't handle.  
If you know the symbol name it should decode to, that'd help.  

On Thu, 23 Dec 2010, Andrej Mitrovic wrote:

 On 12/23/10, Sean Kelly <sean invisibleduck.org> wrote:
 Okay, I'm about to check in this change.  With it, demangle works on the
 string you supplied provided it's prefixed with "_D8" or "D8".  Simply
 having "demangle4mainFAAyaZv4testMFZv" isn't a complete symbol.
Thanks. It works for _D3 as well. But not all of them. I can demangle this: _D3std5stdio4File17LockingTextWriter12__T3putTAyaZ3putMFAyaZv
 void std.stdio.File.LockingTextWriter.put!(immutable(char)[]).put(immuta
ble(char)[]) but not this: _D3std9algorithm28__T6reduceVAyaa5_61202b2062Z255__T6reduceTS3std9algorithm221__T3MapS723std10fu1B89DCD92D22D288E31BD77EB8883277 That one's from a trace log. I don't know why this name is mangled like that, though.
Dec 22 2010
prev sibling next sibling parent Stanislav Blinov <blinov loniir.ru> writes:
23.12.2010 7:49, Andrej Mitrovic пишет:
 On 12/23/10, Sean Kelly<sean invisibleduck.org>  wrote:
 Okay, I'm about to check in this change.  With it, demangle works on the
 string you supplied provided it's prefixed with "_D8" or "D8".  Simply
 having "demangle4mainFAAyaZv4testMFZv" isn't a complete symbol.
Thanks. It works for _D3 as well. But not all of them. I can demangle this:
Do you mean it works with _D3 even for mangled name starting with "demangle"? It shouldn't. 3 is a character count of the following name.
 _D3std5stdio4File17LockingTextWriter12__T3putTAyaZ3putMFAyaZv
 void std.stdio.File.LockingTextWriter.put!(immutable(char)[]).put(immuta
ble(char)[]) but not this: _D3std9algorithm28__T6reduceVAyaa5_61202b2062Z255__T6reduceTS3std9algorithm221__T3MapS723std10fu1B89DCD92D22D288E31BD77EB8883277 That one's from a trace log. I don't know why this name is mangled like that, though.
I beleive the hex part at the end is a hash that is used to mangle very long names.
Dec 23 2010
prev sibling parent Andrej Mitrovic <andrej.mitrovich gmail.com> writes:
On 12/23/10, Stanislav Blinov <blinov loniir.ru> wrote:
 Do you mean it works with _D3 even for mangled name starting with
 "demangle"? It shouldn't. 3 is a character count of the following name.
No, I meant without "demangle", so that's fine.
 I beleive the hex part at the end is a hash that is used to mangle very
 long names.
I see. It does make reading the trace logs more difficult when some functions are demangled while others are not.
Dec 23 2010
prev sibling next sibling parent kenji hara <k.hara.pg gmail.com> writes:
I tested this issue.
I think mangledName does not support nested function.
I'll try to resolve it.

Kenji Hara

2010/12/23 Andrej Mitrovic <none none.none>:
 import std.stdio;
 import std.demangle;
 import std.traits;

 void main()
 {
 =A0 =A0void test()
 =A0 =A0{
 =A0 =A0}

 =A0 =A0auto mystr =3D mangledName!(test); // ----------- demangle4mainFAA=
yaZv4testMFZv
 =A0 =A0writeln(demangle(mystr)); =A0 =A0 =A0 =A0// writes back demangle4m=
ainFAAyaZv4testMFZv
 }

 Also, the example code is broken in http://www.digitalmars.com/d/2.0/phob=
os/std_demangle.html

Dec 23 2010
prev sibling next sibling parent kenji hara <k.hara.pg gmail.com> writes:
Sorry, current dmd does't provide the mangled name from function symbol.
see http://d.puremagic.com/issues/show_bug.cgi?id=3D2774

2010/12/24 kenji hara <k.hara.pg gmail.com>:
 I tested this issue.
 I think mangledName does not support nested function.
 I'll try to resolve it.

 Kenji Hara

 2010/12/23 Andrej Mitrovic <none none.none>:
 import std.stdio;
 import std.demangle;
 import std.traits;

 void main()
 {
 =A0 =A0void test()
 =A0 =A0{
 =A0 =A0}

 =A0 =A0auto mystr =3D mangledName!(test); // ----------- demangle4mainFA=
AyaZv4testMFZv
 =A0 =A0writeln(demangle(mystr)); =A0 =A0 =A0 =A0// writes back demangle4=
mainFAAyaZv4testMFZv
 }

 Also, the example code is broken in http://www.digitalmars.com/d/2.0/pho=
bos/std_demangle.html

Dec 23 2010
prev sibling parent Andrej Mitrovic <andrej.mitrovich gmail.com> writes:
Okay, thanks for letting me know!

On 12/23/10, kenji hara <k.hara.pg gmail.com> wrote:
 Sorry, current dmd does't provide the mangled name from function symbol.
 see http://d.puremagic.com/issues/show_bug.cgi?id=3D2774

 2010/12/24 kenji hara <k.hara.pg gmail.com>:
 I tested this issue.
 I think mangledName does not support nested function.
 I'll try to resolve it.

 Kenji Hara

 2010/12/23 Andrej Mitrovic <none none.none>:
 import std.stdio;
 import std.demangle;
 import std.traits;

 void main()
 {
 =A0 =A0void test()
 =A0 =A0{
 =A0 =A0}

 =A0 =A0auto mystr =3D mangledName!(test); // -----------
 demangle4mainFAAyaZv4testMFZv
 =A0 =A0writeln(demangle(mystr)); =A0 =A0 =A0 =A0// writes back
 demangle4mainFAAyaZv4testMFZv
 }

 Also, the example code is broken in
 http://www.digitalmars.com/d/2.0/phobos/std_demangle.html
Dec 23 2010