Skip to content

Commit c7521b1

Browse files
authored
Add support for unwinding the stack on 32-bit arm platforms (armv6, armv7) (#54)
This is a simple mod suggested by @weissi that now works thanks to supporting DWARF v3 properly in #53. Tested with a Raspberry Pi 3B+ running Ubuntu 22.04 for armv7.
1 parent fa142f7 commit c7521b1

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

Sources/CProfileRecorderSampler/fp_unwinder.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,11 @@ int swipr_fp_unwinder_getcontext(struct swipr_fp_unwinder_context *context, ucon
7676
intptr_t reg_ip = uc->uc_mcontext.pc;
7777
intptr_t reg_fp = uc->uc_mcontext.regs[29];
7878
intptr_t reg_sp = uc->uc_mcontext.sp;
79+
#elif defined(__linux__) && defined(__arm__)
80+
// ARM (32-bit) on Linux (e.g. ARMv6 and ARMv7)
81+
intptr_t reg_ip = uc->uc_mcontext.arm_pc;
82+
intptr_t reg_fp = uc->uc_mcontext.arm_fp; // r11 is the frame pointer
83+
intptr_t reg_sp = uc->uc_mcontext.arm_sp; // r13 is the stack pointer
7984
#elif defined(__APPLE__) && defined(__x86_64__)
8085
intptr_t reg_ip = uc->uc_mcontext->__ss.__rip;
8186
intptr_t reg_fp = uc->uc_mcontext->__ss.__rbp;

0 commit comments

Comments
 (0)