| 1 |
The libbacktrace library |
| 2 |
Initially written by Ian Lance Taylor <[email protected]> |
| 3 |
|
| 4 |
The libbacktrace library may be linked into a program or library and |
| 5 |
used to produce symbolic backtraces. |
| 6 |
Sample uses would be to print a detailed backtrace when an error |
| 7 |
occurs or to gather detailed profiling information. |
| 8 |
|
| 9 |
In general the functions provided by this library are async-signal-safe, |
| 10 |
meaning that they may be safely called from a signal handler. |
| 11 |
That said, on systems that use dl_iterate_phdr, such as GNU/Linux, |
| 12 |
the first call to a libbacktrace function will call dl_iterate_phdr, |
| 13 |
which is not in general async-signal-safe. Therefore, programs |
| 14 |
that call libbacktrace from a signal handler should ensure that they |
| 15 |
make an initial call from outside of a signal handler. |
| 16 |
Similar considerations apply when arranging to call libbacktrace |
| 17 |
from within malloc; dl_iterate_phdr can also call malloc, |
| 18 |
so make an initial call to a libbacktrace function outside of |
| 19 |
malloc before trying to call libbacktrace functions within malloc. |
| 20 |
|
| 21 |
The libbacktrace library is provided under a BSD license. |
| 22 |
See the source files for the exact license text. |
| 23 |
|
| 24 |
The public functions are declared and documented in the header file |
| 25 |
backtrace.h, which should be #include'd by a user of the library. |
| 26 |
|
| 27 |
Building libbacktrace will generate a file backtrace-supported.h, |
| 28 |
which a user of the library may use to determine whether backtraces |
| 29 |
will work. |
| 30 |
See the source file backtrace-supported.h.in for the macros that it |
| 31 |
defines. |
| 32 |
|
| 33 |
As of July 2024, libbacktrace supports ELF, PE/COFF, Mach-O, and |
| 34 |
XCOFF executables with DWARF debugging information. |
| 35 |
In other words, it supports GNU/Linux, *BSD, macOS, Windows, and AIX. |
| 36 |
The library is written to make it straightforward to add support for |
| 37 |
other object file and debugging formats. |
| 38 |
|
| 39 |
The library relies on the C++ unwind API defined at |
| 40 |
https://itanium-cxx-abi.github.io/cxx-abi/abi-eh.html |
| 41 |
This API is provided by GCC and clang. |