Thread overview
[Issue 906] New: GDC Phobos std.demangle can't demangle symbol
Jan 30, 2007
d-bugmail
Jan 30, 2007
d-bugmail
Jan 30, 2007
d-bugmail
Jan 30, 2007
d-bugmail
Jan 30, 2007
d-bugmail
Jan 30, 2007
d-bugmail
Jan 31, 2007
d-bugmail
Jan 31, 2007
d-bugmail
January 30, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=906

           Summary: GDC Phobos std.demangle can't demangle symbol
           Product: DGCC aka GDC
           Version: unspecified
          Platform: Macintosh
        OS/Version: Mac OS X
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: dvdfrdmn@users.sf.net
        ReportedBy: rmann-d-lang@latencyzero.com


(Wow, the CC list is LOONG. I hope I'm doing the right thing by posting this
bug here).

I wrote a simple program to demangle symbols. When I try to demangle the following, I just get the same thing back out. This symbol was emitted by GDC 0.27/DMD 1.00 as part of a link error message.

__D5macos6carbon16carboneventscore19InstallEventHandlerFT5macos6carbon16carboneventscore14EventTargetRefT5macos6carbon16carboneventscore15EventHandlerUPPkPS5macos6carbon16carboneventscore13EventTypeSpecPvJT5macos6carbon16carboneventscore15EventHandlerRefZT5macos6carbon5types8OSStatus


-- 

January 30, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=906





------- Comment #1 from rmann-d-lang@latencyzero.com  2007-01-29 21:59 -------
Hmm. I tried feeding it a mangled symbol generated in the same little program using the .mangleof property, and it still returns its input unchaged. Maybe it doesn't work at all on GDC.


-- 

January 30, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=906





------- Comment #2 from rmann-d-lang@latencyzero.com  2007-01-30 12:42 -------
Looking at the std.demangle code, it seems that it's looking for a valid symbol to begin with "_D", rather than the "__D" that is being emitted by gdc. The symbol above demangles to:

typedef macos.carbon.hitoolbox.Types.OSStatus macos.carbon.hitoolbox.CarbonEventsCore.InstallEventHandler(typedef macos.carbon.hitoolbox.CarbonEventsCore.EventTargetRef, typedef macos.carbon.hitoolbox.CarbonEventsCore.EventHandlerUPP, struct macos.carbon.hitoolbox.CarbonEventsCore.EventTypeSpec[], void*, out typedef macos.carbon.hitoolbox.CarbonEventsCore.EventHandlerRef)


-- 

January 30, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=906





------- Comment #3 from thomas-dloop@kuehne.cn  2007-01-30 15:10 -------
Are you sure that the symbol starts with 2 underscores instead of 1?


-- 

January 30, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=906





------- Comment #4 from afb@algonet.se  2007-01-30 15:46 -------
All Mac OS X symbols start with underscore.

This D code:
void main () { }
extern(C) void test () { }

Produces symbols:
__Dmain
_test

For details see "Mach-O" on Apple Developer.


-- 

January 30, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=906





------- Comment #5 from rmann-d-lang@latencyzero.com  2007-01-30 15:51 -------
I don't know if phobos on the Mac should be modified so that std.demangle can grok the extra underscore. If so, I'll leave this open. If not, feel free to close this bug.


-- 

January 31, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=906





------- Comment #6 from afb@algonet.se  2007-01-31 02:41 -------
std.demangle should probably be left to operate on the real symbols - without the extra underscore, but you might want to add the feature to your simple program ?


if you use dlsym to load symbols, that will use the symbols without underscores*. so the extra underscore is more a quirk of the object format, than anything else.

(* actually something of a minefield if you want portable code, some systems do require the underscore prepended and yet others do not. but that's another story)


-- 

January 31, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=906


rmann-d-lang@latencyzero.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |INVALID




------- Comment #7 from rmann-d-lang@latencyzero.com  2007-01-31 03:16 -------
Fair 'nough. Closing.


--