Summary: OSX: symbols mangled on gdb,ggdb,cgdb,lldb but not on
                    ubuntu; no line numbers on stacktraces
           Product: D
           Version: D2
          Platform: All
        OS/Version: Mac OS X
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD

--- Comment #0 from 2012-05-31 00:54:11 PDT ---
I'm trying to have proper debug info for D on OSX (D2, 2.059 but it shouldn't
matter). Currently I can only do that on ubuntu. I see several posts about this
topic but they seem out of date and the information is scattered.

I tried several options:
1) gdb (default provided by apple: gdb 6.3.50)
2) ggdb (from macports: version 7.3) => doesn't seem to work at all even for
simple C hello world
3) gdb-7.4.1 (manual build from gdb website, somehow requires to run as sudo
otherwise complains : please check gdb is codesigned - see taskgated, but
despite instructions online running as sudo was the only way to make it work)
4) cgdb
5) lldb

B) Ubuntu
1) gdb 7.2 (according to, a patch
for D is part of GDB " as of 7.2)

I'm compiling a simple hello world with a forced seg fault: compiled with dmd
-g main.d. 
cat main.d:
module main; void fun(){int *x = null; *x = 1;} void main(){fun;}

Here are the results on $debugger_name main:
A.1: mangled names, line numbers: 0x00000001000014e3 in _D4main3funFZv () at
A.2: just addresses: 0x000000010bb5a4e3 in ?? ()
A.3: mangled names, no line numbers: 0x00000001000014e3 in D4main3funFZv ()
A.4: mangled names, line numbers: 0x00000001000014e3 in _D4main3funFZv () at
A.5: mangled names, line numbers: frame #0: 0x00000001000014e3
main`D4main3funFZv + 15 at main.d:2
B.1: demangled names, line numbers 0x00000000004016c7 in () at

Note, even on OSX the D demangling would be easy via dfilt or ddemangle [cf git
repo: dmd/tools/ddemangle.d for a tool or dmd/druntime/src/core/demangle.d for
the function]): 
dfilt D4fun25fun2bFPiZv => void

Would you have any ideas how to make it work on OSX?

Another related issue is wrt stacktraces: the situation is reversed, ie it
displays the demangled names, but no line numbers:
6   main2                           0x000000010b6b94db void main.__assert(int)
+ 23

There were some previous threads about requiring to add to dmd.conf
"-L--export-dynamic" but that will not let dmd run. 
I'm not sure whether it's relevant, but I am able to get proper stack traces in
C++ programs on OSX using code similar to

btw is there a way to print stack trace without having an assertion failed in

Configure issuemail:
------- You are receiving this mail because: -------

Reply via email to