linfeng 3d663af8a2
fix: remove useless c code (#1116)
* 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>
2025-03-27 14:16:10 +08:00

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
}
}