Single stepping with RTOS

I’m running FreeRTOS application on RV32 Spike simulation.
I’m debugging it with openocd and gdb.
Setting breakpoints and resuming in gdb works fine. The problem is single step.

When trying to single step, the timer interrupt brings the control back to the trap_entry, vPortSysTickHandler and context switch handling, instead of stopping on the next command.

I expected single step to mask the timer interrupt, allowing me to single step linearly through the code, and unmask interrupts upon gdb “continue”.

  • What is the expected way gdb single step is supposed to work on RISCv+RTOS?
  • If I want to fix this, where should I look? Should I change the way openocd handles single step? Should I make changes in gdb?
  • Are there other ways to tackle this other than masking interrupts temporarily during single step?