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.
filename
is the path name of the executable file; if it isnull
the library will try system-specific path names. If notnull
,filename
must point to a permanent buffer. Ifthreaded
is non-zero the state may be accessed by multiple threads simultaneously, and the library will use appropriate atomic operations. Ifthreaded
is zero the state may only be accessed by one thread at a time. This returns a state pointer on success,null
on error. If an error occurs, this will call theerror_callback
routine.Calling this function allocates resources that cannot be freed. There is no
backtrace_free_state
function. 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.
skip
is the number of frames to skip; passing 0 will start the trace with the function calling backtrace_full.data
is passed to the callback routine. If any call tocallback
returns 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 tocallback
return 0, backtrace returns 0. The backtrace_full function will make at least one call to eithercallback
orerror_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. Thedata
argument is passed to the function that calls this one. The MSG argument is an error message. Theerrnum
argument, if greater than 0, holds an errno value. The MSG buffer may become invalid after this function returns.As a special case, the
errnum
argument 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,errnum
will 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.
data
is the argument passed to backtrace_full.pc
is the program counter.filename
is the name of the file containingpc
, ornull
if not available.lineno
is the line number infilename
containingpc
, or 0 if not available.function
is the name of the function containingpc
, ornull
if not available. This should return 0 to continuing tracing. Thefilename
andfunction
buffers may become invalid after this function returns.