[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH] gdbstub: send a terminaison packet instead of c
From: |
Stefan Hajnoczi |
Subject: |
Re: [Qemu-devel] [PATCH] gdbstub: send a terminaison packet instead of crashing gdb |
Date: |
Mon, 19 Mar 2018 17:09:31 +0000 |
User-agent: |
Mutt/1.9.2 (2017-12-15) |
On Fri, Mar 16, 2018 at 07:45:18PM +0100, KONRAD Frederic wrote:
> On 03/16/2018 05:34 PM, Peter Maydell wrote:
> > On 16 March 2018 at 16:23, KONRAD Frederic <address@hidden> wrote:
> > > Since the commit:
> > > commit 4486e89c219c0d1b9bd8dfa0b1dd5b0d51ff2268
> > > Author: Stefan Hajnoczi <address@hidden>
> > > Date: Wed Mar 7 14:42:05 2018 +0000
> > >
> > > vl: introduce vm_shutdown()
> > >
> > > GDB crash when qemu exits (at least on sparc-softmmu):
> > > Remote communication error. Target disconnected.: Connection reset by
> > > peer.
> > > Quitting: putpkt: write failed: Broken pipe.
> > >
> > > So send a packet to kill GDB before we exit QEMU:
> > > [Inferior 1 (Thread 0) exited normally]
> > >
> > > Signed-off-by: KONRAD Frederic <address@hidden>
> > > ---
> > > gdbstub.c | 7 +++++++
> > > include/exec/gdbstub.h | 2 ++
> > > vl.c | 2 ++
> > > 3 files changed, 11 insertions(+)
> >
> > We didn't send an exiting packet before commit 4486e89c219c0,
> > so do you know why this worked before then? (Telling gdb we're
> > exiting seems like the right thing, though.)
> >
>
> Hmmm good question, I didn't had time to investigate in detail
>
> Before 4486e89c219c0:
>
> (gdb) tar rem :1234
> Remote debugging using :1234
> 0x40000000 in trap_table ()
> (gdb) c
> Continuing.
> Remote connection closed
>
> After 4486e89c219c0:
>
> (gdb) tar rem :1234
> Remote debugging using :1234
> 0x40000000 in trap_table ()
> (gdb) c
> Continuing.
> putpkt: write failed: Connection reset by peer.
>
> With the patch:
>
> (gdb) tar rem :1234
> Remote debugging using :1234
> 0x40000000 in trap_table ()
> (gdb) c
> Continuing.
> [Inferior 1 (Thread 0) exited normally]
>
> We use to have this patch in our repository to avoid the remote
> connection closed above.
Previously pause_vcpus() didn't invoke the vm change state handler.
Therefore the gdbstub didn't tell GDB that the vcpu was being stopped
from gdb_vm_state_change().
Now vm_shutdown() invokes vm change state handlers so the gdbstub tells
GDB that the vcpu is stopping. As a result GDB sends a packet to query
the state of the vcpu - but QEMU terminates and closes the connection
partway through.
Here is the strace:
31365 poll([{fd=3, events=POLLIN}, {fd=7, events=POLLIN}, {fd=11,
events=POLLIN}, {fd=13, events=POLLIN}], 4, -1) = 1 ([{fd=13, revents=POLLIN}])
31365 recvfrom(13, "$T03thread:01;#05", 8192, 0, NULL, NULL) = 17
31365 poll([{fd=13, events=POLLIN}], 1, 0) = 1 ([{fd=13, revents=POLLIN}])
31365 sendto(13, "+", 1, 0, NULL, 0) = 1
31365 sendto(13, "$g#67", 5, 0, NULL, 0) = -1 EPIPE (Broken pipe)
31365 --- SIGPIPE {si_signo=SIGPIPE, si_code=SI_USER, si_pid=31365,
si_uid=1000} ---
The ugly error message is because QEMU doesn't respond to GDB's "$g#67"
message.
Your patch is making GDB exit gracefully.
Reviewed-by: Stefan Hajnoczi <address@hidden>
signature.asc
Description: PGP signature