4

I can find instructions online to break on accesses to memory addresses using gdb (Watch a memory range in gdb?) but I can't figure out how to do so for memory addresses on the guest machine when I use qemu.

Community
  • 1
  • 1
cstack
  • 2,152
  • 6
  • 28
  • 47

1 Answers1

3

You start qemu with gdb server listening on port 1234 by supplying -s to the qemu comman line. From qemu man page:

   -s  Shorthand for -gdb tcp::1234, i.e. open a gdbserver on TCP port
       1234.

In additon to this, you can also use option -S which will stop Qemu from progressing until you connect gdb to it and issue continue command.

-S  Do not start CPU at startup (you must type 'c' in the monitor).

From gdb, you connect to the gdb server running on qemu, by starting gdb (version of gdb that fits you guest architecture). Then connect to the gdb server by command (if qemu is running on the same machine):

(gdb) target remote :1234

References:

  1. http://wiki.qemu.org/Documentation/Debugging
  2. How to debug the Linux kernel with GDB and QEMU?
Community
  • 1
  • 1
hesham_EE
  • 1,125
  • 13
  • 24