Function backtrace::resolve[][src]

pub fn resolve<F: FnMut(&Symbol)>(addr: *mut c_void, cb: F)
Expand description

Resolve an address to a symbol, passing the symbol to the specified closure.

This function will look up the given address in areas such as the local symbol table, dynamic symbol table, or DWARF debug info (depending on the activated implementation) to find symbols to yield.

The closure may not be called if resolution could not be performed, and it also may be called more than once in the case of inlined functions.

Symbols yielded represent the execution at the specified addr, returning file/line pairs for that address (if available).

Note that if you have a Frame then it’s recommended to use the resolve_frame function instead of this one.

Required features

This function requires the std feature of the backtrace crate to be enabled, and the std feature is enabled by default.

Panics

This function strives to never panic, but if the cb provided panics then some platforms will force a double panic to abort the process. Some platforms use a C library which internally uses callbacks which cannot be unwound through, so panicking from cb may trigger a process abort.

Example

extern crate backtrace;

fn main() {
    backtrace::trace(|frame| {
        let ip = frame.ip();

        backtrace::resolve(ip, |symbol| {
            // ...
        });

        false // only look at the top frame
    });
}