Debugging sys_exec :(

This commit is contained in:
Yifan Wu 2021-09-30 10:09:21 -07:00
parent 6d88ef9d99
commit ad0a7bcaa1
14 changed files with 371 additions and 182 deletions

View file

@ -1,5 +1,6 @@
use core::panic::PanicInfo;
use crate::sbi::shutdown;
use crate::task::current_kstack_top;
#[panic_handler]
fn panic(info: &PanicInfo) -> ! {
@ -8,5 +9,19 @@ fn panic(info: &PanicInfo) -> ! {
} else {
println!("[kernel] Panicked: {}", info.message().unwrap());
}
unsafe { backtrace(); }
shutdown()
}
unsafe fn backtrace() {
let mut fp: usize;
let stop = current_kstack_top();
asm!("mv {}, s0", out(reg) fp);
println!("---START BACKTRACE---");
for i in 0..10 {
if fp == stop { break; }
println!("#{}:ra={:#x}", i, *((fp-8) as *const usize));
fp = *((fp-16) as *const usize);
}
println!("---END BACKTRACE---");
}