Debugging

Graham St Jack Graham.StJack at internode.on.net
Mon Jul 12 23:26:22 PDT 2010


I have jumped back onto the D2 band-wagon after a long absence, read 
Andrei's book, and am having a great time cutting heaps of D code. My 
increase in productivity and happiness when compared to working in C++ is 
enormous. 

Bug thumbs up to everyone involved with D2, Phobos and the book.

One area I am having a bit of trouble with is debugging. Can anyone help 
me out with how to debug a D2 program in Linux? Currently I am reduced to 
printing out heaps of debug text.

Specifically:

Stack Trace:
------------

I can't get the D2 stack-trace to work properly. All I get is something 
like this, which isn't helpful:

Segmentation fault

The code I used to generate this was:
import std.stdio;
import std.file;
void foo(File file) {
    file.flush;
}
void main(string[] args) {
    File file;
    foo(file);
}
Is stack-trace support broken, or do I have to do something to enable it?

GDB:
----

What is the status of D support in GDB? The last post I saw was back in 
April. It is currently hard work to debug with gdb when it doesn't 
understand D name mangling.

Profiling:
----------

How do I profile a D2 program? When I try -profile in dmd, the resultant 
executable crashes with a segfault when I try to run it. When I try 
sysprof, I get a handful of mangled names, and no call graph.


More information about the Digitalmars-d mailing list