D 2.0 Stacktrace

Denis Koroskin 2korden at gmail.com
Fri Oct 8 12:00:12 PDT 2010


On Wed, 06 Oct 2010 15:50:25 +0400, Benjamin Thaut  
<code at benjamin-thaut.de> wrote:

> I wrote a small piece of sourcecode that generates stacktraces in D 2.0  
> under
> windows. It works both with the pdb and cv debug symbol format. For  
> Exceptions
> that are derived from the Error class the trace information is  
> automatically
> appended, this causes all builtin D errors to get a stacktrace  
> information.
> The only point where this does not work is the Access Vioaltion error,  
> as it
> does not call the stacktrace callback function for some reason.
>
> It is very easy to use, just copy the two files from the zip archive to  
> your
> root source directory and import the stacktrace module inside your main  
> file.
> For more informaiton and the download go to:
> http://3d.benjamin-thaut.de
>
> Let me know what you think.
>
> Kind Regards
> Benjamin Thaut

I modified druntime to support stack-tracing for all kind of exceptions.  
It's very simple:

1) In object_.d, change traceContext() function linkage to C:
extern(C) Throwable.TraceInfo traceContext(void* ptr = null) { ... }

2) In rt\deh.c, declare
Interface* traceContext(void* ptr);

and add the following line to _d_create_exception_object (rt\deh.c)
exc->info = traceContext(NULL);

that's it. Works like a charm!


More information about the Digitalmars-d-announce mailing list