Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to watch memory access with gdb on guest machine in qemu?

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.

like image 773
cstack Avatar asked Oct 15 '25 17:10

cstack


1 Answers

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?
like image 141
hesham_EE Avatar answered Oct 18 '25 15:10

hesham_EE



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!