[GDB] Debugger seems to crash when stepping inside an IRQ handler

Hello there,

Describe the bug
When setting a breakpoint inside an IRQ handler in my application, I'm experiencing the following crash each time I try to continue, step over, step into or step out of the handler:

/__w/_temp/workspace/build/.build/arm-zephyr-eabi/src/gdb/gdb/infrun.c:5825: internal-error: finish_step_over: Assertion `ecs->event_thread->control.trap_expected' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.

Quit this debugging session?
(y or n) [answered Y; input not from terminal]

This is a bug, please report it.
  For instructions, see:
<github.com/.../issues>.

/__w/_temp/workspace/build/.build/arm-zephyr-eabi/src/gdb/gdb/infrun.c:5825: internal-error: finish_step_over: Assertion `ecs->event_thread->control.trap_expected' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.

Create a core file of GDB?
(y or n) [answered Y; input not from terminal]
GDB session ended unexpectedly. exit-code: none, signal: SIGABRT

Here's the GDB coredump: core.zip

Please also mention any information which could help others to understand
the problem you're facing
- Target CPU: NRF5340 Application core
- Zephyr SDK revision: 0.16.4 (gdb v12.1)
- Zephyr OS revision: v3.4.99-ncs1-1 (Nordic's current fork revision on NRF SDK v2.5.1)
- Debugging probe: SEGGER JLink BASE Compact with J-Link GDB Server V7.94f (latest)
- I'm in the process of updating the NRF SDK and I did not encounter this issue in the previous version used in my project (v2.4.1). I'm also reporting this crash as a Zephyr SDK issue in case this should be handled by the Zephyr team.

Steps to reproduce
1. Set a breakpoint inside an IRQ handler
2. Have your code hit the breakpoint
3. Try to step to next instruction after the breakpoint
=> GDB crashes with the reported error
NB: I was able to consistently reproduce the crash on my setup by setting a breakpoint in several distinct IRQ handlers. The crash does not occur when debugging regular code which is why I deduced that the issue is somehow linked to IRQ handlers.

Expected behaviour
Stepping inside function should not crash GDB.

Related