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

Luis Machado via Gdb <[email protected]>
Newsgroups gmane.comp.gdb.devel
Message-ID <[email protected]>
Hi,

On 3/18/22 16:33, Denio, Mike via Gdb wrote:
> I am seeing an issue with the remote protocol  on GDB with multiple threads on a riscv32 using the step command. Not sure if it's a bug or just me, but it seems like a legitimate bug.
> 
> I am using a custom server. The behavior is the same on both GDB 11.1 and 11.2.
> 
> This GDB was configured as follows:
>     configure --host=x86_64-pc-linux-gnu --target=riscv32-unknown-elf
>               --with-auto-load-dir=$debugdir:$datadir/auto-load
>               --with-auto-load-safe-path=$debugdir:$datadir/auto-load
>               --with-expat
>               --with-gdb-datadir=/usr/local/share/gdb (relocatable)
>               --with-jit-reader-dir=/usr/local/lib/gdb (relocatable)
>               --without-libunwind-ia64
>               --with-lzma
>               --without-babeltrace
>               --without-intel-pt
>               --with-mpfr
>               --without-xxhash
>               --with-python=/usr
>               --with-python-libdir=/usr/lib
>               --without-debuginfod
>               --without-guile
>               --disable-source-highlight
>               --with-separate-debug-dir=/usr/local/lib/debug (relocatable)
> 
> I am running in non-stop mode. A full log of the test is at the end of the email. The GDB commands I execute after connecting are:
> (gdb) interrupt -a
> (gdb) s
> 
> The problem is that my code starts off in an infinite loop (endz: jal x0,endz), with the cores basically waiting for an interrupt. If I execute a 'step' command, GDB will basically keep sending "vCont;s:2" in an infinite loop, until the PC addr of thread 2 changes. It also occurs if I fall into an infinite loop while stepping. It doesn't need to be the first instruction.

That's what the step/next commands are designed to do. GDB will keep 
stepping until it sees a line change. I suppose a "continue" command 
here would be more appropriate, as GDB will send it once and keep 
waiting for the outcome. stepi/nexti would be undesirable given they 
will stop after a single instruction.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.