From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 5Kt1EmzoVGoSNgYAWB0awg (envelope-from ) for ; Mon, 13 Jul 2026 09:30:20 -0400 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=n0IqMU+L; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=fQJeEuKA; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=jdwHv2n+; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=Qlr4MGqH; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 3BCA51E033; Mon, 13 Jul 2026 09:30:20 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-5.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED 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 8113E1E033 for ; Mon, 13 Jul 2026 09:30:19 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A24B34BA2E19 for ; Mon, 13 Jul 2026 13:30:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A24B34BA2E19 Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=n0IqMU+L; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=fQJeEuKA; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=jdwHv2n+; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=Qlr4MGqH Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2a07:de40:b251:101:10:150:64:1]) by sourceware.org (Postfix) with ESMTPS id 25B474BA5435 for ; Mon, 13 Jul 2026 13:29:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 25B474BA5435 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 25B474BA5435 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=2a07:de40:b251:101:10:150:64:1 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1783949392; cv=none; b=jXrbTa2AfiaOFWGs6th71cFOb53RxXGMxvLb1wtoPozmQ//HhAbsRDqRvf+nIlEGSo+SMOLwTVGW1Cosoy4xVR9rpf8T1mx/qiii4NnwIxXs9cMJXyuUSPFa9CeBaZm4o5vkC2Zmvm/RFUgg7vRXiYi2byczmXdPBg6JhPrXNuc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1783949392; c=relaxed/simple; bh=1xfiUE/sxpk/ump3JmrIMijwfdUGtYqtJ3YnlIZIjMY=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature: Message-ID:Date:MIME-Version:Subject:From:To; b=dd0YXw65/BgJ3QXWyW8+yOyEbhgE4AWc6YNqHZS/3s3uTaKx28cLpnw2rQLEcUzm5wmJbDMvMBw+Q7/ATHkGC/tky/5t8X6PB4fot+ahGaL1XA2KYD8AMWPSoD+UO1V8kHcTS6IWz/M/+jV575sQ8sjT6EpNGDV6MrK7kuOJB/s= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=n0IqMU+L; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=fQJeEuKA; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=jdwHv2n+; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=Qlr4MGqH DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 25B474BA5435 Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 0AAAD778D4 for ; Mon, 13 Jul 2026 13:29:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1783949390; h=from:from:reply-to: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=sYzs3236hrcnSoHshZnnNOlID1vj+rFp/H3z8ivQ6+I=; b=n0IqMU+L6BJ8x6ZVjWXxoSjKiapgMd8woUTzmL5tBiw2bercvz9vXrwsR/1PYbWOrmsrEt 2ReYkrQPnXZoL/A+MRzH2gjBVoOThc4GzRJSg7eC1Ac2QTeK1sIriw2Vml/mwmtt50WkfO PWBw5bqOaVbZ6jku0SdyED8VRboNA70= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1783949390; h=from:from:reply-to: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=sYzs3236hrcnSoHshZnnNOlID1vj+rFp/H3z8ivQ6+I=; b=fQJeEuKA2f+EOP6cJkPy6usKa2AtlJGa+SFodUHGKiXfzpY5Gkawp+sJt3jZ+sj7YocAzF Y8YjRgnEeWY81VCQ== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1783949389; h=from:from:reply-to: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=sYzs3236hrcnSoHshZnnNOlID1vj+rFp/H3z8ivQ6+I=; b=jdwHv2n+R5E66msSAp0ue6pwLbOIu4wuAXR621Tgrha/k7tsxNowtbx8HZ6qKBsNh1qRnj /tR4z7waVgBpiSRcqAeHMPHlUomuCTWX/JdOg4758SRaln6M4JDB24/T7of6CbkMfyw7KG sMSO1FwFbgjzIJLIAxKX0u/hOMqrtwI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1783949389; h=from:from:reply-to: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=sYzs3236hrcnSoHshZnnNOlID1vj+rFp/H3z8ivQ6+I=; b=Qlr4MGqHVZCo3e/NFALaCpThrCOv12sxIxcEN9erDNDEXGs2Zenei6+2sVJqabY6dvHuw0 qeZuQBUq3f4R3bDg== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id ED362779AE for ; Mon, 13 Jul 2026 13:29:48 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id qc+POEzoVGqIbwAAD6G6ig (envelope-from ) for ; Mon, 13 Jul 2026 13:29:48 +0000 Message-ID: Date: Mon, 13 Jul 2026 15:29:48 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] [gdb/testsuite] Fix FAIL in gdb.threads/sw-watchpoint-step-over-bp-with-threads.exp From: Tom de Vries To: gdb-patches@sourceware.org References: <20260614120932.3545377-1-tdevries@suse.de> Content-Language: en-US In-Reply-To: <20260614120932.3545377-1-tdevries@suse.de> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spamd-Result: default: False [-4.30 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; FUZZY_RATELIMITED(0.00)[rspamd.com]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; MID_RHS_MATCH_FROM(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_ALL(0.00)[]; PREVIOUSLY_DELIVERED(0.00)[gdb-patches@sourceware.org]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; TO_DN_NONE(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[sourceware.org:url, suse.de:mid, imap1.dmz-prg2.suse.org:helo] 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 6/14/26 2:09 PM, Tom de Vries wrote: > On x86_64-linux, I ran into the following FAIL: > ... > (gdb) cont > Continuing. > [Switching to Thread 0x7ffff7cbe6c0 (LWP 3534988)] > > Thread 2 "sw-watchpoint-s" hit Watchpoint 3: watched_global > > Old value = 0 > New value = 1 > 0x00007ffff7d514bf in futex_wait () at ../sysdeps/nptl/futex-internal.h:146 > 146 int err = lll_futex_timed_wait (futex_word, expected, NULL, private); > (gdb) PASS: $exp: target-non-stop=auto: displaced-stepping=auto: \ > continue to watchpoint > break 64 > No compiled code for line 64 in the current file. > Make breakpoint pending on future shared library load? (y or [n]) n > (gdb) FAIL: $exp: target-non-stop=auto: displaced-stepping=auto: \ > gdb_breakpoint: set breakpoint at 64 > ... > > [ The FAIL initially reproduced only under heavy system load (simulated using > stress -c $(grep -c ^processor: /proc/cpuinfo)), but then I found that > changing the delay in $srcfile from 1 second to 1 millisecond also reproduced > it fairly reliably. Using this approach, I managed to reproduce both on > x86_64-linux and aarch64-linux. ] > > The test-case tries to set a breakpoint at $srcfile:64, using just "64", but > that doesn't work because the inferior is not stopped in $srcfile. > > This can be trivially fixed by using $srcfile:64 instead, and indeed, this is > what this patch does. > > However, that fix is only correct if gdb is indeed allowed to report a stop in > thread 2. > > This is a question I found difficult to answer. > > I found some text in the docs [1] that seems related to the test-case > scenario: > ... > Warning: In multi-threaded programs, software watchpoints have only limited > usefulness. If GDB creates a software watchpoint, it can only watch the value > of an expression in a single thread. If you are confident that the expression > can only change due to the current thread’s activity (and if you are also > confident that no other thread can become current), then you can use software > watchpoints as usual. However, GDB may not notice when a non-current thread’s > activity changes the expression. (Hardware watchpoints, in contrast, watch an > expression in all threads.) > ... > > After reading this text, my impression was that gdb shouldn't report a stop in > thread 2, because: > - GDB "can only watch the value of an expression in a single thread", > - the expression can only change due the current thread's activity (thread 1), > and > - thread 2 cannot become current, it just spins and there's no breakpoint set > in the range where it spins. > > However, in the test-case I came across the following text: > ... > # The final continue, with the software watchpoint set, so that > # GDB single-steps all threads (if the target is non-stop). > ... > > Indeed, the test-case iterates over some dimensions: > ... > foreach_with_prefix target-non-stop {auto on off} { > foreach_with_prefix displaced-stepping {auto on off} { > test ${target-non-stop} ${displaced-stepping} > } > } > ... > and disregarding the auto, the FAIL reproduces with both displaced-stepping on > and off, but only with target-non-stop on. > > So we have the default non-stop off, and target-non-stop on. > > The documentation says about this [2]: > ... > set non-stop off, target operating in non-stop mode > > When a thread hits a breakpoint, finishes a step, etc., the target does not > immediately stop all other threads. If, while processing the event, infrun > decides the stop should be reported to the user, it then explicitly stops all > threads, just before presenting the stop to the user; otherwise, infrun > re-resumes the stopped thread. This scenario is also called “all-stop on top > of non-stop”. > ... > > I was not able to deduce why in this situation and in presence of a software > watchpoint all threads should be single stepping, so I asked Claude Code. > > It gave the following background information: > - in the pure all-stop case (set non-stop off, target operating in all-stop > mode), in presence of a software watchpoint: > - the current thread single-steps > - the other threads stay stopped > - consequently, only modifications by the current thread are detected, > - in the all-stop on non-stop case (set non-stop off, target operating in > non-stop mode), in presence of a software watchpoint: > - all threads single-step > - consequently, modifications by any thread are detected, but it's not > possible to attribute the modification to any specific thread, so gdb > attributes it to the thread whose stop happens to be processed. > > This adequately explains the behavior in the test-case. > > I suspect that the warning text in the documentation needs updating, because > AFAICT it doesn't cover the "set non-stop off, target operating in non-stop > mode" behavior described above. > I've pushed this. Thanks, - Tom > Tested on x86_64-linux. > > Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=34280 > > [1] https://sourceware.org/gdb/current/onlinedocs/gdb.html/Set-Watchpoints.html > [2] https://sourceware.org/gdb/current/onlinedocs/gdb.html/Maintenance-Commands.html#index-maint-set-target_002dnon_002dstop-mode-_005bon_007coff_007cauto_005d > --- > .../gdb.threads/sw-watchpoint-step-over-bp-with-threads.exp | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/gdb/testsuite/gdb.threads/sw-watchpoint-step-over-bp-with-threads.exp b/gdb/testsuite/gdb.threads/sw-watchpoint-step-over-bp-with-threads.exp > index 3dac2b85987..bd520cd62dd 100644 > --- a/gdb/testsuite/gdb.threads/sw-watchpoint-step-over-bp-with-threads.exp > +++ b/gdb/testsuite/gdb.threads/sw-watchpoint-step-over-bp-with-threads.exp > @@ -80,7 +80,7 @@ proc test {target-non-stop displaced-stepping} { > # fail an assertion that checks that we never ask the target to > # hardware single-step a thread when we have a software > # single-step breakpoint set for that thread. > - gdb_breakpoint [gdb_get_line_number "break here end"] > + gdb_breakpoint $::srcfile:[gdb_get_line_number "break here end"] > gdb_continue_to_breakpoint "end" > } > > > base-commit: 95451ea43a7e2e4aa806ee7405e9167b2ee653c1