From patchwork Tue Nov 21 03:53:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 56404 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B365D385829B for ; Tue, 21 Nov 2023 03:53:35 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from omta038.useast.a.cloudfilter.net (omta038.useast.a.cloudfilter.net [44.202.169.37]) by sourceware.org (Postfix) with ESMTPS id 0BF3A3858D37 for ; Tue, 21 Nov 2023 03:53:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0BF3A3858D37 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 0BF3A3858D37 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=44.202.169.37 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700538802; cv=none; b=fTuoSYVoPOfYGf7BGSJrMvpZFXB29Aop3jexHUL/irrCNHU0kIvISyJRaBNzPOyzCsRI/J7OYUWqodUdlLCa00bfTMemMBmiKzgdMb6DFF0k3HuOlsM67jw/GivvPEhUJx4BRT5p4t9XxlfXuz48idKKNEF2f9/Eq6HCOMJF8c0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700538802; c=relaxed/simple; bh=DNWkAuq4BYKsoUXuMKEcDmeuWmOUADHzgo/rZiOtJis=; h=DKIM-Signature:From:Subject:Date:Message-Id:MIME-Version:To; b=xP7dh200A+u3RqvtdSpss8pzPMINeOCKkKk6qUnVf04I7bn3VqZpxUqLEJcFk4YAeBVbupykZaYw2v0lZ39at91WWpGO2HABoLqP79dZ86j1sP7VaVYoInf94DDz3TfhNce9EfpJmjfiPm0wR+3CexKM3k6NO3RuRepKhU3LLLM= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from eig-obgw-6004a.ext.cloudfilter.net ([10.0.30.197]) by cmsmtp with ESMTPS id 5C58rnO1ZWcCI5Hp9rZVLB; Tue, 21 Nov 2023 03:53:19 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id 5Hp8rvsRMRGmS5Hp8rFKfX; Tue, 21 Nov 2023 03:53:18 +0000 X-Authority-Analysis: v=2.4 cv=efcuwpIH c=1 sm=1 tr=0 ts=655c29ae a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=OWjo9vPv0XrRhIrVQ50Ab3nP57M=:19 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=IkcTkHD0fZMA:10 a=BNY50KLci1gA:10 a=Qbun_eYptAEA:10 a=zstS-IiYAAAA:8 a=i4ms9WQblCVCBNXyuK4A:9 a=QEXdDO2ut3YA:10 a=4G6NA9xxw8l3yy4pmD5M:22 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=To:Content-Transfer-Encoding:Content-Type:MIME-Version: Message-Id:Date:Subject:From:Sender:Reply-To:Cc: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=IXyrMmaul1JMpK9gizbK9c03FBLI1vmDX/l8QxPvJrM=; b=AkrhsaelIY5oh0XHoNq6hXOlYe yVINk9sjyM2tPOUIr0Ivuf7AhHHzQcaAXbcwATO3LGoAqYW46g1NgAy+97dBXHeWyCGGzBCf4Il+N 31wjHDRYt4ZzR8Knwxscb8mQS; Received: from 97-122-77-73.hlrn.qwest.net ([97.122.77.73]:47856 helo=[192.168.0.21]) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96.2) (envelope-from ) id 1r5Hp8-0040be-0t for gdb-patches@sourceware.org; Mon, 20 Nov 2023 20:53:18 -0700 From: Tom Tromey Subject: [PATCH 00/29] Restructure symbol domains Date: Mon, 20 Nov 2023 20:53:31 -0700 Message-Id: <20231120-submit-domain-hacks-2-v1-0-29650d01b198@tromey.com> MIME-Version: 1.0 X-B4-Tracking: v=1; b=H4sIALwpXGUC/x3MMQ7CMAxA0atUnrEUB8jAVRCDkxhioaQobhFS1 bsTGN/w/wYmXcXgMm3Q5a2mcxugwwSpcHsIah4G7/yRyDu0NVZdMM+VtWHh9DT0SIkkhHjK5+B gtK8ud/38v9fbcGQTjJ1bKr9bZVukw75/Ab4qaOCAAAAA To: gdb-patches@sourceware.org X-Mailer: b4 0.12.4 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.77.73 X-Source-L: No X-Exim-ID: 1r5Hp8-0040be-0t X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-77-73.hlrn.qwest.net ([192.168.0.21]) [97.122.77.73]:47856 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: MS4xfA5JAzXXlaiL+2JbnmpXnbMnCPxo/j7RQIMmJPlEERGwjYOxWPG2s7KQAZzgeiHTqYBI95AE4Mwvy8YN81bSraIjk/Ac/oCnpGgvfUYT73NQsnpaw7K5 QHmj+BYqc86hAod3zzfDimTjUOkcrvVHk6oETrOA8ZhG+P1vLR7EkNVmo/hApMpRjG4hGh/8xrXEIF78t29xASqPQzEaSLdSmpY= X-Spam-Status: No, score=-3018.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, JMQ_SPF_NEUTRAL, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.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+patchwork=sourceware.org@sourceware.org gdb's symbol domains have long needed some restructuring. The current symbol domains are C-centric, with the "struct" domain being separate from types (which is not the case in non-C languages) and function and types being lumped in with variables. This latter decision makes it impossible to search the symbol table for a function, resulting in bugs like PR 30158, where "main" was found as a namespace, causing a crash. This series adds new symbol domains for types and functions, and changes the various symbol-lookup functions to allow multiple domains to be searched at once. Then, the symbol readers are changed to use the new domains. Finally, selected bits of code are changed to be more precise in which domains they search. symbol_matches_domain currently has a C++-specific hack. This hack handles the C++ language rule where a tag is also entered as a typedef. While working on this series, I discovered that the non-DWARF symbol readers will actually emit a second typedef symbol. DWARF could do this as well, at some memory expense; and while I consider this to be cleaner in an abstract way, for the time being I've left the hack in place. I regression tested this on x86-64 Fedora 38. I also regression tested using the debug-names and gdb-index target boards. --- Tom Tromey (29): Fix bug in cooked index scanner Small cleanup in DWARF reader Make nsalias.exp more reliable Fix latent bug in mdebugread.c Give names to unspecified types Remove NR_DOMAINS Simplify symbol_to_info_string Split up a big 'if' in symtab.c Use a .def file for domain_enum Add two new symbol domains Add domain_search_flags Replace search_domain with domain_search_flags Remove a check of VAR_DOMAIN Introduce "scripting" domains Use domain_search_flags in lookup_global_symbol_language Use domain_search_flags in lookup_symbol et al Remove some obsolete Python constants Remove old symbol_matches_domain Use the new symbol domains Simplify some symbol searches in Ada code Simplify some symbol searches in linespec.c Only search for "main" as a function Only look for functions in expand_symtabs_for_function Use a function-domain search in inside_main_func Only search types in cp_lookup_rtti_type Only search types in lookup_typename Only search for functions in rust_structop::evaluate_funcall Refine search in cp_search_static_and_baseclasses Document new Python and Guile constants gdb/NEWS | 12 + gdb/ada-exp.y | 13 +- gdb/ada-lang.c | 77 +++-- gdb/ada-lang.h | 6 +- gdb/ada-tasks.c | 17 +- gdb/alpha-mdebug-tdep.c | 2 +- gdb/ax-gdb.c | 5 +- gdb/block.c | 24 +- gdb/block.h | 15 +- gdb/c-exp.y | 19 +- gdb/c-lang.c | 2 +- gdb/c-valprint.c | 2 +- gdb/coffread.c | 5 +- gdb/compile/compile-c-symbols.c | 17 +- gdb/compile/compile-cplus-symbols.c | 15 +- gdb/compile/compile-cplus-types.c | 8 +- gdb/compile/compile-object-load.c | 6 +- gdb/cp-namespace.c | 66 +++-- gdb/cp-support.c | 10 +- gdb/cp-support.h | 8 +- gdb/ctfread.c | 2 +- gdb/d-exp.y | 12 +- gdb/d-lang.c | 2 +- gdb/d-lang.h | 9 +- gdb/d-namespace.c | 24 +- gdb/doc/guile.texi | 13 + gdb/doc/python.texi | 30 +- gdb/dwarf2/ada-imported.c | 2 +- gdb/dwarf2/cooked-index.c | 12 + gdb/dwarf2/cooked-index.h | 45 +-- gdb/dwarf2/index-write.c | 7 +- gdb/dwarf2/loc.c | 2 +- gdb/dwarf2/read-debug-names.c | 132 ++------- gdb/dwarf2/read-gdb-index.c | 75 +++-- gdb/dwarf2/read.c | 65 +++-- gdb/dwarf2/read.h | 2 +- gdb/dwarf2/tag.h | 78 +++++ gdb/eval.c | 5 +- gdb/f-exp.y | 8 +- gdb/f-lang.c | 2 +- gdb/f-lang.h | 2 +- gdb/f-valprint.c | 2 +- gdb/fbsd-tdep.c | 5 +- gdb/frame.c | 9 +- gdb/ft32-tdep.c | 3 +- gdb/gdbtypes.c | 35 ++- gdb/gnu-v3-abi.c | 2 +- gdb/go-exp.y | 9 +- gdb/guile/scm-frame.c | 2 +- gdb/guile/scm-symbol.c | 25 +- gdb/infrun.c | 2 +- gdb/jit.c | 2 +- gdb/language.c | 5 +- gdb/language.h | 4 +- gdb/linespec.c | 67 +++-- gdb/m2-exp.y | 10 +- gdb/mdebugread.c | 6 +- gdb/mi/mi-cmd-stack.c | 5 +- gdb/mi/mi-symbol-cmds.c | 35 +-- gdb/moxie-tdep.c | 3 +- gdb/objc-lang.c | 4 +- gdb/objfiles.h | 9 +- gdb/p-exp.y | 19 +- gdb/p-valprint.c | 2 +- gdb/parse.c | 3 +- gdb/printcmd.c | 2 +- gdb/psymtab.c | 52 ++-- gdb/psymtab.h | 7 +- gdb/python/py-frame.c | 3 +- gdb/python/py-objfile.c | 6 +- gdb/python/py-symbol.c | 53 ++-- gdb/python/python.c | 2 +- gdb/quick-symbol.h | 12 +- gdb/rust-lang.c | 7 +- gdb/rust-lang.h | 2 +- gdb/rust-parse.c | 8 +- gdb/source.c | 5 +- gdb/stabsread.c | 8 +- gdb/stack.c | 4 +- gdb/sym-domains.def | 58 ++++ gdb/symfile-debug.c | 30 +- gdb/symfile.c | 9 +- gdb/symfile.h | 2 +- gdb/symmisc.c | 3 +- gdb/symtab.c | 480 +++++++++++++++++-------------- gdb/symtab.h | 177 ++++++------ gdb/testsuite/gdb.ada/info_auto_lang.exp | 4 +- gdb/testsuite/gdb.ada/ptype-o.exp | 2 +- gdb/testsuite/gdb.cp/nsalias.exp | 2 +- gdb/testsuite/gdb.fortran/info-types.exp | 2 +- gdb/valops.c | 14 +- gdb/value.c | 6 +- gdb/xcoffread.c | 9 +- gdb/xstormy16-tdep.c | 3 +- 94 files changed, 1117 insertions(+), 981 deletions(-) --- base-commit: 8116169676604839ecfa39c1fe609249efb481d8 change-id: 20231120-submit-domain-hacks-2-1c1e66b4d560 Best regards,