Commit cd55ddb3 authored by Caiyi H.'s avatar Caiyi H.
Browse files

chore: Fix stack trace

Showing with 9 additions and 5 deletions
+9 -5
......@@ -3,6 +3,8 @@
.global _start
_start:
la sp, boot_stack_top
# Make fp 0 so that stack trace knows where to stop
xor fp, fp, fp
j __kernel_start_main
.section .bss.stack
......
......@@ -4,15 +4,17 @@ pub unsafe fn print_stack_trace() {
let mut fp: *const usize;
asm!("mv {}, fp", out(reg) fp);
let mut saved_ra = *fp.sub(1);
let mut saved_fp = *fp.sub(2);
println!("== Begin stack trace ==");
while !fp.is_null() {
let saved_ra = *fp.sub(1);
let saved_fp = *fp.sub(2);
while !fp.is_null() && saved_fp != 0 {
saved_ra = *fp.sub(1);
saved_fp = *fp.sub(2);
println!("0x{:016x}, fp = 0x{:016x}", saved_ra, saved_fp);
fp = saved_fp as *const usize;
println!("== End stack trace ==");
}
println!("== End stack trace ==");
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment