I have a pretty trivial bit of bare-metal assembly code running on an arm64 QEMU instance. When debugging with GDB via the QEMU debug port, single step (stepi) is advancing over instructions rather than advancing per line of assembly. The pattern seems to be that it advances directly to the next branch instruction or branch target. The code being advancing over definitely is executed as the register side-effects are visible.
For example, the following code when stepped through (stepi), only stops on the following highlighted lines which are either branches or branch targets, however, x2 is clearly incremented:
ldr x0, =0x08000000 ldr x3, =-1loop: ldxr x2, [x0] <<< GDB "stepi" stops here add x2, x2, #1 <<< skipped stxr w3, x2, [x0] <<< skipped b trampoline <<< GDB "stepi" stops here noptrampoline: b loop <<< GDB "stepi" stops here
This smells on the surface like missing/incomplete debug info in the .elf file, but i've tried every gcc/as -g option I am aware of. I haven't experienced this behavior when running GDB natively on a userspace application, so wondering if this is a QEMU oddity.