non-working squashfs driver updates, partial stack traces, and more
This commit is contained in:
26
src/arch/x86_common/stack_trace.rs
Normal file
26
src/arch/x86_common/stack_trace.rs
Normal file
@@ -0,0 +1,26 @@
|
||||
#[repr(C)]
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
struct StackFrame {
|
||||
back: *const StackFrame,
|
||||
rip: u64,
|
||||
}
|
||||
|
||||
pub fn print_stack_trace(max_frames: usize) {
|
||||
let mut stackframe: *const StackFrame;
|
||||
|
||||
unsafe {
|
||||
core::arch::asm!("mov {0:r}, rbp", out(reg) stackframe);
|
||||
};
|
||||
|
||||
crate::println!("Stack Trace:");
|
||||
for _frame in 0..max_frames {
|
||||
if stackframe.is_null() || unsafe { (*stackframe).back.is_null() } {
|
||||
break;
|
||||
}
|
||||
|
||||
unsafe {
|
||||
crate::println!(" {:#X}", (*stackframe).rip);
|
||||
stackframe = (*stackframe).back;
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user