From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id GEWQIYbN7WfNjiQAWB0awg (envelope-from ) for ; Wed, 02 Apr 2025 19:51:34 -0400 Authentication-Results: simark.ca; dkim=fail reason="signature verification failed" (768-bit key; unprotected) header.d=tromey.com header.i=@tromey.com header.a=rsa-sha256 header.s=default header.b=TpfNzhjB; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 84BA71E0C3; Wed, 2 Apr 2025 19:51:34 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-3.8 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_INVALID,DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_BL_SPAMCOP_NET, RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=4.0.1 Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (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 F00B91E0C0 for ; Wed, 2 Apr 2025 19:51:33 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id AAE50385842D for ; Wed, 2 Apr 2025 23:51:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AAE50385842D Authentication-Results: sourceware.org; dkim=fail reason="signature verification failed" (768-bit key, unprotected) header.d=tromey.com header.i=@tromey.com header.a=rsa-sha256 header.s=default header.b=TpfNzhjB Received: from omta40.uswest2.a.cloudfilter.net (omta40.uswest2.a.cloudfilter.net [35.89.44.39]) by sourceware.org (Postfix) with ESMTPS id 44CBD385842D for ; Wed, 2 Apr 2025 23:45:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 44CBD385842D Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 44CBD385842D Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=35.89.44.39 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1743637512; cv=none; b=YMiTzoNZnLFK/NRdI04ENna7t5xq6gtgqksFsAnWVnBsqukYW+p0NLvtaLW9ar879la3iix1u8P0eCFIakbi8YWSA4PmyGoOnS6dUqfYuwvggSqw/0vSs/pFzgaQFM/VCfHBsRUyK3+zObAuHd9/WpmtXe1j06zVbh2W8L9LcK8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1743637512; c=relaxed/simple; bh=1c3BE/r0+6ecZ6VBTK8Y23cC+fp2299IuZWEOWTlSJc=; h=DKIM-Signature:From:Subject:Date:Message-Id:MIME-Version:To; b=XJ7LXAG8El4KL1WadPi7znRKc4+ivlzhuSc8Mc9U23i+viU6/Fqrg+eOO/4It0+QsZ2vwJgHdejSDxlV5hjrvSRKLlOX0q9zt3K8JTKGQmX30u95f2SWtZcFO6GVkBwAWqcZALkBwcIF2oQX3Mo2ZZNaq0WqU1LmR1siX7OXGOw= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 44CBD385842D Received: from eig-obgw-6010a.ext.cloudfilter.net ([10.0.30.248]) by cmsmtp with ESMTPS id zzcxtbMOGf1UX07lfuFIjN; Wed, 02 Apr 2025 23:45:11 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id 07leufRlRqEhj07leu3Ubu; Wed, 02 Apr 2025 23:45:11 +0000 X-Authority-Analysis: v=2.4 cv=SMVEVvvH c=1 sm=1 tr=0 ts=67edcc07 a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=IkcTkHD0fZMA:10 a=XR8D0OoHHMoA:10 a=ItBw4LHWJt0A:10 a=CCpqsmhAAAAA:8 a=zstS-IiYAAAA:8 a=NcnIpn5XW5c8qPhX-TUA:9 a=QEXdDO2ut3YA:10 a=ul9cdbp4aOFLsgKbc677:22 a=4G6NA9xxw8l3yy4pmD5M:22 a=6Ogn3jAGHLSNbaov7Orx:22 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Cc:To:Content-Transfer-Encoding:Content-Type:MIME-Version: Message-Id:Date:Subject:From:Sender:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=ER3CPWywJ20gaVzj2urlo1gM9OMXRXHt72ZeaxEPYO0=; b=TpfNzhjB5oXVG3rdD2t+rSJT3P huT5cFagY1EUk3G87r5nhna/rVsEnJIExrdIh5/kme8TLOkr042LcHgZb0fDKb3H0QBNDMl87dEfy 13pJG/EcRWb9e1ZB/xBQaEDuw; Received: from 97-122-123-18.hlrn.qwest.net ([97.122.123.18]:56394 helo=prentzel.local) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.1) (envelope-from ) id 1u07le-000000014hd-0d5V; Wed, 02 Apr 2025 17:45:10 -0600 From: Tom Tromey Subject: [PATCH v2 00/28] Search symbols via quick API Date: Wed, 02 Apr 2025 17:44:59 -0600 Message-Id: <20250402-search-in-psyms-v2-0-ea91704487cb@tromey.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-B4-Tracking: v=1; b=H4sIAPzL7WcC/3WOzQ6CMBCEX8X0bLU/GsST72E4tGWle2hLdgmRE N7dwt3jl8x8M6tgIAQWz9MqCGZkLLmCOZ9EiC4PILGvLIwyd2W1lgyOQpSY5chLYmnBa3VrddO AErU1EnzwexjfXWXvGKQnl0PcPYVwwHxNjiegPR+Rp0LLcWDWe+v/1qylkn1j+9aDUe3DviYqC ZZLKEl027b9ABCJmuTPAAAA X-Change-ID: 20250311-search-in-psyms-3eb1049177e0 To: gdb-patches@sourceware.org Cc: Tom Tromey X-Mailer: b4 0.14.2 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5379.bluehost.com X-AntiAbuse: Original Domain - sourceware.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 97.122.123.18 X-Source-L: No X-Exim-ID: 1u07le-000000014hd-0d5V X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-123-18.hlrn.qwest.net (prentzel.local) [97.122.123.18]:56394 X-Source-Auth: tom+tromey.com X-Email-Count: 1 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfKELiWNHsIbIgz/fPTOadwSF9A05qf3JRknG7SVl0dhJh7Cp5fRXt2WqUkgdTZmm6B4w4cTg7QT3JFlTkAXHnbMIhF7TD/8bkfzNYOMv8TKcyA3J4Ov1 QZxaX6d+hN+JRmvTQ5qbriRw40bY5VCSw13b41kYUWo5/2tWpozAsdihWkBVgINHd6JWH67Zylq++COH1zl6i1zM/r1QATtAZzo= 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 This series changes how symbols are looked up in gdb. Currently, symbol lookup is done in two phases. In one phase, gdb searches all existing symtabs for a symbol. In another phase, gdb will call expand_symtabs_matching to expand some symtabs. Different spots in gdb may order these phases differently -- so some places will expand symtabs and then search the compunits, but other places will first search expanded symtabs and then use the expand_symtabs_matching callback to add further results. This approach has a few drawbacks. * The double search means that some discrepancies between the indexer and the full reader go unnoticed. This may arguably be a strength of the approach, though frequently a carefully crafted test case can show this as a bug. Essentially, though, some searches only work by accident. * Searching all expanded symtabs means that, as a debug session drags on, searches will examine many irrelevant symtabs. * In some places, the two phases use different code to perform the actual search, meaning that the results can depend on previous CU expansion decisions. * Similarly, if just a single symbol is needed, then both approaches are bad: expand-then-search will be unnecessarily inefficient, while search-then-expand approach means that the result depends on which CUs happen to have already been expanded. This series changes all of this. Now, all symbol lookups are done via the "quick" API, with the idea being that the final search of the expanded symtab is done via the expand_symtabs_matching callback. This fixes all the issues pointed out above: * Only relevant symtabs are searched, because the index only considers matching symbols. * Some discrepancies between the indexer and the full reader show up as symbol lookup failures. Others (if the indexer thinks a symbol exists but the full reader does not) will just be inefficient -- but we could add a verifier for this. * Lookups are no longer dependent on symtab expansion state, because again the indexer is pre-filtering the matches. Re-reading the series -- it's been in development for quite a while and I've already landed ~20 preliminary patches -- shows that there are still a few cleanups in here that could perhaps have gone in separately. Anyway, the essential change is to make the implementations of expand_symtabs_matching also call the callback when a symtab has already been expanded. After this, most of the work is cleaning up individual callers. This change lead to some surprising places. For example, I had to rewrite the .gdb_index reader, because the work done for "templates.exp" simply never worked in this mode -- and the test obscured the problems, a classic case of lookups working by accident. I regression tested each patch in this series. Furthermore I regression tested the series as a whole using the cc-with-debug-names and cc-with-gdb-index target boards. All of this was done on x86-64 Fedora 40. I think maybe I've separately submitted "Ada import functions not in index" patch. Anyway it's part of this series now. Signed-off-by: Tom Tromey --- Changes in v2: - Rebased for all the other recent DWARF changes - Link to v1: https://inbox.sourceware.org/gdb-patches/20250311-search-in-psyms-v1-0-d73d9be20983@tromey.com --- Tom Tromey (28): Add another minor hack to cooked_index_entry::full_name Change ada_decode to preserve upper-case in some situations Emit some type declarations in .gdb_index Ada import functions not in index Fix index's handling of DW_TAG_imported_declaration Put all CTF symbols in global scope Restore "ingestion" of .debug_str when writing .debug_names Entries from anon-struct.exp not in cooked index Remove dwarf2_per_cu_data::mark Have expand_symtabs_matching work for already-expanded CUs Rewrite the .gdb_index reader Convert default_collect_symbol_completion_matches_break_on Convert gdbpy_lookup_static_symbols Convert ada_add_global_exceptions Convert ada_language_defn::collect_symbol_completion_matches Convert ada-lang.c:map_matching_symbols Remove expand_symtabs_matching Simplify basic_lookup_transparent_type Remove objfile::expand_symtabs_for_function Convert linespec.c:iterate_over_all_matching_symtabs Simplify block_lookup_symbol_primary Pass lookup_name_info to block_lookup_symbol_primary Simplify block_lookup_symbol Add best_symbol_tracker Convert lookup_symbol_via_quick_fns Convert lookup_symbol_in_objfile Make dw_expand_symtabs_matching_file_matcher static Remove enter_symbol_lookup gdb/ada-lang.c | 221 ++--- gdb/ada-lang.h | 15 +- gdb/block.c | 57 +- gdb/block.h | 27 +- gdb/cp-support.c | 28 +- gdb/ctfread.c | 6 +- gdb/dwarf2/abbrev.c | 7 +- gdb/dwarf2/abbrev.h | 8 + gdb/dwarf2/cooked-index-entry.c | 7 + gdb/dwarf2/cooked-index-shard.c | 13 +- gdb/dwarf2/cooked-index-shard.h | 7 + gdb/dwarf2/cooked-index-worker.h | 17 +- gdb/dwarf2/cooked-indexer.c | 37 +- gdb/dwarf2/index-write.c | 103 ++- gdb/dwarf2/read-gdb-index.c | 1268 ++++++----------------------- gdb/dwarf2/read-gdb-index.h | 14 + gdb/dwarf2/read.c | 176 ++-- gdb/dwarf2/read.h | 48 +- gdb/dwarf2/tag.h | 12 + gdb/linespec.c | 17 +- gdb/objfiles.h | 4 - gdb/psymtab.c | 3 - gdb/python/py-symbol.c | 29 +- gdb/symfile-debug.c | 22 - gdb/symfile.c | 25 - gdb/symfile.h | 9 - gdb/symtab.c | 223 ++--- gdb/symtab.h | 2 +- gdb/testsuite/gdb.ada/import.exp | 28 +- gdb/testsuite/gdb.ctf/cross-tu-cyclic.exp | 4 +- 30 files changed, 861 insertions(+), 1576 deletions(-) --- base-commit: 60ac9c60fe5b6dc5a59a30a971c3fad020fecf45 change-id: 20250311-search-in-psyms-3eb1049177e0 Best regards, -- Tom Tromey