www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - It is impossible to debug code compiled with dmd

reply Eldar Insafutdinov <e.insafutdinov gmail.com> writes:
On Linux dmd outputs faulty debug info. On Windows optlink crashes when
building code in debug. Current situation is a complete disaster.
Mar 31 2010
next sibling parent reply Robert Clipsham <robert octarineparrot.com> writes:
On 31/03/10 10:41, Eldar Insafutdinov wrote:
 On Linux dmd outputs faulty debug info.
There are several bugs in the debug info on linux, one of them I've fixed (for most cases ie. anything that requires phobos, I'm working on the other cases ie. anything that needs funky libraries that use a lot of complicated function pointers), and another one you've sent me a massive test case for which I'm working down to a manageable size for a bug report now (I'd have done it by now, your make file doesn't play nicely with my multilib system though ;)). Other than those 2 bugs I don't know what else is blocking debug info on linux... I'm becoming quite familiar with DWARF/dmd's backend code for DWARF through all this debugging, so if I can get these bugs fixed I'd be happy to work on any others while I have time.
 On Windows optlink crashes when building code in debug. Current
 situation is a complete disaster.
OPTLINK still has problems, hopefully this situation will improve as it gradually gets ported to C and eventually open sourced (or at least we can hope that happens ;)). If not I guess we need to either write a new linker, or a new backend for dmd so it can output COFF and use another linker. Hopefully we can sort this situation out and get debug info for D on a par with C/C++ :)
Mar 31 2010
next sibling parent Fawzi Mohamed <fawzi gmx.ch> writes:
On 31-mar-10, at 17:09, Robert Clipsham wrote:

 On 31/03/10 10:41, Eldar Insafutdinov wrote:
 On Linux dmd outputs faulty debug info.
There are several bugs in the debug info on linux, one of them I've fixed (for most cases ie. anything that requires phobos, I'm working on the other cases ie. anything that needs funky libraries that use a lot of complicated function pointers), and another one you've sent me a massive test case for which I'm working down to a manageable size for a bug report now (I'd have done it by now, your make file doesn't play nicely with my multilib system though ;)). Other than those 2 bugs I don't know what else is blocking debug info on linux... I'm becoming quite familiar with DWARF/dmd's backend code for DWARF through all this debugging, so if I can get these bugs fixed I'd be happy to work on any others while I have time.
 On Windows optlink crashes when building code in debug. Current
 situation is a complete disaster.
OPTLINK still has problems, hopefully this situation will improve as it gradually gets ported to C and eventually open sourced (or at least we can hope that happens ;)). If not I guess we need to either write a new linker, or a new backend for dmd so it can output COFF and use another linker.
a new backend like gcc (of gdc) or even better llvm (ldc)? for linux that was already done, and for D 1.0 it works well (I am using linux x86_64). and debugging normally works, even tango's stacktrace... windows is indeed a different story (but I know some people use gdc).
 Hopefully we can sort this situation out and get debug info for D on  
 a par with C/C++ :)
Mar 31 2010
prev sibling next sibling parent reply Robert Clipsham <robert octarineparrot.com> writes:
On 31/03/10 16:09, Robert Clipsham wrote:
 On 31/03/10 10:41, Eldar Insafutdinov wrote:
 On Linux dmd outputs faulty debug info.
There are several bugs in the debug info on linux, one of them I've fixed (for most cases ie. anything that requires phobos, I'm working on the other cases ie. anything that needs funky libraries that use a lot of complicated function pointers), and another one you've sent me a massive test case for which I'm working down to a manageable size for a bug report now (I'd have done it by now, your make file doesn't play nicely with my multilib system though ;)). Other than those 2 bugs I don't know what else is blocking debug info on linux... I'm becoming quite familiar with DWARF/dmd's backend code for DWARF through all this debugging, so if I can get these bugs fixed I'd be happy to work on any others while I have time.
Having played with the testcase you sent me, it isn't another bug. You were using -g instead of -gc, which won't work until debuggers support the D extensions to debug info. When using -gc it gives the error as
Mar 31 2010
parent reply Matthias Pleh <matthias.pleh gmx.at> writes:
Am 31.03.2010 20:16, schrieb Robert Clipsham:
 On 31/03/10 16:09, Robert Clipsham wrote:
 On 31/03/10 10:41, Eldar Insafutdinov wrote:
 On Linux dmd outputs faulty debug info.
