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: Thu, 8 Jul 2021 10:12:38 +0100

On Thu, 8 Jul 2021 at 07:12, Dmitrii Bundin <dmitrii@cmventures.com> wrote:
>
> Hello,
>
> My current installation is Ubuntu 20.04 and QEMU emulator version 6.0.0. I'm 
> trying to attach gdb to the guest via a serial port. Using a default 
> /dev/ttyS0 I tried to run QEMU as follows
>
> $ sudo qemu-system-x86_64 -serial /dev/ttyS0 -gdb /dev/ttyS0 -S

This says "Connect the guest serial port to the host's serial port.
Also, connect the QEMU gdbstub to the host's ttyS0". This
won't work because you're trying to do two things with the
host serial port at the same time.

You then try
(gdb) target remote /dev/ttyS0
which says "connect to a remote gdbstub on the host's serial port";
that won't work unless you've really got a loopback serial cable
connected to that host serial port.

> Is there a way to open a serial port to use for GDB debugging?

If you can explain exactly what you want to connect to what,
we can probably help with the command line arguments.

I'm guessing you probably don't really want to connect anything
to your host's physical serial ports, for example, but maybe
you do. 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.
Then you connect from gdb with 'target remote localhost:1234'.

https://qemu-project.gitlab.io/qemu/system/gdb.html#gdb-usage
has more details.

thanks
-- PMM



reply via email to

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