diff --git a/core/arch/arm/include/arm32.h b/core/arch/arm/include/arm32.h index 78887bb64..9b8ee63d3 100644 --- a/core/arch/arm/include/arm32.h +++ b/core/arch/arm/include/arm32.h @@ -558,6 +558,22 @@ static __always_inline uint32_t read_lr(void) asm volatile ("mov %0, lr" : "=r" (val)); return val; } + +static __always_inline uint32_t read_fp(void) +{ + uint32_t val; + + asm volatile ("mov %0, fp" : "=r" (val)); + return val; +} + +static __always_inline uint32_t read_r7(void) +{ + uint32_t val; + + asm volatile ("mov %0, r7" : "=r" (val)); + return val; +} #endif /*ASM*/ #endif /*ARM32_H*/ diff --git a/core/arch/arm/kernel/unwind_arm32.c b/core/arch/arm/kernel/unwind_arm32.c index b8b53c848..7efe94ba0 100644 --- a/core/arch/arm/kernel/unwind_arm32.c +++ b/core/arch/arm/kernel/unwind_arm32.c @@ -367,10 +367,14 @@ void print_stack(int level) { struct unwind_state state; - memset(&state, 0, sizeof(state)); + memset(state.registers, 0, sizeof(state.registers)); + /* r7: Thumb-style frame pointer */ + state.registers[7] = read_r7(); + /* r11: ARM-style frame pointer */ + state.registers[FP] = read_fp(); state.registers[SP] = read_sp(); state.registers[LR] = read_lr(); - state.registers[PC] = read_pc(); + state.registers[PC] = (uint32_t)print_stack; do { switch (level) {