www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 8172] New: OSX: symbols mangled on gdb,ggdb,cgdb,lldb but not on ubuntu; no line numbers on stacktraces

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8172

           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
        AssignedTo: nobody puremagic.com
        ReportedBy: thelastmammoth gmail.com



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:
****
A) OSX
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 http://www.dsource.org/projects/gdb-patches, 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
main.d:2
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
main.d:2

main`D4main3funFZv + 15 at main.d:2
B.1: demangled names, line numbers 0x00000000004016c7 in main.fun () at
main.d:2

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 main.fun()

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
http://www.tekkotsu.org/dox/StackTrace_8h.html

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

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 31 2012
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8172


klickverbot <code klickverbot.at> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |code klickverbot.at



---
Issue 8208 might be related, depending on how the GDB patches expect the
mangled names.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 07 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8172





 Issue 8208 might be related, depending on how the GDB patches expect the
 mangled names.
Did you mean Issue 8207? I would LOVE to see this resolved ASAP, this issue has been there for a while! -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jun 07 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8172




---
Oh, yes, the perils of _not_ using copy and paste… ;)

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 07 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8172





 Oh, yes, the perils of _not_ using copy and paste… ;)
does your intended pull request solve this issue on OSX ? -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jun 07 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8172




---
Didn't try yet; I didn't have too much luck with getting newer (non-Apple) GDB
versions to reliably work so far.

For LLDB to display demangled names, somebody would need to write a LLDB
patch/plugin for D, which, to my knowledge, has not happened yet.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 07 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8172





 Didn't try yet; I didn't have too much luck with getting newer (non-Apple) GDB
 versions to reliably work so far.
 
 For LLDB to display demangled names, somebody would need to write a LLDB
 patch/plugin for D, which, to my knowledge, has not happened yet.
newer, non-apple gdb versions work on osx, but have to be run under sudo in my experience; I could try myself if I had your pull request to see if it resolves this issue. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jun 07 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8172


klickverbot <code klickverbot.at> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Depends on|                            |8207



---
With my preliminary patches and GDB 7.4.1, name demangling in GDB indeed seems
to work. Added a dependency on Issue 8207.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 07 2012
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8172





 With my preliminary patches and GDB 7.4.1, name demangling in GDB indeed seems
 to work. Added a dependency on Issue 8207.
wonderful, at last! btw did you figure out a way to run the new gdb without sudo on osx? looking forward for your patch -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jun 07 2012