How to debug cross-compiled QEMU program with GDB?
问题 I'm having trouble debugging a simple program running in QEMU with GDB. GDB seems unable to find where I am in the program (in that it always displays ?? as my current location), and it never hits any breakpoint I set. In one terminal, I run QEMU: $ cat add.c int main() { int x = 9; int v = 1; while (1) { int q = x + v; } return 0; } $ riscv64-unknown-elf-gcc add.c -g $ qemu-system-riscv64 -gdb tcp::1234 -drive file=a.out,format=raw And in another terminal, I run GDB: $ riscv64-unknown-elf