From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id ji5YJj+Q8Gk3pAAAWB0awg (envelope-from ) for ; Tue, 28 Apr 2026 06:47:27 -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=bVOEdTvv; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=prD7DgrG; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=bVOEdTvv; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=prD7DgrG; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 8D5911E067; Tue, 28 Apr 2026 06:47:27 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-2.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,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 26F9B1E067 for ; Tue, 28 Apr 2026 06:47:26 -0400 (EDT) Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id 4F0E94BB5933 for ; Tue, 28 Apr 2026 10:47:25 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4F0E94BB5933 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=bVOEdTvv; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=prD7DgrG; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=bVOEdTvv; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=prD7DgrG Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2a07:de40:b251:101:10:150:64:2]) by sourceware.org (Postfix) with ESMTPS id 3BB484BB3BFC for ; Tue, 28 Apr 2026 10:47:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3BB484BB3BFC 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 3BB484BB3BFC Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a07:de40:b251:101:10:150:64:2 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1777373220; cv=none; b=UiDyrvexXld7O0/9Ex6G/eK6K5OHJYl2HX8hgbyMxh1FCrUlFQqumFPLK78+onVimUMrAbeU0o6yWEqX3HMFVu7zSltmORDRcKqqfuHmr4r7ziKfSqgKOfE0ep0whtm3Iyyt40kJh/G2XQJq/BXH0ExYQPTSsTrOb1DCv1EJNcQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1777373220; c=relaxed/simple; bh=UPS+XGSv3Bk1z4N9SOGK9sw3n0ADt2WmeAwZ/n/OZyk=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature:From: To:Subject:Date:Message-ID:MIME-Version; b=Ft3e1BNVWDiYRoksCtQC53tF0lDYEoWwp+eYZlRE/4Ie6EYfwVF3hazDUS9nwydLZrYxkxGEdSfgF2tZQmGN/uM2GajAx3wp3Jp9JIYcYN+vBxOzk2cFYcTxciKzTOLt1V9gY+4CQ5GeoviCXna/yIfOXSuigKMv5/DAC3ItpGE= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3BB484BB3BFC 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-out2.suse.de (Postfix) with ESMTPS id 7676F5BCC9 for ; Tue, 28 Apr 2026 10:46:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1777373218; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=f0SolsPk3A7DQpD8vsrpDMtZsDH9nTYRXDSSRaLRVi4=; b=bVOEdTvvSiCeZ47rBD6p2Ux0giXa4qDapXB78yHEewxnoRP0YP19Ca0tyh0h2MOHy1DnSQ igK39ha2aI3mKZ8RHmu8a6jAzK2ppgw+eGye/2oKG2CXcHjtKnZPQlxlSEr0X1W9WmEbUk QGl4C/uAo200PJRI179/g0X1Rhrm0oU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1777373218; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=f0SolsPk3A7DQpD8vsrpDMtZsDH9nTYRXDSSRaLRVi4=; b=prD7DgrGvV8NToKfGtQoJkB7yuK1MbwTkLXn3njEvcyL7ixkU5cjoDosTj8tHtP5PLuEQr 1OVtb19eqKvJXhAA== Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1777373218; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=f0SolsPk3A7DQpD8vsrpDMtZsDH9nTYRXDSSRaLRVi4=; b=bVOEdTvvSiCeZ47rBD6p2Ux0giXa4qDapXB78yHEewxnoRP0YP19Ca0tyh0h2MOHy1DnSQ igK39ha2aI3mKZ8RHmu8a6jAzK2ppgw+eGye/2oKG2CXcHjtKnZPQlxlSEr0X1W9WmEbUk QGl4C/uAo200PJRI179/g0X1Rhrm0oU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1777373218; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=f0SolsPk3A7DQpD8vsrpDMtZsDH9nTYRXDSSRaLRVi4=; b=prD7DgrGvV8NToKfGtQoJkB7yuK1MbwTkLXn3njEvcyL7ixkU5cjoDosTj8tHtP5PLuEQr 1OVtb19eqKvJXhAA== 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 60C3D593B0 for ; Tue, 28 Apr 2026 10:46:58 +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 CQlsFiKQ8GnEQgAAD6G6ig (envelope-from ) for ; Tue, 28 Apr 2026 10:46:58 +0000 From: Tom de Vries To: gdb-patches@sourceware.org Subject: [PATCH] [gdb/breakpoints] Don't ignore in rbreak : Date: Tue, 28 Apr 2026 12:46:57 +0200 Message-ID: <20260428104657.1402486-1-tdevries@suse.de> X-Mailer: git-send-email 2.51.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spamd-Result: default: False [-2.80 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; 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)[]; RCPT_COUNT_ONE(0.00)[1]; ARC_NA(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,suse.de:mid]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; TO_DN_NONE(0.00)[]; PREVIOUSLY_DELIVERED(0.00)[gdb-patches@sourceware.org]; RCVD_TLS_ALL(0.00)[] 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 PR breakpoints/34112 reports that "rbreak :" sets breakpoints in files other than . This is a regression since commit c4c093a31f6 ("Make global_symbol_searcher::filenames private"), which did: ... if (file_name != nullptr) - spec.filenames.push_back (file_name); + spec.add_filename (std::move (file_name)); ... The std::move nullifies file_name, so a subsequent file_name check: ... if (file_name != nullptr) ... now always evaluates to false. Fix this by: - introducing a variable bool file_name_p, initialized before the std::move, and - using that instead. Tested on x86_64-linux. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=34112 --- gdb/symtab.c | 9 +++++++-- gdb/testsuite/gdb.base/rbreak-2.c | 28 ++++++++++++++++++++++++++ gdb/testsuite/gdb.base/rbreak.c | 30 ++++++++++++++++++++++++++++ gdb/testsuite/gdb.base/rbreak.exp | 33 +++++++++++++++++++++++++++++++ 4 files changed, 98 insertions(+), 2 deletions(-) create mode 100644 gdb/testsuite/gdb.base/rbreak-2.c create mode 100644 gdb/testsuite/gdb.base/rbreak.c create mode 100644 gdb/testsuite/gdb.base/rbreak.exp diff --git a/gdb/symtab.c b/gdb/symtab.c index 357b8e63b19..3c10e1fd750 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -5440,8 +5440,13 @@ rbreak_command (const char *regexp, int from_tty) } } + /* Compute this property now. We want to use the property after + std::move (file_name), but at that point we can no longer compute it + because the std::move nullifies file_name. */ + bool file_name_p = file_name != nullptr; + global_symbol_searcher spec (SEARCH_FUNCTION_DOMAIN, regexp); - if (file_name != nullptr) + if (file_name_p) spec.add_filename (std::move (file_name)); std::vector symbols = spec.search (); @@ -5454,7 +5459,7 @@ rbreak_command (const char *regexp, int from_tty) std::string name; if (p.msymbol.minsym == nullptr) { - if (file_name != nullptr) + if (file_name_p) { struct symtab *symtab = p.symbol->symtab (); const char *fullname = symtab_to_fullname (symtab); diff --git a/gdb/testsuite/gdb.base/rbreak-2.c b/gdb/testsuite/gdb.base/rbreak-2.c new file mode 100644 index 00000000000..f0d30df2f3c --- /dev/null +++ b/gdb/testsuite/gdb.base/rbreak-2.c @@ -0,0 +1,28 @@ +/* This testcase is part of GDB, the GNU debugger. + + 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 . */ + +static int +foo (void) +{ + return 0; +} + +int +bar (void) +{ + return foo (); +} diff --git a/gdb/testsuite/gdb.base/rbreak.c b/gdb/testsuite/gdb.base/rbreak.c new file mode 100644 index 00000000000..9df951f3397 --- /dev/null +++ b/gdb/testsuite/gdb.base/rbreak.c @@ -0,0 +1,30 @@ +/* This testcase is part of GDB, the GNU debugger. + + 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 . */ + +static int +foo (void) +{ + return 1; +} + +extern int bar (void); + +int +main (void) +{ + return foo () + bar (); +} diff --git a/gdb/testsuite/gdb.base/rbreak.exp b/gdb/testsuite/gdb.base/rbreak.exp new file mode 100644 index 00000000000..16c7e83cd49 --- /dev/null +++ b/gdb/testsuite/gdb.base/rbreak.exp @@ -0,0 +1,33 @@ +# 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 . + +# Check rbreak : command. + +standard_testfile .c -2.c + +if { [prepare_for_testing "failed to prepare" $testfile \ + [list $srcfile $srcfile2]] } { + return -1 +} + +# Regression test for PR34112. Check that "rbreak $srcfile:foo" doesn't set +# a breakpoint on $srcfile2:foo. +set re_line \ + [quotemeta \ + "Breakpoint @DECIMAL at @HEX: file @...$srcfile, line @DECIMAL."] +gdb_test "rbreak $srcfile:foo" \ + [multi_line \ + $re_line \ + ".*"] base-commit: 986e397e3a42f114c8dd81f544782f040210dac2 -- 2.51.0