Debugging

Graham St Jack Graham.StJack at internode.on.net
Tue Jul 13 14:42:41 PDT 2010


On Tue, 13 Jul 2010 08:48:50 -0400, Steven Schveighoffer wrote:

> On Tue, 13 Jul 2010 02:26:22 -0400, Graham St Jack
> <Graham.StJack at internode.on.net> wrote:
> 
>> 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?
> 
> Seg faults do not generate stack traces in Linux/MacOS.  This is because
> a segmentation fault is generated by a signal, and it's unsafe to throw
> exceptions from signals.
> 
> I believe seg faults can generate exceptions in Windows, but I'm not
> sure.
> 
> Your best bet is to get a debugger working, and it will halt on the
> signal.  As I understand it, a lot of good work was done recently on dmd
> (can't remember who did it) to get it working better with gdb.
> 
> -Steve

Thanks. I will persist with gdb and look forward to the D support coming 
through.


More information about the Digitalmars-d mailing list