Skip to content

Commit e5910d4

Browse files
committed
docs: Improve our gdbstub documentation
The documentation of our -s and -gdb options is quite old; in particular it still claims that it will cause QEMU to stop and wait for the gdb connection, when this has not been true for some time: you also need to pass -S if you want to make QEMU not launch the guest on startup. Improve the documentation to mention this requirement in the executable's --help output, the documentation of the -gdb option in the manual, and in the "GDB usage" chapter. Includes some minor tweaks to these paragraphs of documentation since I was editing them anyway (such as dropping the description of our gdb support as "primitive"). Signed-off-by: Peter Maydell <[email protected]> Reviewed-by: Philippe Mathieu-Daudé <[email protected]> Reviewed-by: Richard Henderson <[email protected]> Reviewed-by: Alex Bennée <[email protected]> Message-id: [email protected]
1 parent 9edfa35 commit e5910d4

File tree

2 files changed

+34
-14
lines changed

2 files changed

+34
-14
lines changed

docs/system/gdb.rst

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,25 @@
33
GDB usage
44
---------
55

6-
QEMU has a primitive support to work with gdb, so that you can do
7-
'Ctrl-C' while the virtual machine is running and inspect its state.
8-
9-
In order to use gdb, launch QEMU with the '-s' option. It will wait for
10-
a gdb connection:
6+
QEMU supports working with gdb via gdb's remote-connection facility
7+
(the "gdbstub"). This allows you to debug guest code in the same
8+
way that you might with a low-level debug facility like JTAG
9+
on real hardware. You can stop and start the virtual machine,
10+
examine state like registers and memory, and set breakpoints and
11+
watchpoints.
12+
13+
In order to use gdb, launch QEMU with the ``-s`` and ``-S`` options.
14+
The ``-s`` option will make QEMU listen for an incoming connection
15+
from gdb on TCP port 1234, and ``-S`` will make QEMU not start the
16+
guest until you tell it to from gdb. (If you want to specify which
17+
TCP port to use or to use something other than TCP for the gdbstub
18+
connection, use the ``-gdb dev`` option instead of ``-s``.)
1119

1220
.. parsed-literal::
1321
14-
|qemu_system| -s -kernel bzImage -hda rootdisk.img -append "root=/dev/hda"
15-
Connected to host network interface: tun0
16-
Waiting gdb connection on port 1234
22+
|qemu_system| -s -S -kernel bzImage -hda rootdisk.img -append "root=/dev/hda"
23+
24+
QEMU will launch but will silently wait for gdb to connect.
1725

1826
Then launch gdb on the 'vmlinux' executable::
1927

qemu-options.hx

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3680,14 +3680,26 @@ SRST
36803680
ERST
36813681

36823682
DEF("gdb", HAS_ARG, QEMU_OPTION_gdb, \
3683-
"-gdb dev wait for gdb connection on 'dev'\n", QEMU_ARCH_ALL)
3683+
"-gdb dev accept gdb connection on 'dev'. (QEMU defaults to starting\n"
3684+
" the guest without waiting for gdb to connect; use -S too\n"
3685+
" if you want it to not start execution.)\n",
3686+
QEMU_ARCH_ALL)
36843687
SRST
36853688
``-gdb dev``
3686-
Wait for gdb connection on device dev (see
3687-
:ref:`gdb_005fusage`). Typical connections will likely be
3688-
TCP-based, but also UDP, pseudo TTY, or even stdio are reasonable
3689-
use case. The latter is allowing to start QEMU from within gdb and
3690-
establish the connection via a pipe:
3689+
Accept a gdb connection on device dev (see
3690+
:ref:`gdb_005fusage`). Note that this option does not pause QEMU
3691+
execution -- if you want QEMU to not start the guest until you
3692+
connect with gdb and issue a ``continue`` command, you will need to
3693+
also pass the ``-S`` option to QEMU.
3694+
3695+
The most usual configuration is to listen on a local TCP socket::
3696+
3697+
-gdb tcp::3117
3698+
3699+
but you can specify other backends; UDP, pseudo TTY, or even stdio
3700+
are all reasonable use cases. For example, a stdio connection
3701+
allows you to start QEMU from within gdb and establish the
3702+
connection via a pipe:
36913703

36923704
.. parsed-literal::
36933705

0 commit comments

Comments
 (0)