* [PATCH v2] gdb: Remove redundant clear_proceed_status() call
@ 2026-06-17 12:44 Claudiu Zissulescu
2026-06-17 13:52 ` Lancelot SIX
0 siblings, 1 reply; 2+ messages in thread
From: Claudiu Zissulescu @ 2026-06-17 12:44 UTC (permalink / raw)
To: gdb-patches; +Cc: pedro, lancesix, Claudiu Zissulescu
This patch fixes a Windows issue with "-target-attach <pid>", where
"running" is emitted instead of "done". The "done" message should be
synchronous for "-target-attach", but "mi_proceeded" variable is
incorrectly set to "1" when clear_proceed_status(0, true) is
called. As a result, "mi_interp::on_about_to_proceed" sets mi_proceed
to 1, and later "mi_interp::on_resume" emits "running" instead of
"done".
Remove redundant clear_proceed_status(0) call (the notify argument is
set to true by default). The init_wait_for_inferior(), which runs on
the very next line, already calls clear_proceed_status (0, false). A
new test is added too.
What is new:
- Improved commit message
- Added a mi test for showing the issue in Windows hosts.
Signed-off-by: Claudiu Zissulescu <claudiu.zissulescu-ianculescu@amd.com>
---
gdb/testsuite/gdb.mi/mi-attach.c | 19 ++++++++++++++++++
gdb/testsuite/gdb.mi/mi-attach.exp | 32 ++++++++++++++++++++++++++++++
gdb/windows-nat.c | 1 -
3 files changed, 51 insertions(+), 1 deletion(-)
create mode 100644 gdb/testsuite/gdb.mi/mi-attach.c
create mode 100644 gdb/testsuite/gdb.mi/mi-attach.exp
diff --git a/gdb/testsuite/gdb.mi/mi-attach.c b/gdb/testsuite/gdb.mi/mi-attach.c
new file mode 100644
index 00000000000..6fd195320a9
--- /dev/null
+++ b/gdb/testsuite/gdb.mi/mi-attach.c
@@ -0,0 +1,19 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+#ifdef _WIN32
+#include <windows.h>
+#else
+#include <unistd.h>
+#endif
+
+int main (void)
+{
+ /* Sleep long enough (5 min) to be attached to. */
+#ifdef _WIN32
+ Sleep (300000);
+#else
+ sleep (300);
+#endif
+ return 0;
+}
diff --git a/gdb/testsuite/gdb.mi/mi-attach.exp b/gdb/testsuite/gdb.mi/mi-attach.exp
new file mode 100644
index 00000000000..d0bb7e778cb
--- /dev/null
+++ b/gdb/testsuite/gdb.mi/mi-attach.exp
@@ -0,0 +1,32 @@
+# Copyright 2026 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+load_lib mi-support.exp
+set MIFLAGS "-i=mi"
+
+require can_spawn_for_attach
+
+standard_testfile
+
+if {[build_executable "failed to prepare" $testfile $srcfile {debug}]} {
+ return
+}
+
+set spawn_id [spawn_wait_for_attach $::binfile]
+set prog_pid [spawn_id_get_pid $spawn_id]
+
+mi_clean_restart
+
+mi_gdb_test "-target-attach $prog_pid" ".*\\^done.*" "attach \$PROG_PID"
diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c
index d9e924f16c6..f1660a02175 100644
--- a/gdb/windows-nat.c
+++ b/gdb/windows-nat.c
@@ -1944,7 +1944,6 @@ windows_nat_target::do_initial_windows_stuff (DWORD pid, bool attaching)
if (!inf->target_is_pushed (this))
inf->push_target (this);
windows_clear_solib ();
- clear_proceed_status (0);
init_wait_for_inferior ();
inferior_appeared (inf, pid);
--
2.54.0
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH v2] gdb: Remove redundant clear_proceed_status() call
2026-06-17 12:44 [PATCH v2] gdb: Remove redundant clear_proceed_status() call Claudiu Zissulescu
@ 2026-06-17 13:52 ` Lancelot SIX
0 siblings, 0 replies; 2+ messages in thread
From: Lancelot SIX @ 2026-06-17 13:52 UTC (permalink / raw)
To: Claudiu Zissulescu, gdb-patches; +Cc: pedro, lancesix
Hi Claudiu,
On 17/06/2026 13:44, Claudiu Zissulescu wrote:
> This patch fixes a Windows issue with "-target-attach <pid>", where
> "running" is emitted instead of "done". The "done" message should be
> synchronous for "-target-attach", but "mi_proceeded" variable is
> incorrectly set to "1" when clear_proceed_status(0, true) is
> called. As a result, "mi_interp::on_about_to_proceed" sets mi_proceed
> to 1, and later "mi_interp::on_resume" emits "running" instead of
> "done".
>
> Remove redundant clear_proceed_status(0) call (the notify argument is
> set to true by default). The init_wait_for_inferior(), which runs on
> the very next line, already calls clear_proceed_status (0, false). A
> new test is added too.
>
> What is new:
> - Improved commit message
> - Added a mi test for showing the issue in Windows hosts.
>
>
> Signed-off-by: Claudiu Zissulescu <claudiu.zissulescu-ianculescu@amd.com>
> ---
> gdb/testsuite/gdb.mi/mi-attach.c | 19 ++++++++++++++++++
> gdb/testsuite/gdb.mi/mi-attach.exp | 32 ++++++++++++++++++++++++++++++
> gdb/windows-nat.c | 1 -
> 3 files changed, 51 insertions(+), 1 deletion(-)
> create mode 100644 gdb/testsuite/gdb.mi/mi-attach.c
> create mode 100644 gdb/testsuite/gdb.mi/mi-attach.exp
>
> diff --git a/gdb/testsuite/gdb.mi/mi-attach.c b/gdb/testsuite/gdb.mi/mi-attach.c
> new file mode 100644
> index 00000000000..6fd195320a9
> --- /dev/null
> +++ b/gdb/testsuite/gdb.mi/mi-attach.c
It seems this file is missing the usual copyright header.
Best,
Lancelot.
> @@ -0,0 +1,19 @@
> +#include <stdio.h>
> +#include <stdlib.h>
> +
> +#ifdef _WIN32
> +#include <windows.h>
> +#else
> +#include <unistd.h>
> +#endif
> +
> +int main (void)
Code style: missing a line break before the function name:
int
main (void)
Best,
Lancelot.
> +{
> + /* Sleep long enough (5 min) to be attached to. */
> +#ifdef _WIN32
> + Sleep (300000);
> +#else
> + sleep (300);
> +#endif
> + return 0;
> +}
> diff --git a/gdb/testsuite/gdb.mi/mi-attach.exp b/gdb/testsuite/gdb.mi/mi-attach.exp
> new file mode 100644
> index 00000000000..d0bb7e778cb
> --- /dev/null
> +++ b/gdb/testsuite/gdb.mi/mi-attach.exp
> @@ -0,0 +1,32 @@
> +# Copyright 2026 Free Software Foundation, Inc.
> +
> +# This program is free software; you can redistribute it and/or modify
> +# it under the terms of the GNU General Public License as published by
> +# the Free Software Foundation; either version 3 of the License, or
> +# (at your option) any later version.
> +#
> +# This program is distributed in the hope that it will be useful,
> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> +# GNU General Public License for more details.
> +#
> +# You should have received a copy of the GNU General Public License
> +# along with this program. If not, see <http://www.gnu.org/licenses/>.
> +
> +load_lib mi-support.exp
> +set MIFLAGS "-i=mi"
> +
> +require can_spawn_for_attach
> +
> +standard_testfile
> +
> +if {[build_executable "failed to prepare" $testfile $srcfile {debug}]} {
> + return
> +}
> +
> +set spawn_id [spawn_wait_for_attach $::binfile]
> +set prog_pid [spawn_id_get_pid $spawn_id]
> +
> +mi_clean_restart
> +
> +mi_gdb_test "-target-attach $prog_pid" ".*\\^done.*" "attach \$PROG_PID"
> diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c
> index d9e924f16c6..f1660a02175 100644
> --- a/gdb/windows-nat.c
> +++ b/gdb/windows-nat.c
> @@ -1944,7 +1944,6 @@ windows_nat_target::do_initial_windows_stuff (DWORD pid, bool attaching)
> if (!inf->target_is_pushed (this))
> inf->push_target (this);
> windows_clear_solib ();
> - clear_proceed_status (0);
> init_wait_for_inferior ();
>
> inferior_appeared (inf, pid);
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-06-17 13:53 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-06-17 12:44 [PATCH v2] gdb: Remove redundant clear_proceed_status() call Claudiu Zissulescu
2026-06-17 13:52 ` Lancelot SIX
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox