mirror of
https://github.com/rcore-os/rCore.git
synced 2024-11-22 16:16:16 +04:00
Replace hardcoded instruction length with size_of in backtrace
This commit is contained in:
parent
5350ecb09f
commit
6e887d5505
@ -1,3 +1,5 @@
|
||||
use core::intrinsics::size_of;
|
||||
|
||||
extern "C" {
|
||||
fn stext();
|
||||
fn etext();
|
||||
@ -45,7 +47,7 @@ pub fn backtrace() {
|
||||
let mut current_fp = fp();
|
||||
let mut stack_num = 0;
|
||||
while current_pc >= stext as usize && current_pc <= etext as usize && current_fp as usize != 0 {
|
||||
println!("#{} {:#018X} fp {:#018X}", stack_num, current_pc - 4, current_fp);
|
||||
println!("#{} {:#018X} fp {:#018X}", stack_num, current_pc - size_of::<usize>(), current_fp);
|
||||
stack_num = stack_num + 1;
|
||||
#[cfg(any(target_arch = "riscv32", target_arch = "riscv64"))]
|
||||
{
|
||||
|
@ -6,6 +6,7 @@
|
||||
#![feature(optin_builtin_traits)]
|
||||
#![feature(panic_info_message)]
|
||||
#![feature(global_asm)]
|
||||
#![feature(core_intrinsics)]
|
||||
#![no_std]
|
||||
|
||||
// just keep it ...
|
||||
|
Loading…
Reference in New Issue
Block a user