Skip to main content

Module stacktrace

Module stacktrace 

Source
Expand description

Native symbol resolution for stack traces.

Two layers of resolution:

  1. dladdr β€” lightweight, zero deps: function name + library path
  2. 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_debuglink section, build-id paths, /usr/lib/debug/ mirror
  • musl: no dladdr or backtrace() β€” graceful no-op

ModulesΒ§

dladdr_ffi πŸ”’

StructsΒ§

DwarfCache πŸ”’
Cache of addr2line contexts, keyed by library path. Library bytes are leaked to get a 'static lifetime for gimli’s EndianSlice. This is bounded by the number of unique .so files loaded per session (typically < 20).
ResolvedFrame
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-id section 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_debuglink section 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.