qemu-discuss
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Open serial port to attach via GDB


From: Peter Maydell
Subject: Re: Open serial port to attach via GDB
Date: Sat, 10 Jul 2021 16:17:34 +0100

On Sat, 10 Jul 2021 at 08:22, Dmitrii Bundin <dmitrii@cmventures.com> wrote:
>
> On Thu, Jul 8, 2021 at 12:13 PM Peter Maydell <peter.maydell@linaro.org> 
> wrote:
> > The more usual way to connect to the QEMU gdbstub is to
> > have it listen on a TCP port and connect gdb to that. You can
> > do that by passing QEMU "-s -S" (and no -gdb option), which will
> > make it pause on startup and use the default TCP port 1234.
>
> Yes, connecting to the gdbstub via TCP works fine. The source of
> confusion was that the gdb manual page
> https://qemu-project.gitlab.io/qemu/system/gdb.html#gdb-usage allows
> us to use something other than TCP:
>
> > If you want to specify which TCP port to use or to use something other than 
> > TCP for the gdbstub connection, use the -gdb dev option instead of -s.
>
> So my first thought was to try to establish GDB connectionn using a
> serial port.

I'm not sure why your first thought wasn't "let's see if
the recommended default works for me" ? We recommend that at
the top of the gdb.html page because we expect that to be what
99% of users will want.

> Or what is the potential use-case of such "other than
> TCP" gdbstub connection?

The default is TCP, because almost everybody wants to use that.
Other types of connection are permitted mostly because the gdbstub
uses the same "chardev" infrastructure that many other bits of QEMU do
(allowing you to plumb not just the gdbstub but also emulated
guest serial ports, the QEMU monitor, etc through to TCP, pipes,
files, serial ports, parallel ports and lots of other things). Some of
those choices are more likely to be useful for the gdbstub than others,
but technically speaking they will all function if you need them.

In theory it is perfectly possible to tell QEMU "connect the
gdbstub to the host serial port", plug an RS232 cable
into the back of the host machine, connect it to a totally
different computer, and run gdb on that other machine telling
it to talk to that machine's serial port. But unless you really
need to do something that convoluted, it's a lot simpler to
run gdb on the same host machine and talk to the stub with TCP :-)

thanks
-- PMM



reply via email to

[Prev in Thread] Current Thread [Next in Thread]