Expand description
Native symbol resolution for stack traces.
Two layers of resolution:
- dladdr β lightweight, zero deps: function name + library path
- addr2line/gimli β DWARF debug info: file:line for C code
The DWARF layer is optional and gracefully falls back to dladdr-only output when debug info is unavailable.
Platform quirks handled:
- macOS: dSYM bundles (
<lib>.dSYM/Contents/Resources/DWARF/<filename>) - Linux:
.gnu_debuglinksection, build-id paths,/usr/lib/debug/mirror - musl: no
dladdrorbacktrace()β graceful no-op
ModulesΒ§
- dladdr_
ffi π
StructsΒ§
- Dwarf
Cache π - Cache of addr2line contexts, keyed by library path.
Library bytes are leaked to get a
'staticlifetime for gimliβsEndianSlice. This is bounded by the number of unique .so files loaded per session (typically < 20). - Resolved
Frame - A resolved native stack frame.
ConstantsΒ§
- DWARF_
CACHE π
FunctionsΒ§
- dwarf_
resolve π - Try to resolve file:line for an address using DWARF debug info.
- find_
build_ πid_ debug - Read the ELF
.note.gnu.build-idsection and check/usr/lib/debug/.build-id/<xx>/<rest>.debug. - find_
debug_ πfile - Find the file containing DWARF debug info for a given library. Returns the library_path itself if debug info is embedded, or a separate debug file path if found via platform-specific mechanisms.
- find_
gnu_ πdebuglink - Read the
.gnu_debuglinksection to find a separate debug file. The section contains a filename (no directory) and a CRC32 checksum. Search order: same directory as the library, then/usr/lib/debug/. - find_
linux_ πdebug_ file - Linux: find separate debug info via multiple strategies.
- format_
native_ frames - Format resolved native frames as indented lines for display under an R call frame.
- resolve_
native_ backtrace - Resolve a native backtrace into human-readable frames.