Fix panic when print stack trace for panic

This commit is contained in:
Marsman1996
2024-08-28 20:02:43 +08:00
committed by Tate, Hongliang Tian
parent 6ce25dc38b
commit ce7413c0fd

View File

@ -80,6 +80,7 @@ fn print_stack_trace() {
let data = unsafe { &mut *(arg as *mut CallbackData) }; let data = unsafe { &mut *(arg as *mut CallbackData) };
data.counter += 1; data.counter += 1;
let pc = _Unwind_GetIP(unwind_ctx); let pc = _Unwind_GetIP(unwind_ctx);
if pc > 0 {
let fde_initial_address = _Unwind_FindEnclosingFunction(pc as *mut c_void) as usize; let fde_initial_address = _Unwind_FindEnclosingFunction(pc as *mut c_void) as usize;
early_println!( early_println!(
"{:4}: fn {:#18x} - pc {:#18x} / registers:", "{:4}: fn {:#18x} - pc {:#18x} / registers:",
@ -87,6 +88,7 @@ fn print_stack_trace() {
fde_initial_address, fde_initial_address,
pc, pc,
); );
}
// Print the first 8 general registers for any architecture. The register number follows // Print the first 8 general registers for any architecture. The register number follows
// the DWARF standard. // the DWARF standard.
for i in 0..8u16 { for i in 0..8u16 {