1
0
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:
Jiajie Chen 2019-01-08 19:08:17 +08:00
parent 5350ecb09f
commit 6e887d5505
2 changed files with 4 additions and 1 deletions

View File

@ -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"))]
{

View File

@ -6,6 +6,7 @@
#![feature(optin_builtin_traits)]
#![feature(panic_info_message)]
#![feature(global_asm)]
#![feature(core_intrinsics)]
#![no_std]
// just keep it ...