D-Programming-GDC/GDC — pull request #65 by jpf91 (2013-06-19 07:18:14+00:00)
Title: [DO NOT PULL] Use libbacktrace for backtraces if it's available

This pull adds support to use the new GCC libbacktrace which is part of gcc 4.8. Libbacktrace can use debug info as well as the symbol table to find function names, so it's way superior to our current solution. It's probably also more portable. This code obtains the symbol information lazily. At first it only obtains the pointers, the symbol name, line, etc are only obtained when the backtrace is being printed.

I would not recommend merging this until the unittests work again but it's ready for early review.

TODO:
* Integrating this with the druntime unittest segv handler (requires duplicating some scoped! code for stack allocation)
* Performance testing

Example output (with -g)
```
std.conv.ConvException@/opt/gdc/include/d/4.8.1/std/conv.d(1811): Unexpected 'H' when converting from type string to type int
----------------
0x407fa5 void std.conv.convError!(immutable(char)[], int).convError(immutable(char)[], immutable(char)[], ulong)
/opt/gdc/include/d/4.8.1/std/conv.d:52
0x407ea2 int std.conv.parse!(int, immutable(char)[]).parse(ref immutable(char)[])
/opt/gdc/include/d/4.8.1/std/conv.d:1811
0x40a2e7 int std.conv.toImpl!(int, immutable(char)[]).toImpl(immutable(char)[])
/opt/gdc/include/d/4.8.1/std/conv.d:1600
0x407330 int std.conv.to!(int).to!(immutable(char)[]).to(immutable(char)[])
/opt/gdc/include/d/4.8.1/std/conv.d:276
0x403d9e int test.doSomeThing(immutable(char)[])
/home/jpf/Dokumente/Code/gdc/objdir/test.d:10
0x403d66 _Dmain
/home/jpf/Dokumente/Code/gdc/objdir/test.d:5
0x4142ee extern (C) int rt.dmain2._d_run_main(int, char**, extern (C) int function(char[][])*).void runMain()
../../../../gcc-4.8.1/libphobos/libdruntime/rt/dmain2.d:620
0x414a4e extern (C) int rt.dmain2._d_run_main(int, char**, extern (C) int function(char[][])*).void tryExec(scope void delegate())
../../../../gcc-4.8.1/libphobos/libdruntime/rt/dmain2.d:595
0x414c7f extern (C) int rt.dmain2._d_run_main(int, char**, extern (C) int function(char[][])*).void runAll()
../../../../gcc-4.8.1/libphobos/libdruntime/rt/dmain2.d:630
0x414a4e extern (C) int rt.dmain2._d_run_main(int, char**, extern (C) int function(char[][])*).void tryExec(scope void delegate())
../../../../gcc-4.8.1/libphobos/libdruntime/rt/dmain2.d:595
0x414be7 _d_run_main
----------------
```
Output without -g
```
std.conv.ConvException@/opt/gdc/include/d/4.8.1/std/conv.d(1811): Unexpected 'H' when converting from type string to type int
----------------
0x407fa5 void std.conv.convError!(immutable(char)[], int).convError(immutable(char)[], immutable(char)[], ulong)
???:0
0x407ea2 int std.conv.parse!(int, immutable(char)[]).parse(ref immutable(char)[])
???:0
0x40a2e7 int std.conv.toImpl!(int, immutable(char)[]).toImpl(immutable(char)[])
???:0
0x407330 int std.conv.to!(int).to!(immutable(char)[]).to(immutable(char)[])
???:0
0x403d9e int test.doSomeThing(immutable(char)[])
???:0
0x403d66 _Dmain
???:0
0x4142ee extern (C) int rt.dmain2._d_run_main(int, char**, extern (C) int function(char[][])*).void runMain()
../../../../gcc-4.8.1/libphobos/libdruntime/rt/dmain2.d:620
0x414a4e extern (C) int rt.dmain2._d_run_main(int, char**, extern (C) int function(char[][])*).void tryExec(scope void delegate())
../../../../gcc-4.8.1/libphobos/libdruntime/rt/dmain2.d:595
0x414c7f extern (C) int rt.dmain2._d_run_main(int, char**, extern (C) int function(char[][])*).void runAll()
../../../../gcc-4.8.1/libphobos/libdruntime/rt/dmain2.d:630
0x414a4e extern (C) int rt.dmain2._d_run_main(int, char**, extern (C) int function(char[][])*).void tryExec(scope void delegate())
../../../../gcc-4.8.1/libphobos/libdruntime/rt/dmain2.d:595
0x414be7 _d_run_main
../../../../gcc-4.8.1/libphobos/libdruntime/rt/dmain2.d:639
0x3ad6621734 ???
???:0
0x403c64 ???
???:0
----------------
```