Debug is hell
by Leandro Lucarella on 2009-05-04 00:24 (updated on 2009-05-04 00:24)- with 8 comment(s)
Warning
Rant ahead.
If Matt Groeing would ever written a garbage collector I'm sure he would made a book in the Life in Hell series called Debug is Hell.
You can't rely on anything: unit tests are useless, they depend on your code to run and you can't get a decent backtrace ever using a debugger (the runtime calls seems to hidden to the debugger). I don't know if the last one is a compiler issue (I'm using DMD right now because my LDC copy broken =( ).
Add that to the fact that GNU Gold doesn't work, DMD doesn't work, Tango doesn't work [*] and LDC doesn't work, and that it's already hard to debug in D because most of the mainstream tools (gdb, binutils, valgrind) don't support the language (can't demangle D symbols for instance) and you end up with a very hostile environment to work with.
Anyway, it was a very unproductive weekend, my statistics gathering code seems to have some nasty bug and I'm not being able to find it.
PS: I want to apologize in advance to the developers of GNU Gold, DMD, Tango and LDC because they make great software, much less crappier than mine (well, to be honest I'm not so sure about DMD ;-P), it's just a bad weekend. Thank you for your hard work, guys =)
| [*] | Tango trunk is supposed to be broken for Linux |
Comment #2
by tweak on 2009-05-06 12:05"and you can't get a decent backtrace ever using a debugger "
Have you tried a backtrace hack?
http://petermodzelewski.blogspot.com/2008/01/development-in-d-with-use-of-backtrace.html
http://petermodzelewski.blogspot.com/2008/01/installing-tango-backtrace-hack-on.html
http://petermodzelewski.blogspot.com/search/label/backtrace hack
unit tests are useless, they depend on your code to run
please elaborate on that. Maybe __traits in D2 could be somewhat useful.
Hmm.. we definitly need some more tutorials on unit tests in D.. Is anyone satisfied here with built-in compiler's unittest ? I'm somewhat jealous on what Eclipse support has for JUnit and alike. Descent really needs to have support DUnit http://dsource.org/projects/dmocks/wiki/DUnit ported :))
What's current common knowledge about unittest's support in D? I heard some use flectioned + experimental Descent branch, some use their own testing framework (i believe team0xf has something in-house), or just anyone is happy with -unittest and console output?
Comment #3
by tweak on 2009-05-06 12:46Add that to the fact that GNU Gold doesn't work, DMD doesn't work, Tango doesn't work [*] and LDC doesn't work, and that it's already hard to debug in D because most of the mainstream tools (gdb, binutils, valgrind) don't support the language (can't demangle D symbols for instance) and you end up with a very hostile environment to work with.
just wait some time while svn trunk will stabilize things. And for "demangle D symbols", there are gdb patches in Gentoo D-overlay http://www.assembla.com/wiki/show/d-overlay which could be useful. Patches are from zero bugs debugger, i guess. gdc (from svn) seems works fine, maybe other projects will backport them, too.
Comment #4
by Leandro Lucarella on 2009-05-07 13:21Well, I guess all you have to do to get some comments in a blog is rant a little =)
by Vladimir Panteleev
I'm on Windows, not sure if this applies, but have you recompiled the stardard library with symbols and stack frames? Disabling inlining also improves stack traces' quality. Also, there's ddbg (again, Windows-only) which worked for my GC-debugging needs.
I've tried compiling with debug symbols and no optimizations and I have no luck still. And I'm on Linux, so I can't use the Windows stuff, but thanks for the recommendations =)
by Lars Ivar Igesund on 2009-05-04 15:55
Tango trunk is supposed to compile again :)
Yei! That's nice, thanks Lars...
by tweak on 2009-05-06 12:05
Have you tried a backtrace hack?
Nope.
by tweak on 2009-05-06 12:05
unit tests are useless, they depend on your code to runplease elaborate on that. Maybe __traits in D2 could be somewhat useful.
I mean, I can't use D unittest'ing because the runtime uses the GC to allocate memory to run the unit tests themselves, so when there is trouble, there's nothing a unit test can do to help me figure what's wrong.
by tweak on 2009-05-06 12:46
And for "demangle D symbols", there are gdb patches in Gentoo D-overlay http://www.assembla.com/wiki/show/d-overlay which could be useful. Patches are from zero bugs debugger, i guess. gdc (from svn) seems works fine, maybe other projects will backport them, too.
I knew there were some patches somewhere, but I would be nice if the patches would be merged upstream, is really a PITA having to bootstrap almost everything patched to work with D. It's a butchery job =)
I'd love to have time to make pressure to gdb to accept D support patches, or make patches to demangle D symbols in Valgrind and nm, but unfortunately I have to finish my thesis first :S (which by the way, i would be much more easy if that get done =P)
Comment #5
by Sean Kelly on 2009-05-10 00:15Druntime builds both release and debug libraries, and you can link against the proper one with a bit of work. Assuming you're using D 2.0, that is.
Comment #6
by Leandro Lucarella on 2009-05-17 19:11I'm using D 1.0 (LDC), but I know Tango runtime can do that too.
Comment #7
by tweak on 2009-05-19 16:21I'd love to have time to make pressure to gdb to accept D support patches, or make patches to demangle D symbols in Valgrind and nm, but unfortunately I have to finish my thesis first :S (which by the way, i would be much more easy if that get done =P)
well, there are alot of demangle.d versions floating around, just google it (one is in dmd*.zip). So it would be possible to check gdb patches and repeat the same for nm and valgrind.
Have you tried a backtrace hack?Nope.
I guess backtrace hack is for dmd-windows only, so it would take some effort to port it to Linux, anyway. Also, xfLinker from team 0xf could be somewhat useful to port that hack, but that hack seems to be windows-specific at first glance.
I mean, I can't use D unittest'ing because the runtime uses the GC to allocate memory to run the unit tests themselves, so when there is trouble, there's nothing a unit test can do to help me figure what's wrong.
so, static assert + your own new/delete from global static array is your best friend?
Comment #0
by Vladimir Panteleev on 2009-05-04 01:03I'm on Windows, not sure if this applies, but have you recompiled the stardard library with symbols and stack frames? Disabling inlining also improves stack traces' quality. Also, there's ddbg (again, Windows-only) which worked for my GC-debugging needs.