There are several bugs in the debug info on linux, one of them I've fixed (for most cases ie. anything that requires phobos, I'm working on the other cases ie. anything that needs funky libraries that use a lot of complicated function pointers), and another one you've sent me a massive test case for which I'm working down to a manageable size for a bug report now (I'd have done it by now, your make file doesn't play nicely with my multilib system though ;)). Other than those 2 bugs I don't know what else is blocking debug info on linux... I'm becoming quite familiar with DWARF/dmd's backend code for DWARF through all this debugging, so if I can get these bugs fixed I'd be happy to work on any others while I have time.
Having played with the testcase you sent me, it isn't another bug. You were using -g instead of -gc, which won't work until debuggers support the D extensions to debug info. When using -gc it gives the error as
Does this mean, the -g option only works in compination with the ddbg debugger and all other debugger need the -gc option? I need this to set a defaultsetting in codeblocks!
Mar 31 2010
parent Robert Clipsham <robert octarineparrot.com> writes:
On 31/03/10 19:31, Matthias Pleh wrote:
 Having played with the testcase you sent me, it isn't another bug. You
 were using -g instead of -gc, which won't work until debuggers support
 the D extensions to debug info. When using -gc it gives the error as

Does this mean, the -g option only works in compination with the ddbg debugger and all other debugger need the -gc option? I need this to set a defaultsetting in codeblocks!
Having never used ddbg I can't say if it supports -g or not (although it looks like it should). But yes, as far as I'm aware, all other debuggers need -gc to be used, unless they have had D support written for them (even gdb with the D patches doesn't support -g).
Mar 31 2010
prev sibling parent reply Walter Bright <newshound1 digitalmars.com> writes:
Robert Clipsham wrote:
 On 31/03/10 10:41, Eldar Insafutdinov wrote:
 On Linux dmd outputs faulty debug info.
There are several bugs in the debug info on linux, one of them I've fixed (for most cases ie. anything that requires phobos, I'm working on the other cases ie. anything that needs funky libraries that use a lot of complicated function pointers), and another one you've sent me a massive test case for which I'm working down to a manageable size for a bug report now (I'd have done it by now, your make file doesn't play nicely with my multilib system though ;)). Other than those 2 bugs I don't know what else is blocking debug info on linux... I'm becoming quite familiar with DWARF/dmd's backend code for DWARF through all this debugging, so if I can get these bugs fixed I'd be happy to work on any others while I have time.
Please let me know when you have dwarf.c patches ready, and thank you for trying to figure this out.
Mar 31 2010
parent reply Robert Clipsham <robert octarineparrot.com> writes:
On 31/03/10 21:37, Walter Bright wrote:
 Please let me know when you have dwarf.c patches ready, and thank you
 for trying to figure this out.
The first one is in bugzilla, you just need to comment out/remove the lines: abuf.writeByte(DW_AT_type); abuf.writeByte(DW_FORM_ref4); (at about line 1447, in the TYjfunc case of the switch statement in dwarf_typidx()). And: infobuf->write32(nextidx); // DW_AT_type At about line 1469 of dwarf.c. This fixes debug info for druntime, phobos, and a couple of test projects (the debug info looks identical to the equivalent output from clang too). There is one case which this patch doesn't solve, and that's for function pointers in the form: T function(U function(V)) foobar; Where T, U and V are any type. If you look at the .debug_info produced by dmd (either before or after the above patch, use objdump --dwarf=info testFile), you will see that it ends up writing what is parsed as a DW_TAG_compile_unit after the second DW_TAG_formal_parameter, so it seems some stray bytes are getting written causing the 0x1 to be detected as the abbrev rather than what ever it was intended to be (I'm still looking into this).
Mar 31 2010
parent reply Walter Bright <newshound1 digitalmars.com> writes:
Robert Clipsham wrote:
 The first one is in bugzilla,
Do you mean http://d.puremagic.com/issues/show_bug.cgi?id=1079 or another?
Mar 31 2010
parent reply Robert Clipsham <robert octarineparrot.com> writes:
On 31/03/10 21:58, Walter Bright wrote:
 Robert Clipsham wrote:
 The first one is in bugzilla,
Do you mean http://d.puremagic.com/issues/show_bug.cgi?id=1079 or another?
http://d.puremagic.com/issues/show_bug.cgi?id=3987 Please ignore the attached patch file, it's the incorrect fix (although it does work). I haven't written a formal patch, I didn't see a need with it only being 2 lines needing removing (which are mentioned in my last post, and a comment on that bug). As an update to the case it doesn't fix, it seems the second DW_TAG_formal_param is causing the debug info for something else to be written half way between the debug info for something else, so when it's read it's read incorrectly. Still working on this, I'm hoping to have a patch for it tonight, I've already put days into this, I'd rather not spend too much more ;)
Mar 31 2010
parent reply Walter Bright <newshound1 digitalmars.com> writes:
Robert Clipsham wrote:
 On 31/03/10 21:58, Walter Bright wrote:
 Robert Clipsham wrote:
 The first one is in bugzilla,
