GDB backtrace through an Arm IRQ handler

Programming, for all ages and all languages.
Post Reply
thejpster
Posts: 1
Joined: Fri Oct 16, 2026 1:22 pm

GDB backtrace through an Arm IRQ handler

Post by thejpster »

I'd like GDB backtraces to work, even if handling an IRQ (or other exception). I've tried adding `.cfi_xxx` directives to my hand-coded assembly language IRQ handler routines (which stack registers and then call a C/Rust function), but I'm confused about how to explain to GDB:

* the fact we're doing the exception from some unspecified mode to *IRQ* mode (with its unique stack),
* the handler then switching to *SVC* mode (with its unique stack) to run the C/Rust handler,
* the 8 byte stack alignment needed on the *SVC* stack before we call the C/Rust handler, and
* the fact we return to *IRQ* mode and then return from the exception back to whatever the calling mode was.

Does anyone have an example of an Arm ASM IRQ handler which has enough debug info to correctly show backtraces from the current PC, back through the interrupted function, all the way down to `_start`?

This is a 32-bit AArch32 (ARM7, ARM9, ARM11, Cortex-A and Cortex-R). Obviously it's much less of an issue on Cortex-M, with the handler written in C and the hardware doing the pushing and popping.
Post Reply