pprof/backtrace/
backtrace_rs.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
impl super::Frame for backtrace::Frame {
    type S = backtrace::Symbol;

    fn ip(&self) -> usize {
        self.ip() as usize
    }

    fn resolve_symbol<F: FnMut(&Self::S)>(&self, cb: F) {
        backtrace::resolve_frame(self, cb);
    }

    fn symbol_address(&self) -> *mut libc::c_void {
        self.symbol_address()
    }
}

pub struct Trace {}

impl super::Trace for Trace {
    type Frame = backtrace::Frame;

    fn trace<F: FnMut(&Self::Frame) -> bool>(_: *mut libc::c_void, cb: F) {
        unsafe { backtrace::trace_unsynchronized(cb) }
    }
}

pub use backtrace::Frame;
pub use backtrace::Symbol;