gdbstub/gdbstub.c | 6 ++++++ gdbstub/user.c | 1 + 2 files changed, 7 insertions(+)
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.
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
---
gdbstub/gdbstub.c | 6 ++++++
gdbstub/user.c | 1 +
2 files changed, 7 insertions(+)
diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c
index 0a328b0dd48..dbb2000c817 100644
--- a/gdbstub/gdbstub.c
+++ b/gdbstub/gdbstub.c
@@ -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+");
diff --git a/gdbstub/user.c b/gdbstub/user.c
index d810f0f38c3..9b6d42d210a 100644
--- a/gdbstub/user.c
+++ b/gdbstub/user.c
@@ -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;
}
--
2.47.3
On 10/30/2026 2:21 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. > > Signed-off-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com> > --- > 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/20261105075346.52926-1-pierrick.bouvier@oss.qualcomm.com/T/#u Thanks, Pierrick
On Fri, Oct 30, 2026 at 5:21 PM 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. > > Signed-off-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com> > --- > 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.
On 11/4/2026 11:09 AM, Marco Liebel wrote: > On Fri, Oct 30, 2026 at 5:21 PM 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. >> >> Signed-off-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com> >> --- >> 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. Thanks, that's a good catch Marco. I'll move the fork-events reset at beginning of handle_query_supported instead. Regards, Pierrick
Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com> writes:
> 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.
>
> Signed-off-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
> ---
> gdbstub/gdbstub.c | 6 ++++++
> gdbstub/user.c | 1 +
> 2 files changed, 7 insertions(+)
>
> diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c
> index 0a328b0dd48..dbb2000c817 100644
> --- a/gdbstub/gdbstub.c
> +++ b/gdbstub/gdbstub.c
> @@ -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.
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
> 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+");
> diff --git a/gdbstub/user.c b/gdbstub/user.c
> index d810f0f38c3..9b6d42d210a 100644
> --- a/gdbstub/user.c
> +++ b/gdbstub/user.c
> @@ -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;
> }
--
Alex Bennée
Virtualisation Tech Lead @ Linaro
On 10/30/2026 3:21 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.
>
> Signed-off-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
> ---
> gdbstub/gdbstub.c | 6 ++++++
> gdbstub/user.c | 1 +
> 2 files changed, 7 insertions(+)
>
> diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c
> index 0a328b0dd48..dbb2000c817 100644
> --- a/gdbstub/gdbstub.c
> +++ b/gdbstub/gdbstub.c
> @@ -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+");
> diff --git a/gdbstub/user.c b/gdbstub/user.c
> index d810f0f38c3..9b6d42d210a 100644
> --- a/gdbstub/user.c
> +++ b/gdbstub/user.c
> @@ -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
© 2016 - 2026 Red Hat, Inc.