Incorrect line numbers in the example?
In this example:
object.Exception@source/app.d(15): Exception thrown
----------------
Stack trace:
#1: /path/to/source/app.d line (16) in void app.goToF2(uint)
(13)
(14) void goToF2(uint i = 0) {
(15) if (i == 2) throw new Exception("Exception thrown");
>(16) goToF2(++i);
(17) }
#2: /path/to/source/app.d line (17) in void app.goToF2(uint)
(14) void goToF2(uint i = 0) {
(15) if (i == 2) throw new Exception("Exception thrown");
(16) goToF2(++i);
>(17) }
#3: /path/to/source/app.d line (17) in void app.goToF2(uint)
#4: /path/to/source/app.d line (12) in void app.goToF1()
#5: /path/to/source/app.d line (7) in _Dmain
shouldn't the backtrace actually be more like this (frame 1: 16 -> 15, frame2: 17 -> 16, frame 3: 17 -> 16, frame 4: 12 -> 11):
object.Exception@source/app.d(15): Exception thrown
----------------
Stack trace:
#1: /path/to/source/app.d line (15) in void app.goToF2(uint)
(13)
(14) void goToF2(uint i = 0) {
>(15) if (i == 2) throw new Exception("Exception thrown");
(16) goToF2(++i);
(17) }
#2: /path/to/source/app.d line (16) in void app.goToF2(uint)
(14) void goToF2(uint i = 0) {
(15) if (i == 2) throw new Exception("Exception thrown");
>(16) goToF2(++i);
(17) }
#3: /path/to/source/app.d line (16) in void app.goToF2(uint)
#4: /path/to/source/app.d line (11) in void app.goToF1()
#5: /path/to/source/app.d line (7) in _Dmain
I realise the error in the line numbers. However, this is as good as it can get for now. It is a problem in either the backtrace addresses returned or their transformation to code lines.
Currently I'm using the backtrace code from druntime for DMD, and using the system backtrace call on LDC. And using addr2line to transform the addresses. I have previously written code the replaces addr2line and reads the dwarf debug info directly and they produced the same results, so the error source doesn't seem to be there. However the debug info emitted by the compilers may be the cause. I still don't know how to go about this.
What's the role of LDC here? What if you just used DMD all the way?
I also figured I can't test it on OS X because there's no addr2line... there is atos, wonder if that's exactly the same thing...
I mean when compiling using LDC I use different code to find the backtrace addresses.
Using the system call backtrace on a program compiled using DMD doesn't return anything useful.
Uhmm.. If atos works, then I'll look into adding support for it.