Bindings to libbacktrace
Structs
Functions
-
extern "C" fn backtrace_create_state(filename: &c_char, threaded: c_int, error: BacktraceErrorCallback, data: &mut void) -> &mut BacktraceState
Create state information for the backtrace routines.
This must be called before any of the other routines, and its return value must be passed to all of the other routines.
filenameis the path name of the executable file; if it isnullthe library will try system-specific path names. If notnull,filenamemust point to a permanent buffer. Ifthreadedis non-zero the state may be accessed by multiple threads simultaneously, and the library will use appropriate atomic operations. Ifthreadedis zero the state may only be accessed by one thread at a time. This returns a state pointer on success,nullon error. If an error occurs, this will call theerror_callbackroutine.Calling this function allocates resources that cannot be freed. There is no
backtrace_free_statefunction. The state is used to cache information that is expensive to recompute. Programs are expected to call this function at most once and to save the return value for all later calls to backtrace functions. -
extern "C" fn backtrace_full(state: &mut BacktraceState, skip: c_int, callback: BacktraceFullCallback, error: BacktraceErrorCallback, data: &mut void) -> c_int
Get a full stack backtrace.
skipis the number of frames to skip; passing 0 will start the trace with the function calling backtrace_full.datais passed to the callback routine. If any call tocallbackreturns a non-zero value, the stack backtrace stops, and backtrace returns that value; this may be used to limit the number of stack frames desired. If all calls tocallbackreturn 0, backtrace returns 0. The backtrace_full function will make at least one call to eithercallbackorerror_callback. This function requires debug info for the executable.
Types
-
type BacktraceErrorCallback = fn(&mut void, &c_char, c_int)
The type of the error callback argument to backtrace functions.
This function, if not
null, will be called for certain error cases. Thedataargument is passed to the function that calls this one. The MSG argument is an error message. Theerrnumargument, if greater than 0, holds an errno value. The MSG buffer may become invalid after this function returns.As a special case, the
errnumargument will be passed as -1 if no debug info can be found for the executable, or if the debug info exists but has an unsupported version, but the function requires debug info (e.g., backtrace_full,backtrace_pcinfo). The MSG in this case will be something along the lines of "no debug info". Similarly,errnumwill be passed as -1 if there is no symbol table, but the function requires a symbol table (e.g.,backtrace_syminfo). This may be used as a signal that some other approach should be tried. -
The type of the callback argument to the backtrace_full function.
datais the argument passed to backtrace_full.pcis the program counter.filenameis the name of the file containingpc, ornullif not available.linenois the line number infilenamecontainingpc, or 0 if not available.functionis the name of the function containingpc, ornullif not available. This should return 0 to continuing tracing. Thefilenameandfunctionbuffers may become invalid after this function returns.