Re: Step causes GDB to spin in infinite loop when PC doesn't change

Pedro Alves
2022-03-18T18:40:12Z

On 2022-03-18 17:57, Denio, Mike via Gdb wrote:
>
>>>>>
> I recall we used to have some issues like that, where GDB wouldn't stop
> stepping and would give you enough time to ctrl-C your way out of it,
> but they were fixed as far as I recall.
>
> Are you using non-stop mode with synchronous commands? You might want to
> try sending asynchronous commands (passing &), that way GDB will give
> you the prompt instantly and you will have full control again. You can
> then issue an interruption (interrupt -a) to stop everything.
> <<<<
>
> Again, its not so much "what is the right command to use?" as it is "what happens if the user sends the wrong command?".
>
> I'm still new to this, but my interpretation of "step" was "step until the high level language instruction is complete, even if its multiple opcodes". This makes sense to me, to step over C instructions or multi opcode pseudo ops. The interpretation of "step" that makes less sense to me is "keep calling step until the PC changes", because if the PC didn't change after the first step, why would it ever change?

"step" is defined as

(gdb) help step
Step program until it reaches a different source line.

If the program has a loop that never reaches a different line, GDB will happily continue stepping.
Nothing wrong with that. Could be spinlock, for example, waiting on some external condition, interrupt,
whatever.

Now, if Ctrl-C doesn't work, then that's a bug somewhere.