From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id DDq3JP0xrWq3ahsAWB0awg (envelope-from ) for ; Fri, 18 Sep 2026 08:43:41 -0400 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Z7qYqLKI; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 7EF2A1E01F; Fri, 18 Sep 2026 08:43:41 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_VALIDITY_CERTIFIED_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [38.145.34.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 71EA81E01F for ; Fri, 18 Sep 2026 08:43:40 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 08FA94BA7983 for ; Fri, 18 Sep 2026 12:43:40 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 08FA94BA7983 Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Z7qYqLKI Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTP id C03334BB24D5 for ; Fri, 18 Sep 2026 12:42:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C03334BB24D5 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org C03334BB24D5 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1789735336; cv=none; b=iWY/YlEpvPVfF1EuqzYunN8tQOlgZevxOMFdQT1zEW4Z1BNTJESVi76YeRNIawRgy5JmfwFV2wAWgnd/DqJE1A2qZ3KyUWBr7N+u2oLKfI1kvVyMeetW+Ofhi/KZhGOgZLH3drTSrR668XXaq1e8ZQhlbngALUsvL64LFUZBP/w= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1789735336; c=relaxed/simple; bh=A6uIxjH+BpaA4teZrusATjzt/SwlaC1fifX/EbHqJI4=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=rUdcVV7yCh6lION2dfd3vjhDvfQnB6v1z/TrCcS9HBmlf7wSYDhKap1zVaJAIvKDDiJdb+Vt8Sap94LX5G6gfimcT2323UNSNzEfauvRCHcNcvprDPKsvxsDmbxXpvyQWaT1zdi5USyuD5/b2bYvysiNPM8LVRjc09OQwxmbxQ4= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Z7qYqLKI DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C03334BB24D5 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789735336; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=e8/60ZDOLyJMjmytE1/zD1S5CDn77/rRGj7VLz+sL4k=; b=Z7qYqLKIXCl4MKXYbJPMD6edIcC8Za31Dub5fMWEQB9Dw6v0Dc108v59SFmSsKFUxF4zTv itsLs5tswPlfNvnS3b6I+zbto8GHZY+VmodMm2oO6NSDubx+2fIvuyRukt0/3hYQtAwviw QDSxoDKq/BAp3S5fPSAj+qTF4zfh4dU= Received: from mail-vs1-f70.google.com (mail-vs1-f70.google.com [209.85.217.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-363-_EOs8BYYOtG3Cic-l7KW5Q-1; Fri, 18 Sep 2026 08:42:14 -0400 X-MC-Unique: _EOs8BYYOtG3Cic-l7KW5Q-1 X-Mimecast-MFC-AGG-ID: _EOs8BYYOtG3Cic-l7KW5Q_1789735334 Received: by mail-vs1-f70.google.com with SMTP id ada2fe7eead31-79f1b2e25edso148747137.3 for ; Fri, 18 Sep 2026 05:42:14 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1789735334; x=1790340134; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:to:subject:user-agent:mime-version:date :message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=e8/60ZDOLyJMjmytE1/zD1S5CDn77/rRGj7VLz+sL4k=; b=Vezzsvltq9CcVjyySuhDlz1gNWPYHP8YCUPBog7JgBgOM88fm/JAYYWY9xS5+gOHcn 2xcpCQ1MSg+vL+JeAMBWXtJhVoWTFp5HbzbPSIrm6aaPFIQcKkhReGIftI44VKDdGc1k hE50TQPRF7TINsAvgVjkSdfWhu8gIPY/XsGGZ+V7H2B+ATP8BKM6V4DUYAdupaTHc02E x5BKWx15flhPPoNekFQp+sEsFL/DTiZS7Xu9sa1ptzknZbg0eTnUfYzS3JeppQC+3gLj lzMzYdgi6HW0LvLYIfZdlHDd+p3uaMjdRzYsRUDRY2IuSgUsBgnRbDuzXPSDcc1Eczbt LssA== X-Forwarded-Encrypted: i=1; AKwUvBytS7TQ9vWjoboRYk6DrDSBCyTVawYOqIk+4pei4NARScYz9LKUkruyHqD23BsdM+V7Xo/5v0aBbMCpow==@sourceware.org X-Gm-Message-State: AFuF++k3kUqG7QiUdQiy1gcwh7x+rF+S5w9ENksYuFuN2QmEA/8ppQa9 tyAKIlDvv5hPAhevmKIzOMGdZ729g7AgkLN+EGO4WTG0/kkGdoues0o5OuXeXeOmizLulrcPWg+ qEP2oM20nxG1KAWFoSmneUT5zajr5PoTGbTma3C8C+krDFMCjDQKDgvaDinIxslEhnLafua8= X-Gm-Gg: AYBFou1bWUlPWLv5sgVRpnqe304ijtrlQW25/qb66xLVcFgU6S3qO41a9GIwdEy1xeW 3Kx9GZc+d1UV352f0AbhnY/sIVY7xpSiHg0yecNqSrVaTVwxMcJo2Pr4IaluZOZTgPEXM6QsJOT l6FxL4iw2QkrqDRB9XFADeJYR7WAH93E8VLN51+SABcQwH8s/gzA7lXNrwT9t1I6e5gk346UpZN xJiGta2gUVRGPxixdTfPTNmEya2M7Patr45+SwXx68Ymjjmv6lWzpbFT25S2RYkgVWdEYSHLQVg 2rC055hm0KXXbGFhCmahfFvR79DAUtQp4sQfbD9FPT5oAtPhyoiiJmY0ZjhBnZnJUhPYAQDBRSu 667H4h2pqhW/JuDkBSaSacAvNuoPvC7vdvpibeD/DKNFAVOK9 X-Received: by 2002:a05:6102:4412:b0:7a1:f7d2:e84b with SMTP id ada2fe7eead31-7a55e3b8192mr764507137.27.1789735334159; Fri, 18 Sep 2026 05:42:14 -0700 (PDT) X-Received: by 2002:a05:6102:4412:b0:7a1:f7d2:e84b with SMTP id ada2fe7eead31-7a55e3b8192mr764498137.27.1789735333634; Fri, 18 Sep 2026 05:42:13 -0700 (PDT) Received: from ?IPV6:2804:14d:8084:993e:22e8:4ed1:527a:55c0? ([2804:14d:8084:993e:22e8:4ed1:527a:55c0]) by smtp.gmail.com with ESMTPSA id a1e0cc1a2514c-9833c674d74sm712022241.5.2026.09.18.05.42.11 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 18 Sep 2026 05:42:13 -0700 (PDT) Message-ID: Date: Fri, 18 Sep 2026 09:42:09 -0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] gdb, infrun: do not discard a step-completed pending waitstatus To: Markus Metzger , gdb-patches@sourceware.org References: <20260915141441.2274270-1-markus.t.metzger@intel.com> From: Guinevere Larsen In-Reply-To: <20260915141441.2274270-1-markus.t.metzger@intel.com> X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: SytozsJXQZdj7ICSHslOu5qor5S67Ht3CBetkUP79KI_1789735334 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org On 9/15/26 11:14 AM, Markus Metzger wrote: > Consider a scenario with two breakpoints on adjacent instructions: > > bp1 at 0xf00 > bp2 at 0xf01 > > as well as two threads in all-stop-on-top-of-non-stop mode. > > Assume that threads A hits bp1 and we report the breakpoint hit to the > user. When the user continues, we start a step-over for thread A at 0xf00. > > Assume that thread B now hits bp1 and we report the breakpoint hit to the > user. We stop all threads to report the event. Meanwhile, the step-over > of thread A completes, so we save the pending waitstatus (stop_pc=0xf01, > currently_stepping=1) of thread A. > > When the user continues, clear_proceed_status_thread() discards the > pending step completed waitstatus of thread A, and proceed() starts > another step-over for thread A at 0xf01. > > We skip bp2 for thread A. > > Remove the code in clear_proceed_status_thread() that discards a step > completed waitstatus and let it get handled normally. Hi! Thanks for working on this. I have a question about the situation in general. From what I understand, the original intent of the code is that, if a user has asked for a step, but we hit something more important (like watchpoint or breakpoint), then we shouldn't mention the step. With this change, a user will now see the step once they resume from the breakpoint, if I understand the code correctly. Should we restrict this change to only announcing breakpoints, or is this behavior change for stepping ok? I don't have an opinion on what is better, but I think if we think that the new behavior is better, it should be called out in the commit message. -- Cheers, Guinevere Larsen it/its she/her (deprecated) > --- > gdb/infrun.c | 25 ++----- > gdb/testsuite/gdb.threads/adjacent-bp.c | 48 +++++++++++++ > gdb/testsuite/gdb.threads/adjacent-bp.exp | 86 +++++++++++++++++++++++ > 3 files changed, 139 insertions(+), 20 deletions(-) > create mode 100644 gdb/testsuite/gdb.threads/adjacent-bp.c > create mode 100644 gdb/testsuite/gdb.threads/adjacent-bp.exp > > diff --git a/gdb/infrun.c b/gdb/infrun.c > index b9618fb6422..4ab9f4aaf64 100644 > --- a/gdb/infrun.c > +++ b/gdb/infrun.c > @@ -3100,28 +3100,13 @@ clear_proceed_status_thread (struct thread_info *tp) > infrun_debug_printf ("%s", tp->ptid.to_string ().c_str ()); > gdb_assert (tp->internal_state () != THREAD_INT_RUNNING); > > - /* If we're starting a new sequence, then the previous finished > - single-step is no longer relevant. */ > if (tp->has_pending_waitstatus ()) > { > - if (tp->stop_reason () == TARGET_STOPPED_BY_SINGLE_STEP) > - { > - infrun_debug_printf ("pending event of %s was a finished step. " > - "Discarding.", > - tp->ptid.to_string ().c_str ()); > - > - tp->set_internal_state (THREAD_INT_STOPPED); > - tp->clear_pending_waitstatus (); > - tp->set_stop_reason (TARGET_STOPPED_BY_NO_REASON); > - } > - else > - { > - infrun_debug_printf > - ("thread %s has pending wait status %s (currently_stepping=%d).", > - tp->ptid.to_string ().c_str (), > - tp->pending_waitstatus ().to_string ().c_str (), > - tp->control.currently_stepping); > - } > + infrun_debug_printf > + ("thread %s has pending wait status %s (currently_stepping=%d).", > + tp->ptid.to_string ().c_str (), > + tp->pending_waitstatus ().to_string ().c_str (), > + tp->control.currently_stepping); > } > > /* If this signal should not be seen by program, give it zero. > diff --git a/gdb/testsuite/gdb.threads/adjacent-bp.c b/gdb/testsuite/gdb.threads/adjacent-bp.c > new file mode 100644 > index 00000000000..e72e674f52a > --- /dev/null > +++ b/gdb/testsuite/gdb.threads/adjacent-bp.c > @@ -0,0 +1,48 @@ > +/* Copyright 2026 Free Software Foundation, Inc. > + > + This file is part of GDB. > + > + 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 . */ > + > +#include > +#include > + > +static pthread_barrier_t barrier; > + > +static void * > +test (void *arg) > +{ > + pthread_barrier_wait (&barrier); > + int a = 0; /* break here. */ > + int b = 0; > + int c = 0; > + return arg; > +} > + > +int > +main () > +{ > + pthread_t th; > + > + alarm (500); > + > + pthread_barrier_init (&barrier, NULL, 2); > + pthread_create (&th, NULL, test, NULL); > + test (NULL); > + > + pthread_join (th, NULL); > + pthread_barrier_destroy (&barrier); > + > + return 0; > +} > diff --git a/gdb/testsuite/gdb.threads/adjacent-bp.exp b/gdb/testsuite/gdb.threads/adjacent-bp.exp > new file mode 100644 > index 00000000000..9e7782c01c2 > --- /dev/null > +++ b/gdb/testsuite/gdb.threads/adjacent-bp.exp > @@ -0,0 +1,86 @@ > +# 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 . > + > +# Test that GDB does not skip a breakpoint when a step-over completes > +# while another event leads to a stop. > + > +standard_testfile > + > +if {[prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \ > + {debug pthreads}]} { > + return > +} > + > +if {![runto_main]} { > + return > +} > + > +# Find a sequence of adjacent instructions. > +set bp_line [gdb_get_line_number "break here"] > +set pcs {} > +gdb_test_multiple "info line $bp_line" "" { > + -re -wrap "starts at address ($hex).*" { > + pass $gdb_test_name > + > + set line "\\s+($hex) \[^\r\n\]+" > + gdb_test_multiple "x/3i $expect_out(1,string)" "disassemble" { > + -re -wrap "$line\r\n$line\r\n$line.*" { > + pass $gdb_test_name > + > + lappend pcs $expect_out(1,string) > + lappend pcs $expect_out(2,string) > + lappend pcs $expect_out(3,string) > + } > + -re -wrap "" { > + fail $gdb_test_name > + } > + } > + } > + -re -wrap "" { > + fail $gdb_test_name > + } > +} > + > +# Set breakpoints on adjacent instructions. > +foreach pc $pcs { > + gdb_breakpoint "\*$pc" > +} > + > +# Continue from breakpoint to breakpoint. > +set hits [dict create] > +set iter 0 > +gdb_test_multiple "continue" "" { > + -re -wrap "hit Breakpoint.*" { > + dict incr hits [get_hexadecimal_valueof "\$pc" invalid "stop $iter"] > + incr iter > + send_gdb "continue\n" > + exp_continue > + } > + -re -wrap "$inferior_exited_re normally.*" { > + pass "$gdb_test_name" > + } > +} > + > +# We expect all breakpoints to be hit by both threads. > +foreach pc $pcs { > + if {[dict exists $hits $pc]} { > + gdb_assert {[dict get $hits $pc] eq 2} "breakpoint at $pc" > + dict unset hits $pc > + } else { > + fail "breakpoint at $pc" > + } > +} > +# And no unrelated stops. > +gdb_assert {[dict size $hits] eq 0} "no extra stops"