jive.stacktrace

Module for stacktracing exceptions and crashes.

Please note that libbfd has limited success resolving symbols generated by DMD, but it works somewhat.

Tracing works perfectly with GDC. (use -g to get line numbers)

Principle of operation:

glibc backtrace() is used for obtaining a trace of return addresses, it uses GCC exception handling frames when available and frame pointers otherwise - meaning you only need either of them for traces to work

Symbolic information is found using libbfd. A list of object files mapped into memory is found through /proc/self/maps and all of them are loaded using libbfd.

Portability:
linux x86 and x86_64

Dependencies:
libbfd (included with binutils)

License:
zlib

Authors:
Zygfryd (aka Hxal)



struct TraceConfig ;
Global configuration

static uint traceDepth ;
Maximum depth of stacktrace to obtain

static bool traceExceptions ;
Whether to append stacktraces to exceptions

static bool throwOnAccessViolation ;
Throwing exceptions on fault signals: this feature doesn't work very well with either DMD or GDC, it causes GDC to abort and DMD can leak those exceptions; GDC should support it once -fnon-call-exceptions or -fasynchronous-unwind-tables gets implemented

When these options are disabled the handler will dump a stacktrace to stderr and exit

static bool throwOnNumericException ;


static bool throwOnIllegalInstruction ;


static void throwOnAll (bool val);


struct CodeLocation ;
Struct encapsulating a code address and symbolic information obtained for that address

void* address ;


char[] segment ;
Segment / object file that owns this location

char[] file ;
Name of file containing this location

char[] subprogram ;
Name of function containing this location

uint line ;
Line numbers corresponding to this location

char[] sprint (char[] buf);
Output this into a static buffer.

The format looks like: address [segment] subprogram @ file:line

char[] toString ();


static CodeLocation findCurrent (uint depth = cast(uint)0);
Resolve the location of calls on the current stack.

depth == 0 means the location where this function is called,

depth > 0 means that many frames should be skipped

Warning:
It's not very fast.

static void updateDebugInfo ();
Update the debugging information, should be called after loading dynamic libraries through libdl or tango.sys.SharedLib, before using findCurrent

Page was generated with on Sat Jan 5 17:50:40 2008