Thread overview
[phobos] Stack traces in druntime/phobos
Aug 28, 2010
Denis
Aug 28, 2010
Sean Kelly
Aug 28, 2010
Brad Roberts
Sep 19, 2010
Denis
Sep 21, 2010
Sean Kelly
Sep 22, 2010
Denis
August 28, 2010
Hi, guys!

I've been told that there was some work on stack tracing is going on, so I'd like to share some of the code that I use in ddmd to print call stack. It can be used like this:

CallStackInfo info = new CallStackInfo();
info.dump(); // prints the call stack to stdout

It can also be used as an unhandled exception handler (there is a
helper function called CrashHandlerInit).
Windows only, but it has some extensibility potential.

It doesn't rely on anything but druntime, and should work on both 32 and 64 bits.

Most of the code is written by Jeremie Pelletier, and put into Public
Domain. Here is his original announcement (about a year old):
http://www.digitalmars.com/d/archives/digitalmars/D/announce/Crash_handler_with_stack_trace_16815.html

I hope someone will find it useful.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: dbg.zip
Type: application/zip
Size: 17297 bytes
Desc: not available
URL: <http://lists.puremagic.com/pipermail/phobos/attachments/20100828/dad239ef/attachment-0001.zip>
August 28, 2010
Yes please. Who can integrate it?

Sent by shouting through my showerhead.

On Aug 28, 2010, at 1:45 AM, Denis <2korden at gmail.com> wrote:

> Hi, guys!
>
> I've been told that there was some work on stack tracing is going on, so I'd like to share some of the code that I use in ddmd to print call stack. It can be used like this:
>
> CallStackInfo info = new CallStackInfo();
> info.dump(); // prints the call stack to stdout
>
> It can also be used as an unhandled exception handler (there is a
> helper function called CrashHandlerInit).
> Windows only, but it has some extensibility potential.
>
> It doesn't rely on anything but druntime, and should work on both 32 and 64 bits.
>
> Most of the code is written by Jeremie Pelletier, and put into Public
> Domain. Here is his original announcement (about a year old):
> http://www.digitalmars.com/d/archives/digitalmars/D/announce/Crash_handler_with_stack_trace_16815.html
>
> I hope someone will find it useful.
> <dbg.zip>
> _______________________________________________
> phobos mailing list
> phobos at puremagic.com
> http://lists.puremagic.com/mailman/listinfo/phobos
August 28, 2010
Awesome, I'll check it out.

Sent from my iPhone

On Aug 27, 2010, at 11:45 PM, Denis <2korden at gmail.com> wrote:

> Hi, guys!
> 
> I've been told that there was some work on stack tracing is going on, so I'd like to share some of the code that I use in ddmd to print call stack. It can be used like this:
> 
> CallStackInfo info = new CallStackInfo();
> info.dump(); // prints the call stack to stdout
> 
> It can also be used as an unhandled exception handler (there is a
> helper function called CrashHandlerInit).
> Windows only, but it has some extensibility potential.
> 
> It doesn't rely on anything but druntime, and should work on both 32 and 64 bits.
> 
> Most of the code is written by Jeremie Pelletier, and put into Public
> Domain. Here is his original announcement (about a year old):
> http://www.digitalmars.com/d/archives/digitalmars/D/announce/Crash_handler_with_stack_trace_16815.html
> 
> I hope someone will find it useful.
> <dbg.zip>
> _______________________________________________
> phobos mailing list
> phobos at puremagic.com
> http://lists.puremagic.com/mailman/listinfo/phobos
August 28, 2010
Don't forget, there's still a lot of good info and some todo's in bug 1001, the one all about this topic.

On 8/28/2010 7:12 AM, Sean Kelly wrote:
> Awesome, I'll check it out.
> 
> Sent from my iPhone
> 
> On Aug 27, 2010, at 11:45 PM, Denis <2korden at gmail.com> wrote:
> 
>> Hi, guys!
>>
>> I've been told that there was some work on stack tracing is going on, so I'd like to share some of the code that I use in ddmd to print call stack. It can be used like this:
>>
>> CallStackInfo info = new CallStackInfo();
>> info.dump(); // prints the call stack to stdout
>>
>> It can also be used as an unhandled exception handler (there is a
>> helper function called CrashHandlerInit).
>> Windows only, but it has some extensibility potential.
>>
>> It doesn't rely on anything but druntime, and should work on both 32 and 64 bits.
>>
>> Most of the code is written by Jeremie Pelletier, and put into Public
>> Domain. Here is his original announcement (about a year old):
>> http://www.digitalmars.com/d/archives/digitalmars/D/announce/Crash_handler_with_stack_trace_16815.html
>>
>> I hope someone will find it useful.
>> <dbg.zip>
>> _______________________________________________
September 19, 2010
I've made an attempt to intergrate stack tracer into druntime, modified runtime.d is attached to this message.

It also relies on codeview.d (which I placed into core.sys.windows package because it is Windows specific). Strictly speaking, it isn't mandatory for stack traces to work and I I can get rid of it if you believe it doesn't belong to druntime, but it adds module names and line numbers to stack trace (which I believe is a good thing to have).

Symbol names are extracted from a dmd-generated map file. Compile with -g -map for the best trace info.

It does quite a few of memory allocations, so generating call-stack for an OutOfMemory exception may result in a stack overflow. It's an issue I can fix, but it's far from being a trivial one.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: changes.zip
Type: application/zip
Size: 19579 bytes
Desc: not available
URL: <http://lists.puremagic.com/pipermail/phobos/attachments/20100919/c9871650/attachment-0001.zip>
September 21, 2010
Pretty slick.  I was hoping to avoid reading the map file if possible though, and use StackWalk64 for the trace.

On Sep 18, 2010, at 6:56 PM, Denis wrote:

> I've made an attempt to intergrate stack tracer into druntime, modified runtime.d is attached to this message.
> 
> It also relies on codeview.d (which I placed into core.sys.windows package because it is Windows specific). Strictly speaking, it isn't mandatory for stack traces to work and I I can get rid of it if you believe it doesn't belong to druntime, but it adds module names and line numbers to stack trace (which I believe is a good thing to have).
> 
> Symbol names are extracted from a dmd-generated map file. Compile with -g -map for the best trace info.
> 
> It does quite a few of memory allocations, so generating call-stack
> for an OutOfMemory exception may result in a stack overflow. It's an
> issue I can fix, but it's far from being a trivial one.
> <changes.zip>_______________________________________________
> phobos mailing list
> phobos at puremagic.com
> http://lists.puremagic.com/mailman/listinfo/phobos

September 22, 2010
On Wed, Sep 22, 2010 at 3:29 AM, Sean Kelly <sean at invisibleduck.org> wrote:
> Pretty slick. ?I was hoping to avoid reading the map file if possible though, and use StackWalk64 for the trace.
>

It doesn't require map file, but provides better debug info if one is present.