From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 2JKrCB6aLmqqRwYAWB0awg (envelope-from ) for ; Sun, 14 Jun 2026 08:10:06 -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=DfNzKfl7; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=WgO3bOAB; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=DfNzKfl7; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=WgO3bOAB; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 0FBDC1E024; Sun, 14 Jun 2026 08:10:06 -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 7D7641E024 for ; Sun, 14 Jun 2026 08:10:04 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 95A574B920C4 for ; Sun, 14 Jun 2026 12:10:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 95A574B920C4 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=DfNzKfl7; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=WgO3bOAB; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=DfNzKfl7; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=WgO3bOAB Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) by sourceware.org (Postfix) with ESMTPS id F37444B9DB7B for ; Sun, 14 Jun 2026 12:09:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org F37444B9DB7B 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 F37444B9DB7B Authentication-Results: sourceware.org; arc=none smtp.remote-ip=195.135.223.131 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1781438974; cv=none; b=AUqirG6XFC3yZ3eNg1I63G384/Y7Z5JMw/2XFStIKBYE2q+ysroNEWxN6cG9RCMIQpyleik2dasw52Yai0ub8uXCPKS8gTNaLlTC354qKRTFgJyVBYOM8+6e+iFxZaXrprNe00HjeSsfdIJR9v8OL/dYMCPYon636IsrAUcD/G8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1781438974; c=relaxed/simple; bh=GrHDqyVh11qXCVVuP5269nyT66zXTWPsP0iTNat5UZY=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature:From: To:Subject:Date:Message-ID:MIME-Version; b=wSu4c6C2zoQoC6EkUX7+s/SmZHrLQyrUc2bheS6PRB1oI8kyWsfnKibTvlfsnkGsuXMx5V/B5UDYRFv0M5HaxyxpEE6R469N7kNgkdi8mLhCGXIdUMC7gmsGQC38d8I1fkbe16FKw1jtOwYy54DpyVmYBduzzteUtcudRA8QMbo= 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=DfNzKfl7; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=WgO3bOAB; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=DfNzKfl7; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=WgO3bOAB DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org F37444B9DB7B Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104: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-out2.suse.de (Postfix) with ESMTPS id 8C78968063 for ; Sun, 14 Jun 2026 12:09:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1781438972; 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; bh=QTVM+mS3mpC3udV685lGeWnpvewTFMHHYo2VUuhhVYU=; b=DfNzKfl7sHrHHII00E+Mu1bgALSkUhx6JZVgq6Bg+4unKp2AcsbNafheYeXCDkyMmuORqi KYAJ5TbvZAYr0EBl3HUmt4Y5EAwaXiuzTrijozHoSkZUVUbtiMhTzn+SpyJIsl+EAKGkDE SZoChQXHrIo4NVTkd7hIZqI6zmPXKLw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1781438972; 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; bh=QTVM+mS3mpC3udV685lGeWnpvewTFMHHYo2VUuhhVYU=; b=WgO3bOABE2/V5wfGIJuYYUxLwo+8GNM/uYzR7Q6eidRGiorihP6DMVn5zuqrWH7WfiYvuZ R9PTpwBjju/Qh9AA== Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=DfNzKfl7; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=WgO3bOAB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1781438972; 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; bh=QTVM+mS3mpC3udV685lGeWnpvewTFMHHYo2VUuhhVYU=; b=DfNzKfl7sHrHHII00E+Mu1bgALSkUhx6JZVgq6Bg+4unKp2AcsbNafheYeXCDkyMmuORqi KYAJ5TbvZAYr0EBl3HUmt4Y5EAwaXiuzTrijozHoSkZUVUbtiMhTzn+SpyJIsl+EAKGkDE SZoChQXHrIo4NVTkd7hIZqI6zmPXKLw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1781438972; 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; bh=QTVM+mS3mpC3udV685lGeWnpvewTFMHHYo2VUuhhVYU=; b=WgO3bOABE2/V5wfGIJuYYUxLwo+8GNM/uYzR7Q6eidRGiorihP6DMVn5zuqrWH7WfiYvuZ R9PTpwBjju/Qh9AA== 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 777C8779A7 for ; Sun, 14 Jun 2026 12:09:32 +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 hCDkG/yZLmorFAAAD6G6ig (envelope-from ) for ; Sun, 14 Jun 2026 12:09:32 +0000 From: Tom de Vries To: gdb-patches@sourceware.org Subject: [PATCH] [gdb/testsuite] Fix FAIL in gdb.threads/sw-watchpoint-step-over-bp-with-threads.exp Date: Sun, 14 Jun 2026 14:09:32 +0200 Message-ID: <20260614120932.3545377-1-tdevries@suse.de> X-Mailer: git-send-email 2.51.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Action: no action X-Rspamd-Queue-Id: 8C78968063 X-Spamd-Result: default: False [-3.51 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; FUZZY_RATELIMITED(0.00)[rspamd.com]; ARC_NA(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; RCVD_VIA_SMTP_AUTH(0.00)[]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:rdns,imap1.dmz-prg2.suse.org:helo,suse.de:mid,suse.de:dkim]; DNSWL_BLOCKED(0.00)[2a07:de40:b281:104:10:150:64:97:from,2a07:de40:b281:106:10:150:64:167:received]; RCVD_COUNT_TWO(0.00)[2]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; TO_DN_NONE(0.00)[]; PREVIOUSLY_DELIVERED(0.00)[gdb-patches@sourceware.org]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; DKIM_TRACE(0.00)[suse.de:+] X-Rspamd-Server: rspamd1.dmz-prg2.suse.org 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 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. 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 -- 2.51.0