From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id dm4KMjGkM2r3CQ0AWB0awg (envelope-from ) for ; Thu, 18 Jun 2026 03:54:25 -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=ofeL/560; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=Y37wH4Hh; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=MnbP2CLy; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=vGlavI6L; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id AA1691E024; Thu, 18 Jun 2026 03:54:25 -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 [IPv6:2620:52:6:3111::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 EE63A1E024 for ; Thu, 18 Jun 2026 03:54:23 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id CFFBE4BA2E1A for ; Thu, 18 Jun 2026 07:54:21 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CFFBE4BA2E1A 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=ofeL/560; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=Y37wH4Hh; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=MnbP2CLy; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=vGlavI6L 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 29B664BA2E13 for ; Thu, 18 Jun 2026 07:53:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 29B664BA2E13 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 29B664BA2E13 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=1781769233; cv=none; b=jW5IIX98VtTfVy9OqqNm7ddQ8T5UVJCUTpdHbVQQ7q7KjqofNSre+PfVT6NDlW5e2QasXTrqq6v5B4yaS84XUiJ645e8yFDizA0y0zWiqlTEVo0TsuyRutkeKKYYpETAPiH2W+g04ctMHsjaoOiSnqfB6hJ+frfKXuVpjf0VJzU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1781769233; c=relaxed/simple; bh=/BHirflRGyS3+KFDfNrgh4y66h/KUyk3duxoJfrIY/c=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature: Message-ID:Date:MIME-Version:Subject:From:To; b=pV6Nhwd0y3h7BcM2jAt04fOoGEHvv5Jo1ivJI+SK+N96uO3uwpXTtUHl3DarIRkwOfEn3eVyD4i68FpRchcMs+1YNEW/5vVKxi3vW+L30IP/PeJcEhsnYYqTFiv8Ueax5uIRAduKNViPLxXrU58X0vtO0itv7Mv3EyRzmIb0Am0= 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=ofeL/560; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=Y37wH4Hh; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=MnbP2CLy; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=vGlavI6L DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 29B664BA2E13 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-out1.suse.de (Postfix) with ESMTPS id CD29A6D192 for ; Thu, 18 Jun 2026 07:53:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1781769232; 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=Om2/Bj0onY0r+fAQS3toTWJFXM9BWAt11T9phQcmqyo=; b=ofeL/560JWNFz4sUrHPbtyqFOUNjs1k4UT1PjFuS+bhYcsqU/3LU+gqwp3GL+fPi+BZr5N Bu72tUurPsK+xDHhZqqjgJeTi5LbKVWANq10C/CoeNHms/57eWjGY1+X9dPU72gTpMlghq IogUeR3FxZn/aT3HS13OzTTWMvi5sFA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1781769232; 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=Om2/Bj0onY0r+fAQS3toTWJFXM9BWAt11T9phQcmqyo=; b=Y37wH4Hh2pynWN1V49pRxrUfmu/RQDtKhdsCUCb6uroky66hlWIRNMNh5EiG0yKiUGGn8u akBoUmrhYF1K6aDA== Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=MnbP2CLy; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=vGlavI6L DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1781769231; 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=Om2/Bj0onY0r+fAQS3toTWJFXM9BWAt11T9phQcmqyo=; b=MnbP2CLyY20/3PENvPNduNwK8ZsDY/9R8xHsfEeHev74ewiOvqM6+BdBRkUv5IiPmW1yZq m+5XIMoJZ7lK87bWwZwyl/VaWghjaP5K5MS8wWlGThHmmzMV9neyABe4PRWctIA44SngDh dAlznDsAFAgC+n3ZtVZDwAcWVq/y+gY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1781769231; 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=Om2/Bj0onY0r+fAQS3toTWJFXM9BWAt11T9phQcmqyo=; b=vGlavI6LWP2ME+P2SMQL/MPBHszQwSBUSYakklQeNXy4sR15DshSyljuJ7jGIyQ3hkG/jH Zsv54OBHdKjrhFDA== 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 BBCA7779A8 for ; Thu, 18 Jun 2026 07:53:51 +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 hnaDLA+kM2ptDgAAD6G6ig (envelope-from ) for ; Thu, 18 Jun 2026 07:53:51 +0000 Message-ID: <6e2bce3d-96f2-4957-bf5a-bf66219bd7dd@suse.de> Date: Thu, 18 Jun 2026 09:53:51 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PING][PATCH] [gdb/exp] Limit workaround in using_direct::valid_line to broken GCC versions From: Tom de Vries To: gdb-patches@sourceware.org References: <20260604162135.2846175-1-tdevries@suse.de> Content-Language: en-US In-Reply-To: <20260604162135.2846175-1-tdevries@suse.de> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Rspamd-Action: no action X-Rspamd-Queue-Id: CD29A6D192 X-Spamd-Result: default: False [-4.51 / 50.00]; BAYES_HAM(-3.00)[100.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]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; MIME_TRACE(0.00)[0:+]; RCPT_COUNT_ONE(0.00)[1]; DBL_BLOCKED_OPENRESOLVER(0.00)[gnu.org:url,sourceware.org:url,suse.de:mid,suse.de:dkim,imap1.dmz-prg2.suse.org:rdns,imap1.dmz-prg2.suse.org:helo]; RCVD_TLS_ALL(0.00)[]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; RCVD_COUNT_TWO(0.00)[2]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; MID_RHS_MATCH_FROM(0.00)[]; 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 6/4/26 6:21 PM, Tom de Vries wrote: > Consider test.c: > ... > 1 namespace mod_a { > 2 int xxx = 10; > 3 } > 4 > 5 static void > 6 foo () > 7 { > 8 } > 9 > 10 int > 11 main () > 12 { > 13 { > 14 foo (); > 15 using namespace mod_a; > 16 } > 17 > 18 return mod_a::xxx; > 19 } > ... > compiled with "g++ test.c -g". > > Attempting to print xxx at line 14 shouldn't find anything (because it's > before the "using namespace mod_a"), but it does: > ... > $ gdb -q -batch a.out -ex start -ex "p xxx" > ... > Temporary breakpoint 1, main () at test.c:14 > 14 foo (); > $1 = 10 > ... > > This happens because using_direct::valid_line returns true here: > ... > return (decl_line <= curr_sal.line) > || (decl_line >= boundary); > ... > > Since we have decl_line == 15 and curr_sal.line == 14, > "(decl_line <= curr_sal.line)" evaluates to false. > > But boundary == 14, so "(decl_line >= boundary)" evaluates to true. > > The "(decl_line >= boundary)" bit was added as a workaround for > GCC PR debug/108716. > > Since I'm using GCC 15, the workaround is not needed. > > Fix this by limiting the workaround to broken GCC versions. > Ping. Thanks, - Tom > Tested on x86_64-linux, using GCC 15.2, and 7.5. > > Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=34203 > --- > gdb/cp-namespace.c | 26 +++++++++++--- > gdb/namespace.c | 9 +++-- > gdb/testsuite/gdb.cp/ns-before-using.c | 37 ++++++++++++++++++++ > gdb/testsuite/gdb.cp/ns-before-using.exp | 44 ++++++++++++++++++++++++ > 4 files changed, 110 insertions(+), 6 deletions(-) > create mode 100644 gdb/testsuite/gdb.cp/ns-before-using.c > create mode 100644 gdb/testsuite/gdb.cp/ns-before-using.exp > > diff --git a/gdb/cp-namespace.c b/gdb/cp-namespace.c > index c8cd5c245aa..16fd4e2ded8 100644 > --- a/gdb/cp-namespace.c > +++ b/gdb/cp-namespace.c > @@ -33,6 +33,7 @@ > #include "namespace.h" > #include "inferior.h" > #include "gdbsupport/unordered_map.h" > +#include "producer.h" > #include > #include > > @@ -410,9 +411,26 @@ cp_lookup_symbol_via_imports (const char *scope, > found_symbols[sym.symbol->m_name] = sym; > } > > - /* Due to a GCC bug, we need to know the boundaries of the current block > - to know if a certain using directive is valid. */ > - symtab_and_line boundary_sal = find_sal_for_pc (block->end () - 1, 0); > + unsigned boundary_line = 0; > + { > + struct symbol *fn = block->containing_function (); > + int major, minor; > + if (fn != nullptr > + && producer_is_gcc (fn->symtab ()->compunit ()->producer (), > + &major, &minor) > + && (major <= 9 > + || (major == 10 && minor < 5) > + || (major == 11 && minor < 4) > + || (major == 12 && minor < 3) > + || (major == 13 && minor < 1))) > + { > + /* Due to a GCC bug (PR debug/108716, fixed in 10.5, 11.4, 12.3, 13.1), > + we need to know the boundaries of the current block to know if a > + certain using directive is valid. */ > + symtab_and_line boundary_sal = find_sal_for_pc (block->end () - 1, 0); > + boundary_line = boundary_sal.line; > + } > + } > > /* Go through the using directives. If any of them add new names to > the namespace we're searching in, see if we can find a match by > @@ -423,7 +441,7 @@ cp_lookup_symbol_via_imports (const char *scope, > > /* If the using directive was below the place we are stopped at, > do not use this directive. */ > - if (!current->valid_line (boundary_sal.line)) > + if (!current->valid_line (boundary_line)) > continue; > len = strlen (current->import_dest); > directive_match = (search_parents > diff --git a/gdb/namespace.c b/gdb/namespace.c > index 5b5749369ee..d81365a284a 100644 > --- a/gdb/namespace.c > +++ b/gdb/namespace.c > @@ -113,8 +113,13 @@ using_direct::valid_line (unsigned int boundary) const > { > CORE_ADDR curr_pc = get_frame_pc (get_selected_frame (nullptr)); > symtab_and_line curr_sal = find_sal_for_pc (curr_pc, 0); > - return (decl_line <= curr_sal.line) > - || (decl_line >= boundary); > + > + /* Apply GCC PR debug/108716 workaround. */ > + if (boundary != 0 > + && decl_line >= boundary) > + return true; > + > + return decl_line <= curr_sal.line; > } > catch (const gdb_exception &ex) > { > diff --git a/gdb/testsuite/gdb.cp/ns-before-using.c b/gdb/testsuite/gdb.cp/ns-before-using.c > new file mode 100644 > index 00000000000..f74c35b0d3f > --- /dev/null > +++ b/gdb/testsuite/gdb.cp/ns-before-using.c > @@ -0,0 +1,37 @@ > +/* 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 . */ > + > +namespace mod_a > +{ > + int xxx = 10; > +} > + > +static void > +foo () > +{ > +} > + > +int > +main () > +{ > + { > + foo (); > + using namespace mod_a; > + } > + > + return mod_a::xxx; > +} > diff --git a/gdb/testsuite/gdb.cp/ns-before-using.exp b/gdb/testsuite/gdb.cp/ns-before-using.exp > new file mode 100644 > index 00000000000..f891cf56c49 > --- /dev/null > +++ b/gdb/testsuite/gdb.cp/ns-before-using.exp > @@ -0,0 +1,44 @@ > +# 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 . > + > +standard_testfile .c > + > +if {[prepare_for_testing "failed to prepare" $testfile $srcfile \ > + {debug c++}]} { > + return > +} > + > +if {![runto_main]} { > + continue > +} > + > +# Xfail for incorrect decl_line on DW_TAG_imported_module, > +# GCC PR debug/108716. > +set have_gcc108716_xfail \ > + [expr {[test_compiler_info gcc-*] && [gcc_major_version] < 13}] > + > +# Regression test for PR exp/34203. > +set re_pass [string_to_regexp {No symbol "xxx" in current context.}] > +gdb_test_multiple "print xxx" "" { > + -re -wrap $re_pass { > + pass $gdb_test_name > + } > + -re -wrap "$valnum_re = 10" { > + if {$have_gcc108716_xfail} { > + setup_xfail *-*-* gcc/108716 > + } > + fail $gdb_test_name > + } > +} > > base-commit: bd64797371d27c766d551d0bf115d9090f1d0594