Re: [PATCH v2] gdb/infrun: do not restart a stepped thread if not running (was: gdb/infrun: reset thread control's step info in end_stepping_range)

Kevin Buettner
2026-02-21T20:48:33Z

Hi Baris,

I've taken a look at your patch and have found a few nits that'll
merit a v3, though some, I think, are due to changes made to the
testing framework since you originally posted your patch.

The C code looks okay to me, but posting a v3 with the testsuite nits
fixed might get a few more pairs of eyes on it before it goes in.

On Tue, 20 Jun 2023 17:24:55 +0200
Tankut Baris Aktemur via Gdb-patches <gdb-patches@sourceware.org> wrote:

[...]
> diff --git a/gdb/testsuite/gdb.multi/detach-stepi.exp
> b/gdb/testsuite/gdb.multi/detach-stepi.exp new file mode 100644
> index 00000000000..28ef8c4f9f7
> --- /dev/null
> +++ b/gdb/testsuite/gdb.multi/detach-stepi.exp
> @@ -0,0 +1,66 @@
> +# This testcase is part of GDB, the GNU debugger.
> +
> +# Copyright 2022 Free Software Foundation, Inc.

I think that the copyright year should be updated.

[...]
> +standard_testfile
> +
> +if {[use_gdb_stub]} {
> + untested "using gdb stub"
> + return 0
> +}

The above should be replaced with:

require !use_gdb_stub

Other tests in gdb.multi also use:

require allow_multi_inferior_tests

...so I recommend adding this too.

> +
> +if {[prepare_for_testing "failed to prepare" $testfile $srcfile]} {
> + return -1
> +}
> +
> +if {![runto_main]} {
> + return -1
> +}
> +
> +delete_breakpoints
> +
> +# Setup inferior 2.
> +gdb_test "add-inferior" "Added inferior .*" \
> + "add empty inferior"
> +gdb_test "inferior 2" "Switching to inferior .*" \
> + "switch to inferior"
> +
> +gdb_load $binfile
> +runto "a_function"
> +gdb_test "info inferiors"

Is there something that you want to look for with "info inferiors"?
Or is it for debugging purposes?

> +
> +# The bug for which this regression test is written appears in
> +# schedule-multi mode.
> +gdb_test_no_output "set schedule-multiple on"
> +
> +# Single-step the thread in Inferior 2, then detach Inferior 1.
> +gdb_test "info threads" ".*" "threads before stepi"
> +gdb_test "stepi"

Is there some pattern which might be usefully matched for the stepi?

> +gdb_test "info threads" ".*" "threads after stepi"
> +
> +gdb_test "set debug infrun on"

Use gdb_test_no_output for the above command.

> +gdb_test_multiple "detach inferior 1" "" {
> + -re "resuming previously stepped thread.*$gdb_prompt" {
> + fail $gdb_test_name
> + }
> + -re "$gdb_prompt $" {
> + pass $gdb_test_name
> + }
> +}