Bug 906 – GDC Phobos std.demangle can't demangle symbol

Status
RESOLVED
Resolution
INVALID
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
PowerPC
OS
Mac OS X
Creation time
2007-01-29T21:55:00Z
Last change time
2015-06-09T01:31:15Z
Assigned to
dvdfrdmn
Creator
rmann-d-lang

Comments

Comment #0 by rmann-d-lang — 2007-01-29T21:55:59Z
(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
Comment #1 by rmann-d-lang — 2007-01-29T21:59:57Z
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.
Comment #2 by rmann-d-lang — 2007-01-30T12:42:48Z
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)
Comment #3 by thomas-dloop — 2007-01-30T15:10:04Z
Are you sure that the symbol starts with 2 underscores instead of 1?
Comment #4 by afb — 2007-01-30T15:46:25Z
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.
Comment #5 by rmann-d-lang — 2007-01-30T15:51:40Z
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.
Comment #6 by afb — 2007-01-31T02:41:14Z
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)
Comment #7 by rmann-d-lang — 2007-01-31T03:16:12Z
Fair 'nough. Closing.