test gdb as it runs qemu simulator

"Mock, George via Gdb" <[email protected]> Wed, 29 Oct 2025 20:21:13 +0000
Newsgroups gmane.comp.gdb.devel
Message-ID <[email protected]>
Hello!

I work on a team that implements C/C++ cross compilers.  Among other combinations, one cross compiler runs on Linux and generates code for RISC-V systems.  I want to use the gdb testsuite.  Not for the purpose of testing gdb, but to test whether the Dwarf generated by our compiler works with gdb.  I need to test gdb while it controls execution of code running under a qemu simulator for RISC-V.

The following shows a typical way, from Linux, to interactively use gdb on one program.

# In one process
$ qemu-riscv32 -g 1234 riscv-program

# In a different process
$ riscv32-unknown-elf-gdb riscv-program
(gdb) target remote localhost:1234
(gdb) # typical gdb commands go here

The option -g 1234 tells qemu-riscv32 to start gdbserver and wait for communication through port 1234.

I have some familiarity with testing gdb.  I learned how to build and test it for Linux.  I built riscv32-unknown-elf-gdb, and I can interactively watch it work.  I know how to configure the testsuite to build with our cross compiler.  But I cannot find the configuration (I presume some combination of a board file and command line options) which causes the testsuite to interface with qemu-riscv32 in a manner similar to that interactive example.

While I would appreciate a fully fleshed out solution, I'm sure that is too much to expect.  I suspect many have done this before me, but none of my many searches have found the blog post (or whatever) which shows how they did it.

I'd appreciate any light you can shed.

Thanks and regards,

-George Mock