libunwind is a portable and efficient C API for determining the current call chain of ELF program threads of execution and for resuming execution at any point in that call chain. The API supports both local (same process) and remote (other process) operation.
The API is useful in a number of applications, including but not limited to the following.
- program introspection Either for error messages showing a back trace of the call chain leading to a problem or for performance monitoring and analysis.
- debugging Whether the debugging and analysis of the call chain of a remote program or the post-mortem analysis of a coredump.
- language runtime exception handling libunwind optionally provides an alternative implementation of the Itanium exception handling ABI used by many popular toolchains.
- alternative
setjmp()/longjmp()libunwind optionally provides an alternative implementation of thesetjmp()/longjmp()functionality of the C standard library.
This library supports several architecture/operating-system combinations:
| System | Architecture | Status |
|---|---|---|
| Linux | x86-64 | ✓ |
| Linux | x86 | ✓ |
| Linux | ARM | ✓ |
| Linux | AArch64 | ✓ |
| Linux | Alpha | ✓ |
| Linux | PPC32 | ✓ |
| Linux | PPC64 | ✓ |
| Linux | PPC64LE | ✓ |
| Linux | s390x | ✓ |
| Linux | SuperH | ✓ |
| Linux | IA-64 | ✓ |
| Linux | PA-RISC | Works well, but C library missing unwind-info |
| Linux | MIPS | ✓ |
| Linux | RISC-V | ✓ |
| Linux | LoongArch | 64-bit only |
| HP-UX | IA-64 | Mostly works, but known to have serious limitations |
| FreeBSD | x86-64 | ✓ |
| FreeBSD | x86 | ✓ |
| FreeBSD | AArch64 | ✓ |
| FreeBSD | PPC32 | ✓ |
| FreeBSD | PPC64 | ✓ |
| FreeBSD | RISC-V | ✓ |
| QNX | Aarch64 | ✓ |
| QNX | x86-64 | ✓ |
| Solaris | x86-64 | ✓ |
In general, this library can be built and installed with the following commands:
$ autoreconf -i # Needed only for building from git. Depends on libtool.
$ ./configure --prefix=PREFIX
$ make
$ make install
where PREFIX is the installation prefix. By default, a prefix of
/usr/local is used, such that libunwind.a is installed in
/usr/local/lib and unwind.h is installed in /usr/local/include.
After building the library, you can run a set of regression tests with:
$ make check
This distribution includes a few simple performance tests which give some idea of the basic cost of various libunwind operations. After building the library, you can run these tests with the following commands:
$ cd tests
$ make perf
Please raise issues and pull requests through the GitHub repository: https://github.com/libunwind/libunwind.