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)

Aktemur, Tankut Baris
2026-02-23T10:34:52Z

Hi Kevin,

On Saturday, February 21, 2026 9:45 PM, Kevin Buettner wrote:
> 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.

Thank you.

> 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.

I removed use_gdb_stub and added `require allow_multi_inferior_tests` only
because it checks for use_gdb_stub, 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?

It was only for logging purposes. I changed it to

gdb_test "info inferiors" ".*" "info inferiors for logging"

> > +
> > +# 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?

Nothing interesting, really. I added ".*" to make this clear.

> > +gdb_test "info threads" ".*" "threads after stepi"
> > +
> > +gdb_test "set debug infrun on"
>
> Use gdb_test_no_output for the above command.

I removed the command completely.

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

I'll send v3 soon. Thanks for the review!

-Baris

Intel Deutschland GmbH
Registered Address: Dornacher Straße 1, 85622 Feldkirchen, Germany
Tel: +49 89 991 430, www.intel.de
Managing Directors: Harry Demas, Jeffrey Schneiderman, Yin Chong Sorrell
Chairperson of the Supervisory Board: Nicole Lau
Registered Seat: Munich
Commercial Register: Amtsgericht München HRB 186928