Do you mean http://d.puremagic.com/issues/show_bug.cgi?id=1079 or another?
http://d.puremagic.com/issues/show_bug.cgi?id=3987 Please ignore the attached patch file, it's the incorrect fix (although it does work). I haven't written a formal patch, I didn't see a need with it only being 2 lines needing removing (which are mentioned in my last post, and a comment on that bug). As an update to the case it doesn't fix, it seems the second DW_TAG_formal_param is causing the debug info for something else to be written half way between the debug info for something else, so when it's read it's read incorrectly. Still working on this, I'm hoping to have a patch for it tonight, I've already put days into this, I'd rather not spend too much more ;)
I and I'm sure many others appreciate your efforts.
Mar 31 2010
parent reply Robert Clipsham <robert octarineparrot.com> writes:
On 31/03/10 23:15, Walter Bright wrote:
 I and I'm sure many others appreciate your efforts.
Thanks :) I've finished a complete and working patch now, it's attached to http://d.puremagic.com/issues/show_bug.cgi?id=3987 and should fix the remaining issues with debugging info on linux. I've tested it with QtD, and various other projects, so I'd be grateful if you could review the patch and apply it!
Apr 01 2010
parent reply Walter Bright <newshound1 digitalmars.com> writes:
Robert Clipsham wrote:
 On 31/03/10 23:15, Walter Bright wrote:
 I and I'm sure many others appreciate your efforts.
Thanks :) I've finished a complete and working patch now, it's attached to http://d.puremagic.com/issues/show_bug.cgi?id=3987 and should fix the remaining issues with debugging info on linux. I've tested it with QtD, and various other projects, so I'd be grateful if you could review the patch and apply it!
Will do. Thanks very much!
Apr 01 2010
next sibling parent Robert Clipsham <robert octarineparrot.com> writes:
On 01/04/10 22:56, Walter Bright wrote:
 Robert Clipsham wrote:
 On 31/03/10 23:15, Walter Bright wrote:
 I and I'm sure many others appreciate your efforts.
Thanks :) I've finished a complete and working patch now, it's attached to http://d.puremagic.com/issues/show_bug.cgi?id=3987 and should fix the remaining issues with debugging info on linux. I've tested it with QtD, and various other projects, so I'd be grateful if you could review the patch and apply it!
Will do. Thanks very much!
There are a couple of other debugging patches that I created later on, they're attached to separate bugs: http://d.puremagic.com/issues/show_bug.cgi?id=4037 http://d.puremagic.com/issues/show_bug.cgi?id=4038 It'd be good if you could apply them too :)
Apr 01 2010
prev sibling parent Robert Clipsham <robert octarineparrot.com> writes:
On 01/04/10 22:56, Walter Bright wrote:
 Will do. Thanks very much!
Thought I'd call your attention to: http://d.puremagic.com/issues/show_bug.cgi?id=4044 I created a tracker bug for all the gdb/debugging/DWARF/etc issues with dmd, quite a lot of them already have patches, so while you're looking through my patches, making sure they're ok, could you take a glance at some of the others and pass comment? Thanks again :)
Apr 02 2010
prev sibling next sibling parent reply Walter Bright <newshound1 digitalmars.com> writes:
Eldar Insafutdinov wrote:
 On Linux dmd outputs faulty debug info.
 On Windows optlink crashes when
 building code in debug.
Is there a bugzilla for this? For example, I compile the entire test suite on Windows with debugging on, and no optlink crashes.
Mar 31 2010
parent Max Samukha <spambox d-coding.com> writes:
On 31.03.2010 23:36, Walter Bright wrote:
 Eldar Insafutdinov wrote:
 On Linux dmd outputs faulty debug info.
 On Windows optlink crashes when
 building code in debug.
Is there a bugzilla for this? For example, I compile the entire test suite on Windows with debugging on, and no optlink crashes.
I've filed a bug report: http://d.puremagic.com/issues/show_bug.cgi?id=4035 Sorry, cannot make the test case smaller. And there is another that may describe the same bug: http://d.puremagic.com/issues/show_bug.cgi?id=4009
Apr 01 2010
prev sibling parent Robert Clipsham <robert octarineparrot.com> writes:
On 31/03/10 10:41, Eldar Insafutdinov wrote:
 On Linux dmd outputs faulty debug info.
case and it works fine now.
Apr 01 2010