[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: |
Philippe Mathieu-Daudé |
Subject: |
Re: [Qemu-devel] [PATCH] gdbstub: send a terminaison packet instead of crashing gdb |
Date: |
Mon, 19 Mar 2018 00:30:21 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 |
On 03/16/2018 05:23 PM, KONRAD Frederic 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>
Reviewed-by: Philippe Mathieu-Daudé <address@hidden>
> ---
> gdbstub.c | 7 +++++++
> include/exec/gdbstub.h | 2 ++
> vl.c | 2 ++
> 3 files changed, 11 insertions(+)
>
> diff --git a/gdbstub.c b/gdbstub.c
> index f1d5148..a76b2fa 100644
> --- a/gdbstub.c
> +++ b/gdbstub.c
> @@ -2052,6 +2052,13 @@ int gdbserver_start(const char *device)
> return 0;
> }
>
> +void gdbserver_cleanup(void)
> +{
> + if (gdbserver_state) {
> + put_packet(gdbserver_state, "W00");
> + }
> +}
> +
> static void register_types(void)
> {
> type_register_static(&char_gdb_type_info);
> diff --git a/include/exec/gdbstub.h b/include/exec/gdbstub.h
> index 9aa7756..2e8a4b8 100644
> --- a/include/exec/gdbstub.h
> +++ b/include/exec/gdbstub.h
> @@ -103,6 +103,8 @@ int gdbserver_start(int);
> int gdbserver_start(const char *port);
> #endif
>
> +void gdbserver_cleanup(void);
> +
> /**
> * gdb_has_xml:
> * This is an ugly hack to cope with both new and old gdb.
> diff --git a/vl.c b/vl.c
> index 3ef04ce..0427b15 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -4723,6 +4723,8 @@ int main(int argc, char **argv, char **envp)
>
> main_loop();
>
> + gdbserver_cleanup();
> +
> /* No more vcpu or device emulation activity beyond this point */
> vm_shutdown();
>
>