core.internal.backtrace.libunwind

Basic D language bindings for LLVM libunwind

There are two available libunwind: The "upstream" one, inherited from HP, which is maintained as a GNU project, and the LLVM one, part of llvm-project, and the default on Mac OSX.

They are both essential part of other languages ABI, and are available in both GCC and LLVM. However, in GCC, only the higher-level functions are exposed (e.g. _Unwind_*) while LLVM expose the higher-level and lower-level (unw_*) functions. Many distributions have a libunwind package as well, that provides the unw_* functions, but since it also supports remote unwinding, the function names are actually platform dependent and binding them is a pain as many things rely on #define.

In the future, we would like to implement backtrace using only the higher-level functions (_Unwind_*), which will allow us to not use backtrace and friends directly, and only retrieve the functions names when needed (currently we need to eagerly get the functions names).

Authors

Mathias 'Geod24' Lang

Types 5

aliasunw_word_t = uintptr_t
aliasunw_regnum_t = int
structunw_context_t
Fields
ulong[_LIBUNWIND_CONTEXT_SIZE] data
structunw_cursor_t
Fields
ulong[_LIBUNWIND_CURSOR_SIZE] data
structunw_proc_info_t
Fields
unw_word_t start_ip
unw_word_t end_ip
unw_word_t lsda
unw_word_t handler
unw_word_t gp
unw_word_t flags
uint format
uint unwind_info_size
unw_word_t unwind_info
unw_word_t extra

Functions 6

fnint unw_getcontext(unw_context_t *)Initialize the context at the current call site
fnint unw_init_local(unw_cursor_t *, unw_context_t *)Initialize a cursor at the call site
fnint unw_step(unw_cursor_t *)Goes one level up in the call chain
fnint unw_get_proc_info(unw_cursor_t *, unw_proc_info_t *)Get infos about the current procedure (function)
fnint unw_get_proc_name(unw_cursor_t *, char *, size_t, unw_word_t *)Get the name of the current procedure (function)
fnint unw_get_reg(unw_cursor_t * cp, unw_regnum_t reg, unw_word_t * valp)Reads the value of register `reg` in the stack frame identified by cursor `cp` and stores the value in the word pointed to by `valp`.