From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id cTVTLxZJtGpdRDkAWB0awg (envelope-from ) for ; Wed, 23 Sep 2026 17:48:06 -0400 Authentication-Results: simark.ca; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=Bi4tm04I; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id A414B1E06B; Wed, 23 Sep 2026 17:48: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 [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 B631A1E01F for ; Wed, 23 Sep 2026 17:48:05 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4B6344BB3BAE for ; Wed, 23 Sep 2026 21:48:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4B6344BB3BAE Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=Bi4tm04I Received: from mail-ua2-x0f.google.com (mail-ua2-x0f.google.com [IPv6:2a00:1450:4864:39::f]) by sourceware.org (Postfix) with ESMTPS id BA4AE4BA23FC for ; Wed, 23 Sep 2026 21:47:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BA4AE4BA23FC Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org BA4AE4BA23FC Authentication-Results: sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:39::f ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1790200058; cv=none; b=Q3utM01gq72RgfcNzIM/OdSafoHOqHjawoRT9MCh/54p345GKH2ixck1ZuVoNEHuNXYYFrj42yHLiLdHoUalkN5mEaHiJoI3/RymMDoUJckjrCk6Hln8yXkFMS1EDp8La3vsC87tusgezfxqwMxNgYBnX79nOichY48hH4AbS8s= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1790200058; c=relaxed/simple; bh=26Qiba0+D94r1Dw2ihBr022/rkpogMSwqRIiVtzvTWk=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=NSolA4CU6JzOyuy6Nny39k45puqTxKDx7oZNc1PDXRi2pQEA5TAiO5D19Vaxa+Ltc08OWOxBYz3gHhfPtYWkP/Bc9VgvuJxDM++XXAS2hyWFDNGoRdYKaSQVBXv5W3UM59xHuscSnyi6lvT/SWuxYrHtiJEYFMkHozzsmcmX/ZE= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=Bi4tm04I DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BA4AE4BA23FC Received: by mail-ua2-x0f.google.com with SMTP id a1e0cc1a2514c-9832c759198so698843241.3 for ; Wed, 23 Sep 2026 14:47:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1790200058; x=1790804858; darn=sourceware.org; h=content-type:mime-version:message-id:date:user-agent:references :in-reply-to:subject:cc:to:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=v87DU6IWf90dUtaK8eHp/rjyOlc93Fu2mcCfKAn7PNM=; b=Bi4tm04IcJYsTxMGFJrP697A1IVd8jSc8ENQtN8hTSyqTB+ZgZZ49/8dVjzRygqAey y05QYP8P+AD3ZTy/ZHedobII4B8AXPL1/inVmJo8w9zqdtr5GoRiHEicekR/5Qy3o/85 45+oqgT1bgkEMVa8Yk7xKy6vXwgMYE+NcQ0hx4v5OsHE0c8wJGE24X9wMUIOsQUFom8s 0jRWVQs7EYpIPUrd6Kca0eQmgVau5aXuiootf2z8GcN/sGFozjdlA3TdQ6k8FeUxZ/a3 r2eBYFUMrvVrFkYT4Ki8s9oDMOrhIPEZ4ei3gDmWllpZJ0eNeoFhvCxymIeJkT78zI+x P1tQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790200058; x=1790804858; h=content-type:mime-version:message-id:date:user-agent:references :in-reply-to:subject:cc:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=v87DU6IWf90dUtaK8eHp/rjyOlc93Fu2mcCfKAn7PNM=; b=HWZHOykzYN41noamcFD097eUWCtDyfnY40R/bPOlMw/EZ3zzLcUWNl4dd2GpuAZeny NZ6oZ8XpQeLk0HK61KNLRBEGCBA0mDP34kn4LKzgJnLKS7lqYvxmUt84+jnM1m62jyT7 +tfEk0TevNYrNhO6CxlVMKd0+wFDNViusxyTyyasLb7Zu6GtU/Hm/UZHaO+iBC7k1Eah iR8GDTlAK2HtHxp8mwbn/w0/6N4OT5+O2f3w6nQoR01tWC70p+qFwgimUI2qKvJ1W5ZZ +6W4pQclxUaXH6BTl6CGRW4QC96BER9qDKRl4iQnlZUN4qZccL+1b+FqXnvCZu52mETc repA== X-Gm-Message-State: AFuF++kiGTH/I4APSHjdvrkC8POGEj+NY5Fcw8tHdS5JYQkMsBXX3byc rDyKtSBVLwchFN5bT2MAZHt6nWiksU8UpSic7OXFQHQPxmH0exAvpcAyxf5sJ5h+VRZFvPSvUYM 8NAty X-Gm-Gg: AYBFou1U03ZDqPtHS2f8heLF26CqbAGIawRiHtFjWAXpetkvj0Vyb/Xl0fZW3kUv4Fe QXr8yPRwExSTPB2n3oSAGKZ5QC3Qh9FF3kbE/ka+uR2AEOFwhvZoP+7HZl9Xj6uYXbHuH22O0RG 5AdALealAU6EeYeWxEZfbWvUhVk2tCq8eyRvtqAJPCNnSXeAwTDl3UagymKfxVd8+D1wViVWI75 PwyBfTxegKhQLBTFwCI2b8wAGxF8knyPpI0dYoGGbUBA4mcZyJ5hnO26cqCJIRJazP0STAETTC9 FxpR8I6SnOQAdfFvgnmmliS06vSJ5BEYlwnu0f6pKpvg3NgrjBNub7zyZkJnqAwPk5VNOQ35Wq9 TBU5SWKX30xf4M859cfhLQISaPXNaCY2XTaCoqRwyGmPCPnBQM4g4QVVW1zf8+TSr+aBAa+7F5x K0A70jZuLkhvvZbXLdySc1qBaZjb27UXg7nZHv1c+QZqts6LlTYm05jxA0ai7XrQainTALnC9YG xR6sljW X-Received: by 2002:a05:6102:5549:b0:79b:1b6c:4f66 with SMTP id ada2fe7eead31-7af1c799adamr488045137.1.1790200057775; Wed, 23 Sep 2026 14:47:37 -0700 (PDT) Received: from localhost ([2804:14d:7e39:8083:f04c:42e3:5943:38f6]) by smtp.gmail.com with ESMTPSA id a1e0cc1a2514c-9851a07144dsm4239814241.9.2026.09.23.14.47.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Sep 2026 14:47:37 -0700 (PDT) From: Thiago Jung Bauermann To: Adhemerval Zanella Cc: gdb-patches@sourceware.org Subject: Re: [PATCH] gdb: Skip useless minsym scan in variable-only symbol searches In-Reply-To: <20260922155125.3710118-1-adhemerval.zanella@linaro.org> References: <20260922155125.3710118-1-adhemerval.zanella@linaro.org> User-Agent: mu4e 1.14.3; emacs 31.1 Date: Wed, 23 Sep 2026 21:47:34 +0000 Message-ID: <87ecejmyh5.fsf@linaro.org> MIME-Version: 1.0 Content-Type: text/plain 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 Adhemerval Zanella writes: > The symbol-listing command -symbol-info-* family goes through > global_symbol_searcher::search, which has 3 steps: > > 1. expand_symtabs (objfile, preg): make sure every compunit that could > contain a match is expanded. Returns found_msymbol = true if it > saw a matching msymbol that has no debug info. > > 2. add_matching_symbols (...): walk the compunits and collect the real > matches. > > 3. After the loop, a minsym fallback: if found_msymbol was set, or > unconditionally for any variable search with no file filter, re-scan > msymbols and append the ones without debug info (unless the searcher > set exclude_minsyms). > > Step 1 had two phases, first objfile::search, which uses the > quick-symbol index to expand candidate compunits; then the pre-pass > for every msymbol in the objfile whose name matches the regexp: > > 1.1. function search: call find_compunit_symtab_for_pc (address). This > consults the quick functions and can expand the compunit containing > that address. > > 1.2. variable search: call lookup_symbol_in_objfile_from_linkage_name, > which does a linear scan of objfile->compunits () per lookup. It > can not expand anything; its only output is setting found_msymbol > when the lookup fails. > > So for variables the pre-pass costs 'msymbols * expanded-compunits' > block lookups and produces exactly one bit of information (found_msymbol) > and this dominates the command execution time. > > And in step 3. these MI3 commands (search_module_symbols) calls > spec2.set_exclude_minsyms (true), which sets !m_exclude_minsyms to false. > The fallback never runs (found_msymbol is ignored), making the pre-pass > calculation not required. > > The fix is make SEARCH_VAR_DOMAIN skip the pre-pass. For variable > searches with no filenames the fallback condition already contains > '(m_kind & SEARCH_VAR_DOMAIN) != 0' as an unconditional alternative. > > Since the pre-pass now only runs for searches that include > SEARCH_FUNCTION_DOMAIN, the lookup_symbol_in_objfile_from_linkage_name > branch of the conditional inside the loop is unreachable. > > Also update the comments, which still described the variable lookup and > claimed it forces symtabs to be read. That was true when > lookup_symbol_in_objfile_from_linkage_name was added in commit > 422d65e705c7, but it no longer expands any symtab. > > -symbol-info-module-variables --module on the 2000-module benchmark > drops from 90 s to 0.56 s cold. > > Change-Id: I6019bcf80629f21cf6dee74d0e96fa788a70e220 > --- > gdb/symtab.c | 35 ++++++++++++++--------------------- > 1 file changed, 14 insertions(+), 21 deletions(-) I reviewed this patch and it looks good to me, but I'm not knowledgeable enough on GDB symbol handling for a Reviewed-by. I did check that it doesn't cause any testsuite regression so: Tested-by: Thiago Jung Bauermann -- Thiago (he/him)