mirror of
https://github.com/DragonOS-Community/DragonOS.git
synced 2025-06-08 14:16:47 +00:00
* fix: remove useless c code remove printk.c file remove old test_ebpf file implement `lookup_kallsyms` and `addr_from_symbol` using rust * fix the weak linkage * feat(kernel): 添加cfg-if依赖并优化panic模块的条件编译 Signed-off-by: longjin <longjin@DragonOS.org> --------- Signed-off-by: longjin <longjin@DragonOS.org> Co-authored-by: longjin <longjin@DragonOS.org>
25 lines
740 B
Rust
25 lines
740 B
Rust
use crate::debug::traceback::lookup_kallsyms;
|
|
use unwinding::abi::{UnwindContext, UnwindReasonCode, _Unwind_GetIP};
|
|
use unwinding::panic::UserUnwindTrace;
|
|
|
|
/// User hook for unwinding
|
|
///
|
|
/// During stack backtrace, the user can print the function location of the current stack frame.
|
|
pub struct Tracer;
|
|
pub struct CallbackData {
|
|
pub counter: usize,
|
|
}
|
|
impl UserUnwindTrace for Tracer {
|
|
type Arg = CallbackData;
|
|
|
|
fn trace(ctx: &UnwindContext<'_>, arg: *mut Self::Arg) -> UnwindReasonCode {
|
|
let data = unsafe { &mut *(arg) };
|
|
data.counter += 1;
|
|
let pc = _Unwind_GetIP(ctx);
|
|
unsafe {
|
|
lookup_kallsyms(pc as u64, data.counter as i32);
|
|
}
|
|
UnwindReasonCode::NO_REASON
|
|
}
|
|
}
|