A working backtrace for linux

David Bryant bagnose at gmail.com
Mon Aug 2 22:17:38 PDT 2010


Hi all,

I've been using D under Ubuntu for some time and the kinds of backtraces 
I get when assertion fails look like this:

core.exception.AssertError at doodle.dia.standard_tools(71): Assertion failure
----------------
./bin/doodler() [0x8102086]
./bin/doodler() [0x804e38f]
./bin/doodler() [0x81022b1]
./bin/doodler() [0x81021d9]
./bin/doodler() [0x8102188]
/lib/tls/i686/cmov/libc.so.6(__libc_start_main+0xe6) [0x289bd6]
./bin/doodler() [0x8049a01]

And for segment faults I don't get a stack trace at all.

I am interested in knowing if this is the case for other users and if 
so, what is being done about it in druntime?

I've attached my own implementation of backtrace that I find useful. It 
is quick and dirty, but it works. It gives an output like the following 
when exceptions are thrown and segmentation faults triggered:

core.exception.AssertError at doodle.dia.standard_tools(71): Assertion failure
----------------
[0x0810bbf8] onAssertError
[0x081022c6] _d_assertm
[0x0804e43f] void doodle.dia.standard_tools.__assert(int)
[0x0804dfb8] bool doodle.dia.standard_tools.ZoomTool.handle_scroll(class 
doodle.dia.icanvas.Viewport, const(class doodle.tk.events.ScrollEvent))
[0x0804e951] bool doodle.dia.tool_layer.ToolLayer.handle_scroll(class 
doodle.dia.icanvas.Viewport, const(class doodle.tk.events.ScrollEvent))
[0x0804b607] bool doodle.gtk.canvas.Canvas.on_scroll(struct 
gtkc.gdktypes.GdkEventScroll*, class gtk.Widget.Widget)
[0x080672c5] extern (C) int gtk.Widget.Widget.callBackScroll(struct 
gtkc.gtktypes.GtkWidget*, struct gtkc.gdktypes.GdkEventScroll*, class 
gtk.Widget.Widget)
[0x08062155] void gtk.Main.Main.run()
[0x08049e7b] _Dmain
[0x08102594] extern (C) int rt.dmain2.main(int, char**) . void runMain()
[0x081024f9] extern (C) int rt.dmain2.main(int, char**) . void 
tryExec(void delegate())

Using it couldn't be easier, just import the module and link the object.

Regards,
Dave
-------------- next part --------------
A non-text attachment was scrubbed...
Name: backtrace.d
Type: text/x-dsrc
Size: 9229 bytes
Desc: not available
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20100803/2ada880e/attachment-0001.d>


More information about the Digitalmars-d mailing list