gdbstub: reset supported features on Supported request
PATCH 1/1 gdbstub: reset supported features on Supported request
From: Justin Sapp <[email protected]>
https://sourceware.org/gdb/current/onlinedocs/gdb.html/General-Query-Packets.html#qSupported
``` Whenever the stub receives a ‘qSupported’ request, the supplied set of GDB features should override any previous request. This allows GDB to put the stub in a known state, even if the stub had previously been communicating with a different version of GDB. ```
We exposed this by connecting to gdbstub using a gdb client first, and then WinDbg (EXDI) for windows kernel debugging. Since they both differ in their multiprocess support, this was confusing EXDI.
While we are here, fix the same for fork_events in user mode.
--- gdbstub/gdbstub.c | 6 ++++++ gdbstub/user.c | 1 + 2 files changed, 7 insertions(+)
gdbstub/gdbstub.c +6 -0
@@ -1679,6 +1679,12 @@ void gdb_extend_qsupported_features(char *qflags)static void handle_query_supported (GArray *params,void *user_ctx) { +/* +* Reset multiprocess support as a new gdb client may have different support +* than a previous one. +*/ + gdbserver_state.multiprocess = false; +g_string_printf (gdbserver_state.str_buf,"PacketSize=%x" ,MAX_PACKET_LENGTH );if (gdb_get_core_xml_file (first_cpu)) {g_string_append (gdbserver_state.str_buf,";qXfer:features:read+" );
gdbstub/user.c +1 -0
@@ -701,6 +701,7 @@ fail:void gdb_handle_query_supported_user (const char *gdb_supported) { + gdbserver_user_state.fork_events = false;if (strstr (gdb_supported,"fork-events+" )) { gdbserver_user_state.fork_events = true; }
Signature · 1 line
2.47.3
Quoted 44 lines · Pierrick Bouvier
From: Justin Sapp <[email protected]>
https://sourceware.org/gdb/current/onlinedocs/gdb.html/General-Query-Packets.html#qSupported
``` Whenever the stub receives a ‘qSupported’ request, the supplied set of GDB features should override any previous request. This allows GDB to put the stub in a known state, even if the stub had previously been communicating with a different version of GDB. ```We exposed this by connecting to gdbstub using a gdb client first, and then WinDbg (EXDI) for windows kernel debugging. Since they both differ in their multiprocess support, this was confusing EXDI.
While we are here, fix the same for
fork_eventsin user mode.Signed-off-by Pierrick Bouvier <[email protected]>--- gdbstub/gdbstub.c | 6 ++++++ gdbstub/user.c | 1 + 2 files changed, 7 insertions(+)gdbstub/gdbstub.c +6
-0@@ -1679,6 +1679,12 @@ void gdb_extend_qsupported_features(char *qflags)static void handle_query_supported (GArray *params,void *user_ctx) { +/* +* Reset multiprocess support as a new gdb client may have different support +* than a previous one. +*/ + gdbserver_state.multiprocess = false; +g_string_printf (gdbserver_state.str_buf,"PacketSize=%x" ,MAX_PACKET_LENGTH );if (gdb_get_core_xml_file (first_cpu)) {g_string_append (gdbserver_state.str_buf,";qXfer:features:read+" );gdbstub/user.c +0
-0
gdbstub/user.c fail: · line 707
Quoted 7 lines
gdbstub/user.c +1
-0@@ -701,6 +701,7 @@ fail:void gdb_handle_query_supported_user (const char *gdb_supported) { + gdbserver_user_state.fork_events = false;if (strstr (gdb_supported,"fork-events+" )) { gdbserver_user_state.fork_events = true; }
Ping on this patch.
@Alex: I noticed you have an 11.2 series going on, this could be nice if we had a chance to add this patch there also.
Regards,
Pierrick
Quoted 27 lines · Pierrick Bouvier
From: Justin Sapp <[email protected]>
https://sourceware.org/gdb/current/onlinedocs/gdb.html/General-Query-Packets.html#qSupported
``` Whenever the stub receives a ‘qSupported’ request, the supplied set of GDB features should override any previous request. This allows GDB to put the stub in a known state, even if the stub had previously been communicating with a different version of GDB. ```We exposed this by connecting to gdbstub using a gdb client first, and then WinDbg (EXDI) for windows kernel debugging. Since they both differ in their multiprocess support, this was confusing EXDI.
While we are here, fix the same for
fork_eventsin user mode.Signed-off-by Pierrick Bouvier <[email protected]>--- gdbstub/gdbstub.c | 6 ++++++ gdbstub/user.c | 1 + 2 files changed, 7 insertions(+)gdbstub/gdbstub.c +0
-0
gdbstub/gdbstub.c void gdb_extend_qsupported_features(char *qflags) · line 1687
Quoted 9 lines
gdbstub/gdbstub.c +6
-0@@ -1679,6 +1679,12 @@ void gdb_extend_qsupported_features(char *qflags)static void handle_query_supported (GArray *params,void *user_ctx) { +/* +* Reset multiprocess support as a new gdb client may have different support +* than a previous one. +*/ + gdbserver_state.multiprocess = false; +
This looks fine to me based on the commit write-up. Although it does highlight that struct GDBState is due a clean-up to separate what is negotiated features, temporary workspace and accelerator supported features. Currently its just a random collection of stuff.
Quoted 15 lines
gdbstub/gdbstub.c +0
-0g_string_printf (gdbserver_state.str_buf,"PacketSize=%x" ,MAX_PACKET_LENGTH );if (gdb_get_core_xml_file (first_cpu)) {g_string_append (gdbserver_state.str_buf,";qXfer:features:read+" );gdbstub/user.c +1
-0@@ -701,6 +701,7 @@ fail:void gdb_handle_query_supported_user (const char *gdb_supported) { + gdbserver_user_state.fork_events = false;if (strstr (gdb_supported,"fork-events+" )) { gdbserver_user_state.fork_events = true; }
Signature · 2 lines
Alex Bennée Virtualisation Tech Lead @ Linaro
Quoted 15 lines · Pierrick Bouvier
From: Justin Sapp <[email protected]>
https://sourceware.org/gdb/current/onlinedocs/gdb.html/General-Query-Packets.html#qSupported
``` Whenever the stub receives a ‘qSupported’ request, the supplied set of GDB features should override any previous request. This allows GDB to put the stub in a known state, even if the stub had previously been communicating with a different version of GDB. ```We exposed this by connecting to gdbstub using a gdb client first, and then WinDbg (EXDI) for windows kernel debugging. Since they both differ in their multiprocess support, this was confusing EXDI.
Quoted 8 lines
While we are here, fix the same for
fork_eventsin user mode.Signed-off-by Pierrick Bouvier <[email protected]>--- gdbstub/gdbstub.c | 6 ++++++ gdbstub/user.c | 1 + 2 files changed, 7 insertions(+)
IIUC, in user mode a bare qSupported doesn't clear fork_events, so a previous client's fork-events+ stays active for the next client.
E.g. GDB connects with fork-events+ and disconnects, then a client sends a bare qSupported. On fork() the stub stops the parent and reports the fork to the client, but it should not report it and the parent should keep running.
Quoted 26 lines · Marco Liebel
Quoted 15 lines · Pierrick Bouvier
From: Justin Sapp <[email protected]>
https://sourceware.org/gdb/current/onlinedocs/gdb.html/General-Query-Packets.html#qSupported
``` Whenever the stub receives a ‘qSupported’ request, the supplied set of GDB features should override any previous request. This allows GDB to put the stub in a known state, even if the stub had previously been communicating with a different version of GDB. ```We exposed this by connecting to gdbstub using a gdb client first, and then WinDbg (EXDI) for windows kernel debugging. Since they both differ in their multiprocess support, this was confusing EXDI.
Quoted 8 lines
While we are here, fix the same for
fork_eventsin user mode.Signed-off-by Pierrick Bouvier <[email protected]>--- gdbstub/gdbstub.c | 6 ++++++ gdbstub/user.c | 1 + 2 files changed, 7 insertions(+)
Quoted 7 lines
IIUC, in user mode a bare qSupported doesn't clear
fork_events, so a previous client's fork-events+ stays active for the next client.E.g. GDB connects with fork-events+ and disconnects, then a client sends a bare qSupported. On
fork()the stub stops the parent and reports the fork to the client, but it should not report it and the parent should keep running.
Thanks, that's a good catch Marco. I'll move the fork-events reset at beginning of handle_query_supported instead.
Regards,
Pierrick
Quoted 14 lines · Pierrick Bouvier
From: Justin Sapp <[email protected]>
https://sourceware.org/gdb/current/onlinedocs/gdb.html/General-Query-Packets.html#qSupported
``` Whenever the stub receives a ‘qSupported’ request, the supplied set of GDB features should override any previous request. This allows GDB to put the stub in a known state, even if the stub had previously been communicating with a different version of GDB. ```We exposed this by connecting to gdbstub using a gdb client first, and then WinDbg (EXDI) for windows kernel debugging. Since they both differ in their multiprocess support, this was confusing EXDI.
Quoted 8 lines
While we are here, fix the same for
fork_eventsin user mode.Signed-off-by Pierrick Bouvier <[email protected]>--- gdbstub/gdbstub.c | 6 ++++++ gdbstub/user.c | 1 + 2 files changed, 7 insertions(+)
Sent v2, fixing the rest of fork_events, and simplifying control flow. @Alex, I didn't apply your R-b, so I would appreciate if you could take a new look at it.
https://lore.kernel.org/qemu-devel/[email protected]/T/#u
Thanks,
Pierrick