From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id KWP1Lf1xIGqcpzIAWB0awg (envelope-from ) for ; Wed, 03 Jun 2026 14:27:09 -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=cdI6oIu9; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 972C31E0A6; Wed, 03 Jun 2026 14:27:09 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-6.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 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 9C0EC1E062 for ; Wed, 03 Jun 2026 14:27:08 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 0A71D4BA2E39 for ; Wed, 3 Jun 2026 18:27:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0A71D4BA2E39 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=cdI6oIu9 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 3EA764BA2E35 for ; Wed, 3 Jun 2026 18:26:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3EA764BA2E35 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 3EA764BA2E35 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=1780511191; cv=none; b=cejBGAUCQ2s3pqwG7CHzQNk1dawERkTXE2Wodznkw/dbL/hvc13pVBX4RQvZA2QjnZuMuDhE37v6EZuAVdq/1xfrc3MItRvLGPjc0JiKELAiHBVXVDbCZj56qYQKN2etPPk5DNL2yDmkxuCZduZkCZ4NG6EeQBu6jijjq7pDFmg= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1780511191; c=relaxed/simple; bh=d+f1rHr347e7aIIsrG6IeS8te+xSmooc5Bhd009c2mQ=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=xumqMjrBbWTvEVunON3+L63fX7qUGz0DsVn87LKdFsErKafGN8S/jz/tA+IJYS0Flbdr3o2COFh/AdekJk7B8CXmLZ3syPWslnEnaEbAX/vnHCTeD0U1mBS84s+pb5TR77Cak+m91e/nojDgHWYcnVoF1ZvBrIrMhSsEhbarvaw= 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=cdI6oIu9 DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3EA764BA2E35 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1780511190; 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=r4qFGWgz2OOaRk3BcXO6hy37b1jl+Tq+SY0UKzUMVeY=; b=cdI6oIu9AumhRNt/pSpLuJQZTXicoyZWiepweF2U+SudyIKDWcEcyF05KNiMiAQJ2jdLWl ih67Zw1tT3nrdeLhhp98vOdalveB8Ht62zYtdRv4YwGgdoAqNdDEwOBAQPaC1WuDsunpfI GL21Fbk/TSc5/81jjIh7WGAiA94N9CQ= Received: from mail-vk1-f200.google.com (mail-vk1-f200.google.com [209.85.221.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-317-U7YdTvSAOiydC0ZpF-qZNg-1; Wed, 03 Jun 2026 14:26:29 -0400 X-MC-Unique: U7YdTvSAOiydC0ZpF-qZNg-1 X-Mimecast-MFC-AGG-ID: U7YdTvSAOiydC0ZpF-qZNg_1780511189 Received: by mail-vk1-f200.google.com with SMTP id 71dfb90a1353d-5a10923f7d7so1484518e0c.0 for ; Wed, 03 Jun 2026 11:26:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780511189; x=1781115989; h=content-transfer-encoding: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; bh=r4qFGWgz2OOaRk3BcXO6hy37b1jl+Tq+SY0UKzUMVeY=; b=kL2/nZi08h7ZDycnaDlAO86a7WagdByucjag38f3f+jjPAWtsBTEFwjoXSV+hjKu+u koFAqqshQXYLYDh1MRB00+rtmsbWx05T00v1HXFij8yu2mAc0LtWBpU+xoryHUvjOkEr 1G4cd/EpIh5skikI/0h4YFqqeZy/lU2jql/42YW55HsRbqSDTPHug3YNPcDIGKPPjwyW b1BnmrUM53NZOaNoyrapStgJynE/7psGz8igpbdnOTv3gapLedosOEefZR0y3IJcYd71 h3Svq7GVkdrN6hXSHIieN15u6CrFpRVv+5IBYjAEpEX/s3zh4BCrGgnahnNQP1yu1JO2 rbow== X-Gm-Message-State: AOJu0Yyb7/LtXd/0tePjw4k68cdCRklFDoSV2AovE0TWXz7jsbKRC3+S zgQ+CAlkQ43wc5O6rKB/7am7LR57JFYs+70iDg5OvshxxXD67rHPmYMey7QR7ofCF4v1Nm/TGqP s4OPaWUJo6ABARZEBpZOrSpuqCzAp8Wov9QeQIoN2PjVJOtE9rlG2UF4SYiBnVxprhprR0CfjOx UA2C5FgJ4yXQ68eh9cPKoEMO7RZPx+05sHr5Rl8rZixGXVq81I X-Gm-Gg: Acq92OGIqviOFGYNpuTSj97ibwba0bkOdG+IaMQCWubQR5CedgE/GBHB7IX3o2Wyipq mIXMNvpdbSj8+MB5kTm4l9vKjXukOndFRLUoChT0lxiWl84wigAvgFiTp/Z+SbbWmv5x+RESvrl oZBfgf5qCd6ZCrvykq4/s1jGb+KhGjPGgC0nNdRHgACccgbJtdLOJn7u5m5No1kYJAlFKIyTAU5 ei1prGsxDfKxvUgpbg7KhVjVyWhmFDz2bEPTlMHyoX0oBq4qiFiwUOrLzvVZn7DwJzO17CH4XM9 uNwrfMQ416qqAly0zWwyymuTYt/y5p0OeIm2afMVYaXgnNlFkiAid1pX+8k/PPY03JBh442ybgf FdrKh9r+0UDyAHkllTdNvrkd3KwO8YPBxE3c5gRrfUCkbv/Al2M3F7egdnifk2EhiFYwvAt7GGc KJHzA= X-Received: by 2002:a05:6122:218c:b0:5a0:90e0:a4c5 with SMTP id 71dfb90a1353d-5a96eb21057mr335212e0c.8.1780511188946; Wed, 03 Jun 2026 11:26:28 -0700 (PDT) X-Received: by 2002:a05:6122:218c:b0:5a0:90e0:a4c5 with SMTP id 71dfb90a1353d-5a96eb21057mr335181e0c.8.1780511188340; Wed, 03 Jun 2026 11:26:28 -0700 (PDT) Received: from ?IPV6:2804:14d:8084:993e:2d5d:7adb:2b6:a50e? ([2804:14d:8084:993e:2d5d:7adb:2b6:a50e]) by smtp.gmail.com with ESMTPSA id 71dfb90a1353d-5a6dc44d226sm2974681e0c.11.2026.06.03.11.26.26 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 03 Jun 2026 11:26:27 -0700 (PDT) Message-ID: Date: Wed, 3 Jun 2026 15:26:24 -0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v7 5/5] gdb: prefer symtabs for the current linker namespace To: gdb-patches@sourceware.org References: <20260601192251.60958-1-guinevere@redhat.com> <20260601192251.60958-6-guinevere@redhat.com> From: Guinevere Larsen In-Reply-To: <20260601192251.60958-6-guinevere@redhat.com> X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: YskQVPdtoE7Dk0ziHAxqZMluG0cEMdHvkJipzIyPTJw_1780511189 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 6/1/26 4:22 PM, Guinevere Larsen wrote: > When a user uses the syntax 'filename'::expression, GDB will search > symtabs in the order they were loaded by the inferior. This can lead to > situations where the following happens: > > (gdb) p $_linker_namespace > $1 = 3 > (gdb) p [[1]]::gdb_dlmopen_glob = 1 > $2 = 1 > (gdb) p [[2]]::gdb_dlmopen_glob = 2 > $3 = 2 > (gdb) p [[3]]::gdb_dlmopen_glob = 3 > $4 = 3 > (gdb) p gdb_dlmopen_glob == 'dlmopen-ns-ids-lib.c'::gdb_dlmopen_glob > $5 = 0 > (gdb) p gdb_dlmopen_glob > $6 = 3 > (gdb) p 'dlmopen-ns-ids-lib.c'::gdb_dlmopen_glob > $7 = 1 > > As a user, I would expect the expressions with and without the filename > returned the exact same variable. As mentioned, because the library was > loaded on namespace 1 first, that symtab is loaded first. > > This commit solves that issue by placing a copy of all symtabs in the > current namespace first, and then adding all solibs. This can lead to a > performance loss if the user is in namespace N and the symtab they are > looking for is after all symtabs in namespace N, because all those > symtabs will be searched first. However, I believe this is not a big > concern, as I imagine most of the times that this syntax will be used, > the user will either search for a symtab in the current namespace or the > default one, meaning there is little chance that this will be very > noticeable. This could be avoided by creating a set of the symtabs on > the current namespace, and then when adding all symtabs, not re-adding > ones that were there already, but this seems like too much complexity > for an edge case. > --- Turns out I didn't test this patch thoroughly enough and Linaro CI pointed out that this causes several regressions. I'm trying to figure out how to fix it, but just as a heads up to anyone who might be looking at this, I am aware of the failures... > gdb/symtab.c | 4 ++++ > gdb/testsuite/gdb.base/dlmopen-ns-ids-main.c | 3 +++ > gdb/testsuite/gdb.base/dlmopen-ns-ids.exp | 9 +++++++++ > 3 files changed, 16 insertions(+) > > diff --git a/gdb/symtab.c b/gdb/symtab.c > index d7317a758b1..b5ef0ddc147 100644 > --- a/gdb/symtab.c > +++ b/gdb/symtab.c > @@ -655,6 +655,10 @@ find_symtab (program_space *pspace, const char *name, > } > else > { > + if (pspace->solib_ops ()->supports_namespaces ()) > + objfiles_to_search > + = get_objfiles_in_linker_namespace (get_current_linker_namespace (), > + pspace); > for (objfile &objf : pspace->objfiles ()) > objfiles_to_search.push_back (&objf); > } > diff --git a/gdb/testsuite/gdb.base/dlmopen-ns-ids-main.c b/gdb/testsuite/gdb.base/dlmopen-ns-ids-main.c > index 35c5124a65e..012decc25e5 100644 > --- a/gdb/testsuite/gdb.base/dlmopen-ns-ids-main.c > +++ b/gdb/testsuite/gdb.base/dlmopen-ns-ids-main.c > @@ -52,6 +52,9 @@ main (void) > fun = dlsym (handle[0], "func_with_other_call"); > fun (0); > > + fun = dlsym (handle[2], "func_with_other_call"); > + fun (0); > + > dlclose (handle[0]); /* TAG: first dlclose */ > dlclose (handle[1]); /* TAG: second dlclose */ > dlclose (handle[2]); /* TAG: third dlclose */ > diff --git a/gdb/testsuite/gdb.base/dlmopen-ns-ids.exp b/gdb/testsuite/gdb.base/dlmopen-ns-ids.exp > index 78daed4518e..9c9f97e6887 100644 > --- a/gdb/testsuite/gdb.base/dlmopen-ns-ids.exp > +++ b/gdb/testsuite/gdb.base/dlmopen-ns-ids.exp > @@ -370,6 +370,15 @@ proc_with_prefix test_print_namespace_symbol {} { > gdb_test "print ${ns2}::'${::srcfile_lib}'::gdb_dlmopen_glob + '${::srcfile}'::global_main_file" \ > ".* = 1312" > > + gdb_continue_to_breakpoint "change_global in namespace 2" > + # GDB would find symtabs in load order, ignoring the current linker namespace. > + # This test ensures that we prefer the symtabs in the namespace in the current > + # point of execution instead. > + gdb_test "print gdb_dlmopen_glob == '${::srcfile_lib}'::gdb_dlmopen_glob" \ > + ".* = 1" "symtab prioritizes the current namespace" > + gdb_test "print &gdb_dlmopen_glob == &'${::srcfile_lib}'::gdb_dlmopen_glob" \ > + ".* = 1" "Double checking with addresses" > + > # Leave to default namespace. > gdb_continue_to_breakpoint "TAG: first dlclose" > # This global doesn't exist in the default namespace. Rather than -- Cheers, Guinevere Larsen It/she