| Message ID | 20261105075346.52926-1-pierrick.bouvier@oss.qualcomm.com |
|---|---|
| State | New |
| Headers | show |
| Series | [v2] gdbstub: reset supported features on Supported request | expand |
On 11/4/2026 11:53 PM, Pierrick Bouvier wrote: > From: Justin Sapp <jsapp@qti.qualcomm.com> > > 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. > Simplify control flow to always call gdb_handle_query_supported_user. > > Signed-off-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com> > --- > gdbstub/gdbstub.c | 15 +++++++-------- > gdbstub/user.c | 4 +--- > 2 files changed, 8 insertions(+), 11 deletions(-) > v2 -- - fix fork_events reset - (slightly) simplify control flow Regards, Pierrick
On Thu, Nov 5, 2026 at 1:54 AM Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com> wrote: > > From: Justin Sapp <jsapp@qti.qualcomm.com> > > 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. > Simplify control flow to always call gdb_handle_query_supported_user. > > Signed-off-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com> > --- > gdbstub/gdbstub.c | 15 +++++++-------- > gdbstub/user.c | 4 +--- > 2 files changed, 8 insertions(+), 11 deletions(-) > Reviewed-by: Marco Liebel <marco.liebel@oss.qualcomm.com>
diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c index 0a328b0dd48..38fe56a5d36 100644 --- a/gdbstub/gdbstub.c +++ b/gdbstub/gdbstub.c @@ -1679,6 +1679,11 @@ void gdb_extend_qsupported_features(char *qflags) static void handle_query_supported(GArray *params, void *user_ctx) { + const char *gdb_supported = ""; + if (params->len) { + gdb_supported = gdb_get_cmd_param(params, 0)->data; + } + 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+"); @@ -1701,16 +1706,10 @@ static void handle_query_supported(GArray *params, void *user_ctx) g_string_append(gdbserver_state.str_buf, ";qXfer:exec-file:read+"); #endif - if (params->len) { - const char *gdb_supported = gdb_get_cmd_param(params, 0)->data; - - if (strstr(gdb_supported, "multiprocess+")) { - gdbserver_state.multiprocess = true; - } + gdbserver_state.multiprocess = strstr(gdb_supported, "multiprocess+"); #if defined(CONFIG_USER_ONLY) - gdb_handle_query_supported_user(gdb_supported); + gdb_handle_query_supported_user(gdb_supported); #endif - } g_string_append(gdbserver_state.str_buf, ";vContSupported+;multiprocess+"); diff --git a/gdbstub/user.c b/gdbstub/user.c index d810f0f38c3..6526200a360 100644 --- a/gdbstub/user.c +++ b/gdbstub/user.c @@ -701,9 +701,7 @@ fail: void gdb_handle_query_supported_user(const char *gdb_supported) { - if (strstr(gdb_supported, "fork-events+")) { - gdbserver_user_state.fork_events = true; - } + gdbserver_user_state.fork_events = strstr(gdb_supported, "fork-events+"); g_string_append(gdbserver_state.str_buf, ";fork-events+"); }