From patchwork Tue Nov 21 03:53:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 80391 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 1227538582AE for ; Tue, 21 Nov 2023 03:53:36 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from omta036.useast.a.cloudfilter.net (omta036.useast.a.cloudfilter.net [44.202.169.35]) by sourceware.org (Postfix) with ESMTPS id 05C6F3858D35 for ; Tue, 21 Nov 2023 03:53:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 05C6F3858D35 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 05C6F3858D35 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=44.202.169.35 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700538802; cv=none; b=hl0RocebV5SgVCyyly1AXVM0hY8BrtBLPDZIcQt7sx4CfoxZ03GQ/UduSky9z7DfpgM5NR+4HPIkgg1k1A5c/XIUGcYu4Q+foBB4A9IVoZO2jChrCTKr/HFY6f9wjQvXnQLqK7WP4w9j3G84fUa66udp7hPWOpcM4XW1sXySvV0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700538802; c=relaxed/simple; bh=PbrkEJkvo0Xf0Q4GFXdT0pppJMwCSHNO7D/lhGnfQpQ=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=n1Cthsdho3grxgLMVWSaTZkduqrj9thYVfU4QjCjANdX2uOMLuuLdmLEKIhrb2fClbJKp3dDw3X8NWjJ+j5eGuZQUSzdi4EBKZ9Wxo1K6OunyBnF50eK0SjhaJPkOoE6LhLMD8z3FXk/q7j8/u7dZleyxRdUKsJeJLdm+izVdHM= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from eig-obgw-5002a.ext.cloudfilter.net ([10.0.29.215]) by cmsmtp with ESMTPS id 59xZrJwZugpyE5Hp9rHEgx; Tue, 21 Nov 2023 03:53:19 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id 5Hp8rp9tHRQmi5Hp9rrjal; Tue, 21 Nov 2023 03:53:19 +0000 X-Authority-Analysis: v=2.4 cv=CdcbWZnl c=1 sm=1 tr=0 ts=655c29af 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=N5RK8avXPxMtqR0ytacA:9 a=QEXdDO2ut3YA:10 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=To:In-Reply-To:References:Message-Id:Content-Transfer-Encoding: Content-Type:MIME-Version:Subject:Date:From:Sender:Reply-To:Cc:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=YZ9P2XymnIIpteNcAw5pF1eYgG7vfLnfs+0kMNf6v/A=; b=e85tJ1cL4iDFPeWGkjXKQg04Nc 0B/H4XOm7vcQrFU4jjPy3zHTdmPmb5kabR2+Z3otfrUNO14NR7Jdg3+Pn3exl5ywcvtAqD6Y7A7Hi 2fSGaj0Qu7T/wxA+8s7xjCFLz; 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-1S for gdb-patches@sourceware.org; Mon, 20 Nov 2023 20:53:18 -0700 From: Tom Tromey Date: Mon, 20 Nov 2023 20:53:32 -0700 Subject: [PATCH 01/29] Fix bug in cooked index scanner MIME-Version: 1.0 Message-Id: <20231120-submit-domain-hacks-2-v1-1-29650d01b198@tromey.com> References: <20231120-submit-domain-hacks-2-v1-0-29650d01b198@tromey.com> In-Reply-To: <20231120-submit-domain-hacks-2-v1-0-29650d01b198@tromey.com> 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-1S 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: 2 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfCudubTznU8IxfHd5/fBPDTTo2UghcKJVVu0bD78+JRVtSBlm8Awjzr+Wm7c09/p/eoijiPqbwCVZTyFn8yTcxu30hF6BJiDH311moUiGm2C9EZGfXWh OaHkxEI98u7s1RxqzHpVusyVbueXavOWPRoA5j9o5yTs2CM++fWyV/BBr4JklutF3qi/tPmRFDs5GU/s7H+aEidclCroCItp4ws= X-Spam-Status: No, score=-3024.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham 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 Testing this entire series pointed out that the cooked index scanner disagrees with new_symbol about certain symbols. In particular, new_symbol has this comment: Ada and Fortran subprograms, whether marked external or not, are always stored as a global symbol, because we want This patch updates the scanner to match. I don't know why the current code does not cause failures. It's maybe worth noting that incremental CU expansion -- creating symtabs directly from the index -- would eliminate this sort of bug. --- gdb/dwarf2/read.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index e8ff4d8f29a..1aca36e6179 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -16303,6 +16303,12 @@ cooked_indexer::scan_attributes (dwarf2_per_cu_data *scanning_per_cu, || abbrev->tag == DW_TAG_enumeration_type || abbrev->tag == DW_TAG_enumerator)) *flags &= ~IS_STATIC; + + /* Keep in sync with new_symbol. */ + if (abbrev->tag == DW_TAG_subprogram + && (m_language == language_ada + || m_language == language_fortran)) + *flags &= ~IS_STATIC; } return info_ptr; From patchwork Tue Nov 21 03:53:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 80396 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 AC049385843B for ; Tue, 21 Nov 2023 03:54:16 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from omta34.uswest2.a.cloudfilter.net (omta34.uswest2.a.cloudfilter.net [35.89.44.33]) by sourceware.org (Postfix) with ESMTPS id F39B13858C42 for ; Tue, 21 Nov 2023 03:53:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org F39B13858C42 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 F39B13858C42 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=35.89.44.33 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700538804; cv=none; b=NDfqx6iA+8fdPEeNwilldllcCBx1a3RUWIVVHu3/lJ6E6po8jCvX+20u7VdLd8RgtZogzo32TxNyEV8XUR3zBoSusJ7LRCj1ZmoSTrQ3HXRBjAShXjEqaONYV2WW0ebXYrJ6Qft6oCcdPQWX5Wrwp1wKBHGCdFyWBObxAUKrOOo= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700538804; c=relaxed/simple; bh=q9NqVWLXihYZkZRj1EFgSeyEC6EJrhnOd/kcsP6Ho9s=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=pFlZbDZ6XHnC6rpDNn7+jBHAu7mb1Q6uS03eGijQL1Owtlq+HmAtUxHcrGuLsasrM9XXK3Sdzkc6sjSaUI5kv6lbzPe5Fwr+rmqkrB/NhCAjlvIm1KVpBVBjkPq6owdFZC6ru50noexxCJMIqUN8UHl0NMgIo+Z0PIgq9EwSD7o= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from eig-obgw-5003a.ext.cloudfilter.net ([10.0.29.159]) by cmsmtp with ESMTPS id 5BpmrSOJM8Hte5Hp9rHZWA; Tue, 21 Nov 2023 03:53:19 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id 5Hp8rBK9GnCfv5Hp9rIOMC; Tue, 21 Nov 2023 03:53:19 +0000 X-Authority-Analysis: v=2.4 cv=KKpJsXJo c=1 sm=1 tr=0 ts=655c29af 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=B_Tv2JfvxkIVyvo0GuEA:9 a=QEXdDO2ut3YA:10 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=To:In-Reply-To:References:Message-Id:Content-Transfer-Encoding: Content-Type:MIME-Version:Subject:Date:From:Sender:Reply-To:Cc:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=lXSv5FX6HR2vHVE7LSOct9FQnlLcuLQwyVC3I9CG6KI=; b=juSgEIOONxcSdClGo+SaUNzPHX H6wREyFKTV9pVfxpD5/eYAM3DarSqMRwaM7A2kVxnjzK1zTK29c8KulOavOcfqzgiKGhQfh6Q+aoY n/7QPzFyu7wVAgrR1EgTJ9zwj; 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-1r for gdb-patches@sourceware.org; Mon, 20 Nov 2023 20:53:18 -0700 From: Tom Tromey Date: Mon, 20 Nov 2023 20:53:33 -0700 Subject: [PATCH 02/29] Small cleanup in DWARF reader MIME-Version: 1.0 Message-Id: <20231120-submit-domain-hacks-2-v1-2-29650d01b198@tromey.com> References: <20231120-submit-domain-hacks-2-v1-0-29650d01b198@tromey.com> In-Reply-To: <20231120-submit-domain-hacks-2-v1-0-29650d01b198@tromey.com> 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-1r 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: 3 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfH1GAvlYAvLr6qxhVgmJvJ3lw/HwV0sI2dy+Z4Vq65lCWElMX5x0jxf/c7NWSyJ5OmuKT6jd/ivoJtNidGaG5Jd5DR8P+Vrqx5uxfX8I0ItIQVPkjWCf OGjw/kMKJAazAskR6inOOz6BPpiiEu//Zx2O4cXq9AlQrxrtIJ5kuqfxPuMAvEXFVKo2kaJVRMQ0YwY4fg34Vk0PxjTwPdphvg0= X-Spam-Status: No, score=-3023.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_STOCKGEN, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham 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 I noticed a couple of spots in the dwarf/read.c:new_symbol that call add_symbol_to_list. However, this function is generally written to set list_to_add, and then have a single call to add_symbol_to_list at the end. This patch cleans up this discrepancy. Note that new_symbol is overlong and should probably be split up. --- gdb/dwarf2/read.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 1aca36e6179..d0c21967809 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -18968,7 +18968,7 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu, sym->set_aclass_index (LOC_OPTIMIZED_OUT); sym->set_type (builtin_type (objfile)->builtin_core_addr); sym->set_domain (LABEL_DOMAIN); - add_symbol_to_list (sym, cu->list_in_scope); + list_to_add = cu->list_in_scope; break; case DW_TAG_subprogram: /* SYMBOL_BLOCK_VALUE (sym) will be filled in later by @@ -19293,7 +19293,7 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu, case DW_TAG_common_block: sym->set_aclass_index (LOC_COMMON_BLOCK); sym->set_domain (COMMON_BLOCK_DOMAIN); - add_symbol_to_list (sym, cu->list_in_scope); + list_to_add = cu->list_in_scope; break; default: /* Not a tag we recognize. Hopefully we aren't processing From patchwork Tue Nov 21 03:53:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 80392 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 7BC5F385829A for ; Tue, 21 Nov 2023 03:53:40 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from omta040.useast.a.cloudfilter.net (omta040.useast.a.cloudfilter.net [44.202.169.39]) by sourceware.org (Postfix) with ESMTPS id 0EA8E3858D38 for ; Tue, 21 Nov 2023 03:53:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0EA8E3858D38 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 0EA8E3858D38 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=44.202.169.39 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700538802; cv=none; b=kHk8LQ17wK0kDGsarwTAeE5Getsq/hxTlM4DBarxOe3noe9dGgHfaq/q/F3FWWrXwt+AZjfKyWRV7KK+EVZNH/YnLkyqScCyMomYN5fqo1ssbXA8kKgmX4WzTwzP6YMGnS2zrLlbxmvUAGqrbUPLHdWz52XO1liNmPwd4uvNHes= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700538802; c=relaxed/simple; bh=BTkfsC3nsDr9n9xeiRVjnA24KTOSHroRiTr6lD+nmSE=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=ZmmWV6NhtAnlLWaJ3mc/SyK5SBnVRYG7A2fAT1h3GU6KftZWl2127mlvraoPgeJPxlr3LiThSBGLBmKXBPbwg46WwhhE3F3gsvj3aSs92KAUHQ70N4lNHGHGck4CcIt026S+u9ZW0z+/fcSSrASCOp9t1AXCJ0GrqhBAKqRgg9o= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from eig-obgw-5001a.ext.cloudfilter.net ([10.0.29.139]) by cmsmtp with ESMTPS id 5Bpyrpjok6nOZ5Hp9rzrP0; Tue, 21 Nov 2023 03:53:19 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id 5Hp8rCu7nkTVW5Hp9r6qRp; Tue, 21 Nov 2023 03:53:19 +0000 X-Authority-Analysis: v=2.4 cv=a58jSGeF c=1 sm=1 tr=0 ts=655c29af 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=eoaZ9IUwQebqolqbARkA:9 a=QEXdDO2ut3YA:10 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=To:In-Reply-To:References:Message-Id:Content-Transfer-Encoding: Content-Type:MIME-Version:Subject:Date:From:Sender:Reply-To:Cc:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=glmK8V+hbgNASKf4HzWOgrO4LVanGvZNgIN266fIBFc=; b=cGQ5m74/bQKvtucTy9oZEptTwx 5H7OJqmdkGvqOseQyWm92zDHRAxcWn27hPqsn5MBMbxoH1mzjqDIUrjTVDTNQgv/DRlK1Y2v+aR8r Lcef91nZxZYHdZsvzhlGmlJEc; 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-2K for gdb-patches@sourceware.org; Mon, 20 Nov 2023 20:53:18 -0700 From: Tom Tromey Date: Mon, 20 Nov 2023 20:53:34 -0700 Subject: [PATCH 03/29] Make nsalias.exp more reliable MIME-Version: 1.0 Message-Id: <20231120-submit-domain-hacks-2-v1-3-29650d01b198@tromey.com> References: <20231120-submit-domain-hacks-2-v1-0-29650d01b198@tromey.com> In-Reply-To: <20231120-submit-domain-hacks-2-v1-0-29650d01b198@tromey.com> 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-2K 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: 4 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfOZw1r9TPullGFA6yDiVfNWHH0HtsiCJrs9bOJRp8z8969CDaCScYGGqSK2PJhDafkwaGKIl6DE0CFQQTSuaYIroPXfu+8tgbzgvMDekcXooYVohaOvz tAOun3XGaO/+vkn6/Rt9itbcKSwllnMs9NTn4HgTq1/fQJnq2zT7CaYjlFRllD/txD+4hnz1S/Lgu/IY99xnxRLIONPIksU3h6Q= X-Spam-Status: No, score=-3024.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham 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 nsalias.exp tries to detect a complaint that is issued when expanding a CU. However, the test is a bit funny in that, while gdb does currently expand the CU and issue the complaint, it also emits this error: No symbol "N100" in current context. This series will change gdb such that this CU is not expanded -- which makes sense, the symbol in question doesn't actually match the lookups that are done. So, to make the test more robust, a direct request to expand symtabs is done instead. --- gdb/testsuite/gdb.cp/nsalias.exp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gdb/testsuite/gdb.cp/nsalias.exp b/gdb/testsuite/gdb.cp/nsalias.exp index 2727041f074..9c919948f11 100644 --- a/gdb/testsuite/gdb.cp/nsalias.exp +++ b/gdb/testsuite/gdb.cp/nsalias.exp @@ -324,5 +324,5 @@ if { $readnow_p } { global gdb_file_cmd_msg gdb_assert {[regexp $re $gdb_file_cmd_msg]} $test } else { - gdb_test "print N100::x" $re $test + gdb_test "maint expand-symtabs" $re $test } From patchwork Tue Nov 21 03:53:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 80402 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 5481F3858439 for ; Tue, 21 Nov 2023 03:54:40 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from omta34.uswest2.a.cloudfilter.net (omta34.uswest2.a.cloudfilter.net [35.89.44.33]) by sourceware.org (Postfix) with ESMTPS id F09AE3858C98 for ; Tue, 21 Nov 2023 03:53:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org F09AE3858C98 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 F09AE3858C98 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=35.89.44.33 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700538804; cv=none; b=SwK4NS6OQ5LvDGWoBufgcSuKjSJNQeZMxil71pfkdWCYo0pX4jRuVvXXw+ELENjoRtYdsfbp+1486Q9XlXqLqjQOCIW+OXEdwTNq/19kwGd+gGeWfpPF2uxNjWg4HVXno09hT4TWwo6usq4Q3VZdq+ZgzLIUz2HJDAB3oacDD0A= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700538804; c=relaxed/simple; bh=jhmg/Ywi+OfSpzmzECHXqvEpVWL6d834YzdcybaTXDI=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=hCBYjxSJ4R/HrzmCrNVsbsqgnMPB1rfCPOyBQX2O2yRNHkKgtidssZkGrrhL/96yWsIW10T3cj/o52vsrwhaSdGFlI2jAdKawVFxmlceQ29lGqULqddIxMfOVKxi4s5DdcHqs7QRnzZhjwZQeiLjlsUeBy4cvDRRMK+6CuCU9z0= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from eig-obgw-6001a.ext.cloudfilter.net ([10.0.30.140]) by cmsmtp with ESMTPS id 5BpmrSOJy8Hte5HpArHZWF; Tue, 21 Nov 2023 03:53:20 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id 5Hp9rwHxJb8Qn5Hp9r3fjQ; Tue, 21 Nov 2023 03:53:19 +0000 X-Authority-Analysis: v=2.4 cv=IuQNzZzg c=1 sm=1 tr=0 ts=655c29af 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=pfhLtNyfPs45aFG1YTEA:9 a=QEXdDO2ut3YA:10 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=To:In-Reply-To:References:Message-Id:Content-Transfer-Encoding: Content-Type:MIME-Version:Subject:Date:From:Sender:Reply-To:Cc:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=ZfbohtmvFd93cUKqi987Fd02MrPt6MsVWj+xEIv5eIg=; b=KYdur3OAlpL/GVJr27Sr9nwjtn WCIQKtt/IDIGnIGgNQt8UI621ckVDCFY5RmIZabcPnXelkQjr19Ukx5vOfaSsdypyD+9O62xRj/1o PAvYuH7kknUcRu1IW/Nf0SS+w; 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-2o for gdb-patches@sourceware.org; Mon, 20 Nov 2023 20:53:18 -0700 From: Tom Tromey Date: Mon, 20 Nov 2023 20:53:35 -0700 Subject: [PATCH 04/29] Fix latent bug in mdebugread.c MIME-Version: 1.0 Message-Id: <20231120-submit-domain-hacks-2-v1-4-29650d01b198@tromey.com> References: <20231120-submit-domain-hacks-2-v1-0-29650d01b198@tromey.com> In-Reply-To: <20231120-submit-domain-hacks-2-v1-0-29650d01b198@tromey.com> 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-2o 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: 5 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfOOKDtDtZym7TwLQMYnpneKg1rxwVLSKpNiBDRF3jZZPAjPSJOd7PwQR9TzIXdbvcNJ2J7xTnFzphspoyW00DeMkuJbQKDDtUrQkgAm8SS9cjelQfuhG tVsQfYeYs3QGszaHMuRBKkv+YuQbpwinDnKEbh8PJSLpBep6zrLyPUXNAb5W/8Cu7iBFifBQRMKRbwJV9RJSzXMG1gbwHIRfPtU= X-Spam-Status: No, score=-3024.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham 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 mdebugread.c makes a label symbol but puts it into VAR_DOMAIN. I think LABEL_DOMAIN is more appropriate. I don't have a way to test this. --- gdb/mdebugread.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c index cd6638224e7..02cd0dc43d5 100644 --- a/gdb/mdebugread.c +++ b/gdb/mdebugread.c @@ -711,7 +711,7 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend, case stLabel: /* label, goes into current block. */ s = new_symbol (name); - s->set_domain (VAR_DOMAIN); /* So that it can be used */ + s->set_domain (LABEL_DOMAIN); /* So that it can be used */ s->set_aclass_index (LOC_LABEL); /* but not misused. */ s->set_section_index (section_index); s->set_value_address (sh->value); From patchwork Tue Nov 21 03:53:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 80393 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 C63973858436 for ; Tue, 21 Nov 2023 03:53:46 +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 2362C3858D39 for ; Tue, 21 Nov 2023 03:53:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2362C3858D39 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 2362C3858D39 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=aDmkanlPIkr90/xMe0t28ExyMhgUrgiifaBAk6YOfbDRMltkhf5bqd8JLsPS2yXAHK+nBCie6dN6KlibgBHSWzgPBgoN2g8travVJbp3IcfxebwDP38ql82YGWZaCZtpFbgVyQhTPW/ymdRh+JVcV+ivN/CLfqsWX9CPhKp0ARc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700538802; c=relaxed/simple; bh=cUcCYzXzQ0XfeNhyFLGLoJeKK5ZdRW+wdskIfFAdJec=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=W6uHCdTzyioBQhr8Gz3MClrEH3dOKAl34cbGCGm11AMJq+acnoJAPlv0/D43eMAYB6BYBlJC3AhofAfJc9Zc7uQx++8QNJHpxxWHFvXR1X/xkZcvK2FVodnZlHY51O3jKhGl4vzR/RfXgFaJ4rPSp5ZqSHS4H4ymW0RG45lr4+k= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from eig-obgw-5001a.ext.cloudfilter.net ([10.0.29.139]) by cmsmtp with ESMTPS id 5BpyrnKQ7WcCI5Hp9rZVLH; Tue, 21 Nov 2023 03:53:19 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id 5Hp9rCu7skTVW5Hp9r6qRx; Tue, 21 Nov 2023 03:53:19 +0000 X-Authority-Analysis: v=2.4 cv=a58jSGeF c=1 sm=1 tr=0 ts=655c29af 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=1fc2yS3rMq-BXBd_2S0A:9 a=QEXdDO2ut3YA:10 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=To:In-Reply-To:References:Message-Id:Content-Transfer-Encoding: Content-Type:MIME-Version:Subject:Date:From:Sender:Reply-To:Cc:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=wABP52SOZiYBYYmWsUAT2+kuWPqwpduV2EHG3hmDDFo=; b=SbYujns2X3F1RP25xSzalPMeeN MzYSj3xB9zrN2f0wJ0Tm/wDlV5YzFUQJGjFNfTcoqF9v7Nt2tuM/I5/8VfAeZcCxITXv+gQWbcKlg 3SIAynGvn3DORQK0b67cR4gQq; 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 1r5Hp9-0040be-00 for gdb-patches@sourceware.org; Mon, 20 Nov 2023 20:53:19 -0700 From: Tom Tromey Date: Mon, 20 Nov 2023 20:53:36 -0700 Subject: [PATCH 05/29] Give names to unspecified types MIME-Version: 1.0 Message-Id: <20231120-submit-domain-hacks-2-v1-5-29650d01b198@tromey.com> References: <20231120-submit-domain-hacks-2-v1-0-29650d01b198@tromey.com> In-Reply-To: <20231120-submit-domain-hacks-2-v1-0-29650d01b198@tromey.com> 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: 1r5Hp9-0040be-00 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: 6 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfOZw1r9TPullGFA6yDiVfNWHH0HtsiCJrs9bOJRp8z8969CDaCScYGGqSK2PJhDafkwaGKIl6DE0CFQQTSuaYIroPXfu+8tgbzgvMDekcXooYVohaOvz tAOun3XGaO/+vkn6/Rt9itbcKSwllnMs9NTn4HgTq1/fQJnq2zT7CaYjlFRllD/txD+4hnz1S/Lgu/IY99xnxRLIONPIksU3h6Q= X-Spam-Status: No, score=-3024.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham 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 A patch later in this series will change check_typedef to also look in the type domain. This change by itself caused a regression, but one that revealed some peculiar behavior. The regression is in nullptr_t.exp, where examining a std::nullptr_t will change from the correct: typedef decltype(nullptr) std::nullptr_t; to typedef void std::nullptr_t; Right now, the DWARF reader marks all unspecified types as stub types. However, this interacts weirdly with check_typedef, which currently does not try to resolve types -- only struct-domain objects. My first attempt here was to fix this by changing void types not to be stub types, as I didn't see what value that provided. However, this caused another regression, because call_function_by_hand_dummy checks for stub-ness: if (values_type == NULL || values_type->is_stub ()) values_type = default_return_type; I'm not really sure why it does this rather than check for TYPE_CODE_VOID. While looking into this, I found another oddity: the DWARF reader correctly creates a type named 'decltype(nullptr)' when it seems a DW_TAG_unspecified_type -- but it creates a symbol named "void" instead. This patch changes the DWARF reader to give the symbol the correct name. This avoids the regression. --- gdb/dwarf2/read.c | 1 + 1 file changed, 1 insertion(+) diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index d0c21967809..aa44d19b517 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -6541,6 +6541,7 @@ process_die (struct die_info *die, struct dwarf2_cu *cu) case DW_TAG_subrange_type: case DW_TAG_generic_subrange: case DW_TAG_typedef: + case DW_TAG_unspecified_type: /* Add a typedef symbol for the type definition, if it has a DW_AT_name. */ new_symbol (die, read_type_die (die, cu), cu); From patchwork Tue Nov 21 03:53:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 80395 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 7D98E385840B for ; Tue, 21 Nov 2023 03:54:08 +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 C88D73858CD1 for ; Tue, 21 Nov 2023 03:53:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C88D73858CD1 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 C88D73858CD1 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=1700538803; cv=none; b=xwkYzWy5HSGwSCuo1d1v3xe6TyLpqEzc/bDHlWZQF7LC+po37ZcuE5wQHVHJn8Qgxuko4KC1GrC+1zXiucBZp25jkcD26qhwkRwPDCiZWrQiv+kuuuAC/5klEMwLigkXQU7ssgPqypgbSx81I7KZl7lVo0jwQN2XK79jk4g2eWA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700538803; c=relaxed/simple; bh=lTwt4TRThKGWaYyF2xSS3HHunSH5xJ7WAfgT1xlQTCQ=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=Qer+kRXva3to1LNnlUnKHhqoyCXj/NOYvcqWRnMy5bKvlq262FTguOoHU6n/3y5hP/Avjsaofr8Q6o0EOb+lebJ5nRoim5ZwjeDSDK+K4ODTvhZLvFhmqfXCu9UE7pVBFmIJQ8FbHvST67AQc7QXubFHbfuqkg53bXFaWY3aMPQ= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from eig-obgw-6010a.ext.cloudfilter.net ([10.0.30.248]) by cmsmtp with ESMTPS id 5C7SrnOYzWcCI5HpArZVLL; Tue, 21 Nov 2023 03:53:20 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id 5Hp9rSMJN8vT05Hp9rMCxD; Tue, 21 Nov 2023 03:53:19 +0000 X-Authority-Analysis: v=2.4 cv=ffi+dmcF c=1 sm=1 tr=0 ts=655c29af 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=j2nSuGdwE-VHdcfjFbAA:9 a=QEXdDO2ut3YA:10 a=ZXulRonScM0A:10 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=To:In-Reply-To:References:Message-Id:Content-Transfer-Encoding: Content-Type:MIME-Version:Subject:Date:From:Sender:Reply-To:Cc:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=Qm2+Kcf75Hn3tn2MclzAEf3tD0pwcpxo1CcerF0iq4g=; b=rIUVjvKlisai5/3ynabsD369cO HARRthq1idnBYv9QJNmWQFzY8Fq5+cVKPMpQI1il1uISZxtOK4FczesUr15rl6XIfHCXhQj9cmwFa 7KNfO6+C6KpiysTJY7DSi/NFv; 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 1r5Hp9-0040be-0S for gdb-patches@sourceware.org; Mon, 20 Nov 2023 20:53:19 -0700 From: Tom Tromey Date: Mon, 20 Nov 2023 20:53:37 -0700 Subject: [PATCH 06/29] Remove NR_DOMAINS MIME-Version: 1.0 Message-Id: <20231120-submit-domain-hacks-2-v1-6-29650d01b198@tromey.com> References: <20231120-submit-domain-hacks-2-v1-0-29650d01b198@tromey.com> In-Reply-To: <20231120-submit-domain-hacks-2-v1-0-29650d01b198@tromey.com> 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: 1r5Hp9-0040be-0S 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: 7 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfJQT0U4fZia3XKdM7CeA0PKFRbaNXZorFrPUKwe4oCorCLtWMVBfwg7wigCMow5XS+/93UR2jnDhLzugH+zF8dHUcr2eQPPwkGY6XQ5/oPuGUG2fCiQq Z95jLXSKxW8pva8xXrsHmDq1DUc+IqV6VCJDIKhfMFExoHTOxhiyNDT0NEKfa/JBLSfZHRj+Qiz1fWlNVJ6IDhEqkLnB9qQHKGk= X-Spam-Status: No, score=-3023.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_STOCKGEN, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham 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 NR_DOMAINS is only used for a static assert, but we no longer need it now. If we add too many constants to this enum, GCC will warn about the bitfield overflow: error: ‘symbol::m_domain’ is too small to hold all values of ‘enum domain_enum’ --- gdb/symtab.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/gdb/symtab.h b/gdb/symtab.h index 8dfc873b1c9..21c84cbe006 100644 --- a/gdb/symtab.h +++ b/gdb/symtab.h @@ -916,15 +916,11 @@ enum domain_enum /* Fortran common blocks. Their naming must be separate from VAR_DOMAIN. They also always use LOC_COMMON_BLOCK. */ COMMON_BLOCK_DOMAIN, - - /* This must remain last. */ - NR_DOMAINS }; /* The number of bits in a symbol used to represent the domain. */ #define SYMBOL_DOMAIN_BITS 3 -gdb_static_assert (NR_DOMAINS <= (1 << SYMBOL_DOMAIN_BITS)); extern const char *domain_name (domain_enum); From patchwork Tue Nov 21 03:53:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 80394 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 69126385840E for ; Tue, 21 Nov 2023 03:53:53 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from omta040.useast.a.cloudfilter.net (omta040.useast.a.cloudfilter.net [44.202.169.39]) by sourceware.org (Postfix) with ESMTPS id A1E303858D3C for ; Tue, 21 Nov 2023 03:53:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A1E303858D3C 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 A1E303858D3C Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=44.202.169.39 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700538802; cv=none; b=V9ZV+AgPRUsvAIfl3HlSeFQpMpjxPgmSkAVUyjN49yvHhP5dlyfiren3iC2K/XjhDxPzmaCyHiKO6A2pBba/YqK0k6DP6xXVMoKTGjpb2G1S9HlBGLlMavHYxXmCTbwUZB6A1tvtyizaeAwswoUBEEltHOnaAr4VXXT0FcsKq3Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700538802; c=relaxed/simple; bh=yz4bqxH6115JZxyYFGXVhBvZatjTgzmlTXwyHRlW0KE=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=jRth2rSsn8oEq+eZN+hF95g1uveUBCxQlvRxlrscQ3bJQM09p53X8qQM0RF9ksN/KQCK6gZ7ZkpfBXNSffIYQJ2ZCU++mAy+9lPAlZ28qwEZpcpo/idvlulZEWN5TwJg9cdNDQK8YWuLjCLLN4nJGagyFdHOjyVXvA44bl3KpvQ= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from eig-obgw-6006a.ext.cloudfilter.net ([10.0.30.182]) by cmsmtp with ESMTPS id 520arn4qY6nOZ5HpArzrP7; Tue, 21 Nov 2023 03:53:20 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id 5Hp9rEg3nGKIc5Hp9rxrMv; Tue, 21 Nov 2023 03:53:19 +0000 X-Authority-Analysis: v=2.4 cv=E+beGIRl c=1 sm=1 tr=0 ts=655c29af 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=cCc6LzOX12iO7udG6-IA:9 a=QEXdDO2ut3YA:10 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=To:In-Reply-To:References:Message-Id:Content-Transfer-Encoding: Content-Type:MIME-Version:Subject:Date:From:Sender:Reply-To:Cc:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=52cZKN//gJYibADxzMb4fH4/04dNy/VaWMzKZF3P4pY=; b=YOLVirEN2A5/B3UTsIv64lJX+1 0sFqnoLV62YuxPIkghGYy01k9Y78DlzoKVIZcR1upP1IEh1/NK0n2FTwcFOab/In9Ds06+U79o0+f iUrpL7yiQOavdcNxv/02fbEhQ; 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 1r5Hp9-0040be-0w for gdb-patches@sourceware.org; Mon, 20 Nov 2023 20:53:19 -0700 From: Tom Tromey Date: Mon, 20 Nov 2023 20:53:38 -0700 Subject: [PATCH 07/29] Simplify symbol_to_info_string MIME-Version: 1.0 Message-Id: <20231120-submit-domain-hacks-2-v1-7-29650d01b198@tromey.com> References: <20231120-submit-domain-hacks-2-v1-0-29650d01b198@tromey.com> In-Reply-To: <20231120-submit-domain-hacks-2-v1-0-29650d01b198@tromey.com> 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: 1r5Hp9-0040be-0w 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: 8 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfNe/jyH1QdgT8ORa67r7bxITDv1C+cJBIQbWujccnzFBf759BRMze/ONiIrzZCzWiZe6mJA8ITQmw5O/a3cpB5CMkYmpt7wl9Wo/JCL/sfFcwsRuLMad jqD0j5vvf8bZd7Kc+4M+Zy0Zf0B2sgpD6yKRL8B6jaP+rWgCQP4z9qy82luNeBm75rfuhafvknRB2LO7UbehD2MRyJZEltnKiFI= X-Spam-Status: No, score=-3024.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham 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 Thi simplifies symbol_to_info_string, removing the 'kind' parameter and instead having it use the symbol's domain. --- gdb/mi/mi-symbol-cmds.c | 2 +- gdb/symtab.c | 44 ++++++++++++++++++-------------------------- gdb/symtab.h | 6 ++---- 3 files changed, 21 insertions(+), 31 deletions(-) diff --git a/gdb/mi/mi-symbol-cmds.c b/gdb/mi/mi-symbol-cmds.c index d26378e8310..7492d007fba 100644 --- a/gdb/mi/mi-symbol-cmds.c +++ b/gdb/mi/mi-symbol-cmds.c @@ -87,7 +87,7 @@ output_debug_symbol (ui_out *uiout, enum search_domain kind, type_print (sym->type (), "", &tmp_stream, -1); uiout->field_string ("type", tmp_stream.string ()); - std::string str = symbol_to_info_string (sym, block, kind); + std::string str = symbol_to_info_string (sym, block); uiout->field_string ("description", str); } } diff --git a/gdb/symtab.c b/gdb/symtab.c index 5ec56f4f2af..6abebcd929c 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -4957,19 +4957,19 @@ global_symbol_searcher::search () const /* See symtab.h. */ std::string -symbol_to_info_string (struct symbol *sym, int block, - enum search_domain kind) +symbol_to_info_string (struct symbol *sym, int block) { std::string str; gdb_assert (block == GLOBAL_BLOCK || block == STATIC_BLOCK); - if (kind != TYPES_DOMAIN && block == STATIC_BLOCK) + if (block == STATIC_BLOCK + && sym->domain () == VAR_DOMAIN + && sym->aclass () != LOC_TYPEDEF) str += "static "; /* Typedef that is not a C++ class. */ - if (kind == TYPES_DOMAIN - && sym->domain () != STRUCT_DOMAIN) + if (sym->domain () == VAR_DOMAIN && sym->aclass () == LOC_TYPEDEF) { string_file tmp_stream; @@ -4988,9 +4988,7 @@ symbol_to_info_string (struct symbol *sym, int block, str += tmp_stream.string (); } /* variable, func, or typedef-that-is-c++-class. */ - else if (kind < TYPES_DOMAIN - || (kind == TYPES_DOMAIN - && sym->domain () == STRUCT_DOMAIN)) + else if (sym->domain () == VAR_DOMAIN || sym->domain () == STRUCT_DOMAIN) { string_file tmp_stream; @@ -5005,23 +5003,21 @@ symbol_to_info_string (struct symbol *sym, int block, /* Printing of modules is currently done here, maybe at some future point we might want a language specific method to print the module symbol so that we can customise the output more. */ - else if (kind == MODULES_DOMAIN) + else if (sym->domain () == MODULE_DOMAIN) str += sym->print_name (); return str; } -/* Helper function for symbol info commands, for example 'info functions', - 'info variables', etc. KIND is the kind of symbol we searched for, and - BLOCK is the type of block the symbols was found in, either GLOBAL_BLOCK - or STATIC_BLOCK. SYM is the symbol we found. If LAST is not NULL, - print file and line number information for the symbol as well. Skip - printing the filename if it matches LAST. */ +/* Helper function for symbol info commands, for example 'info + functions', 'info variables', etc. BLOCK is the type of block the + symbols was found in, either GLOBAL_BLOCK or STATIC_BLOCK. SYM is + the symbol we found. If LAST is not NULL, print file and line + number information for the symbol as well. Skip printing the + filename if it matches LAST. */ static void -print_symbol_info (enum search_domain kind, - struct symbol *sym, - int block, const char *last) +print_symbol_info (struct symbol *sym, int block, const char *last) { scoped_switch_to_sym_language_if_auto l (sym); struct symtab *s = sym->symtab (); @@ -5043,7 +5039,7 @@ print_symbol_info (enum search_domain kind, gdb_puts ("\t"); } - std::string str = symbol_to_info_string (sym, block, kind); + std::string str = symbol_to_info_string (sym, block); gdb_printf ("%s\n", str.c_str ()); } @@ -5139,10 +5135,7 @@ symtab_symbol_info (bool quiet, bool exclude_minsyms, } else { - print_symbol_info (kind, - p.symbol, - p.block, - last_filename); + print_symbol_info (p.symbol, p.block, last_filename); last_filename = symtab_to_filename_for_display (p.symbol->symtab ()); } @@ -5378,7 +5371,7 @@ rbreak_command (const char *regexp, int from_tty) string = string_printf ("%s:'%s'", fullname, p.symbol->linkage_name ()); break_command (&string[0], from_tty); - print_symbol_info (FUNCTIONS_DOMAIN, p.symbol, p.block, NULL); + print_symbol_info (p.symbol, p.block, nullptr); } else { @@ -6739,8 +6732,7 @@ info_module_subcommand (bool quiet, const char *module_regexp, last_filename = ""; } - print_symbol_info (FUNCTIONS_DOMAIN, q.symbol, q.block, - last_filename); + print_symbol_info (q.symbol, q.block, last_filename); last_filename = symtab_to_filename_for_display (q.symbol->symtab ()); } diff --git a/gdb/symtab.h b/gdb/symtab.h index 21c84cbe006..71d37e84a43 100644 --- a/gdb/symtab.h +++ b/gdb/symtab.h @@ -2639,11 +2639,9 @@ extern std::vector search_module_symbols /* Convert a global or static symbol SYM (based on BLOCK, which should be either GLOBAL_BLOCK or STATIC_BLOCK) into a string for use in 'info' - type commands (e.g. 'info variables', 'info functions', etc). KIND is - the type of symbol that was searched for which gave us SYM. */ + type commands (e.g. 'info variables', 'info functions', etc). */ -extern std::string symbol_to_info_string (struct symbol *sym, int block, - enum search_domain kind); +extern std::string symbol_to_info_string (struct symbol *sym, int block); extern bool treg_matches_sym_type_name (const compiled_regex &treg, const struct symbol *sym); From patchwork Tue Nov 21 03:53:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 80398 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 873543858439 for ; Tue, 21 Nov 2023 03:54:24 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from omta034.useast.a.cloudfilter.net (omta034.useast.a.cloudfilter.net [44.202.169.33]) by sourceware.org (Postfix) with ESMTPS id 028043858C50 for ; Tue, 21 Nov 2023 03:53:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 028043858C50 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 028043858C50 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=44.202.169.33 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700538803; cv=none; b=j/VMTMZX0QEug88kXWVpGHeFxsB8/dfaQribXhKrMCnsGXG13AL+FrT1sWiWR2zjZAXkxVWixkHsCsasdd4jJxgRFXbhlUwc2AK02c/qQ1+A1p72UOpmYFHrR/NnUSVXcob0909U5plueJm4baKBJL7WqADnW5pVSyCf2VDxGkc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700538803; c=relaxed/simple; bh=najN2t/t6MxhweWQk4mL2w4afdgYN0iAatqrYM7ngNo=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=mfD5GtCVOFFyzuBx4IjkUXhqabKz0rSzgcSyX8HzUkvp2ah78MA7GFeS0mpI3GTdBZxTtDIdZ69QDYj2cnn47htpkGKeG9aAHt+O2fCBicC1yOg0bBQrNhpfruOeQiTiX7BJSGIBjTKu0A7ca+cA0ALIu/lFpQX7BxSu6a2jwZc= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from eig-obgw-6003a.ext.cloudfilter.net ([10.0.30.151]) by cmsmtp with ESMTPS id 5BpqrOjv5jtZ35HpFrWync; Tue, 21 Nov 2023 03:53:25 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id 5Hp9r0SroAKSc5Hp9rxntn; Tue, 21 Nov 2023 03:53:20 +0000 X-Authority-Analysis: v=2.4 cv=N6w6qkxB c=1 sm=1 tr=0 ts=655c29b0 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=TmsUUf6PHUkJMu_j2N4A:9 a=QEXdDO2ut3YA:10 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=To:In-Reply-To:References:Message-Id:Content-Transfer-Encoding: Content-Type:MIME-Version:Subject:Date:From:Sender:Reply-To:Cc:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=1rJpysJvNKyULzyCMnB/05JNWNwmfvRq3Kl4AsdkU0c=; b=qoEKZB8Wm3RE8953tmU2+oYi1S fuVQjwp/q4I9z1iTJRBpLo72Qg1Oj7dg4qaVWL+Rw7xBl6iHHSd3ljlvcYxuH5SNViidnA+svXUnE nUcxhjVjY3svCkFRNqLG37UDH; 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 1r5Hp9-0040be-1M for gdb-patches@sourceware.org; Mon, 20 Nov 2023 20:53:19 -0700 From: Tom Tromey Date: Mon, 20 Nov 2023 20:53:39 -0700 Subject: [PATCH 08/29] Split up a big 'if' in symtab.c MIME-Version: 1.0 Message-Id: <20231120-submit-domain-hacks-2-v1-8-29650d01b198@tromey.com> References: <20231120-submit-domain-hacks-2-v1-0-29650d01b198@tromey.com> In-Reply-To: <20231120-submit-domain-hacks-2-v1-0-29650d01b198@tromey.com> 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: 1r5Hp9-0040be-1M 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: 9 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfEbxxsK8mkTuMJZfrMZ8TLFsRZ0ngxl7P7qZ6a3hDrB+hu4ilgf0FC2382XExPf75lmbkB5YdBVs7TJvtBmGa/Nv6XbaIPWzNXW1CvBrf5gHLnbB/gTS suWD5K4bD/TVqciW0Igtsg7w6Z38BiD4XB1rydAXoHdBcuiytkJ0Di9jMJ3YnZFoGtrg4BtMkSJ33JHlcMgimckM2RyfzkiQMKs= X-Spam-Status: No, score=-3024.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham 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 global_symbol_searcher::add_matching_symbols in symtab.c has a gigantic 'if' statement -- 33 lines of conditional expression. This patch splits it up into a series of separate 'if's. --- gdb/symtab.c | 83 ++++++++++++++++++++++++++++++++++++------------------------ 1 file changed, 50 insertions(+), 33 deletions(-) diff --git a/gdb/symtab.c b/gdb/symtab.c index 6abebcd929c..9e28edff7b4 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -4758,39 +4758,56 @@ global_symbol_searcher::add_matching_symbols /* Check first sole REAL_SYMTAB->FILENAME. It does not need to be a substring of symtab_to_fullname as it may contain "./" etc. */ - if ((file_matches (real_symtab->filename, filenames, false) - || ((basenames_may_differ - || file_matches (lbasename (real_symtab->filename), - filenames, true)) - && file_matches (symtab_to_fullname (real_symtab), - filenames, false))) - && ((!preg.has_value () - || preg->exec (sym->natural_name (), 0, - NULL, 0) == 0) - && ((kind == VARIABLES_DOMAIN - && sym->aclass () != LOC_TYPEDEF - && sym->aclass () != LOC_UNRESOLVED - && sym->aclass () != LOC_BLOCK - /* LOC_CONST can be used for more than - just enums, e.g., c++ static const - members. We only want to skip enums - here. */ - && !(sym->aclass () == LOC_CONST - && (sym->type ()->code () - == TYPE_CODE_ENUM)) - && (!treg.has_value () - || treg_matches_sym_type_name (*treg, sym))) - || (kind == FUNCTIONS_DOMAIN - && sym->aclass () == LOC_BLOCK - && (!treg.has_value () - || treg_matches_sym_type_name (*treg, - sym))) - || (kind == TYPES_DOMAIN - && sym->aclass () == LOC_TYPEDEF - && sym->domain () != MODULE_DOMAIN) - || (kind == MODULES_DOMAIN - && sym->domain () == MODULE_DOMAIN - && sym->line () != 0)))) + if (!(file_matches (real_symtab->filename, filenames, false) + || ((basenames_may_differ + || file_matches (lbasename (real_symtab->filename), + filenames, true)) + && file_matches (symtab_to_fullname (real_symtab), + filenames, false)))) + continue; + + if (preg.has_value () && !preg->exec (sym->natural_name (), 0, + nullptr, 0) == 0) + continue; + + bool matches = false; + if (!matches && kind == VARIABLES_DOMAIN) + { + if (sym->aclass () != LOC_TYPEDEF + && sym->aclass () != LOC_UNRESOLVED + && sym->aclass () != LOC_BLOCK + /* LOC_CONST can be used for more than + just enums, e.g., c++ static const + members. We only want to skip enums + here. */ + && !(sym->aclass () == LOC_CONST + && (sym->type ()->code () + == TYPE_CODE_ENUM)) + && (!treg.has_value () + || treg_matches_sym_type_name (*treg, sym))) + matches = true; + } + if (!matches && kind == FUNCTIONS_DOMAIN) + { + if (sym->aclass () == LOC_BLOCK + && (!treg.has_value () + || treg_matches_sym_type_name (*treg, + sym))) + matches = true; + } + if (!matches && kind == TYPES_DOMAIN) + { + if (sym->aclass () == LOC_TYPEDEF + && sym->domain () != MODULE_DOMAIN) + matches = true; + } + if (!matches && kind == MODULES_DOMAIN) + { + if (sym->domain () == MODULE_DOMAIN + && sym->line () != 0) + matches = true; + } + if (matches) { if (result_set->size () < m_max_search_results) { From patchwork Tue Nov 21 03:53:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 80397 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 037333858298 for ; Tue, 21 Nov 2023 03:54:20 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from omta034.useast.a.cloudfilter.net (omta034.useast.a.cloudfilter.net [44.202.169.33]) by sourceware.org (Postfix) with ESMTPS id DCDBC3858CDA for ; Tue, 21 Nov 2023 03:53:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DCDBC3858CDA 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 DCDBC3858CDA Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=44.202.169.33 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700538804; cv=none; b=RmW5qjpmHqXb0h98RRwh4azItEdI5KOSLD0Iw0Lewfw1QWWEE0XbuhWOES8hg7IEV671rG8Xz6FVboQ6AS7usX1bq2PF1LdZVr1ta3lUikGzIcQ2nhmx2rDfPPiMt8evq91rzQ2xxxkONsM6h0hrIX5kzT3zyfugnDxG+rA8f0A= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700538804; c=relaxed/simple; bh=71OP2tOAEiwD88UztZM9ncQo1CX6AHvIU/omMxa8NAY=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=vn13BTMlcpB3q709O7w3lKqrhI9/N9fVElSYLhilIZshfd5eOxKPsWQT7f4xDAheM/aLkcxZT+4B7TZ4sEGOUvvJXwwgPw9kje80U5kMGt5KxiHDlJn6HPGBOood2sh/4FFJz72YdiCuZlSAhtWjqAKLLo4ubjH4wJHZGWe/0Ig= 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 5BporOjtGjtZ35HpFrWynX; Tue, 21 Nov 2023 03:53:25 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id 5Hp9rvsSJRGmS5HpArFKgS; Tue, 21 Nov 2023 03:53:20 +0000 X-Authority-Analysis: v=2.4 cv=efcuwpIH c=1 sm=1 tr=0 ts=655c29b0 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=mDV3o1hIAAAA:8 a=z3Xw3AbGaEhUEUh7u4IA:9 a=QEXdDO2ut3YA:10 a=_FVE-zBwftR9WsbkzFJk:22 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=To:In-Reply-To:References:Message-Id:Content-Transfer-Encoding: Content-Type:MIME-Version:Subject:Date:From:Sender:Reply-To:Cc:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=m4rnJq1dsm/6v/1ruTFnIjJzGauVafCROuD/FAYj5Zk=; b=mkjNepIcT2mfo82WwznBoYzqWa wjUc1XiipE7rGNC0H485evFi/mDG1S2AJvsd1guSGJWw+U7tZCttCiT25sDaN9sdSqxdMmqtX+X1f odOi9GNM+v7b9iK4Y9y9g2/a4; 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 1r5Hp9-0040be-1o for gdb-patches@sourceware.org; Mon, 20 Nov 2023 20:53:19 -0700 From: Tom Tromey Date: Mon, 20 Nov 2023 20:53:40 -0700 Subject: [PATCH 09/29] Use a .def file for domain_enum MIME-Version: 1.0 Message-Id: <20231120-submit-domain-hacks-2-v1-9-29650d01b198@tromey.com> References: <20231120-submit-domain-hacks-2-v1-0-29650d01b198@tromey.com> In-Reply-To: <20231120-submit-domain-hacks-2-v1-0-29650d01b198@tromey.com> 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: 1r5Hp9-0040be-1o 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: 10 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfFGbrGzgZpYOpysMUVjwUROPqKT+jPzTOcW04afcYtKanH6tGKaBPsJi9sgBknOG9YF/DqXDEv1crbpe0kGIaewS7wSmfjAT2iksXqy5kpsA8OfEq1pF nu89lyjVmmxLVJsTVo6THSf3d4wZf0A/QMPxi5s+3wMPRGOJHJgzyCQuSOFwvryxCjSfbhlkHc4ABR7ILDA9JlY09cXj5uz6BaI= X-Spam-Status: No, score=-3023.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_SHORT, KAM_STOCKGEN, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham 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 Future patches will change and reuse the names from domain_enum. This patch makes this less error-prone by having a single point to define these names, using the typical gdb ".def" file. --- gdb/guile/scm-symbol.c | 18 ++++++++++-------- gdb/python/py-symbol.c | 21 ++++++++------------- gdb/sym-domains.def | 47 +++++++++++++++++++++++++++++++++++++++++++++++ gdb/symtab.c | 10 ++++------ gdb/symtab.h | 31 +++---------------------------- 5 files changed, 72 insertions(+), 55 deletions(-) diff --git a/gdb/guile/scm-symbol.c b/gdb/guile/scm-symbol.c index 1619705f065..a7dd21db088 100644 --- a/gdb/guile/scm-symbol.c +++ b/gdb/guile/scm-symbol.c @@ -693,16 +693,18 @@ static const scheme_integer_constant symbol_integer_constants[] = X (LOC_OPTIMIZED_OUT), X (LOC_COMPUTED), X (LOC_REGPARM_ADDR), - - X (UNDEF_DOMAIN), - X (VAR_DOMAIN), - X (STRUCT_DOMAIN), - X (LABEL_DOMAIN), - X (VARIABLES_DOMAIN), - X (FUNCTIONS_DOMAIN), - X (TYPES_DOMAIN), #undef X +#define DOMAIN(X) \ + { "SYMBOL_" #X "_DOMAIN", X ## _DOMAIN }, +#include "sym-domains.def" +#undef DOMAIN + + /* These were never correct. */ + { "SYMBOL_VARIABLES_DOMAIN", VAR_DOMAIN }, + { "SYMBOL_FUNCTIONS_DOMAIN", FUNCTION_DOMAIN }, + { "SYMBOL_TYPES_DOMAIN", TYPE_DOMAIN }, + END_INTEGER_CONSTANTS }; diff --git a/gdb/python/py-symbol.c b/gdb/python/py-symbol.c index 99724cfc95b..ceea4b7e241 100644 --- a/gdb/python/py-symbol.c +++ b/gdb/python/py-symbol.c @@ -670,20 +670,15 @@ gdbpy_initialize_symbols (void) || PyModule_AddIntConstant (gdb_module, "SYMBOL_LOC_COMMON_BLOCK", LOC_COMMON_BLOCK) < 0 || PyModule_AddIntConstant (gdb_module, "SYMBOL_LOC_REGPARM_ADDR", - LOC_REGPARM_ADDR) < 0 - || PyModule_AddIntConstant (gdb_module, "SYMBOL_UNDEF_DOMAIN", - UNDEF_DOMAIN) < 0 - || PyModule_AddIntConstant (gdb_module, "SYMBOL_VAR_DOMAIN", - VAR_DOMAIN) < 0 - || PyModule_AddIntConstant (gdb_module, "SYMBOL_STRUCT_DOMAIN", - STRUCT_DOMAIN) < 0 - || PyModule_AddIntConstant (gdb_module, "SYMBOL_LABEL_DOMAIN", - LABEL_DOMAIN) < 0 - || PyModule_AddIntConstant (gdb_module, "SYMBOL_MODULE_DOMAIN", - MODULE_DOMAIN) < 0 - || PyModule_AddIntConstant (gdb_module, "SYMBOL_COMMON_BLOCK_DOMAIN", - COMMON_BLOCK_DOMAIN) < 0) + LOC_REGPARM_ADDR) < 0) + return -1; + +#define DOMAIN(X) \ + if (PyModule_AddIntConstant (gdb_module, "SYMBOL_" #X "_DOMAIN", \ + X ## _DOMAIN) < 0) \ return -1; +#include "sym-domains.def" +#undef DOMAIN /* These remain defined for compatibility, but as they were never correct, they are no longer documented. Eventually we can remove diff --git a/gdb/sym-domains.def b/gdb/sym-domains.def new file mode 100644 index 00000000000..251c66fa04b --- /dev/null +++ b/gdb/sym-domains.def @@ -0,0 +1,47 @@ +/* Symbol domains -*- c++ -*- + + Copyright (C) 2023 Free Software Foundation, Inc. + + This file is part of GDB. + + 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 . */ + +/* UNDEF_DOMAIN is used when a domain has not been discovered or + none of the following apply. This usually indicates an error either + in the symbol information or in gdb's handling of symbols. */ + +DOMAIN (UNDEF) + +/* VAR_DOMAIN is the usual domain. In C, this contains variables, + function names, typedef names and enum type values. */ + +DOMAIN (VAR) + +/* STRUCT_DOMAIN is used in C to hold struct, union and enum type names. + Thus, if `struct foo' is used in a C program, it produces a symbol named + `foo' in the STRUCT_DOMAIN. */ + +DOMAIN (STRUCT) + +/* MODULE_DOMAIN is used in Fortran to hold module type names. */ + +DOMAIN (MODULE) + +/* LABEL_DOMAIN may be used for names of labels (for gotos). */ + +DOMAIN (LABEL) + +/* Fortran common blocks. Their naming must be separate from VAR_DOMAIN. + They also always use LOC_COMMON_BLOCK. */ +DOMAIN (COMMON_BLOCK) diff --git a/gdb/symtab.c b/gdb/symtab.c index 9e28edff7b4..3bc158cec43 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -304,12 +304,10 @@ domain_name (domain_enum e) { switch (e) { - case UNDEF_DOMAIN: return "UNDEF_DOMAIN"; - case VAR_DOMAIN: return "VAR_DOMAIN"; - case STRUCT_DOMAIN: return "STRUCT_DOMAIN"; - case MODULE_DOMAIN: return "MODULE_DOMAIN"; - case LABEL_DOMAIN: return "LABEL_DOMAIN"; - case COMMON_BLOCK_DOMAIN: return "COMMON_BLOCK_DOMAIN"; +#define DOMAIN(X) \ + case X ## _DOMAIN: return #X "_DOMAIN"; +#include "sym-domains.def" +#undef DOMAIN default: gdb_assert_not_reached ("bad domain_enum"); } } diff --git a/gdb/symtab.h b/gdb/symtab.h index 71d37e84a43..20cc0e90c14 100644 --- a/gdb/symtab.h +++ b/gdb/symtab.h @@ -888,34 +888,9 @@ struct minimal_symbol : public general_symbol_info enum domain_enum { - /* UNDEF_DOMAIN is used when a domain has not been discovered or - none of the following apply. This usually indicates an error either - in the symbol information or in gdb's handling of symbols. */ - - UNDEF_DOMAIN, - - /* VAR_DOMAIN is the usual domain. In C, this contains variables, - function names, typedef names and enum type values. */ - - VAR_DOMAIN, - - /* STRUCT_DOMAIN is used in C to hold struct, union and enum type names. - Thus, if `struct foo' is used in a C program, it produces a symbol named - `foo' in the STRUCT_DOMAIN. */ - - STRUCT_DOMAIN, - - /* MODULE_DOMAIN is used in Fortran to hold module type names. */ - - MODULE_DOMAIN, - - /* LABEL_DOMAIN may be used for names of labels (for gotos). */ - - LABEL_DOMAIN, - - /* Fortran common blocks. Their naming must be separate from VAR_DOMAIN. - They also always use LOC_COMMON_BLOCK. */ - COMMON_BLOCK_DOMAIN, +#define DOMAIN(X) X ## _DOMAIN, +#include "sym-domains.def" +#undef DOMAIN }; /* The number of bits in a symbol used to represent the domain. */ From patchwork Tue Nov 21 03:53:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 80399 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 589FB38582A7 for ; Tue, 21 Nov 2023 03:54:33 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from omta34.uswest2.a.cloudfilter.net (omta34.uswest2.a.cloudfilter.net [35.89.44.33]) by sourceware.org (Postfix) with ESMTPS id A4A403858C56 for ; Tue, 21 Nov 2023 03:53:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A4A403858C56 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 A4A403858C56 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=35.89.44.33 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700538805; cv=none; b=qOoxZKfZ4fKn6bVcrsoxVGt6OsrOVu4B/4FMtCvzCH48OSBpC66WjoQ6HkMwGDl2l61/KZD/i0o/vuLXZGLz2nbDsot7VavUgsMQo5bChpduM0NgSvbJCu3ZMedV3kTZL2M8jJJKAZjciZiQlqcxCqXvDNSlRsq+xlNEFzuXQLM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700538805; c=relaxed/simple; bh=8b22/y1oumfkyc76b8HO4g2wU7AH96HYJGpXiprg1VA=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=t9iMCxPTg/4dKnHYa4amBbzSx7DAP+FV3NjZJE365xsiRBcjM2a53wTG0UqRL+T94Rk235+oLuUweAYZ6mNoB64Nc9eKS0Cu+K2VbmhpU0Q+gb/qkUaO5V/EjWZ+DMPeMVHv2FSMZwW29cCpJRw+pX92S8u6QoHWnh7/R7lBmL0= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from eig-obgw-5002a.ext.cloudfilter.net ([10.0.29.215]) by cmsmtp with ESMTPS id 5924rRhju8Hte5HpArHZWR; Tue, 21 Nov 2023 03:53:20 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id 5Hp9rp9u6RQmi5HpArrjbV; Tue, 21 Nov 2023 03:53:20 +0000 X-Authority-Analysis: v=2.4 cv=CdcbWZnl c=1 sm=1 tr=0 ts=655c29b0 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=r7Wzu623eIwutHv_wZcA:9 a=QEXdDO2ut3YA:10 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=To:In-Reply-To:References:Message-Id:Content-Transfer-Encoding: Content-Type:MIME-Version:Subject:Date:From:Sender:Reply-To:Cc:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=luMcHIa1gHzOLtnVEq2q2Xtg5HUpUz9XXT7yZMWFwLE=; b=iwtb26MiPfZhf1MR7WsqPIzObQ keWCkDD9f/CjHwcXZkpB872Rq29QqpiZUH24Q3kR3KePJJI416bxtEKBYHIClqC2oIpVuqhIoYWxw /+BmlU5LRz28G/zWTznyySN7P; 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 1r5Hp9-0040be-2K for gdb-patches@sourceware.org; Mon, 20 Nov 2023 20:53:19 -0700 From: Tom Tromey Date: Mon, 20 Nov 2023 20:53:41 -0700 Subject: [PATCH 10/29] Add two new symbol domains MIME-Version: 1.0 Message-Id: <20231120-submit-domain-hacks-2-v1-10-29650d01b198@tromey.com> References: <20231120-submit-domain-hacks-2-v1-0-29650d01b198@tromey.com> In-Reply-To: <20231120-submit-domain-hacks-2-v1-0-29650d01b198@tromey.com> 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: 1r5Hp9-0040be-2K 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: 11 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfK6B6X6NTa560+gJ3Au31XPGIEFnBxxi3SyZce/7G4AjB+IiT+f5ADhY8qAEAjXoc2nuKDFNAEmPMSUMAgjapblF5eGaXpakPOq+IO54FQ2yGFIG0/uB ZHwSAh4Huf7KU2h7foXvV5CpzVcnmxNzd7AKEhO4a5maZvw6dnl3pyt3QWN1XGM7ItnR2UAondMTrquY3ChdkPDBK/jH7/qCaKw= X-Spam-Status: No, score=-3024.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham 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 This adds two new symbol domain constants, TYPE_DOMAIN and FUNCTION_DOMAIN. Historically, gdb was a C debugger, and the symbol tables continue to reflect this. In particular, symbol domains match the C language, with VAR_DOMAIN including variables, functions, and types. However, other languages have other approaches to namespacing. And, in any case, it is often useful for other parts of gdb to be able to distinguish between some domains at lookup time, without resorting to examining a symbol's location -- in some situations, this sort of filtering happens too late. Nothing uses these new domains yet, but the idea behind the patch is to separate symbols into more domains and then let the language-specific parts of gdb implement their semantics in terms of these categories. --- gdb/sym-domains.def | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/gdb/sym-domains.def b/gdb/sym-domains.def index 251c66fa04b..cea25a5f5b3 100644 --- a/gdb/sym-domains.def +++ b/gdb/sym-domains.def @@ -45,3 +45,12 @@ DOMAIN (LABEL) /* Fortran common blocks. Their naming must be separate from VAR_DOMAIN. They also always use LOC_COMMON_BLOCK. */ DOMAIN (COMMON_BLOCK) + +/* TYPE_DOMAIN is for types and typedefs. Note that tags are not + found here, see STRUCT_DOMAIN above. */ + +DOMAIN (TYPE) + +/* FUNCTION_DOMAIN is for functions and methods. */ + +DOMAIN (FUNCTION) From patchwork Tue Nov 21 03:53:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 80405 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 B8171385843A for ; Tue, 21 Nov 2023 03:54:57 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from omta040.useast.a.cloudfilter.net (omta040.useast.a.cloudfilter.net [44.202.169.39]) by sourceware.org (Postfix) with ESMTPS id 9FCDA3858C54 for ; Tue, 21 Nov 2023 03:53:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9FCDA3858C54 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 9FCDA3858C54 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=44.202.169.39 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700538805; cv=none; b=qGkwMAY2WTGq8hct4N1Ao2UitTNoM5PM0ffiBE8hCPm7q+g7x82AvkpdpTbDQa/KPaouK4Opu6MZURy2Hg2YoS1qcvhHW3oSuZV0Ur4B+kBqaCf78hD1YP4G4YAcldX0zvt/+75tgjPdQ3NujbG+KNSRQgoXL3ZhJc0Qh9JZXV4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700538805; c=relaxed/simple; bh=yPaNGsvKDVX0+gN2vdRtD4MDBDDj+NNQnidS5Gql5v4=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=BAaAw/8fir6ZML12jlNyATfgbcVG7VqZjt8mWl0B6wITmSbtObTa0UC+FkgJK079l/bjIw+0ASDdVdHfWZ+7qUuByFdS81oXIDGVJQ3VbX44ycBJQnqYqg1TAEW3id01JKFKi78lApqZV5HErCU6nTjCh+B0z5P4zXBKiY4AN8M= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from eig-obgw-6002a.ext.cloudfilter.net ([10.0.30.222]) by cmsmtp with ESMTPS id 5AuCrpVIT6nOZ5HpBrzrPM; Tue, 21 Nov 2023 03:53:21 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id 5HpAr57t3M0U25HpArctLd; Tue, 21 Nov 2023 03:53:20 +0000 X-Authority-Analysis: v=2.4 cv=BuKOfKb5 c=1 sm=1 tr=0 ts=655c29b0 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=INT8-sjlIe3v6QsWUHQA:9 a=QEXdDO2ut3YA:10 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=To:In-Reply-To:References:Message-Id:Content-Transfer-Encoding: Content-Type:MIME-Version:Subject:Date:From:Sender:Reply-To:Cc:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=ERpUl8yTrucQMXt1kEFFjwZdxsQgi37vvaDaVaKhzvs=; b=JjYleOyySsUSZOT879mLEQL0Z2 rdD1uSvt0nCKaPYMB2jarGs39RXeGFTMZte5+w9mtNwVgiRIzGcynw3Y/z/V3fGseVO8txJ+/VOY2 N1uI690nO/eOjDwy1hP8PaVIJ; 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 1r5Hp9-0040be-2q for gdb-patches@sourceware.org; Mon, 20 Nov 2023 20:53:19 -0700 From: Tom Tromey Date: Mon, 20 Nov 2023 20:53:42 -0700 Subject: [PATCH 11/29] Add domain_search_flags MIME-Version: 1.0 Message-Id: <20231120-submit-domain-hacks-2-v1-11-29650d01b198@tromey.com> References: <20231120-submit-domain-hacks-2-v1-0-29650d01b198@tromey.com> In-Reply-To: <20231120-submit-domain-hacks-2-v1-0-29650d01b198@tromey.com> 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: 1r5Hp9-0040be-2q 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: 12 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfLaStsvCDNEP06Prf7RYbmWhlDCLOmUbQfN18Cv3AFp8SL8bMGMjorHkYp9+NnNVwm52Y0XR3hNpApZs4ra6y74KNR1RtRC086xBOw3+XBqlspGRCc1/ J6kSjzsPUlcB228TnsrVFWfk+ouZX9afcx/xtXYW/6XzC2z8GNYdmSigl2f2VRMFsMtgqYaMkbkLgrD/n8RbDpxnCNazRU5pkJU= X-Spam-Status: No, score=-3024.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham 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 This adds a new flag enum type, domain_search_flags, which is the flag version of domain_enum. Nothing uses this yet, but the goal here is to have all symbol searches and lookups use these flags. The new names are chosen to exactly parallel domain_enum. --- gdb/symtab.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ gdb/symtab.h | 45 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 95 insertions(+) diff --git a/gdb/symtab.c b/gdb/symtab.c index 3bc158cec43..3c66cca1cab 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -330,6 +330,21 @@ search_domain_name (enum search_domain e) /* See symtab.h. */ +std::string +domain_name (domain_search_flags flags) +{ + static constexpr domain_search_flags::string_mapping mapping[] = { +#define DOMAIN(X) \ + MAP_ENUM_FLAG (SEARCH_ ## X ## _DOMAIN), +#include "sym-domains.def" +#undef DOMAIN + }; + + return flags.to_string (mapping); +} + +/* See symtab.h. */ + CORE_ADDR linetable_entry::pc (const struct objfile *objfile) const { @@ -2665,6 +2680,41 @@ symbol_matches_domain (enum language symbol_language, /* See symtab.h. */ +bool +symbol::matches (domain_search_flags flags) const +{ + if (language () != language_c + && language () != language_objc + && language () != language_opencl) + { + /* Only C languages distinguish tag and type namespaces. */ + if ((flags & SEARCH_TYPE_DOMAIN) != 0) + flags |= SEARCH_STRUCT_DOMAIN; + } + + if ((flags & SEARCH_FUNCTION_DOMAIN) != 0 + && domain () == VAR_DOMAIN + && aclass () == LOC_BLOCK) + return true; + + if ((flags & SEARCH_VAR_DOMAIN) != 0 + && domain () == VAR_DOMAIN) + return true; + + if ((flags & SEARCH_TYPE_DOMAIN) != 0 + && domain () == VAR_DOMAIN + && aclass () == LOC_TYPEDEF) + return true; + + if ((flags & SEARCH_STRUCT_DOMAIN) != 0 + && domain () == STRUCT_DOMAIN) + return true; + + return search_flags_matches (flags, m_domain); +} + +/* See symtab.h. */ + struct type * lookup_transparent_type (const char *name) { diff --git a/gdb/symtab.h b/gdb/symtab.h index 20cc0e90c14..0328a2024ad 100644 --- a/gdb/symtab.h +++ b/gdb/symtab.h @@ -899,6 +899,48 @@ enum domain_enum extern const char *domain_name (domain_enum); +/* Flags used for searching symbol tables. These can be combined to + let the search match multiple kinds of symbol. */ +enum domain_search_flag +{ +#define DOMAIN(X) \ + SEARCH_ ## X ## _DOMAIN = (1 << X ## _DOMAIN), +#include "sym-domains.def" +#undef DOMAIN +}; +DEF_ENUM_FLAGS_TYPE (enum domain_search_flag, domain_search_flags); + +/* A convenience constant to search for any symbol. */ +constexpr domain_search_flags SEARCH_ALL + = ((domain_search_flags) 0 +#define DOMAIN(X) | SEARCH_ ## X ## _DOMAIN +#include "sym-domains.def" +#undef DOMAIN + ); + +/* A convenience define for "C-like" name lookups, matching variables, + types, and functions. */ +#define SEARCH_VFT \ + (SEARCH_VAR_DOMAIN | SEARCH_FUNCTION_DOMAIN | SEARCH_TYPE_DOMAIN) + +/* Return a string representing the given flags. */ +extern std::string domain_name (domain_search_flags); + +/* Convert a symbol domain to search flags. */ +static inline domain_search_flags +to_search_flags (domain_enum domain) +{ + return domain_search_flags (domain_search_flag (1 << domain)); +} + +/* Return true if the given domain matches the given flags, false + otherwise. */ +static inline bool +search_flags_matches (domain_search_flags flags, domain_enum domain) +{ + return (flags & to_search_flags (domain)) != 0; +} + /* Searching domains, used when searching for symbols. Element numbers are hardcoded in GDB, check all enum uses before changing it. */ @@ -1244,6 +1286,9 @@ struct symbol : public general_symbol_info, public allocate_on_obstack return symbol_matches_domain (language (), domain (), d); } + /* Return true if this symbol's domain matches FLAGS. */ + bool matches (domain_search_flags flags) const; + domain_enum domain () const { return m_domain; From patchwork Tue Nov 21 03:53:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 80416 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 8A6B03858412 for ; Tue, 21 Nov 2023 03:56:04 +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 693653858C53 for ; Tue, 21 Nov 2023 03:53:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 693653858C53 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 693653858C53 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=1700538808; cv=none; b=RvptdQOSZ3R7dAmVqkGCeVR5eekR26yXHAS+93bXCQMFqy8vdIfjOL8GLNSz0ZcnHJ6XnQ7sbY761dhTVAXg2lfFeoW69V3N6ba8q5beyaMgmrIvV0U3O3PI0a6v+qtIE9xQ3maR3ySftE+BXxp5+KwdeGIA0RKPgj4jaC4nLUs= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700538808; c=relaxed/simple; bh=EP5PIpRCAev095xtlZLGnARFoEJf8GLOTDAY1j7xQNA=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=JqsbPD0hcr6NrFPhn/G4nuwsKGGM41dzBkWR4Ib217Zsskz9EEBR/UaLCWrS1YKq7g10Dx64015cMqnDsD22AW3i+tGbHUtzeNNmgGXQejMwcwzJdEle5nG+JCRXVjFIbxKEOFp9VW/fqeRamHnbkSKZ+FynECP2EeekXtzk/7I= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from eig-obgw-5009a.ext.cloudfilter.net ([10.0.29.176]) by cmsmtp with ESMTPS id 5ATqrmyTsWcCI5HpBrZVLU; Tue, 21 Nov 2023 03:53:21 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id 5HpArzUJL97pz5HpArri8s; Tue, 21 Nov 2023 03:53:20 +0000 X-Authority-Analysis: v=2.4 cv=ULDOoQTy c=1 sm=1 tr=0 ts=655c29b0 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=G8phxFYgWPlDxzhUtmMA:9 a=QEXdDO2ut3YA:10 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=To:In-Reply-To:References:Message-Id:Content-Transfer-Encoding: Content-Type:MIME-Version:Subject:Date:From:Sender:Reply-To:Cc:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=DBt46Dic+b742P8Le1ayYzUwMp3A5Cz4viauvlAyrqY=; b=mHeVQ8Q5lEG7k7eZrwLprzE4RE NWBBX5lte849Wcj6yjjpqLq2CHpr4rKZopITBcWDLemz4sVE/uzu4yYRfZNVbVEX1XmABAAm7+lJt xu8ZMrmJrxJVasfmEImrHDOt+; 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 1r5HpA-0040be-08 for gdb-patches@sourceware.org; Mon, 20 Nov 2023 20:53:20 -0700 From: Tom Tromey Date: Mon, 20 Nov 2023 20:53:43 -0700 Subject: [PATCH 12/29] Replace search_domain with domain_search_flags MIME-Version: 1.0 Message-Id: <20231120-submit-domain-hacks-2-v1-12-29650d01b198@tromey.com> References: <20231120-submit-domain-hacks-2-v1-0-29650d01b198@tromey.com> In-Reply-To: <20231120-submit-domain-hacks-2-v1-0-29650d01b198@tromey.com> 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: 1r5HpA-0040be-08 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: 13 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfOb9uK3zo2Mcmpa2RibUfFlUl1ktWY/ch5CGsIZA6OI+ZkZJnT94kcnaFql/Bzp1jpEhhU746rhfDHPh6BFg0T7jOeWkNN8Y0nIBsr7t+hN1adRYrIWK k5SgVAAFUUlyINwl+nKqhKLxIZb4mOqfafVGt9eO/Jg/oAgSzYO4SYNE6246Ls5a6Njw0qyhzby+JORkjzak5LVQM749OOGXoU8= X-Spam-Status: No, score=-3023.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_STOCKGEN, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham 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 This patch changes gdb to replace search_domain with domain_search_flags everywhere. search_domain is removed. --- gdb/ada-lang.c | 4 +- gdb/compile/compile-cplus-symbols.c | 2 +- gdb/dwarf2/cooked-index.c | 34 ++++++++++ gdb/dwarf2/cooked-index.h | 23 +------ gdb/dwarf2/read-debug-names.c | 122 ++++++++++----------------------- gdb/dwarf2/read-gdb-index.c | 33 +++++---- gdb/dwarf2/read.c | 6 +- gdb/linespec.c | 33 ++++----- gdb/mi/mi-symbol-cmds.c | 33 ++++----- gdb/objfiles.h | 2 +- gdb/psymtab.c | 14 ++-- gdb/psymtab.h | 2 +- gdb/python/py-symbol.c | 2 +- gdb/python/python.c | 2 +- gdb/quick-symbol.h | 2 +- gdb/symfile-debug.c | 12 ++-- gdb/symfile.c | 2 +- gdb/symfile.h | 2 +- gdb/symmisc.c | 2 +- gdb/symtab.c | 130 +++++++++++++++++++----------------- gdb/symtab.h | 36 ++-------- 21 files changed, 218 insertions(+), 280 deletions(-) diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 9bb649e901d..eac688cd632 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -13057,7 +13057,7 @@ ada_add_global_exceptions (compiled_regex *preg, }, NULL, SEARCH_GLOBAL_BLOCK | SEARCH_STATIC_BLOCK, - VARIABLES_DOMAIN); + SEARCH_VAR_DOMAIN); /* Iterate over all objfiles irrespective of scope or linker namespaces so we get all exceptions anywhere in the progspace. */ @@ -13602,7 +13602,7 @@ class ada_language : public language_defn NULL, NULL, SEARCH_GLOBAL_BLOCK | SEARCH_STATIC_BLOCK, - ALL_DOMAIN); + SEARCH_ALL); /* At this point scan through the misc symbol vectors and add each symbol you find to the list. Eventually we want to ignore diff --git a/gdb/compile/compile-cplus-symbols.c b/gdb/compile/compile-cplus-symbols.c index 1edbf8f64b5..4a52427a072 100644 --- a/gdb/compile/compile-cplus-symbols.c +++ b/gdb/compile/compile-cplus-symbols.c @@ -368,7 +368,7 @@ gcc_cplus_convert_symbol (void *datum, symbol_searcher searcher; searcher.find_all_symbols (identifier, current_language, - ALL_DOMAIN, nullptr, nullptr); + SEARCH_ALL, nullptr, nullptr); /* Convert any found symbols. */ for (const auto &it : searcher.matching_symbols ()) diff --git a/gdb/dwarf2/cooked-index.c b/gdb/dwarf2/cooked-index.c index 58ea541a5c9..e451e324424 100644 --- a/gdb/dwarf2/cooked-index.c +++ b/gdb/dwarf2/cooked-index.c @@ -181,6 +181,40 @@ test_compare () /* See cooked-index.h. */ +bool +cooked_index_entry::matches (domain_search_flags kind) const +{ + /* Just reject type declarations. */ + if ((flags & IS_TYPE_DECLARATION) != 0) + return false; + + if ((kind & SEARCH_VAR_DOMAIN) != 0 + && (tag == DW_TAG_variable + || tag == DW_TAG_constant + || tag == DW_TAG_enumerator)) + return true; + + if ((kind & SEARCH_STRUCT_DOMAIN) != 0 + && (tag == DW_TAG_structure_type + || tag == DW_TAG_class_type + || tag == DW_TAG_union_type + || tag == DW_TAG_enumeration_type)) + return true; + + if ((kind & SEARCH_MODULE_DOMAIN) != 0 && tag == DW_TAG_module) + return true; + + if ((kind & SEARCH_TYPE_DOMAIN) != 0 && tag_is_type (tag)) + return true; + + if ((kind & SEARCH_FUNCTION_DOMAIN) != 0 && tag == DW_TAG_subprogram) + return true; + + return false; +} + +/* See cooked-index.h. */ + const char * cooked_index_entry::full_name (struct obstack *storage, bool for_main) const { diff --git a/gdb/dwarf2/cooked-index.h b/gdb/dwarf2/cooked-index.h index 5aacb321c91..b3d5b5cd6f6 100644 --- a/gdb/dwarf2/cooked-index.h +++ b/gdb/dwarf2/cooked-index.h @@ -128,28 +128,7 @@ struct cooked_index_entry : public allocate_on_obstack } /* Return true if this entry matches KIND. */ - bool matches (enum search_domain kind) const - { - /* Just reject type declarations. */ - if ((flags & IS_TYPE_DECLARATION) != 0) - return false; - - switch (kind) - { - case VARIABLES_DOMAIN: - return (tag == DW_TAG_variable - || tag == DW_TAG_constant - || tag == DW_TAG_enumerator); - case FUNCTIONS_DOMAIN: - return tag == DW_TAG_subprogram; - case TYPES_DOMAIN: - return tag_is_type (tag); - case MODULES_DOMAIN: - return tag == DW_TAG_module; - } - - return true; - } + bool matches (domain_search_flags kind) const; /* Construct the fully-qualified name of this entry and return a pointer to it. If allocation is needed, it will be done on diff --git a/gdb/dwarf2/read-debug-names.c b/gdb/dwarf2/read-debug-names.c index c1b62b38f93..743cee6c46d 100644 --- a/gdb/dwarf2/read-debug-names.c +++ b/gdb/dwarf2/read-debug-names.c @@ -99,7 +99,7 @@ struct dwarf2_debug_names_index : public dwarf2_base_index_functions gdb::function_view expansion_notify, block_search_flags search_flags, domain_enum domain, - enum search_domain kind) override; + domain_search_flags kind) override; }; quick_symbol_functions_up @@ -544,7 +544,7 @@ class dw2_debug_names_iterator {} dw2_debug_names_iterator (const mapped_debug_names &map, - search_domain search, uint32_t namei, + domain_search_flags search, uint32_t namei, dwarf2_per_objfile *per_objfile, domain_enum domain = UNDEF_DOMAIN) : m_map (map), @@ -582,7 +582,7 @@ class dw2_debug_names_iterator /* The kind of symbol we're looking for. */ const domain_enum m_domain = UNDEF_DOMAIN; - const search_domain m_search = ALL_DOMAIN; + const domain_search_flags m_search = SEARCH_ALL; /* The list of CUs from the index entry of the symbol, or NULL if not found. */ @@ -850,100 +850,46 @@ dw2_debug_names_iterator::next () } } - /* Match dw2_symtab_iter_next, symbol_kind - and debug_names::psymbol_tag. */ - switch (m_domain) + domain_enum domain = UNDEF_DOMAIN; + switch (indexval.dwarf_tag) { - case VAR_DOMAIN: - switch (indexval.dwarf_tag) - { - case DW_TAG_variable: - case DW_TAG_subprogram: - /* Some types are also in VAR_DOMAIN. */ - case DW_TAG_typedef: - case DW_TAG_structure_type: - break; - default: - goto again; - } - break; - case STRUCT_DOMAIN: - switch (indexval.dwarf_tag) - { - case DW_TAG_typedef: - case DW_TAG_structure_type: - break; - default: - goto again; - } + case DW_TAG_variable: + domain = VAR_DOMAIN; break; - case LABEL_DOMAIN: - switch (indexval.dwarf_tag) - { - case 0: - case DW_TAG_variable: - break; - default: - goto again; - } - break; - case MODULE_DOMAIN: - switch (indexval.dwarf_tag) - { - case DW_TAG_module: - break; - default: - goto again; - } - break; - default: + + case DW_TAG_subprogram: + domain = FUNCTION_DOMAIN; break; - } - /* Match dw2_expand_symtabs_matching, symbol_kind and - debug_names::psymbol_tag. */ - switch (m_search) - { - case VARIABLES_DOMAIN: - switch (indexval.dwarf_tag) - { - case DW_TAG_variable: - break; - default: - goto again; - } + case DW_TAG_structure_type: + case DW_TAG_union_type: + case DW_TAG_enumeration_type: + domain = STRUCT_DOMAIN; break; - case FUNCTIONS_DOMAIN: - switch (indexval.dwarf_tag) - { - case DW_TAG_subprogram: - break; - default: - goto again; - } + + case DW_TAG_typedef: + domain = TYPE_DOMAIN; break; - case TYPES_DOMAIN: - switch (indexval.dwarf_tag) - { - case DW_TAG_typedef: - case DW_TAG_structure_type: - break; - default: - goto again; - } + + case DW_TAG_label: + domain = LABEL_DOMAIN; break; - case MODULES_DOMAIN: - switch (indexval.dwarf_tag) - { - case DW_TAG_module: - break; - default: - goto again; - } - default: + + case DW_TAG_module: + domain = MODULE_DOMAIN; break; } + if (! (m_domain == domain + || (m_domain == VAR_DOMAIN + && (domain == TYPE_DOMAIN + || domain == FUNCTION_DOMAIN)))) + goto again; + + domain_search_flags flags = to_search_flags (domain); + if ((flags & m_search) == 0) + goto again; + return per_cu; } @@ -1005,7 +951,7 @@ dwarf2_debug_names_index::expand_symtabs_matching gdb::function_view expansion_notify, block_search_flags search_flags, domain_enum domain, - enum search_domain kind) + domain_search_flags kind) { dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile); diff --git a/gdb/dwarf2/read-gdb-index.c b/gdb/dwarf2/read-gdb-index.c index e789e9c2654..eeb52203ef9 100644 --- a/gdb/dwarf2/read-gdb-index.c +++ b/gdb/dwarf2/read-gdb-index.c @@ -154,7 +154,7 @@ struct dwarf2_gdb_index : public dwarf2_base_index_functions gdb::function_view expansion_notify, block_search_flags search_flags, domain_enum domain, - enum search_domain kind) override; + domain_search_flags kind) override; }; /* This dumps minimal information about the index. @@ -366,7 +366,7 @@ dw2_expand_marked_cus gdb::function_view file_matcher, gdb::function_view expansion_notify, block_search_flags search_flags, - search_domain kind) + domain_search_flags kind) { offset_type vec_len, vec_idx; bool global_seen = false; @@ -417,27 +417,24 @@ dw2_expand_marked_cus continue; } - switch (kind) + domain_search_flags mask = 0; + switch (symbol_kind) { - case VARIABLES_DOMAIN: - if (symbol_kind != GDB_INDEX_SYMBOL_KIND_VARIABLE) - continue; + case GDB_INDEX_SYMBOL_KIND_VARIABLE: + mask = SEARCH_VAR_DOMAIN; break; - case FUNCTIONS_DOMAIN: - if (symbol_kind != GDB_INDEX_SYMBOL_KIND_FUNCTION) - continue; + case GDB_INDEX_SYMBOL_KIND_FUNCTION: + mask = SEARCH_FUNCTION_DOMAIN; break; - case TYPES_DOMAIN: - if (symbol_kind != GDB_INDEX_SYMBOL_KIND_TYPE) - continue; + case GDB_INDEX_SYMBOL_KIND_TYPE: + mask = SEARCH_TYPE_DOMAIN; break; - case MODULES_DOMAIN: - if (symbol_kind != GDB_INDEX_SYMBOL_KIND_OTHER) - continue; - break; - default: + case GDB_INDEX_SYMBOL_KIND_OTHER: + mask = SEARCH_MODULE_DOMAIN; break; } + if ((kind & mask) == 0) + continue; } /* Don't crash on bad data. */ @@ -466,7 +463,7 @@ dwarf2_gdb_index::expand_symtabs_matching gdb::function_view expansion_notify, block_search_flags search_flags, domain_enum domain, - enum search_domain kind) + domain_search_flags kind) { dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile); diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index aa44d19b517..866c00e75a2 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -1652,7 +1652,7 @@ struct readnow_functions : public dwarf2_base_index_functions gdb::function_view expansion_notify, block_search_flags search_flags, domain_enum domain, - enum search_domain kind) override + domain_search_flags kind) override { return true; } @@ -16590,7 +16590,7 @@ struct cooked_index_functions : public dwarf2_base_index_functions gdb::function_view expansion_notify, block_search_flags search_flags, domain_enum domain, - enum search_domain kind) override; + domain_search_flags kind) override; bool can_lazily_read_symbols () override { @@ -16725,7 +16725,7 @@ cooked_index_functions::expand_symtabs_matching gdb::function_view expansion_notify, block_search_flags search_flags, domain_enum domain, - enum search_domain kind) + domain_search_flags kind) { dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile); diff --git a/gdb/linespec.c b/gdb/linespec.c index fa733d880e3..7aabedf239d 100644 --- a/gdb/linespec.c +++ b/gdb/linespec.c @@ -387,13 +387,13 @@ static int symbol_to_sal (struct symtab_and_line *result, static void add_matching_symbols_to_info (const char *name, symbol_name_match_type name_match_type, - enum search_domain search_domain, + domain_search_flags domain_search_flags, struct collect_info *info, struct program_space *pspace); static void add_all_symbol_names_from_pspace (struct collect_info *info, struct program_space *pspace, - const std::vector &names, enum search_domain search_domain); + const std::vector &names, domain_search_flags domain_search_flags); static std::vector collect_symtabs_from_filename (const char *file, @@ -1155,7 +1155,7 @@ iterate_over_all_matching_symtabs (struct linespec_state *state, const lookup_name_info &lookup_name, const domain_enum name_domain, - enum search_domain search_domain, + domain_search_flags domain_search_flags, struct program_space *search_pspace, bool include_inline, gdb::function_view callback) { @@ -1174,7 +1174,7 @@ iterate_over_all_matching_symtabs (SEARCH_GLOBAL_BLOCK | SEARCH_STATIC_BLOCK), UNDEF_DOMAIN, - search_domain); + domain_search_flags); for (compunit_symtab *cu : objfile->compunits ()) { @@ -3323,7 +3323,7 @@ decode_objc (struct linespec_state *self, linespec *ls, const char *arg) return {}; add_all_symbol_names_from_pspace (&info, NULL, symbol_names, - FUNCTIONS_DOMAIN); + SEARCH_FUNCTION_DOMAIN); std::vector values; if (!symbols.empty () || !minimal_symbols.empty ()) @@ -3442,10 +3442,10 @@ lookup_prefix_sym (struct linespec_state *state, if (elt == nullptr) { iterate_over_all_matching_symtabs (state, lookup_name, - STRUCT_DOMAIN, ALL_DOMAIN, + STRUCT_DOMAIN, SEARCH_ALL, NULL, false, collector); iterate_over_all_matching_symtabs (state, lookup_name, - VAR_DOMAIN, ALL_DOMAIN, + VAR_DOMAIN, SEARCH_ALL, NULL, false, collector); } else @@ -3523,12 +3523,12 @@ static void add_all_symbol_names_from_pspace (struct collect_info *info, struct program_space *pspace, const std::vector &names, - enum search_domain search_domain) + domain_search_flags domain_search_flags) { for (const char *iter : names) add_matching_symbols_to_info (iter, symbol_name_match_type::FULL, - search_domain, info, pspace); + domain_search_flags, info, pspace); } static void @@ -3622,7 +3622,7 @@ find_method (struct linespec_state *self, iterate over the symbol tables looking for all matches in this pspace. */ add_all_symbol_names_from_pspace (&info, pspace, result_names, - FUNCTIONS_DOMAIN); + SEARCH_FUNCTION_DOMAIN); superclass_vec.clear (); last_result_len = result_names.size (); @@ -3745,7 +3745,7 @@ symtabs_from_filename (const char *filename, void symbol_searcher::find_all_symbols (const std::string &name, const struct language_defn *language, - enum search_domain search_domain, + domain_search_flags domain_search_flags, std::vector *search_symtabs, struct program_space *search_pspace) { @@ -3767,7 +3767,7 @@ symbol_searcher::find_all_symbols (const std::string &name, info.file_symtabs = search_symtabs; add_matching_symbols_to_info (name.c_str (), symbol_name_match_type::WILD, - search_domain, &info, search_pspace); + domain_search_flags, &info, search_pspace); } /* Look up a function symbol named NAME in symtabs FILE_SYMTABS. Matching @@ -3793,9 +3793,10 @@ find_function_symbols (struct linespec_state *state, find_imps (name, &symbol_names); if (!symbol_names.empty ()) add_all_symbol_names_from_pspace (&info, state->search_pspace, - symbol_names, FUNCTIONS_DOMAIN); + symbol_names, SEARCH_FUNCTION_DOMAIN); else - add_matching_symbols_to_info (name, name_match_type, FUNCTIONS_DOMAIN, + add_matching_symbols_to_info (name, name_match_type, + SEARCH_FUNCTION_DOMAIN, &info, state->search_pspace); } @@ -4310,7 +4311,7 @@ search_minsyms_for_name (struct collect_info *info, static void add_matching_symbols_to_info (const char *name, symbol_name_match_type name_match_type, - enum search_domain search_domain, + domain_search_flags domain_search_flags, struct collect_info *info, struct program_space *pspace) { @@ -4321,7 +4322,7 @@ add_matching_symbols_to_info (const char *name, if (elt == nullptr) { iterate_over_all_matching_symtabs (info->state, lookup_name, - VAR_DOMAIN, search_domain, + VAR_DOMAIN, domain_search_flags, pspace, true, [&] (block_symbol *bsym) { return info->add_symbol (bsym); }); diff --git a/gdb/mi/mi-symbol-cmds.c b/gdb/mi/mi-symbol-cmds.c index 7492d007fba..c1b00e13f88 100644 --- a/gdb/mi/mi-symbol-cmds.c +++ b/gdb/mi/mi-symbol-cmds.c @@ -72,7 +72,7 @@ mi_cmd_symbol_list_lines (const char *command, const char *const *argv, results. */ static void -output_debug_symbol (ui_out *uiout, enum search_domain kind, +output_debug_symbol (ui_out *uiout, domain_search_flags kind, struct symbol *sym, int block) { ui_out_emit_tuple tuple_emitter (uiout, NULL); @@ -81,7 +81,7 @@ output_debug_symbol (ui_out *uiout, enum search_domain kind, uiout->field_unsigned ("line", sym->line ()); uiout->field_string ("name", sym->print_name ()); - if (kind == FUNCTIONS_DOMAIN || kind == VARIABLES_DOMAIN) + if ((kind & (SEARCH_FUNCTION_DOMAIN | SEARCH_VAR_DOMAIN)) != 0) { string_file tmp_stream; type_print (sym->type (), "", &tmp_stream, -1); @@ -113,7 +113,7 @@ output_nondebug_symbol (ui_out *uiout, and then prints the matching [m]symbols in an MI structured format. */ static void -mi_symbol_info (enum search_domain kind, const char *name_regexp, +mi_symbol_info (domain_search_flags kind, const char *name_regexp, const char *type_regexp, bool exclude_minsyms, size_t max_results) { @@ -190,7 +190,7 @@ parse_max_results_option (const char *arg) Processes command line options from ARGV and ARGC. */ static void -mi_info_functions_or_variables (enum search_domain kind, +mi_info_functions_or_variables (domain_search_flags kind, const char *const *argv, int argc) { size_t max_results = SIZE_MAX; @@ -217,7 +217,7 @@ mi_info_functions_or_variables (enum search_domain kind, while (1) { const char *cmd_string - = ((kind == FUNCTIONS_DOMAIN) + = ((kind == SEARCH_FUNCTION_DOMAIN) ? "-symbol-info-functions" : "-symbol-info-variables"); int opt = mi_getopt (cmd_string, argc, argv, opts, &oind, &oarg); if (opt < 0) @@ -253,7 +253,7 @@ typedef std::vector::const_iterator static module_symbol_search_iterator output_module_symbols_in_single_module_and_file (struct ui_out *uiout, module_symbol_search_iterator iter, - const module_symbol_search_iterator end, enum search_domain kind) + const module_symbol_search_iterator end, domain_search_flags kind) { /* The symbol for the module in which the first result resides. */ const symbol *first_module_symbol = iter->first.symbol; @@ -288,7 +288,7 @@ output_module_symbols_in_single_module_and_file static module_symbol_search_iterator output_module_symbols_in_single_module (struct ui_out *uiout, module_symbol_search_iterator iter, - const module_symbol_search_iterator end, enum search_domain kind) + const module_symbol_search_iterator end, domain_search_flags kind) { gdb_assert (iter->first.symbol != nullptr); gdb_assert (iter->second.symbol != nullptr); @@ -316,8 +316,8 @@ output_module_symbols_in_single_module command line options passed to the MI command. */ static void -mi_info_module_functions_or_variables (enum search_domain kind, - const char *const *argv, int argc) +mi_info_module_functions_or_variables (domain_search_flags kind, + const char *const *argv, int argc) { const char *module_regexp = nullptr; const char *regexp = nullptr; @@ -343,7 +343,7 @@ mi_info_module_functions_or_variables (enum search_domain kind, while (1) { const char *cmd_string - = ((kind == FUNCTIONS_DOMAIN) + = ((kind == SEARCH_FUNCTION_DOMAIN) ? "-symbol-info-module-functions" : "-symbol-info-module-variables"); int opt = mi_getopt (cmd_string, argc, argv, opts, &oind, &oarg); @@ -385,7 +385,7 @@ void mi_cmd_symbol_info_functions (const char *command, const char *const *argv, int argc) { - mi_info_functions_or_variables (FUNCTIONS_DOMAIN, argv, argc); + mi_info_functions_or_variables (SEARCH_FUNCTION_DOMAIN, argv, argc); } /* Implement -symbol-info-module-functions command. */ @@ -394,7 +394,7 @@ void mi_cmd_symbol_info_module_functions (const char *command, const char *const *argv, int argc) { - mi_info_module_functions_or_variables (FUNCTIONS_DOMAIN, argv, argc); + mi_info_module_functions_or_variables (SEARCH_FUNCTION_DOMAIN, argv, argc); } /* Implement -symbol-info-module-variables command. */ @@ -403,7 +403,7 @@ void mi_cmd_symbol_info_module_variables (const char *command, const char *const *argv, int argc) { - mi_info_module_functions_or_variables (VARIABLES_DOMAIN, argv, argc); + mi_info_module_functions_or_variables (SEARCH_VAR_DOMAIN, argv, argc); } /* Implement -symbol-inf-modules command. */ @@ -446,7 +446,7 @@ mi_cmd_symbol_info_modules (const char *command, const char *const *argv, } } - mi_symbol_info (MODULES_DOMAIN, regexp, nullptr, true, max_results); + mi_symbol_info (SEARCH_MODULE_DOMAIN, regexp, nullptr, true, max_results); } /* Implement -symbol-info-types command. */ @@ -489,7 +489,8 @@ mi_cmd_symbol_info_types (const char *command, const char *const *argv, } } - mi_symbol_info (TYPES_DOMAIN, regexp, nullptr, true, max_results); + mi_symbol_info (SEARCH_TYPE_DOMAIN | SEARCH_STRUCT_DOMAIN, regexp, nullptr, + true, max_results); } /* Implement -symbol-info-variables command. */ @@ -498,5 +499,5 @@ void mi_cmd_symbol_info_variables (const char *command, const char *const *argv, int argc) { - mi_info_functions_or_variables (VARIABLES_DOMAIN, argv, argc); + mi_info_functions_or_variables (SEARCH_VAR_DOMAIN, argv, argc); } diff --git a/gdb/objfiles.h b/gdb/objfiles.h index ec9d354e4a7..0da44a38c7f 100644 --- a/gdb/objfiles.h +++ b/gdb/objfiles.h @@ -598,7 +598,7 @@ struct objfile gdb::function_view expansion_notify, block_search_flags search_flags, domain_enum domain, - enum search_domain kind); + domain_search_flags kind); /* See quick_symbol_functions. */ struct compunit_symtab *find_pc_sect_compunit_symtab diff --git a/gdb/psymtab.c b/gdb/psymtab.c index 41ecf31424b..dc960b661ea 100644 --- a/gdb/psymtab.c +++ b/gdb/psymtab.c @@ -908,7 +908,7 @@ recursively_search_psymtabs struct objfile *objfile, block_search_flags search_flags, domain_enum domain, - enum search_domain search, + domain_search_flags search, const lookup_name_info &lookup_name, gdb::function_view sym_matcher) { @@ -981,15 +981,15 @@ recursively_search_psymtabs if ((domain == UNDEF_DOMAIN || symbol_matches_domain ((*psym)->ginfo.language (), (*psym)->domain, domain)) - && (search == ALL_DOMAIN - || (search == MODULES_DOMAIN + && (search == SEARCH_ALL + || (search == SEARCH_MODULE_DOMAIN && (*psym)->domain == MODULE_DOMAIN) - || (search == VARIABLES_DOMAIN + || (search == SEARCH_VAR_DOMAIN && (*psym)->aclass != LOC_TYPEDEF && (*psym)->aclass != LOC_BLOCK) - || (search == FUNCTIONS_DOMAIN + || (search == SEARCH_FUNCTION_DOMAIN && (*psym)->aclass == LOC_BLOCK) - || (search == TYPES_DOMAIN + || (search == SEARCH_TYPE_DOMAIN && (*psym)->aclass == LOC_TYPEDEF)) && psymbol_name_matches (*psym, lookup_name) && (sym_matcher == NULL @@ -1019,7 +1019,7 @@ psymbol_functions::expand_symtabs_matching gdb::function_view expansion_notify, block_search_flags search_flags, domain_enum domain, - enum search_domain search) + domain_search_flags search) { /* Clear the search flags. */ for (partial_symtab *ps : partial_symbols (objfile)) diff --git a/gdb/psymtab.h b/gdb/psymtab.h index 41337d0db89..43e6244fd6e 100644 --- a/gdb/psymtab.h +++ b/gdb/psymtab.h @@ -641,7 +641,7 @@ struct psymbol_functions : public quick_symbol_functions gdb::function_view expansion_notify, block_search_flags search_flags, domain_enum domain, - enum search_domain kind) override; + domain_search_flags kind) override; struct compunit_symtab *find_pc_sect_compunit_symtab (struct objfile *objfile, struct bound_minimal_symbol msymbol, diff --git a/gdb/python/py-symbol.c b/gdb/python/py-symbol.c index ceea4b7e241..863e8caf4ce 100644 --- a/gdb/python/py-symbol.c +++ b/gdb/python/py-symbol.c @@ -596,7 +596,7 @@ gdbpy_lookup_static_symbols (PyObject *self, PyObject *args, PyObject *kw) lookup_name_info lookup_name (name, symbol_name_match_type::FULL); expand_symtabs_matching (NULL, lookup_name, NULL, NULL, SEARCH_GLOBAL_BLOCK | SEARCH_STATIC_BLOCK, - ALL_DOMAIN); + SEARCH_ALL); for (objfile *objfile : current_program_space->objfiles ()) { diff --git a/gdb/python/python.c b/gdb/python/python.c index 7e48165db21..9f5f012d77d 100644 --- a/gdb/python/python.c +++ b/gdb/python/python.c @@ -760,7 +760,7 @@ gdbpy_rbreak (PyObject *self, PyObject *args, PyObject *kw) minsyms_p = cmp; } - global_symbol_searcher spec (FUNCTIONS_DOMAIN, regex); + global_symbol_searcher spec (SEARCH_FUNCTION_DOMAIN, regex); SCOPE_EXIT { for (const char *elem : spec.filenames) xfree ((void *) elem); diff --git a/gdb/quick-symbol.h b/gdb/quick-symbol.h index a7fea2ccb49..1eac8f25035 100644 --- a/gdb/quick-symbol.h +++ b/gdb/quick-symbol.h @@ -183,7 +183,7 @@ struct quick_symbol_functions gdb::function_view expansion_notify, block_search_flags search_flags, domain_enum domain, - enum search_domain kind) = 0; + domain_search_flags kind) = 0; /* Return the comp unit from OBJFILE that contains PC and SECTION. Return NULL if there is no such compunit. This diff --git a/gdb/symfile-debug.c b/gdb/symfile-debug.c index 85c43719dee..8fbacef9d30 100644 --- a/gdb/symfile-debug.c +++ b/gdb/symfile-debug.c @@ -227,7 +227,7 @@ objfile::map_symtabs_matching_filename (SEARCH_GLOBAL_BLOCK | SEARCH_STATIC_BLOCK), UNDEF_DOMAIN, - ALL_DOMAIN)) + SEARCH_ALL)) { retval = false; break; @@ -293,7 +293,7 @@ objfile::lookup_symbol (block_enum kind, const char *name, domain_enum domain) ? SEARCH_GLOBAL_BLOCK : SEARCH_STATIC_BLOCK, domain, - ALL_DOMAIN)) + SEARCH_ALL)) break; } @@ -348,7 +348,7 @@ objfile::expand_symtabs_for_function (const char *func_name) (SEARCH_GLOBAL_BLOCK | SEARCH_STATIC_BLOCK), VAR_DOMAIN, - ALL_DOMAIN); + SEARCH_ALL); } void @@ -385,7 +385,7 @@ objfile::expand_symtabs_with_fullname (const char *fullname) (SEARCH_GLOBAL_BLOCK | SEARCH_STATIC_BLOCK), UNDEF_DOMAIN, - ALL_DOMAIN); + SEARCH_ALL); } void @@ -414,7 +414,7 @@ objfile::expand_symtabs_matching gdb::function_view expansion_notify, block_search_flags search_flags, domain_enum domain, - enum search_domain kind) + domain_search_flags kind) { /* This invariant is documented in quick-functions.h. */ gdb_assert (lookup_name != nullptr || symbol_matcher == nullptr); @@ -426,7 +426,7 @@ objfile::expand_symtabs_matching host_address_to_string (&file_matcher), host_address_to_string (&symbol_matcher), host_address_to_string (&expansion_notify), - search_domain_name (kind)); + domain_name (kind).c_str ()); for (const auto &iter : qf_require_partial_symbols ()) if (!iter->expand_symtabs_matching (this, file_matcher, lookup_name, diff --git a/gdb/symfile.c b/gdb/symfile.c index bbac6ad9df1..b21ba73c69d 100644 --- a/gdb/symfile.c +++ b/gdb/symfile.c @@ -3763,7 +3763,7 @@ expand_symtabs_matching gdb::function_view symbol_matcher, gdb::function_view expansion_notify, block_search_flags search_flags, - enum search_domain kind) + domain_search_flags kind) { for (objfile *objfile : current_program_space->objfiles ()) if (!objfile->expand_symtabs_matching (file_matcher, diff --git a/gdb/symfile.h b/gdb/symfile.h index bb61a779314..b3577fdb44c 100644 --- a/gdb/symfile.h +++ b/gdb/symfile.h @@ -352,7 +352,7 @@ bool expand_symtabs_matching gdb::function_view symbol_matcher, gdb::function_view expansion_notify, block_search_flags search_flags, - enum search_domain kind); + domain_search_flags kind); void map_symbol_filenames (gdb::function_view fun, bool need_fullname); diff --git a/gdb/symmisc.c b/gdb/symmisc.c index c1a6ab5cd7d..8f620bb7ebe 100644 --- a/gdb/symmisc.c +++ b/gdb/symmisc.c @@ -920,7 +920,7 @@ maintenance_expand_symtabs (const char *args, int from_tty) NULL, SEARCH_GLOBAL_BLOCK | SEARCH_STATIC_BLOCK, UNDEF_DOMAIN, - ALL_DOMAIN); + SEARCH_ALL); } diff --git a/gdb/symtab.c b/gdb/symtab.c index 3c66cca1cab..e5e168c20e9 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -312,22 +312,6 @@ domain_name (domain_enum e) } } -/* Return the name of a search_domain . */ - -const char * -search_domain_name (enum search_domain e) -{ - switch (e) - { - case VARIABLES_DOMAIN: return "VARIABLES_DOMAIN"; - case FUNCTIONS_DOMAIN: return "FUNCTIONS_DOMAIN"; - case TYPES_DOMAIN: return "TYPES_DOMAIN"; - case MODULES_DOMAIN: return "MODULES_DOMAIN"; - case ALL_DOMAIN: return "ALL_DOMAIN"; - default: gdb_assert_not_reached ("bad search_domain"); - } -} - /* See symtab.h. */ std::string @@ -4677,7 +4661,7 @@ treg_matches_sym_type_name (const compiled_regex &treg, bool global_symbol_searcher::is_suitable_msymbol - (const enum search_domain kind, const minimal_symbol *msymbol) + (const domain_search_flags kind, const minimal_symbol *msymbol) { switch (msymbol->type ()) { @@ -4685,12 +4669,12 @@ global_symbol_searcher::is_suitable_msymbol case mst_bss: case mst_file_data: case mst_file_bss: - return kind == VARIABLES_DOMAIN; + return (kind & SEARCH_VAR_DOMAIN) != 0; case mst_text: case mst_file_text: case mst_solib_trampoline: case mst_text_gnu_ifunc: - return kind == FUNCTIONS_DOMAIN; + return (kind & SEARCH_FUNCTION_DOMAIN) != 0; default: return false; } @@ -4702,7 +4686,7 @@ bool global_symbol_searcher::expand_symtabs (objfile *objfile, const gdb::optional &preg) const { - enum search_domain kind = m_kind; + domain_search_flags kind = m_kind; bool found_msymbol = false; auto do_file_match = [&] (const char *filename, bool basenames) @@ -4741,7 +4725,7 @@ global_symbol_searcher::expand_symtabs all objfiles. In large programs (1000s of shared libs) searching all objfiles is not worth the pain. */ if (filenames.empty () - && (kind == VARIABLES_DOMAIN || kind == FUNCTIONS_DOMAIN)) + && (kind & (SEARCH_VAR_DOMAIN | SEARCH_FUNCTION_DOMAIN)) != 0) { for (minimal_symbol *msymbol : objfile->msymbols ()) { @@ -4761,7 +4745,7 @@ global_symbol_searcher::expand_symtabs in the process we will add matching symbols or msymbols to the results list, and that requires that the symbols tables are expanded. */ - if (kind == FUNCTIONS_DOMAIN + if ((kind & SEARCH_FUNCTION_DOMAIN) != 0 ? (find_pc_compunit_symtab (msymbol->value_address (objfile)) == NULL) : (lookup_symbol_in_objfile_from_linkage_name @@ -4786,7 +4770,7 @@ global_symbol_searcher::add_matching_symbols const gdb::optional &treg, std::set *result_set) const { - enum search_domain kind = m_kind; + domain_search_flags kind = m_kind; /* Add matching symbols (if not already present). */ for (compunit_symtab *cust : objfile->compunits ()) @@ -4819,7 +4803,7 @@ global_symbol_searcher::add_matching_symbols continue; bool matches = false; - if (!matches && kind == VARIABLES_DOMAIN) + if (!matches && (kind & SEARCH_VAR_DOMAIN) != 0) { if (sym->aclass () != LOC_TYPEDEF && sym->aclass () != LOC_UNRESOLVED @@ -4835,7 +4819,7 @@ global_symbol_searcher::add_matching_symbols || treg_matches_sym_type_name (*treg, sym))) matches = true; } - if (!matches && kind == FUNCTIONS_DOMAIN) + if (!matches && (kind & SEARCH_FUNCTION_DOMAIN) != 0) { if (sym->aclass () == LOC_BLOCK && (!treg.has_value () @@ -4843,13 +4827,13 @@ global_symbol_searcher::add_matching_symbols sym))) matches = true; } - if (!matches && kind == TYPES_DOMAIN) + if (!matches && (kind & SEARCH_TYPE_DOMAIN) != 0) { if (sym->aclass () == LOC_TYPEDEF && sym->domain () != MODULE_DOMAIN) matches = true; } - if (!matches && kind == MODULES_DOMAIN) + if (!matches && (kind & SEARCH_MODULE_DOMAIN) != 0) { if (sym->domain () == MODULE_DOMAIN && sym->line () != 0) @@ -4881,7 +4865,7 @@ global_symbol_searcher::add_matching_msymbols (objfile *objfile, const gdb::optional &preg, std::vector *results) const { - enum search_domain kind = m_kind; + domain_search_flags kind = m_kind; for (minimal_symbol *msymbol : objfile->msymbols ()) { @@ -4898,7 +4882,7 @@ global_symbol_searcher::add_matching_msymbols { /* For functions we can do a quick check of whether the symbol might be found via find_pc_symtab. */ - if (kind != FUNCTIONS_DOMAIN + if ((kind & SEARCH_FUNCTION_DOMAIN) == 0 || (find_pc_compunit_symtab (msymbol->value_address (objfile)) == NULL)) { @@ -4928,8 +4912,6 @@ global_symbol_searcher::search () const gdb::optional preg; gdb::optional treg; - gdb_assert (m_kind != ALL_DOMAIN); - if (m_symbol_name_regexp != NULL) { const char *symbol_name_regexp = m_symbol_name_regexp; @@ -5006,11 +4988,13 @@ global_symbol_searcher::search () const user wants to see symbols matching a type regexp, then never give a minimal symbol, as we assume that a minimal symbol does not have a type. */ - if ((found_msymbol || (filenames.empty () && m_kind == VARIABLES_DOMAIN)) + if ((found_msymbol + || (filenames.empty () && (m_kind & SEARCH_VAR_DOMAIN) != 0)) && !m_exclude_minsyms && !treg.has_value ()) { - gdb_assert (m_kind == VARIABLES_DOMAIN || m_kind == FUNCTIONS_DOMAIN); + gdb_assert ((m_kind & (SEARCH_VAR_DOMAIN | SEARCH_FUNCTION_DOMAIN)) + != 0); for (objfile *objfile : current_program_space->objfiles ()) if (!add_matching_msymbols (objfile, preg, &result)) break; @@ -5141,36 +5125,55 @@ print_msymbol_info (struct bound_minimal_symbol msymbol) static void symtab_symbol_info (bool quiet, bool exclude_minsyms, - const char *regexp, enum search_domain kind, + const char *regexp, domain_enum kind, const char *t_regexp, int from_tty) { - static const char * const classnames[] = - {"variable", "function", "type", "module"}; const char *last_filename = ""; int first = 1; - gdb_assert (kind != ALL_DOMAIN); - if (regexp != nullptr && *regexp == '\0') regexp = nullptr; - global_symbol_searcher spec (kind, regexp); + domain_search_flags flags = to_search_flags (kind); + if (kind == TYPE_DOMAIN) + flags |= SEARCH_STRUCT_DOMAIN; + + global_symbol_searcher spec (flags, regexp); spec.set_symbol_type_regexp (t_regexp); spec.set_exclude_minsyms (exclude_minsyms); std::vector symbols = spec.search (); if (!quiet) { + const char *classname; + switch (kind) + { + case VAR_DOMAIN: + classname = "variable"; + break; + case FUNCTION_DOMAIN: + classname = "function"; + break; + case TYPE_DOMAIN: + classname = "type"; + break; + case MODULE_DOMAIN: + classname = "module"; + break; + default: + gdb_assert_not_reached ("invalid domain enum"); + } + if (regexp != NULL) { if (t_regexp != NULL) gdb_printf (_("All %ss matching regular expression \"%s\"" " with type matching regular expression \"%s\":\n"), - classnames[kind], regexp, t_regexp); + classname, regexp, t_regexp); else gdb_printf (_("All %ss matching regular expression \"%s\":\n"), - classnames[kind], regexp); + classname, regexp); } else { @@ -5178,9 +5181,9 @@ symtab_symbol_info (bool quiet, bool exclude_minsyms, gdb_printf (_("All defined %ss" " with type matching regular expression \"%s\" :\n"), - classnames[kind], t_regexp); + classname, t_regexp); else - gdb_printf (_("All defined %ss:\n"), classnames[kind]); + gdb_printf (_("All defined %ss:\n"), classname); } } @@ -5283,7 +5286,7 @@ info_variables_command (const char *args, int from_tty) args = nullptr; symtab_symbol_info - (opts.quiet, opts.exclude_minsyms, args, VARIABLES_DOMAIN, + (opts.quiet, opts.exclude_minsyms, args, VAR_DOMAIN, opts.type_regexp.empty () ? nullptr : opts.type_regexp.c_str (), from_tty); } @@ -5302,7 +5305,7 @@ info_functions_command (const char *args, int from_tty) args = nullptr; symtab_symbol_info - (opts.quiet, opts.exclude_minsyms, args, FUNCTIONS_DOMAIN, + (opts.quiet, opts.exclude_minsyms, args, FUNCTION_DOMAIN, opts.type_regexp.empty () ? nullptr : opts.type_regexp.c_str (), from_tty); } @@ -5345,7 +5348,8 @@ info_types_command (const char *args, int from_tty) (&args, gdb::option::PROCESS_OPTIONS_UNKNOWN_IS_OPERAND, grp); if (args != nullptr && *args == '\0') args = nullptr; - symtab_symbol_info (opts.quiet, false, args, TYPES_DOMAIN, NULL, from_tty); + symtab_symbol_info (opts.quiet, false, args, TYPE_DOMAIN, nullptr, + from_tty); } /* Command completer for 'info types' command. */ @@ -5377,7 +5381,7 @@ info_modules_command (const char *args, int from_tty) (&args, gdb::option::PROCESS_OPTIONS_UNKNOWN_IS_OPERAND, grp); if (args != nullptr && *args == '\0') args = nullptr; - symtab_symbol_info (opts.quiet, true, args, MODULES_DOMAIN, NULL, + symtab_symbol_info (opts.quiet, true, args, MODULE_DOMAIN, nullptr, from_tty); } @@ -5420,7 +5424,7 @@ rbreak_command (const char *regexp, int from_tty) } } - global_symbol_searcher spec (FUNCTIONS_DOMAIN, regexp); + global_symbol_searcher spec (SEARCH_FUNCTION_DOMAIN, regexp); if (file_name != nullptr) spec.filenames.push_back (file_name); std::vector symbols = spec.search (); @@ -5918,7 +5922,7 @@ default_collect_symbol_completion_matches_break_on return true; }, SEARCH_GLOBAL_BLOCK | SEARCH_STATIC_BLOCK, - ALL_DOMAIN); + SEARCH_ALL); /* Search upwards from currently selected frame (so that we can complete on local vars). Also catch fields of types defined in @@ -6615,12 +6619,12 @@ static struct cmd_list_element *info_module_cmdlist = NULL; std::vector search_module_symbols (const char *module_regexp, const char *regexp, - const char *type_regexp, search_domain kind) + const char *type_regexp, domain_search_flags kind) { std::vector results; /* Search for all modules matching MODULE_REGEXP. */ - global_symbol_searcher spec1 (MODULES_DOMAIN, module_regexp); + global_symbol_searcher spec1 (SEARCH_MODULE_DOMAIN, module_regexp); spec1.set_exclude_minsyms (true); std::vector modules = spec1.search (); @@ -6666,8 +6670,10 @@ search_module_symbols (const char *module_regexp, const char *regexp, static void info_module_subcommand (bool quiet, const char *module_regexp, const char *regexp, const char *type_regexp, - search_domain kind) + domain_search_flags kind) { + gdb_assert (kind == SEARCH_FUNCTION_DOMAIN || kind == SEARCH_VAR_DOMAIN); + /* Print a header line. Don't build the header line bit by bit as this prevents internationalisation. */ if (!quiet) @@ -6677,12 +6683,12 @@ info_module_subcommand (bool quiet, const char *module_regexp, if (type_regexp == nullptr) { if (regexp == nullptr) - gdb_printf ((kind == VARIABLES_DOMAIN + gdb_printf ((kind == SEARCH_VAR_DOMAIN ? _("All variables in all modules:") : _("All functions in all modules:"))); else gdb_printf - ((kind == VARIABLES_DOMAIN + ((kind == SEARCH_VAR_DOMAIN ? _("All variables matching regular expression" " \"%s\" in all modules:") : _("All functions matching regular expression" @@ -6693,7 +6699,7 @@ info_module_subcommand (bool quiet, const char *module_regexp, { if (regexp == nullptr) gdb_printf - ((kind == VARIABLES_DOMAIN + ((kind == SEARCH_VAR_DOMAIN ? _("All variables with type matching regular " "expression \"%s\" in all modules:") : _("All functions with type matching regular " @@ -6701,7 +6707,7 @@ info_module_subcommand (bool quiet, const char *module_regexp, type_regexp); else gdb_printf - ((kind == VARIABLES_DOMAIN + ((kind == SEARCH_VAR_DOMAIN ? _("All variables matching regular expression " "\"%s\",\n\twith type matching regular " "expression \"%s\" in all modules:") @@ -6717,7 +6723,7 @@ info_module_subcommand (bool quiet, const char *module_regexp, { if (regexp == nullptr) gdb_printf - ((kind == VARIABLES_DOMAIN + ((kind == SEARCH_VAR_DOMAIN ? _("All variables in all modules matching regular " "expression \"%s\":") : _("All functions in all modules matching regular " @@ -6725,7 +6731,7 @@ info_module_subcommand (bool quiet, const char *module_regexp, module_regexp); else gdb_printf - ((kind == VARIABLES_DOMAIN + ((kind == SEARCH_VAR_DOMAIN ? _("All variables matching regular expression " "\"%s\",\n\tin all modules matching regular " "expression \"%s\":") @@ -6738,7 +6744,7 @@ info_module_subcommand (bool quiet, const char *module_regexp, { if (regexp == nullptr) gdb_printf - ((kind == VARIABLES_DOMAIN + ((kind == SEARCH_VAR_DOMAIN ? _("All variables with type matching regular " "expression \"%s\"\n\tin all modules matching " "regular expression \"%s\":") @@ -6748,7 +6754,7 @@ info_module_subcommand (bool quiet, const char *module_regexp, type_regexp, module_regexp); else gdb_printf - ((kind == VARIABLES_DOMAIN + ((kind == SEARCH_VAR_DOMAIN ? _("All variables matching regular expression " "\"%s\",\n\twith type matching regular expression " "\"%s\",\n\tin all modules matching regular " @@ -6863,7 +6869,7 @@ info_module_functions_command (const char *args, int from_tty) (opts.quiet, opts.module_regexp.empty () ? nullptr : opts.module_regexp.c_str (), args, opts.type_regexp.empty () ? nullptr : opts.type_regexp.c_str (), - FUNCTIONS_DOMAIN); + SEARCH_FUNCTION_DOMAIN); } /* Implements the 'info module variables' command. */ @@ -6882,7 +6888,7 @@ info_module_variables_command (const char *args, int from_tty) (opts.quiet, opts.module_regexp.empty () ? nullptr : opts.module_regexp.c_str (), args, opts.type_regexp.empty () ? nullptr : opts.type_regexp.c_str (), - VARIABLES_DOMAIN); + SEARCH_VAR_DOMAIN); } /* Command completer for 'info module ...' sub-commands. */ diff --git a/gdb/symtab.h b/gdb/symtab.h index 0328a2024ad..d9caeb70856 100644 --- a/gdb/symtab.h +++ b/gdb/symtab.h @@ -941,30 +941,6 @@ search_flags_matches (domain_search_flags flags, domain_enum domain) return (flags & to_search_flags (domain)) != 0; } -/* Searching domains, used when searching for symbols. Element numbers are - hardcoded in GDB, check all enum uses before changing it. */ - -enum search_domain -{ - /* Everything in VAR_DOMAIN minus FUNCTIONS_DOMAIN and - TYPES_DOMAIN. */ - VARIABLES_DOMAIN = 0, - - /* All functions -- for some reason not methods, though. */ - FUNCTIONS_DOMAIN = 1, - - /* All defined types */ - TYPES_DOMAIN = 2, - - /* All modules. */ - MODULES_DOMAIN = 3, - - /* Any type. */ - ALL_DOMAIN = 4 -}; - -extern const char *search_domain_name (enum search_domain); - /* An address-class says where to find the value of a symbol. */ enum address_class @@ -2546,13 +2522,11 @@ class global_symbol_searcher public: /* Constructor. */ - global_symbol_searcher (enum search_domain kind, + global_symbol_searcher (domain_search_flags kind, const char *symbol_name_regexp) : m_kind (kind), m_symbol_name_regexp (symbol_name_regexp) { - /* The symbol searching is designed to only find one kind of thing. */ - gdb_assert (m_kind != ALL_DOMAIN); } /* Set the optional regexp that matches against the symbol type. */ @@ -2594,7 +2568,7 @@ class global_symbol_searcher TYPES_DOMAIN - Search all type names. MODULES_DOMAIN - Search all Fortran modules. ALL_DOMAIN - Not valid for this function. */ - enum search_domain m_kind; + domain_search_flags m_kind; /* Regular expression to match against the symbol name. */ const char *m_symbol_name_regexp = nullptr; @@ -2638,7 +2612,7 @@ class global_symbol_searcher std::vector *results) const; /* Return true if MSYMBOL is of type KIND. */ - static bool is_suitable_msymbol (const enum search_domain kind, + static bool is_suitable_msymbol (const domain_search_flags kind, const minimal_symbol *msymbol); }; @@ -2655,7 +2629,7 @@ typedef std::pair module_symbol_search; within the module. */ extern std::vector search_module_symbols (const char *module_regexp, const char *regexp, - const char *type_regexp, search_domain kind); + const char *type_regexp, domain_search_flags kind); /* Convert a global or static symbol SYM (based on BLOCK, which should be either GLOBAL_BLOCK or STATIC_BLOCK) into a string for use in 'info' @@ -2857,7 +2831,7 @@ class symbol_searcher to search all symtabs and program spaces. */ void find_all_symbols (const std::string &name, const struct language_defn *language, - enum search_domain search_domain, + domain_search_flags domain_search_flags, std::vector *search_symtabs, struct program_space *search_pspace); From patchwork Tue Nov 21 03:53:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 80400 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 BD28C38582B9 for ; Tue, 21 Nov 2023 03:54:35 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from omta040.useast.a.cloudfilter.net (omta040.useast.a.cloudfilter.net [44.202.169.39]) by sourceware.org (Postfix) with ESMTPS id 087D23858C5F for ; Tue, 21 Nov 2023 03:53:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 087D23858C5F 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 087D23858C5F Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=44.202.169.39 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700538805; cv=none; b=mFeYa2/628vHmwir12mcqOq223Jnf/UusO37/JDQMkzaIoPgVGVahKzh0ZVYCbnuZhGAlR/4qW27tPgXy8DrOA/O6zLf7qha0kgGolzJPgWRjEGDVu+f5CTr5tIfxYTt6g3K6jz5+dJMFQ1KgofaOQu5ny2aCFwHQGauooqocTA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700538805; c=relaxed/simple; bh=nng+zizKLwfyyiHxu38Gmq1Os9Fro6jVnY71/V+JvFY=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=pX77+nTMG4LdLgd08Enj2qUFhcFdVX+7CxzZulblNyfq/OWOzRGRaQIRRHhQYiZunicWrY4UvmNk3vTS/5v6SHakRgGWsN2hzzbZl1oWMvB1/mzZGhQ5DAeBb6mjG5ChlO+MA7ACQtUcCFVHh+1qd/ZIRbaz1iJCSVBu4OlESS0= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from eig-obgw-6005a.ext.cloudfilter.net ([10.0.30.201]) by cmsmtp with ESMTPS id 5Bpmrpjkf6nOZ5HpBrzrPV; Tue, 21 Nov 2023 03:53:21 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id 5HpArSwna8KNv5HpAr45JG; Tue, 21 Nov 2023 03:53:20 +0000 X-Authority-Analysis: v=2.4 cv=dp3Itns4 c=1 sm=1 tr=0 ts=655c29b0 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=xBr83xsTwwIbWKOzC-sA:9 a=QEXdDO2ut3YA:10 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=To:In-Reply-To:References:Message-Id:Content-Transfer-Encoding: Content-Type:MIME-Version:Subject:Date:From:Sender:Reply-To:Cc:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=VaRSqmF9BpyglVuutUMW+L9p8CYTiT11Ag2JD6gPx3A=; b=Nk/soVErEuhKnZNOYNdO8+80iq RnrwF1+p2TU83caeJuElCFS1eXhCEYSkEFCOhn2e+fsKjz6ykxJmS3VSqhJL5mCS5aIXEvO+aGUVm D0UowLAO97b+RFvuZdVCpRlfb; 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 1r5HpA-0040be-0n for gdb-patches@sourceware.org; Mon, 20 Nov 2023 20:53:20 -0700 From: Tom Tromey Date: Mon, 20 Nov 2023 20:53:44 -0700 Subject: [PATCH 13/29] Remove a check of VAR_DOMAIN MIME-Version: 1.0 Message-Id: <20231120-submit-domain-hacks-2-v1-13-29650d01b198@tromey.com> References: <20231120-submit-domain-hacks-2-v1-0-29650d01b198@tromey.com> In-Reply-To: <20231120-submit-domain-hacks-2-v1-0-29650d01b198@tromey.com> 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: 1r5HpA-0040be-0n 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: 14 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfDVUQy4HVEnRl3UkgTeqXI3E6BtVgbohOlMurCb+T3QmnrW7UL1qXI0+5SFkFmv3zgbyPjRf5PSONSxkv774ow4E6a1iGoEpct3hZYgWUTEj+ryhWcWc N0lT5hk2m7L24yM+b6Q3UslyqrG47uKJQAgwq8HLTh8vzkTuAgILIP+/rH1FbOQFccSTJHFFx4z3wuYLQM5sQ17HXi7qk4wRDoA= X-Spam-Status: No, score=-3024.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham 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 completion_list_add_symbol checks that the returned symbol has VAR_DOMAIN, but also checks that its address class is LOC_BLOCK. The domain check is redundant -- only functions can possibly be LOC_BLOCK -- and leaving this in place will cause a regression when combined with a later patch in this series. This patch preemptively removes the redundant check. --- gdb/symtab.c | 1 - 1 file changed, 1 deletion(-) diff --git a/gdb/symtab.c b/gdb/symtab.c index e5e168c20e9..3159e5d2cea 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -5534,7 +5534,6 @@ completion_list_add_symbol (completion_tracker &tracker, the msymbol name and removes the msymbol name from the completion tracker. */ if (sym->language () == language_cplus - && sym->domain () == VAR_DOMAIN && sym->aclass () == LOC_BLOCK) { /* The call to canonicalize returns the empty string if the input From patchwork Tue Nov 21 03:53:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 80411 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 6C3D638582B2 for ; Tue, 21 Nov 2023 03:55:29 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from omta34.uswest2.a.cloudfilter.net (omta34.uswest2.a.cloudfilter.net [35.89.44.33]) by sourceware.org (Postfix) with ESMTPS id C4A1F3858C2B for ; Tue, 21 Nov 2023 03:53:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C4A1F3858C2B 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 C4A1F3858C2B Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=35.89.44.33 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700538807; cv=none; b=almpmYSibFkbePgY9fSj3aKdD6MSXzchuqnqPmn1ei8oESyIED0uXLG4f9WHlurN7T9oBQDvc+UY5CZM9k+v9hMHBqiXEtSHcZ2Jp2ajOLDwjbOqchydwzYfN2mNR496epmKDpiIbuAJzB+qs5HiKIIGoKZQBus6Ah/4ejqCmzE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700538807; c=relaxed/simple; bh=HKn+RXvOcNe3wt89a+E6+XQ+Nl03VoycFVI6GXd2lmg=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=meRc9TFX+SKiU6RMzh4kHz8ahJw5Hov5che3I5b8oyP6gN07BZNgDFL+SoReB85rtatVd6EtcbNTCx2Pz0XH5/yFcXks7iHlwYaLnApITfcmoKDEPBiyTxt9W4IeZF3+UaxDmI0Lxu5infjluSriJFAae3TCIExv+8H0voyk1W0= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from eig-obgw-5010a.ext.cloudfilter.net ([10.0.29.199]) by cmsmtp with ESMTPS id 5BpmrSOJl8Hte5HpBrHZWj; Tue, 21 Nov 2023 03:53:22 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id 5HpArfsXBhDny5HpBrXecz; Tue, 21 Nov 2023 03:53:21 +0000 X-Authority-Analysis: v=2.4 cv=fda+dmcF c=1 sm=1 tr=0 ts=655c29b1 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=6hCNZdMetuoarO1jANEA:9 a=QEXdDO2ut3YA:10 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=To:In-Reply-To:References:Message-Id:Content-Transfer-Encoding: Content-Type:MIME-Version:Subject:Date:From:Sender:Reply-To:Cc:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=AnS6NCisU6rOWvIxCLTmX3QhHhuFosGGqmp4bAuneaE=; b=v1GZ07xD1nTq8gdLnkdYgFF8by UVoCK1HepZijO9NF1ley2wdAu6vDLK9hVCDz0dc54CRncH/9Oi2IfoF45YIYcNqNdXr/u+xx2QDiM bRd9YQI62HRXlub1at3+QBcI1; 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 1r5HpA-0040be-1V for gdb-patches@sourceware.org; Mon, 20 Nov 2023 20:53:20 -0700 From: Tom Tromey Date: Mon, 20 Nov 2023 20:53:45 -0700 Subject: [PATCH 14/29] Introduce "scripting" domains MIME-Version: 1.0 Message-Id: <20231120-submit-domain-hacks-2-v1-14-29650d01b198@tromey.com> References: <20231120-submit-domain-hacks-2-v1-0-29650d01b198@tromey.com> In-Reply-To: <20231120-submit-domain-hacks-2-v1-0-29650d01b198@tromey.com> 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: 1r5HpA-0040be-1V 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: 15 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfBqojCMt5wSPYfVq1oTnYfw5ETtKVInfbjezhLsgIRBC+GgWafL5xbktG65yKFONJtUml/qrUub9M+jReqcrPXr/P6JKbyRss6gVo8135ECtx7ho5YJl zp6o8WI+ti0YxILqkl+3VV5PmKQTR3AbdG4434Rzqk/Oq6Dr6fcVxTGbp6chehQ/yw/KKfx7aCfH6Axx61UDURzFAGs3vVIyN+c= X-Spam-Status: No, score=-3024.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham 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 The Python and Guile code exposed the internal domain constants both as attributes of symbols and as values to pass to lookup functions. Now, perfect backward compatibility here can't be achieved: some symbols are going to have domain changes by the end of this series. However, it seemed to me that we can preserve lookups using the basic domain values. This patch implements this by exporting the "or"-able search constants with an extra bit set. Then it introduces some functions to convert such constants to domain_search_flags. This will be used by the Python and Guile code, so that both old- and new-style lookups will work properly; and while preserving the idea that the domain constants can be compared to a symbol's domain. --- gdb/symtab.c | 42 ++++++++++++++++++++++++++++++++++++++++++ gdb/symtab.h | 31 +++++++++++++++++++++++++++++++ 2 files changed, 73 insertions(+) diff --git a/gdb/symtab.c b/gdb/symtab.c index 3159e5d2cea..6020efe197b 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -329,6 +329,48 @@ domain_name (domain_search_flags flags) /* See symtab.h. */ +domain_search_flags +from_scripting_domain (int val) +{ + if ((val & SCRIPTING_SEARCH_FLAG) == 0) + { + /* VAL should be one of the domain constants. Verify this and + convert it to a search constant. */ + switch (val) + { +#define DOMAIN(X) \ + case X ## _DOMAIN: break; +#include "sym-domains.def" +#undef DOMAIN + default: + error (_("unrecognized domain constant")); + } + domain_search_flags result = to_search_flags ((domain_enum) val); + if (val == VAR_DOMAIN) + { + /* This matches the historical practice. */ + result |= SEARCH_TYPE_DOMAIN | SEARCH_FUNCTION_DOMAIN; + } + return result; + } + else + { + /* VAL is several search constants or'd together. Verify + this. */ + val &= ~SCRIPTING_SEARCH_FLAG; + int check = val; +#define DOMAIN(X) \ + check &= ~ (int) SEARCH_ ## X ## _DOMAIN; +#include "sym-domains.def" +#undef DOMAIN + if (check != 0) + error (_("unrecognized domain constant")); + return (domain_search_flag) val; + } +} + +/* See symtab.h. */ + CORE_ADDR linetable_entry::pc (const struct objfile *objfile) const { diff --git a/gdb/symtab.h b/gdb/symtab.h index d9caeb70856..5f2b17a3cee 100644 --- a/gdb/symtab.h +++ b/gdb/symtab.h @@ -941,6 +941,37 @@ search_flags_matches (domain_search_flags flags, domain_enum domain) return (flags & to_search_flags (domain)) != 0; } +/* Some helpers for Python and Guile to account for backward + compatibility. Those exposed the domains for lookup as well as + checking attributes of a symbol, so special encoding and decoding + is needed to continue to support both uses. Domain constants must + remain unchanged, so that comparing a symbol's domain against a + constant yields the correct result, so search symbols are + distinguished by adding a flag bit. This way, either sort of + constant can be used for lookup. */ + +/* The flag bit. */ +constexpr int SCRIPTING_SEARCH_FLAG = 0x8000; +gdb_static_assert (SCRIPTING_SEARCH_FLAG > SEARCH_ALL); + +/* Convert a domain constant to a "scripting domain". */ +static constexpr inline int +to_scripting_domain (domain_enum val) +{ + return val; +} + +/* Convert a search constant to a "scripting domain". */ +static constexpr inline int +to_scripting_domain (domain_search_flags val) +{ + return SCRIPTING_SEARCH_FLAG | (int) val; +} + +/* Convert from a "scripting domain" constant back to search flags. + Throws an exception if VAL is not one of the allowable values. */ +extern domain_search_flags from_scripting_domain (int val); + /* An address-class says where to find the value of a symbol. */ enum address_class From patchwork Tue Nov 21 03:53:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 80419 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 7102D3858413 for ; Tue, 21 Nov 2023 03:57:02 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from omta34.uswest2.a.cloudfilter.net (omta34.uswest2.a.cloudfilter.net [35.89.44.33]) by sourceware.org (Postfix) with ESMTPS id AC8F13858C29 for ; Tue, 21 Nov 2023 03:53:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org AC8F13858C29 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 AC8F13858C29 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=35.89.44.33 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700538812; cv=none; b=v4r1pW94DairZHGxvgq3rvuJvrluQcUVz5Ykc0Vuy1vp/2VQVw1NGj3ArrtaC1x3PKRrRHs0hINxVeFBJ0FyXqAV1bhZOs8ma/fxb0UUu7xfoVmK3V4/0kc9mVEMxd6R7mziVJHydH6N+1tEsP13Du/ivVpVbGI4ch4QUsKFcPA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700538812; c=relaxed/simple; bh=XOqR3CvSf/AKflmjErX2+8GkA2rrfPX+pdlp2yk30Fk=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=nz3AQ6vYDcgKoGfBSDvCH+xgQpibrqdzxoZ3aSyS10BLXB0C44ahFHS0IySiDrVKiWg10Y8AXBc5TiQGHySgV6Qd7I9o1jWBSrAYpvROnmBGa6lYua9RFN7z1oHNc2Ir2J7xx+sb2wppbCr8L8lSYR6wEDtmdShnt7hcr0fgrL8= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from eig-obgw-6008a.ext.cloudfilter.net ([10.0.30.227]) by cmsmtp with ESMTPS id 5BpdrSOGl8Hte5HpBrHZWl; Tue, 21 Nov 2023 03:53:21 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id 5HpArVJ6K0xkr5HpBrJQLD; Tue, 21 Nov 2023 03:53:21 +0000 X-Authority-Analysis: v=2.4 cv=N7U6qkxB c=1 sm=1 tr=0 ts=655c29b1 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=7fyo1awz9btw2pRx8aYA:9 a=QEXdDO2ut3YA:10 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=To:In-Reply-To:References:Message-Id:Content-Transfer-Encoding: Content-Type:MIME-Version:Subject:Date:From:Sender:Reply-To:Cc:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=okymH9Y3GdAEtLnU6/umDvu6M36JKZVfdusqN25020E=; b=W/KGl9Ts12zlf/Tr/rB0rjVp/s XYLNuVrFYHHCUR45uA6L13n7DO8h7L94vLUC/xYaoJ0TWs5gH0p1Vzf2Uu1jvQnWTG/Wf9uTu4oQW H1V6sb89EgNUi9Rji33OdZaK/; 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 1r5HpA-0040be-1y for gdb-patches@sourceware.org; Mon, 20 Nov 2023 20:53:20 -0700 From: Tom Tromey Date: Mon, 20 Nov 2023 20:53:46 -0700 Subject: [PATCH 15/29] Use domain_search_flags in lookup_global_symbol_language MIME-Version: 1.0 Message-Id: <20231120-submit-domain-hacks-2-v1-15-29650d01b198@tromey.com> References: <20231120-submit-domain-hacks-2-v1-0-29650d01b198@tromey.com> In-Reply-To: <20231120-submit-domain-hacks-2-v1-0-29650d01b198@tromey.com> 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: 1r5HpA-0040be-1y 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: 16 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfGoAHmGx7GDcZ6xO/z0+sJT0mI1yEIu5FaJxXw1nUr37G2ZLwXlAbtQ5hWADcJsLqmAfHNqxxxEcMVVDjGL9SvoZ79Bj/cfkxqP2WYeEIHiSFkIVLPsp xB2yZvC/t8pfe4C2r49i7BkussIjjubTEPkGvRlMwnvAWhG7M40jkwBBj2yjThMPo9paVO/zmGRZhe7sHIYIl85XhWnuJ/lyyGw= X-Spam-Status: No, score=-3024.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham 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 This changes quick_symbol_functions::lookup_global_symbol_language to accept domain_search_flags rather than just a domain_enum, and fixes up the fallout. To avoid introducing any regressions, any code passing VAR_DOMAIN now uses SEARCH_VFT. That is, no visible changes should result from this patch. However, it sets the stage to refine some searches later on. --- gdb/ada-exp.y | 13 ++++---- gdb/ada-lang.c | 69 ++++++++++++++++++++++--------------------- gdb/ada-lang.h | 6 ++-- gdb/dwarf2/cooked-index.h | 22 -------------- gdb/dwarf2/read-debug-names.c | 32 +++++++------------- gdb/dwarf2/read-gdb-index.c | 16 +++++----- gdb/dwarf2/read.c | 24 +++++++-------- gdb/dwarf2/read.h | 2 +- gdb/language.h | 2 +- gdb/linespec.c | 42 +++++++++++++++----------- gdb/objfiles.h | 7 ++--- gdb/psymtab.c | 48 ++++++++++-------------------- gdb/psymtab.h | 5 ++-- gdb/quick-symbol.h | 12 ++++---- gdb/symfile-debug.c | 25 ++++++++-------- gdb/symfile.c | 5 ++-- gdb/symmisc.c | 1 - gdb/symtab.c | 7 ++--- gdb/symtab.h | 4 +-- 19 files changed, 144 insertions(+), 198 deletions(-) diff --git a/gdb/ada-exp.y b/gdb/ada-exp.y index 3280a483a5e..df7a85f101d 100644 --- a/gdb/ada-exp.y +++ b/gdb/ada-exp.y @@ -1265,7 +1265,7 @@ write_object_renaming (struct parser_state *par_state, name = obstack_strndup (&temp_parse_space, renamed_entity, renamed_entity_len); - ada_lookup_encoded_symbol (name, orig_left_context, VAR_DOMAIN, &sym_info); + ada_lookup_encoded_symbol (name, orig_left_context, SEARCH_VFT, &sym_info); if (sym_info.symbol == NULL) error (_("Could not find renamed variable: %s"), ada_decode (name).c_str ()); else if (sym_info.symbol->aclass () == LOC_TYPEDEF) @@ -1334,7 +1334,7 @@ write_object_renaming (struct parser_state *par_state, renaming_expr = end; ada_lookup_encoded_symbol (index_name, orig_left_context, - VAR_DOMAIN, &index_sym_info); + SEARCH_VFT, &index_sym_info); if (index_sym_info.symbol == NULL) error (_("Could not find %s"), index_name); else if (index_sym_info.symbol->aclass () == LOC_TYPEDEF) @@ -1404,7 +1404,7 @@ block_lookup (const struct block *context, const char *raw_name) } std::vector syms - = ada_lookup_symbol_list (name, context, VAR_DOMAIN); + = ada_lookup_symbol_list (name, context, SEARCH_VFT); if (context == NULL && (syms.empty () || syms[0].symbol->aclass () != LOC_BLOCK)) @@ -1483,7 +1483,7 @@ find_primitive_type (struct parser_state *par_state, const char *name) (char *) alloca (strlen (name) + sizeof ("standard__")); strcpy (expanded_name, "standard__"); strcat (expanded_name, name); - sym = ada_lookup_symbol (expanded_name, NULL, VAR_DOMAIN).symbol; + sym = ada_lookup_symbol (expanded_name, NULL, SEARCH_VFT).symbol; if (sym != NULL && sym->aclass () == LOC_TYPEDEF) type = sym->type (); } @@ -1670,7 +1670,8 @@ write_var_or_type (struct parser_state *par_state, encoded_name[tail_index] = terminator; std::vector syms - = ada_lookup_symbol_list (decoded_name.c_str (), block, VAR_DOMAIN); + = ada_lookup_symbol_list (decoded_name.c_str (), block, + SEARCH_VFT); type_sym = select_possible_type_sym (syms); @@ -1876,7 +1877,7 @@ write_name_assoc (struct parser_state *par_state, struct stoken name) std::vector syms = ada_lookup_symbol_list (name.ptr, par_state->expression_context_block, - VAR_DOMAIN); + SEARCH_VFT); if (syms.size () != 1 || syms[0].symbol->aclass () == LOC_TYPEDEF) pstate->push_new (copy_name (name)); diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index eac688cd632..36192dc07c6 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -98,12 +98,12 @@ static struct value *make_array_descriptor (struct type *, struct value *); static void ada_add_block_symbols (std::vector &, const struct block *, const lookup_name_info &lookup_name, - domain_enum, struct objfile *); + domain_search_flags, struct objfile *); static void ada_add_all_symbols (std::vector &, const struct block *, const lookup_name_info &lookup_name, - domain_enum, int, int *); + domain_search_flags, int, int *); static int is_nonfunction (const std::vector &); @@ -176,9 +176,6 @@ static LONGEST pos_atr (struct value *); static struct value *val_atr (struct type *, LONGEST); -static struct symbol *standard_lookup (const char *, const struct block *, - domain_enum); - static struct value *ada_search_struct_field (const char *, struct value *, int, struct type *); @@ -335,7 +332,7 @@ struct cache_entry /* The name used to perform the lookup. */ std::string name; /* The namespace used during the lookup. */ - domain_enum domain = UNDEF_DOMAIN; + domain_search_flags domain = 0; /* The symbol returned by the lookup, or NULL if no matching symbol was found. */ struct symbol *sym = nullptr; @@ -349,7 +346,7 @@ struct cache_entry struct cache_entry_search { const char *name; - domain_enum domain; + domain_search_flags domain; hashval_t hash () const { @@ -3751,7 +3748,7 @@ ada_find_operator_symbol (enum exp_opcode op, bool parse_completion, { std::vector candidates = ada_lookup_symbol_list (ada_decoded_op_name (op), - NULL, VAR_DOMAIN); + NULL, SEARCH_VFT); int i = ada_resolve_function (candidates, argvec, nargs, ada_decoded_op_name (op), NULL, @@ -3772,7 +3769,7 @@ ada_resolve_funcall (struct symbol *sym, const struct block *block, innermost_block_tracker *tracker) { std::vector candidates - = ada_lookup_symbol_list (sym->linkage_name (), block, VAR_DOMAIN); + = ada_lookup_symbol_list (sym->linkage_name (), block, SEARCH_VFT); int i; if (candidates.size () == 1) @@ -3838,7 +3835,7 @@ ada_resolve_variable (struct symbol *sym, const struct block *block, innermost_block_tracker *tracker) { std::vector candidates - = ada_lookup_symbol_list (sym->linkage_name (), block, VAR_DOMAIN); + = ada_lookup_symbol_list (sym->linkage_name (), block, SEARCH_VFT); if (std::any_of (candidates.begin (), candidates.end (), @@ -4685,7 +4682,7 @@ ada_clear_symbol_cache (program_space *pspace) SYM. Same principle for BLOCK if not NULL. */ static int -lookup_cached_symbol (const char *name, domain_enum domain, +lookup_cached_symbol (const char *name, domain_search_flags domain, struct symbol **sym, const struct block **block) { htab_t tab = get_ada_pspace_data (current_program_space); @@ -4708,8 +4705,8 @@ lookup_cached_symbol (const char *name, domain_enum domain, in domain DOMAIN, save this result in our symbol cache. */ static void -cache_symbol (const char *name, domain_enum domain, struct symbol *sym, - const struct block *block) +cache_symbol (const char *name, domain_search_flags domain, + struct symbol *sym, const struct block *block) { /* Symbols for builtin types don't have a block. For now don't cache such symbols. */ @@ -4766,7 +4763,7 @@ name_match_type_from_name (const char *lookup_name) static struct symbol * standard_lookup (const char *name, const struct block *block, - domain_enum domain) + domain_search_flags domain) { /* Initialize it just to avoid a GCC false warning. */ struct block_symbol sym = {}; @@ -5169,7 +5166,7 @@ is_package_name (const char *name) /* If it is a function that has not been defined at library level, then we should be able to look it up in the symbols. */ - if (standard_lookup (name, NULL, VAR_DOMAIN) != NULL) + if (standard_lookup (name, NULL, SEARCH_VFT) != NULL) return 0; /* Library-level function names start with "_ada_". See if function @@ -5182,7 +5179,7 @@ is_package_name (const char *name) std::string fun_name = string_printf ("_ada_%s", name); - return (standard_lookup (fun_name.c_str (), NULL, VAR_DOMAIN) == NULL); + return (standard_lookup (fun_name.c_str (), NULL, SEARCH_VFT) == NULL); } /* Return nonzero if SYM corresponds to a renaming entity that is @@ -5342,7 +5339,7 @@ remove_irrelevant_renamings (std::vector *syms, static void ada_add_local_symbols (std::vector &result, const lookup_name_info &lookup_name, - const struct block *block, domain_enum domain) + const struct block *block, domain_search_flags domain) { while (block != NULL) { @@ -5416,7 +5413,7 @@ static int ada_add_block_renamings (std::vector &result, const struct block *block, const lookup_name_info &lookup_name, - domain_enum domain) + domain_search_flags domain) { struct using_direct *renaming; int defns_mark = result.size (); @@ -5567,7 +5564,7 @@ static void map_matching_symbols (struct objfile *objfile, const lookup_name_info &lookup_name, bool is_wild_match, - domain_enum domain, + domain_search_flags domain, int global, match_data &data) { @@ -5594,7 +5591,7 @@ map_matching_symbols (struct objfile *objfile, static void add_nonlocal_symbols (std::vector &result, const lookup_name_info &lookup_name, - domain_enum domain, int global) + domain_search_flags domain, int global) { struct match_data data (&result); @@ -5648,7 +5645,7 @@ static void ada_add_all_symbols (std::vector &result, const struct block *block, const lookup_name_info &lookup_name, - domain_enum domain, + domain_search_flags domain, int full_search, int *made_global_lookup_p) { @@ -5728,7 +5725,7 @@ ada_add_all_symbols (std::vector &result, static std::vector ada_lookup_symbol_list_worker (const lookup_name_info &lookup_name, const struct block *block, - domain_enum domain, + domain_search_flags domain, int full_search) { int syms_from_global_search; @@ -5757,7 +5754,7 @@ ada_lookup_symbol_list_worker (const lookup_name_info &lookup_name, std::vector ada_lookup_symbol_list (const char *name, const struct block *block, - domain_enum domain) + domain_search_flags domain) { symbol_name_match_type name_match_type = name_match_type_from_name (name); lookup_name_info lookup_name (name, name_match_type); @@ -5774,7 +5771,7 @@ ada_lookup_symbol_list (const char *name, const struct block *block, void ada_lookup_encoded_symbol (const char *name, const struct block *block, - domain_enum domain, + domain_search_flags domain, struct block_symbol *info) { /* Since we already have an encoded name, wrap it in '<>' to force a @@ -5796,7 +5793,7 @@ ada_lookup_encoded_symbol (const char *name, const struct block *block, struct block_symbol ada_lookup_symbol (const char *name, const struct block *block0, - domain_enum domain) + domain_search_flags domain) { std::vector candidates = ada_lookup_symbol_list (name, block0, domain); @@ -6068,7 +6065,7 @@ static void ada_add_block_symbols (std::vector &result, const struct block *block, const lookup_name_info &lookup_name, - domain_enum domain, struct objfile *objfile) + domain_search_flags domain, struct objfile *objfile) { /* A matching argument symbol, if any. */ struct symbol *arg_sym; @@ -7501,11 +7498,11 @@ ada_find_any_type_symbol (const char *name) { struct symbol *sym; - sym = standard_lookup (name, get_selected_block (NULL), VAR_DOMAIN); + sym = standard_lookup (name, get_selected_block (NULL), SEARCH_VFT); if (sym != NULL && sym->aclass () == LOC_TYPEDEF) return sym; - sym = standard_lookup (name, NULL, STRUCT_DOMAIN); + sym = standard_lookup (name, NULL, SEARCH_STRUCT_DOMAIN); return sym; } @@ -11383,7 +11380,7 @@ get_var_value (const char *name, const char *err_msg) std::vector syms = ada_lookup_symbol_list_worker (lookup_name, get_selected_block (0), - VAR_DOMAIN, 1); + SEARCH_VFT, 1); if (syms.size () != 1) { @@ -11686,7 +11683,7 @@ ada_has_this_exception_support (const struct exception_support_info *einfo) that should be compiled with debugging information. As a result, we expect to find that symbol in the symtabs. */ - sym = standard_lookup (einfo->catch_exception_sym, NULL, VAR_DOMAIN); + sym = standard_lookup (einfo->catch_exception_sym, NULL, SEARCH_VFT); if (sym == NULL) { /* Perhaps we did not find our symbol because the Ada runtime was @@ -11720,7 +11717,7 @@ ada_has_this_exception_support (const struct exception_support_info *einfo) error (_("Symbol \"%s\" is not a function (class = %d)"), sym->linkage_name (), sym->aclass ()); - sym = standard_lookup (einfo->catch_handlers_sym, NULL, VAR_DOMAIN); + sym = standard_lookup (einfo->catch_handlers_sym, NULL, SEARCH_VFT); if (sym == NULL) { struct bound_minimal_symbol msym @@ -12687,7 +12684,7 @@ ada_exception_sal (enum ada_exception_catchpoint_kind ex) /* Then lookup the function on which we will break in order to catch the Ada exceptions requested by the user. */ sym_name = ada_exception_sym_name (ex); - sym = standard_lookup (sym_name, NULL, VAR_DOMAIN); + sym = standard_lookup (sym_name, NULL, SEARCH_VFT); if (sym == NULL) throw_error (NOT_FOUND_ERROR, _("Catchpoint symbol not found: %s"), @@ -13505,7 +13502,7 @@ class ada_language : public language_defn bool iterate_over_symbols (const struct block *block, const lookup_name_info &name, - domain_enum domain, + domain_search_flags domain, gdb::function_view callback) const override { std::vector results @@ -13742,11 +13739,15 @@ class ada_language : public language_defn { struct block_symbol sym; + domain_search_flags flags = to_search_flags (domain); + if (domain == VAR_DOMAIN) + flags |= SEARCH_TYPE_DOMAIN | SEARCH_FUNCTION_DOMAIN; + sym = ada_lookup_symbol (name, (block == nullptr ? nullptr : block->static_block ()), - domain); + flags); if (sym.symbol != NULL) return sym; diff --git a/gdb/ada-lang.h b/gdb/ada-lang.h index 9eb9326a86c..698d5b9f91a 100644 --- a/gdb/ada-lang.h +++ b/gdb/ada-lang.h @@ -222,14 +222,14 @@ extern std::string ada_decode (const char *name, bool wrap = true, bool operators = true); extern std::vector ada_lookup_symbol_list - (const char *, const struct block *, domain_enum); + (const char *, const struct block *, domain_search_flags); extern struct block_symbol ada_lookup_symbol (const char *, const struct block *, - domain_enum); + domain_search_flags); extern void ada_lookup_encoded_symbol - (const char *name, const struct block *block, domain_enum domain, + (const char *name, const struct block *block, domain_search_flags domain, struct block_symbol *symbol_info); extern struct bound_minimal_symbol ada_lookup_simple_minsym (const char *, diff --git a/gdb/dwarf2/cooked-index.h b/gdb/dwarf2/cooked-index.h index b3d5b5cd6f6..3b49f468be6 100644 --- a/gdb/dwarf2/cooked-index.h +++ b/gdb/dwarf2/cooked-index.h @@ -105,28 +105,6 @@ struct cooked_index_entry : public allocate_on_obstack return false; } - /* Return true if this entry matches DOMAIN. */ - bool matches (domain_enum domain) const - { - /* Just reject type declarations. */ - if ((flags & IS_TYPE_DECLARATION) != 0) - return false; - - switch (domain) - { - case LABEL_DOMAIN: - return false; - - case MODULE_DOMAIN: - return tag == DW_TAG_module; - - case COMMON_BLOCK_DOMAIN: - return tag == DW_TAG_common_block; - } - - return true; - } - /* Return true if this entry matches KIND. */ bool matches (domain_search_flags kind) const; diff --git a/gdb/dwarf2/read-debug-names.c b/gdb/dwarf2/read-debug-names.c index 743cee6c46d..da1b0e9229b 100644 --- a/gdb/dwarf2/read-debug-names.c +++ b/gdb/dwarf2/read-debug-names.c @@ -87,7 +87,7 @@ struct dwarf2_debug_names_index : public dwarf2_base_index_functions void expand_matching_symbols (struct objfile *, const lookup_name_info &lookup_name, - domain_enum domain, + domain_search_flags domain, int global, symbol_compare_ftype *ordered_compare) override; @@ -98,8 +98,7 @@ struct dwarf2_debug_names_index : public dwarf2_base_index_functions gdb::function_view symbol_matcher, gdb::function_view expansion_notify, block_search_flags search_flags, - domain_enum domain, - domain_search_flags kind) override; + domain_search_flags domain) override; }; quick_symbol_functions_up @@ -536,28 +535,27 @@ class dw2_debug_names_iterator public: dw2_debug_names_iterator (const mapped_debug_names &map, block_search_flags block_index, - domain_enum domain, + domain_search_flags domain, const char *name, dwarf2_per_objfile *per_objfile) - : m_map (map), m_block_index (block_index), m_domain (domain), + : m_map (map), m_block_index (block_index), m_search (domain), m_addr (find_vec_in_debug_names (map, name, per_objfile)), m_per_objfile (per_objfile) {} dw2_debug_names_iterator (const mapped_debug_names &map, domain_search_flags search, uint32_t namei, - dwarf2_per_objfile *per_objfile, - domain_enum domain = UNDEF_DOMAIN) + dwarf2_per_objfile *per_objfile) : m_map (map), - m_domain (domain), m_search (search), m_addr (find_vec_in_debug_names (map, namei, per_objfile)), m_per_objfile (per_objfile) {} dw2_debug_names_iterator (const mapped_debug_names &map, - block_search_flags block_index, domain_enum domain, + block_search_flags block_index, + domain_search_flags domain, uint32_t namei, dwarf2_per_objfile *per_objfile) - : m_map (map), m_block_index (block_index), m_domain (domain), + : m_map (map), m_block_index (block_index), m_search (domain), m_addr (find_vec_in_debug_names (map, namei, per_objfile)), m_per_objfile (per_objfile) {} @@ -581,7 +579,6 @@ class dw2_debug_names_iterator | SEARCH_STATIC_BLOCK); /* The kind of symbol we're looking for. */ - const domain_enum m_domain = UNDEF_DOMAIN; const domain_search_flags m_search = SEARCH_ALL; /* The list of CUs from the index entry of the symbol, or NULL if @@ -880,12 +877,6 @@ dw2_debug_names_iterator::next () break; } - if (! (m_domain == domain - || (m_domain == VAR_DOMAIN - && (domain == TYPE_DOMAIN - || domain == FUNCTION_DOMAIN)))) - goto again; - domain_search_flags flags = to_search_flags (domain); if ((flags & m_search) == 0) goto again; @@ -906,7 +897,7 @@ dwarf2_debug_names_index::dump (struct objfile *objfile) void dwarf2_debug_names_index::expand_matching_symbols (struct objfile *objfile, - const lookup_name_info &name, domain_enum domain, + const lookup_name_info &name, domain_search_flags domain, int global, symbol_compare_ftype *ordered_compare) { @@ -950,8 +941,7 @@ dwarf2_debug_names_index::expand_symtabs_matching gdb::function_view symbol_matcher, gdb::function_view expansion_notify, block_search_flags search_flags, - domain_enum domain, - domain_search_flags kind) + domain_search_flags domain) { dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile); @@ -985,7 +975,7 @@ dwarf2_debug_names_index::expand_symtabs_matching { /* The name was matched, now expand corresponding CUs that were marked. */ - dw2_debug_names_iterator iter (map, kind, namei, per_objfile, domain); + dw2_debug_names_iterator iter (map, domain, namei, per_objfile); struct dwarf2_per_cu_data *per_cu; while ((per_cu = iter.next ()) != NULL) diff --git a/gdb/dwarf2/read-gdb-index.c b/gdb/dwarf2/read-gdb-index.c index eeb52203ef9..a45c0f1a730 100644 --- a/gdb/dwarf2/read-gdb-index.c +++ b/gdb/dwarf2/read-gdb-index.c @@ -142,7 +142,7 @@ struct dwarf2_gdb_index : public dwarf2_base_index_functions void expand_matching_symbols (struct objfile *, const lookup_name_info &lookup_name, - domain_enum domain, + domain_search_flags domain, int global, symbol_compare_ftype *ordered_compare) override; @@ -153,8 +153,7 @@ struct dwarf2_gdb_index : public dwarf2_base_index_functions gdb::function_view symbol_matcher, gdb::function_view expansion_notify, block_search_flags search_flags, - domain_enum domain, - domain_search_flags kind) override; + domain_search_flags domain) override; }; /* This dumps minimal information about the index. @@ -183,7 +182,7 @@ struct dw2_symtab_iterator GLOBAL_BLOCK and STATIC_BLOCK. */ gdb::optional block_index; /* The kind of symbol we're looking for. */ - domain_enum domain; + domain_search_flags domain; /* The list of CUs from the index entry of the symbol, or NULL if not found. */ offset_view vec; @@ -204,7 +203,7 @@ static void dw2_symtab_iter_init (struct dw2_symtab_iterator *iter, dwarf2_per_objfile *per_objfile, gdb::optional block_index, - domain_enum domain, offset_type namei, + domain_search_flags domain, offset_type namei, mapped_gdb_index &index) { iter->per_objfile = per_objfile; @@ -320,7 +319,7 @@ dw2_symtab_iter_next (struct dw2_symtab_iterator *iter, void dwarf2_gdb_index::expand_matching_symbols (struct objfile *objfile, - const lookup_name_info &name, domain_enum domain, + const lookup_name_info &name, domain_search_flags domain, int global, symbol_compare_ftype *ordered_compare) { @@ -462,8 +461,7 @@ dwarf2_gdb_index::expand_symtabs_matching gdb::function_view symbol_matcher, gdb::function_view expansion_notify, block_search_flags search_flags, - domain_enum domain, - domain_search_flags kind) + domain_search_flags domain) { dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile); @@ -496,7 +494,7 @@ dwarf2_gdb_index::expand_symtabs_matching [&] (offset_type idx) { if (!dw2_expand_marked_cus (per_objfile, idx, file_matcher, - expansion_notify, search_flags, kind)) + expansion_notify, search_flags, domain)) return false; return true; }, per_objfile); diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 866c00e75a2..35f65bddc3f 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -1638,7 +1638,7 @@ struct readnow_functions : public dwarf2_base_index_functions void expand_matching_symbols (struct objfile *, const lookup_name_info &lookup_name, - domain_enum domain, + domain_search_flags domain, int global, symbol_compare_ftype *ordered_compare) override { @@ -1651,8 +1651,7 @@ struct readnow_functions : public dwarf2_base_index_functions gdb::function_view symbol_matcher, gdb::function_view expansion_notify, block_search_flags search_flags, - domain_enum domain, - domain_search_flags kind) override + domain_search_flags domain) override { return true; } @@ -16578,7 +16577,7 @@ struct cooked_index_functions : public dwarf2_base_index_functions void expand_matching_symbols (struct objfile *, const lookup_name_info &lookup_name, - domain_enum domain, + domain_search_flags domain, int global, symbol_compare_ftype *ordered_compare) override; @@ -16589,8 +16588,7 @@ struct cooked_index_functions : public dwarf2_base_index_functions gdb::function_view symbol_matcher, gdb::function_view expansion_notify, block_search_flags search_flags, - domain_enum domain, - domain_search_flags kind) override; + domain_search_flags domain) override; bool can_lazily_read_symbols () override { @@ -16605,12 +16603,14 @@ struct cooked_index_functions : public dwarf2_base_index_functions enum language lookup_global_symbol_language (struct objfile *objfile, const char *name, - domain_enum domain, + domain_search_flags domain, bool *symbol_found_p) override { *symbol_found_p = false; - if (!(domain == VAR_DOMAIN && streq (name, "main"))) + if ((domain & SEARCH_FUNCTION_DOMAIN) == 0) + return language_unknown; + if (!streq (name, "main")) return language_unknown; dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile); @@ -16682,7 +16682,7 @@ void cooked_index_functions::expand_matching_symbols (struct objfile *objfile, const lookup_name_info &lookup_name, - domain_enum domain, + domain_search_flags domain, int global, symbol_compare_ftype *ordered_compare) { @@ -16724,8 +16724,7 @@ cooked_index_functions::expand_symtabs_matching gdb::function_view symbol_matcher, gdb::function_view expansion_notify, block_search_flags search_flags, - domain_enum domain, - domain_search_flags kind) + domain_search_flags domain) { dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile); @@ -16794,8 +16793,7 @@ cooked_index_functions::expand_symtabs_matching /* See if the symbol matches the type filter. */ if (!entry->matches (search_flags) - || !entry->matches (domain) - || !entry->matches (kind)) + || !entry->matches (domain)) continue; /* We've found the base name of the symbol; now walk its diff --git a/gdb/dwarf2/read.h b/gdb/dwarf2/read.h index da907729320..e7a7466f05c 100644 --- a/gdb/dwarf2/read.h +++ b/gdb/dwarf2/read.h @@ -862,7 +862,7 @@ struct dwarf2_base_index_functions : public quick_symbol_functions enum language lookup_global_symbol_language (struct objfile *objfile, const char *name, - domain_enum domain, + domain_search_flags domain, bool *symbol_found_p) override { *symbol_found_p = false; diff --git a/gdb/language.h b/gdb/language.h index 6ee8f6160e1..b633b3dfa39 100644 --- a/gdb/language.h +++ b/gdb/language.h @@ -369,7 +369,7 @@ struct language_defn used as the definition. */ virtual bool iterate_over_symbols (const struct block *block, const lookup_name_info &name, - domain_enum domain, + domain_search_flags domain, gdb::function_view callback) const { return ::iterate_over_symbols (block, name, domain, callback); diff --git a/gdb/linespec.c b/gdb/linespec.c index 7aabedf239d..8ec9192fb37 100644 --- a/gdb/linespec.c +++ b/gdb/linespec.c @@ -350,7 +350,7 @@ struct linespec_parser static void iterate_over_file_blocks (struct symtab *symtab, const lookup_name_info &name, - domain_enum domain, + domain_search_flags domain, gdb::function_view callback); static void initialize_defaults (struct symtab **default_symtab, @@ -1154,8 +1154,7 @@ static void iterate_over_all_matching_symtabs (struct linespec_state *state, const lookup_name_info &lookup_name, - const domain_enum name_domain, - domain_search_flags domain_search_flags, + const domain_search_flags domain, struct program_space *search_pspace, bool include_inline, gdb::function_view callback) { @@ -1173,15 +1172,13 @@ iterate_over_all_matching_symtabs objfile->expand_symtabs_matching (NULL, &lookup_name, NULL, NULL, (SEARCH_GLOBAL_BLOCK | SEARCH_STATIC_BLOCK), - UNDEF_DOMAIN, - domain_search_flags); + domain); for (compunit_symtab *cu : objfile->compunits ()) { struct symtab *symtab = cu->primary_filetab (); - iterate_over_file_blocks (symtab, lookup_name, name_domain, - callback); + iterate_over_file_blocks (symtab, lookup_name, domain, callback); if (include_inline) { @@ -1193,7 +1190,7 @@ iterate_over_all_matching_symtabs { block = bv->block (i); state->language->iterate_over_symbols - (block, lookup_name, name_domain, + (block, lookup_name, domain, [&] (block_symbol *bsym) { /* Restrict calls to CALLBACK to symbols @@ -1226,7 +1223,8 @@ get_current_search_block (void) static void iterate_over_file_blocks (struct symtab *symtab, const lookup_name_info &name, - domain_enum domain, gdb::function_view callback) + domain_search_flags domain, + gdb::function_view callback) { const struct block *block; @@ -3442,10 +3440,10 @@ lookup_prefix_sym (struct linespec_state *state, if (elt == nullptr) { iterate_over_all_matching_symtabs (state, lookup_name, - STRUCT_DOMAIN, SEARCH_ALL, + SEARCH_STRUCT_DOMAIN, NULL, false, collector); iterate_over_all_matching_symtabs (state, lookup_name, - VAR_DOMAIN, SEARCH_ALL, + SEARCH_VFT, NULL, false, collector); } else @@ -3456,8 +3454,12 @@ lookup_prefix_sym (struct linespec_state *state, gdb_assert (!pspace->executing_startup); set_current_program_space (pspace); - iterate_over_file_blocks (elt, lookup_name, STRUCT_DOMAIN, collector); - iterate_over_file_blocks (elt, lookup_name, VAR_DOMAIN, collector); + iterate_over_file_blocks (elt, lookup_name, + SEARCH_STRUCT_DOMAIN, + collector); + iterate_over_file_blocks (elt, lookup_name, + SEARCH_VFT, + collector); } } @@ -3791,12 +3793,16 @@ find_function_symbols (struct linespec_state *state, /* Try NAME as an Objective-C selector. */ find_imps (name, &symbol_names); + + domain_search_flags flags = SEARCH_FUNCTION_DOMAIN; + if (state->list_mode) + flags = SEARCH_VFT; + if (!symbol_names.empty ()) add_all_symbol_names_from_pspace (&info, state->search_pspace, - symbol_names, SEARCH_FUNCTION_DOMAIN); + symbol_names, flags); else - add_matching_symbols_to_info (name, name_match_type, - SEARCH_FUNCTION_DOMAIN, + add_matching_symbols_to_info (name, name_match_type, flags, &info, state->search_pspace); } @@ -4322,7 +4328,7 @@ add_matching_symbols_to_info (const char *name, if (elt == nullptr) { iterate_over_all_matching_symtabs (info->state, lookup_name, - VAR_DOMAIN, domain_search_flags, + domain_search_flags, pspace, true, [&] (block_symbol *bsym) { return info->add_symbol (bsym); }); @@ -4337,7 +4343,7 @@ add_matching_symbols_to_info (const char *name, program_space *elt_pspace = elt->compunit ()->objfile ()->pspace; gdb_assert (!elt_pspace->executing_startup); set_current_program_space (elt_pspace); - iterate_over_file_blocks (elt, lookup_name, VAR_DOMAIN, + iterate_over_file_blocks (elt, lookup_name, SEARCH_VFT, [&] (block_symbol *bsym) { return info->add_symbol (bsym); }); diff --git a/gdb/objfiles.h b/gdb/objfiles.h index 0da44a38c7f..d5a7ab4b70e 100644 --- a/gdb/objfiles.h +++ b/gdb/objfiles.h @@ -586,7 +586,7 @@ struct objfile /* See quick_symbol_functions. */ void expand_matching_symbols - (const lookup_name_info &name, domain_enum domain, + (const lookup_name_info &name, domain_search_flags domain, int global, symbol_compare_ftype *ordered_compare); @@ -597,8 +597,7 @@ struct objfile gdb::function_view symbol_matcher, gdb::function_view expansion_notify, block_search_flags search_flags, - domain_enum domain, - domain_search_flags kind); + domain_search_flags domain); /* See quick_symbol_functions. */ struct compunit_symtab *find_pc_sect_compunit_symtab @@ -616,7 +615,7 @@ struct objfile /* See quick_symbol_functions. */ enum language lookup_global_symbol_language (const char *name, - domain_enum domain, + domain_search_flags domain, bool *symbol_found_p); /* See quick_symbol_functions. */ diff --git a/gdb/psymtab.c b/gdb/psymtab.c index dc960b661ea..49912c4bd41 100644 --- a/gdb/psymtab.c +++ b/gdb/psymtab.c @@ -42,7 +42,7 @@ static struct partial_symbol *lookup_partial_symbol (struct objfile *, struct partial_symtab *, const lookup_name_info &, int, - domain_enum); + domain_search_flags); static const char *psymtab_to_fullname (struct partial_symtab *ps); @@ -280,7 +280,7 @@ find_pc_sect_psymbol (struct objfile *objfile, enum language psymbol_functions::lookup_global_symbol_language (struct objfile *objfile, const char *name, - domain_enum domain, + domain_search_flags domain, bool *symbol_found_p) { *symbol_found_p = false; @@ -329,7 +329,8 @@ psymbol_name_matches (partial_symbol *psym, static struct partial_symbol * match_partial_symbol (struct objfile *objfile, struct partial_symtab *pst, int global, - const lookup_name_info &name, domain_enum domain, + const lookup_name_info &name, + domain_search_flags domain, symbol_compare_ftype *ordered_compare) { struct partial_symbol **start, **psym; @@ -378,8 +379,7 @@ match_partial_symbol (struct objfile *objfile, while (top <= real_top && psymbol_name_matches (*top, name)) { - if (symbol_matches_domain ((*top)->ginfo.language (), - (*top)->domain, domain)) + if (search_flags_matches (domain, (*top)->domain)) return *top; top++; } @@ -392,8 +392,7 @@ match_partial_symbol (struct objfile *objfile, { for (psym = start; psym < start + length; psym++) { - if (symbol_matches_domain ((*psym)->ginfo.language (), - (*psym)->domain, domain) + if (search_flags_matches (domain, (*psym)->domain) && psymbol_name_matches (*psym, name)) return *psym; } @@ -410,7 +409,7 @@ static struct partial_symbol * lookup_partial_symbol (struct objfile *objfile, struct partial_symtab *pst, const lookup_name_info &lookup_name, - int global, domain_enum domain) + int global, domain_search_flags domain) { struct partial_symbol **start, **psym; struct partial_symbol **top, **real_top, **bottom, **center; @@ -470,8 +469,7 @@ lookup_partial_symbol (struct objfile *objfile, while (top <= real_top && symbol_matches_search_name (&(*top)->ginfo, lookup_name)) { - if (symbol_matches_domain ((*top)->ginfo.language (), - (*top)->domain, domain)) + if (search_flags_matches (domain, (*top)->domain)) return *top; top++; } @@ -484,8 +482,7 @@ lookup_partial_symbol (struct objfile *objfile, { for (psym = start; psym < start + length; psym++) { - if (symbol_matches_domain ((*psym)->ginfo.language (), - (*psym)->domain, domain) + if (search_flags_matches (domain, (*psym)->domain) && symbol_matches_search_name (&(*psym)->ginfo, lookup_name)) return *psym; } @@ -883,7 +880,7 @@ psymtab_to_fullname (struct partial_symtab *ps) void psymbol_functions::expand_matching_symbols (struct objfile *objfile, - const lookup_name_info &name, domain_enum domain, + const lookup_name_info &name, domain_search_flags domain, int global, symbol_compare_ftype *ordered_compare) { @@ -907,8 +904,7 @@ recursively_search_psymtabs (struct partial_symtab *ps, struct objfile *objfile, block_search_flags search_flags, - domain_enum domain, - domain_search_flags search, + domain_search_flags domain, const lookup_name_info &lookup_name, gdb::function_view sym_matcher) { @@ -930,7 +926,7 @@ recursively_search_psymtabs continue; r = recursively_search_psymtabs (ps->dependencies[i], - objfile, search_flags, domain, search, + objfile, search_flags, domain, lookup_name, sym_matcher); if (r != 0) { @@ -978,19 +974,7 @@ recursively_search_psymtabs { QUIT; - if ((domain == UNDEF_DOMAIN - || symbol_matches_domain ((*psym)->ginfo.language (), - (*psym)->domain, domain)) - && (search == SEARCH_ALL - || (search == SEARCH_MODULE_DOMAIN - && (*psym)->domain == MODULE_DOMAIN) - || (search == SEARCH_VAR_DOMAIN - && (*psym)->aclass != LOC_TYPEDEF - && (*psym)->aclass != LOC_BLOCK) - || (search == SEARCH_FUNCTION_DOMAIN - && (*psym)->aclass == LOC_BLOCK) - || (search == SEARCH_TYPE_DOMAIN - && (*psym)->aclass == LOC_TYPEDEF)) + if (search_flags_matches (domain, (*psym)->domain) && psymbol_name_matches (*psym, lookup_name) && (sym_matcher == NULL || sym_matcher ((*psym)->ginfo.search_name ()))) @@ -1018,8 +1002,7 @@ psymbol_functions::expand_symtabs_matching gdb::function_view symbol_matcher, gdb::function_view expansion_notify, block_search_flags search_flags, - domain_enum domain, - domain_search_flags search) + domain_search_flags domain) { /* Clear the search flags. */ for (partial_symtab *ps : partial_symbols (objfile)) @@ -1061,8 +1044,7 @@ psymbol_functions::expand_symtabs_matching if (lookup_name == nullptr || recursively_search_psymtabs (ps, objfile, search_flags, - domain, search, - *psym_lookup_name, + domain, *psym_lookup_name, symbol_matcher)) { compunit_symtab *cust = psymtab_to_symtab (objfile, ps); diff --git a/gdb/psymtab.h b/gdb/psymtab.h index 43e6244fd6e..25214ca4ba1 100644 --- a/gdb/psymtab.h +++ b/gdb/psymtab.h @@ -617,7 +617,7 @@ struct psymbol_functions : public quick_symbol_functions enum language lookup_global_symbol_language (struct objfile *objfile, const char *name, - domain_enum domain, + domain_search_flags domain, bool *symbol_found_p) override; void print_stats (struct objfile *objfile, bool print_bcache) override; @@ -629,7 +629,7 @@ struct psymbol_functions : public quick_symbol_functions void expand_matching_symbols (struct objfile *, const lookup_name_info &lookup_name, - domain_enum domain, + domain_search_flags domain, int global, symbol_compare_ftype *ordered_compare) override; @@ -640,7 +640,6 @@ struct psymbol_functions : public quick_symbol_functions gdb::function_view symbol_matcher, gdb::function_view expansion_notify, block_search_flags search_flags, - domain_enum domain, domain_search_flags kind) override; struct compunit_symtab *find_pc_sect_compunit_symtab diff --git a/gdb/quick-symbol.h b/gdb/quick-symbol.h index 1eac8f25035..8fe7414c4b3 100644 --- a/gdb/quick-symbol.h +++ b/gdb/quick-symbol.h @@ -101,14 +101,14 @@ struct quick_symbol_functions /* Check to see if the global symbol is defined in a "partial" symbol table of OBJFILE. NAME is the name of the symbol to look for. DOMAIN - indicates what sort of symbol to search for. + indicates what sorts of symbols to search for. If found, sets *symbol_found_p to true and returns the symbol language. defined, or NULL if no such symbol table exists. */ virtual enum language lookup_global_symbol_language (struct objfile *objfile, const char *name, - domain_enum domain, + domain_search_flags domain, bool *symbol_found_p) = 0; /* Print statistics about any indices loaded for OBJFILE. The @@ -143,7 +143,7 @@ struct quick_symbol_functions virtual void expand_matching_symbols (struct objfile *, const lookup_name_info &lookup_name, - domain_enum domain, + domain_search_flags domain, int global, symbol_compare_ftype *ordered_compare) = 0; @@ -161,8 +161,7 @@ struct quick_symbol_functions Otherwise, individual symbols are considered. - If DOMAIN or KIND do not match, the symbol is skipped. - If DOMAIN is UNDEF_DOMAIN, that is treated as a wildcard. + If DOMAIN does not match, the symbol is skipped. If the symbol name does not match LOOKUP_NAME, the symbol is skipped. @@ -182,8 +181,7 @@ struct quick_symbol_functions gdb::function_view symbol_matcher, gdb::function_view expansion_notify, block_search_flags search_flags, - domain_enum domain, - domain_search_flags kind) = 0; + domain_search_flags domain) = 0; /* Return the comp unit from OBJFILE that contains PC and SECTION. Return NULL if there is no such compunit. This diff --git a/gdb/symfile-debug.c b/gdb/symfile-debug.c index 8fbacef9d30..a4da8ec28d7 100644 --- a/gdb/symfile-debug.c +++ b/gdb/symfile-debug.c @@ -226,7 +226,6 @@ objfile::map_symtabs_matching_filename on_expansion, (SEARCH_GLOBAL_BLOCK | SEARCH_STATIC_BLOCK), - UNDEF_DOMAIN, SEARCH_ALL)) { retval = false; @@ -282,6 +281,10 @@ objfile::lookup_symbol (block_enum kind, const char *name, domain_enum domain) return true; }; + domain_search_flags flags = to_search_flags (domain); + if (domain == VAR_DOMAIN) + flags |= SEARCH_TYPE_DOMAIN | SEARCH_FUNCTION_DOMAIN; + for (const auto &iter : qf_require_partial_symbols ()) { if (!iter->expand_symtabs_matching (this, @@ -292,8 +295,7 @@ objfile::lookup_symbol (block_enum kind, const char *name, domain_enum domain) kind == GLOBAL_BLOCK ? SEARCH_GLOBAL_BLOCK : SEARCH_STATIC_BLOCK, - domain, - SEARCH_ALL)) + flags)) break; } @@ -347,8 +349,7 @@ objfile::expand_symtabs_for_function (const char *func_name) nullptr, (SEARCH_GLOBAL_BLOCK | SEARCH_STATIC_BLOCK), - VAR_DOMAIN, - SEARCH_ALL); + SEARCH_VFT); } void @@ -384,13 +385,12 @@ objfile::expand_symtabs_with_fullname (const char *fullname) nullptr, (SEARCH_GLOBAL_BLOCK | SEARCH_STATIC_BLOCK), - UNDEF_DOMAIN, SEARCH_ALL); } void objfile::expand_matching_symbols - (const lookup_name_info &name, domain_enum domain, + (const lookup_name_info &name, domain_search_flags domain, int global, symbol_compare_ftype *ordered_compare) { @@ -398,7 +398,7 @@ objfile::expand_matching_symbols gdb_printf (gdb_stdlog, "qf->expand_matching_symbols (%s, %s, %d, %s)\n", objfile_debug_name (this), - domain_name (domain), global, + domain_name (domain).c_str (), global, host_address_to_string (ordered_compare)); for (const auto &iter : qf_require_partial_symbols ()) @@ -413,8 +413,7 @@ objfile::expand_symtabs_matching gdb::function_view symbol_matcher, gdb::function_view expansion_notify, block_search_flags search_flags, - domain_enum domain, - domain_search_flags kind) + domain_search_flags domain) { /* This invariant is documented in quick-functions.h. */ gdb_assert (lookup_name != nullptr || symbol_matcher == nullptr); @@ -426,12 +425,12 @@ objfile::expand_symtabs_matching host_address_to_string (&file_matcher), host_address_to_string (&symbol_matcher), host_address_to_string (&expansion_notify), - domain_name (kind).c_str ()); + domain_name (domain).c_str ()); for (const auto &iter : qf_require_partial_symbols ()) if (!iter->expand_symtabs_matching (this, file_matcher, lookup_name, symbol_matcher, expansion_notify, - search_flags, domain, kind)) + search_flags, domain)) return false; return true; } @@ -514,7 +513,7 @@ objfile::find_compunit_symtab_by_address (CORE_ADDR address) enum language objfile::lookup_global_symbol_language (const char *name, - domain_enum domain, + domain_search_flags domain, bool *symbol_found_p) { enum language result = language_unknown; diff --git a/gdb/symfile.c b/gdb/symfile.c index b21ba73c69d..7147f292535 100644 --- a/gdb/symfile.c +++ b/gdb/symfile.c @@ -3763,7 +3763,7 @@ expand_symtabs_matching gdb::function_view symbol_matcher, gdb::function_view expansion_notify, block_search_flags search_flags, - domain_search_flags kind) + domain_search_flags domain) { for (objfile *objfile : current_program_space->objfiles ()) if (!objfile->expand_symtabs_matching (file_matcher, @@ -3771,8 +3771,7 @@ expand_symtabs_matching symbol_matcher, expansion_notify, search_flags, - UNDEF_DOMAIN, - kind)) + domain)) return false; return true; } diff --git a/gdb/symmisc.c b/gdb/symmisc.c index 8f620bb7ebe..51b134cf219 100644 --- a/gdb/symmisc.c +++ b/gdb/symmisc.c @@ -919,7 +919,6 @@ maintenance_expand_symtabs (const char *args, int from_tty) NULL, NULL, SEARCH_GLOBAL_BLOCK | SEARCH_STATIC_BLOCK, - UNDEF_DOMAIN, SEARCH_ALL); } diff --git a/gdb/symtab.c b/gdb/symtab.c index 6020efe197b..50a0f692521 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -2863,7 +2863,7 @@ basic_lookup_transparent_type (const char *name) bool iterate_over_symbols (const struct block *block, const lookup_name_info &name, - const domain_enum domain, + const domain_search_flags domain, gdb::function_view callback) { for (struct symbol *sym : block_iterator_range (block, &name)) @@ -2885,7 +2885,7 @@ bool iterate_over_symbols_terminated (const struct block *block, const lookup_name_info &name, - const domain_enum domain, + const domain_search_flags domain, gdb::function_view callback) { if (!iterate_over_symbols (block, name, domain, callback)) @@ -4749,7 +4749,6 @@ global_symbol_searcher::expand_symtabs }, NULL, SEARCH_GLOBAL_BLOCK | SEARCH_STATIC_BLOCK, - UNDEF_DOMAIN, kind); /* Here, we search through the minimal symbol tables for functions and @@ -6403,7 +6402,7 @@ find_main_name (void) [&symbol_found_p, pspace] (objfile *obj) { language lang - = obj->lookup_global_symbol_language ("main", VAR_DOMAIN, + = obj->lookup_global_symbol_language ("main", SEARCH_VFT, &symbol_found_p); if (symbol_found_p) { diff --git a/gdb/symtab.h b/gdb/symtab.h index 5f2b17a3cee..80ee9e02475 100644 --- a/gdb/symtab.h +++ b/gdb/symtab.h @@ -2779,7 +2779,7 @@ typedef bool (symbol_found_callback_ftype) (struct block_symbol *bsym); bool iterate_over_symbols (const struct block *block, const lookup_name_info &name, - const domain_enum domain, + const domain_search_flags domain, gdb::function_view callback); /* Like iterate_over_symbols, but if all calls to CALLBACK return @@ -2789,7 +2789,7 @@ bool iterate_over_symbols (const struct block *block, bool iterate_over_symbols_terminated (const struct block *block, const lookup_name_info &name, - const domain_enum domain, + const domain_search_flags domain, gdb::function_view callback); /* Storage type used by demangle_for_lookup. demangle_for_lookup From patchwork Tue Nov 21 03:53:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 80418 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 E891F3858C98 for ; Tue, 21 Nov 2023 03:56:42 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from omta34.uswest2.a.cloudfilter.net (omta34.uswest2.a.cloudfilter.net [35.89.44.33]) by sourceware.org (Postfix) with ESMTPS id 809E53858C20 for ; Tue, 21 Nov 2023 03:53:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 809E53858C20 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 809E53858C20 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=35.89.44.33 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700538810; cv=none; b=q08xvixLB2QET89Vo4otnZFU1LRkOz9glBjNqUBa42u9j7uxBYzLXuvBcvgkFMxtvTGhqdsO0X1fhHmSaw6Eb1sPc3EUwQlmg6FjvRA93pOzphfXuZINpf7/JKMxPW4RUBTQRScofKvLCi7kekwALS+8u8vT64JhZQIc59dS3eM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700538810; c=relaxed/simple; bh=5Gh2BOWveAWof+nrJSKiAkd8H++illGUhIRoyK+QTi4=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=ZG/1u5dOvUtb/fwY+yuyjqQjaOD5qsYrdnrRLZpM3I8c87urPZ+O0PZEDDvjOHmskfLzGXe36JKYX9NdRg1HHfL1S9v906b4Q3I8ovvHJEyiHo+F7rNelvghUpuLutV/H02LOG4lUg9DBkw7gYcOogLQtpPd+Fl14iGlGpGDsSo= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from eig-obgw-6001a.ext.cloudfilter.net ([10.0.30.140]) by cmsmtp with ESMTPS id 5BpmrSOJy8Hte5HpBrHZWi; Tue, 21 Nov 2023 03:53:21 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id 5HpBrwHydb8Qn5HpBr3fkZ; Tue, 21 Nov 2023 03:53:21 +0000 X-Authority-Analysis: v=2.4 cv=IuQNzZzg c=1 sm=1 tr=0 ts=655c29b1 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=SyoSi4yNZ5bcPg2LCrUA:9 a=QEXdDO2ut3YA:10 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=To:In-Reply-To:References:Message-Id:Content-Transfer-Encoding: Content-Type:MIME-Version:Subject:Date:From:Sender:Reply-To:Cc:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=VBLnyEiZUY2hSWkmtEHMu4aV2pj+tPZhAVjtkpkPpZI=; b=hlffhuwfNNCA10GL8fF4qZ/0JY p8VmYqK7ku0p1DUWRk5UEmwDuih87gGlzMagNqBIQAzuCmHwb0T3HCcq//O5f17ak92PxcLfbDBK2 bC/uB5Yz8GQpNLEKqUHK7pSfK; 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 1r5HpA-0040be-2V for gdb-patches@sourceware.org; Mon, 20 Nov 2023 20:53:20 -0700 From: Tom Tromey Date: Mon, 20 Nov 2023 20:53:47 -0700 Subject: [PATCH 16/29] Use domain_search_flags in lookup_symbol et al MIME-Version: 1.0 Message-Id: <20231120-submit-domain-hacks-2-v1-16-29650d01b198@tromey.com> References: <20231120-submit-domain-hacks-2-v1-0-29650d01b198@tromey.com> In-Reply-To: <20231120-submit-domain-hacks-2-v1-0-29650d01b198@tromey.com> 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: 1r5HpA-0040be-2V 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: 17 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfFZOzjROLZuGtX33TAEXbNXAkbjH/7ZFIJhbgd7pR4H+7v5PWQj58SeL5lNUdvQPDVRMelkp0GlwxZ5PmNekgb/if9sw3tf/3dLxhqU1XYHDeTMZ8zBy lXPtVprkJgL0GgSadrQSrMfaHVr23+HPLU1NB1Vp4vZzYhbaiZDMHoG9jCHdQgXU795nN3RZ/HxMI3mwX4YLY3lrdxhMK7rkru0= X-Spam-Status: No, score=-3023.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_STOCKGEN, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham 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 This changes lookup_symbol and associated APIs to accept domain_search_flags rather than a domain_enum. Note that this introduces some new constants to Python and Guile. I chose to break out the documentation patch for this, because the internals here do not change until a later patch, and it seemed simpler to patch the docs just once, rather than twice. --- gdb/ada-lang.c | 10 +-- 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/compile/compile-c-symbols.c | 17 ++--- gdb/compile/compile-cplus-symbols.c | 13 ++-- gdb/compile/compile-cplus-types.c | 8 +-- gdb/compile/compile-object-load.c | 6 +- gdb/cp-namespace.c | 51 ++++++------- gdb/cp-support.c | 6 +- gdb/cp-support.h | 8 +-- gdb/d-exp.y | 12 ++-- gdb/d-lang.c | 2 +- gdb/d-lang.h | 9 +-- gdb/d-namespace.c | 24 +++---- gdb/dwarf2/ada-imported.c | 2 +- gdb/dwarf2/loc.c | 2 +- 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 | 3 +- gdb/ft32-tdep.c | 3 +- gdb/gdbtypes.c | 17 +++-- gdb/gnu-v3-abi.c | 2 +- gdb/go-exp.y | 9 +-- gdb/guile/scm-frame.c | 2 +- gdb/guile/scm-symbol.c | 17 +++-- gdb/infrun.c | 2 +- gdb/language.c | 3 +- gdb/language.h | 2 +- gdb/linespec.c | 4 +- gdb/m2-exp.y | 10 +-- gdb/mi/mi-cmd-stack.c | 5 +- gdb/moxie-tdep.c | 3 +- gdb/objc-lang.c | 4 +- gdb/objfiles.h | 2 +- gdb/p-exp.y | 19 ++--- gdb/p-valprint.c | 2 +- gdb/parse.c | 3 +- gdb/printcmd.c | 2 +- gdb/psymtab.c | 4 +- gdb/python/py-frame.c | 3 +- gdb/python/py-objfile.c | 6 +- gdb/python/py-symbol.c | 22 +++--- gdb/rust-lang.c | 7 +- gdb/rust-lang.h | 2 +- gdb/rust-parse.c | 8 +-- gdb/source.c | 5 +- gdb/stack.c | 4 +- gdb/symfile-debug.c | 11 ++- gdb/symfile.c | 4 +- gdb/symtab.c | 138 +++++++++++++++++------------------- gdb/symtab.h | 23 +++--- gdb/valops.c | 14 ++-- gdb/value.c | 6 +- gdb/xstormy16-tdep.c | 3 +- 64 files changed, 342 insertions(+), 312 deletions(-) diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 36192dc07c6..ad5fac05468 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -13735,19 +13735,15 @@ class ada_language : public language_defn struct block_symbol lookup_symbol_nonlocal (const char *name, const struct block *block, - const domain_enum domain) const override + const domain_search_flags domain) const override { struct block_symbol sym; - domain_search_flags flags = to_search_flags (domain); - if (domain == VAR_DOMAIN) - flags |= SEARCH_TYPE_DOMAIN | SEARCH_FUNCTION_DOMAIN; - sym = ada_lookup_symbol (name, (block == nullptr ? nullptr : block->static_block ()), - flags); + domain); if (sym.symbol != NULL) return sym; @@ -13763,7 +13759,7 @@ class ada_language : public language_defn languages, we search the primitive types this late and only after having searched the global symbols without success. */ - if (domain == VAR_DOMAIN) + if ((domain & SEARCH_TYPE_DOMAIN) != 0) { struct gdbarch *gdbarch; diff --git a/gdb/ada-tasks.c b/gdb/ada-tasks.c index 047566e6228..b62ba779fbd 100644 --- a/gdb/ada-tasks.c +++ b/gdb/ada-tasks.c @@ -520,16 +520,17 @@ ada_get_tcb_types_info (void) C-like) lookups to get the first match. */ struct symbol *atcb_sym = - lookup_symbol_in_language (atcb_name, NULL, STRUCT_DOMAIN, + lookup_symbol_in_language (atcb_name, NULL, SEARCH_STRUCT_DOMAIN, language_c, NULL).symbol; const struct symbol *common_atcb_sym = - lookup_symbol_in_language (common_atcb_name, NULL, STRUCT_DOMAIN, + lookup_symbol_in_language (common_atcb_name, NULL, SEARCH_STRUCT_DOMAIN, language_c, NULL).symbol; const struct symbol *private_data_sym = - lookup_symbol_in_language (private_data_name, NULL, STRUCT_DOMAIN, + lookup_symbol_in_language (private_data_name, NULL, SEARCH_STRUCT_DOMAIN, language_c, NULL).symbol; const struct symbol *entry_call_record_sym = - lookup_symbol_in_language (entry_call_record_name, NULL, STRUCT_DOMAIN, + lookup_symbol_in_language (entry_call_record_name, NULL, + SEARCH_STRUCT_DOMAIN, language_c, NULL).symbol; if (atcb_sym == NULL || atcb_sym->type () == NULL) @@ -537,7 +538,7 @@ ada_get_tcb_types_info (void) /* In Ravenscar run-time libs, the ATCB does not have a dynamic size, so the symbol name differs. */ atcb_sym = lookup_symbol_in_language (atcb_name_fixed, NULL, - STRUCT_DOMAIN, language_c, + SEARCH_STRUCT_DOMAIN, language_c, NULL).symbol; if (atcb_sym == NULL || atcb_sym->type () == NULL) @@ -929,7 +930,8 @@ ada_tasks_inferior_data_sniffer (struct ada_tasks_inferior_data *data) data->known_tasks_addr = msym.value_address (); /* Try to get pointer type and array length from the symtab. */ - sym = lookup_symbol_in_language (KNOWN_TASKS_NAME, NULL, VAR_DOMAIN, + sym = lookup_symbol_in_language (KNOWN_TASKS_NAME, NULL, + SEARCH_VAR_DOMAIN, language_c, NULL).symbol; if (sym != NULL) { @@ -975,7 +977,8 @@ ada_tasks_inferior_data_sniffer (struct ada_tasks_inferior_data *data) data->known_tasks_addr = msym.value_address (); data->known_tasks_length = 1; - sym = lookup_symbol_in_language (KNOWN_TASKS_LIST, NULL, VAR_DOMAIN, + sym = lookup_symbol_in_language (KNOWN_TASKS_LIST, NULL, + SEARCH_VAR_DOMAIN, language_c, NULL).symbol; if (sym != NULL && sym->value_address () != 0) { diff --git a/gdb/alpha-mdebug-tdep.c b/gdb/alpha-mdebug-tdep.c index 868083b3ace..d65f207bb7f 100644 --- a/gdb/alpha-mdebug-tdep.c +++ b/gdb/alpha-mdebug-tdep.c @@ -106,7 +106,7 @@ find_proc_desc (CORE_ADDR pc) symbol reading. */ sym = NULL; else - sym = lookup_symbol (MDEBUG_EFI_SYMBOL_NAME, b, LABEL_DOMAIN, + sym = lookup_symbol (MDEBUG_EFI_SYMBOL_NAME, b, SEARCH_LABEL_DOMAIN, 0).symbol; } diff --git a/gdb/ax-gdb.c b/gdb/ax-gdb.c index a679c864915..51cc0178912 100644 --- a/gdb/ax-gdb.c +++ b/gdb/ax-gdb.c @@ -1457,7 +1457,8 @@ gen_static_field (struct agent_expr *ax, struct axs_value *value, else { const char *phys_name = type->field (fieldno).loc_physname (); - struct symbol *sym = lookup_symbol (phys_name, 0, VAR_DOMAIN, 0).symbol; + struct symbol *sym = lookup_symbol (phys_name, 0, + SEARCH_VAR_DOMAIN, 0).symbol; if (sym) { @@ -1548,7 +1549,7 @@ gen_maybe_namespace_elt (struct agent_expr *ax, struct axs_value *value, sym = cp_lookup_symbol_namespace (namespace_name, name, block_for_pc (ax->scope), - VAR_DOMAIN); + SEARCH_VAR_DOMAIN); if (sym.symbol == NULL) return 0; diff --git a/gdb/block.c b/gdb/block.c index e588a68aa2f..b3a0667a8f6 100644 --- a/gdb/block.c +++ b/gdb/block.c @@ -630,26 +630,32 @@ block_iterator_next (struct block_iterator *iterator) /* See block.h. */ bool -best_symbol (struct symbol *a, const domain_enum domain) +best_symbol (struct symbol *a, const domain_search_flags domain) { - return (a->domain () == domain - && a->aclass () != LOC_UNRESOLVED); + if (a->aclass () == LOC_UNRESOLVED) + return false; + + if ((domain & SEARCH_VAR_DOMAIN) != 0) + return a->domain () == VAR_DOMAIN; + + return a->matches (domain); } /* See block.h. */ struct symbol * -better_symbol (struct symbol *a, struct symbol *b, const domain_enum domain) +better_symbol (struct symbol *a, struct symbol *b, + const domain_search_flags domain) { if (a == NULL) return b; if (b == NULL) return a; - if (a->domain () == domain && b->domain () != domain) + if (a->matches (domain) && !b->matches (domain)) return a; - if (b->domain () == domain && a->domain () != domain) + if (b->matches (domain) && !a->matches (domain)) return b; if (a->aclass () != LOC_UNRESOLVED && b->aclass () == LOC_UNRESOLVED) @@ -675,7 +681,7 @@ better_symbol (struct symbol *a, struct symbol *b, const domain_enum domain) struct symbol * block_lookup_symbol (const struct block *block, const char *name, symbol_name_match_type match_type, - const domain_enum domain) + const domain_search_flags domain) { lookup_name_info lookup_name (name, match_type); @@ -730,7 +736,7 @@ block_lookup_symbol (const struct block *block, const char *name, struct symbol * block_lookup_symbol_primary (const struct block *block, const char *name, - const domain_enum domain) + const domain_search_flags domain) { struct symbol *sym, *other; struct mdict_iterator mdict_iter; @@ -792,7 +798,7 @@ block_lookup_symbol_primary (const struct block *block, const char *name, struct symbol * block_find_symbol (const struct block *block, const lookup_name_info &name, - const domain_enum domain, struct symbol **stub) + const domain_search_flags domain, struct symbol **stub) { /* Verify BLOCK is STATIC_BLOCK or GLOBAL_BLOCK. */ gdb_assert (block->superblock () == NULL diff --git a/gdb/block.h b/gdb/block.h index a29298517b0..94796df0234 100644 --- a/gdb/block.h +++ b/gdb/block.h @@ -554,28 +554,29 @@ typedef iterator_range block_iterator_range; /* Return true if symbol A is the best match possible for DOMAIN. */ -extern bool best_symbol (struct symbol *a, const domain_enum domain); +extern bool best_symbol (struct symbol *a, const domain_search_flags domain); /* Return symbol B if it is a better match than symbol A for DOMAIN. Otherwise return A. */ extern struct symbol *better_symbol (struct symbol *a, struct symbol *b, - const domain_enum domain); + const domain_search_flags domain); /* Search BLOCK for symbol NAME in DOMAIN. */ extern struct symbol *block_lookup_symbol (const struct block *block, const char *name, symbol_name_match_type match_type, - const domain_enum domain); + const domain_search_flags domain); /* Search BLOCK for symbol NAME in DOMAIN but only in primary symbol table of BLOCK. BLOCK must be STATIC_BLOCK or GLOBAL_BLOCK. Function is useful if one iterates all global/static blocks of an objfile. */ -extern struct symbol *block_lookup_symbol_primary (const struct block *block, - const char *name, - const domain_enum domain); +extern struct symbol *block_lookup_symbol_primary + (const struct block *block, + const char *name, + const domain_search_flags domain); /* Find symbol NAME in BLOCK and in DOMAIN. This will return a matching symbol whose type is not a "opaque", see TYPE_IS_OPAQUE. @@ -584,7 +585,7 @@ extern struct symbol *block_lookup_symbol_primary (const struct block *block, extern struct symbol *block_find_symbol (const struct block *block, const lookup_name_info &name, - const domain_enum domain, + const domain_search_flags domain, struct symbol **stub); /* Given a vector of pairs, allocate and build an obstack allocated diff --git a/gdb/c-exp.y b/gdb/c-exp.y index a27dbfa608f..69679360faf 100644 --- a/gdb/c-exp.y +++ b/gdb/c-exp.y @@ -1087,9 +1087,10 @@ block : block COLONCOLON name std::string copy = copy_name ($3); struct symbol *tem = lookup_symbol (copy.c_str (), $1, - VAR_DOMAIN, NULL).symbol; + SEARCH_FUNCTION_DOMAIN, + nullptr).symbol; - if (!tem || tem->aclass () != LOC_BLOCK) + if (tem == nullptr) error (_("No function \"%s\" in specified context."), copy.c_str ()); $$ = tem->value_block (); } @@ -1113,7 +1114,7 @@ variable: block COLONCOLON name std::string copy = copy_name ($3); struct block_symbol sym = lookup_symbol (copy.c_str (), $1, - VAR_DOMAIN, NULL); + SEARCH_VFT, NULL); if (sym.symbol == 0) error (_("No symbol \"%s\" in specified context."), @@ -1168,7 +1169,7 @@ variable: qualified_name struct block_symbol sym = lookup_symbol (name.c_str (), (const struct block *) NULL, - VAR_DOMAIN, NULL); + SEARCH_VFT, NULL); pstate->push_symbol (name.c_str (), sym); } ; @@ -1833,7 +1834,7 @@ name_not_typename : NAME $$.sym = lookup_symbol ($1.ptr, pstate->expression_context_block, - VAR_DOMAIN, + SEARCH_VFT, &is_a_field_of_this); $$.is_a_field_of_this = is_a_field_of_this.type != NULL; @@ -2969,7 +2970,7 @@ lex_one_token (struct parser_state *par_state, bool *is_quoted_name) if (lookup_symbol (copy.c_str (), pstate->expression_context_block, - VAR_DOMAIN, + SEARCH_VFT, (par_state->language ()->la_language == language_cplus ? &is_a_field_of_this : NULL)).symbol @@ -3037,7 +3038,7 @@ classify_name (struct parser_state *par_state, const struct block *block, we can refer to it unconditionally below. */ memset (&is_a_field_of_this, 0, sizeof (is_a_field_of_this)); - bsym = lookup_symbol (copy.c_str (), block, VAR_DOMAIN, + bsym = lookup_symbol (copy.c_str (), block, SEARCH_VFT, par_state->language ()->name_of_this () ? &is_a_field_of_this : NULL); @@ -3060,7 +3061,7 @@ classify_name (struct parser_state *par_state, const struct block *block, { struct field_of_this_result inner_is_a_field_of_this; - bsym = lookup_symbol (copy.c_str (), block, STRUCT_DOMAIN, + bsym = lookup_symbol (copy.c_str (), block, SEARCH_STRUCT_DOMAIN, &inner_is_a_field_of_this); if (bsym.symbol != NULL) { @@ -3167,7 +3168,7 @@ classify_inner_name (struct parser_state *par_state, std::string copy = copy_name (yylval.ssym.stoken); /* N.B. We assume the symbol can only be in VAR_DOMAIN. */ yylval.ssym.sym = cp_lookup_nested_symbol (type, copy.c_str (), block, - VAR_DOMAIN); + SEARCH_VFT); /* If no symbol was found, search for a matching base class named COPY. This will allow users to enter qualified names of class members diff --git a/gdb/c-lang.c b/gdb/c-lang.c index 99cbbff94fa..e84bf61dfd8 100644 --- a/gdb/c-lang.c +++ b/gdb/c-lang.c @@ -1014,7 +1014,7 @@ class cplus_language : public language_defn struct block_symbol lookup_symbol_nonlocal (const char *name, const struct block *block, - const domain_enum domain) const override + const domain_search_flags domain) const override { return cp_lookup_symbol_nonlocal (this, name, block, domain); } diff --git a/gdb/c-valprint.c b/gdb/c-valprint.c index 34a9d0f6075..e47ac83754a 100644 --- a/gdb/c-valprint.c +++ b/gdb/c-valprint.c @@ -205,7 +205,7 @@ print_unpacked_pointer (struct type *type, struct type *elttype, { const char *search_name = msymbol.minsym->search_name (); wsym = lookup_symbol_search_name (search_name, NULL, - VAR_DOMAIN).symbol; + SEARCH_VAR_DOMAIN).symbol; } if (wsym) diff --git a/gdb/compile/compile-c-symbols.c b/gdb/compile/compile-c-symbols.c index 5982178170c..63b0194bb24 100644 --- a/gdb/compile/compile-c-symbols.c +++ b/gdb/compile/compile-c-symbols.c @@ -210,7 +210,7 @@ convert_one_symbol (compile_c_instance *context, static void convert_symbol_sym (compile_c_instance *context, const char *identifier, - struct block_symbol sym, domain_enum domain) + struct block_symbol sym, domain_search_flags domain) { int is_local_symbol; @@ -325,19 +325,19 @@ gcc_convert_symbol (void *datum, { compile_c_instance *context = static_cast (datum); - domain_enum domain; + domain_search_flags domain; int found = 0; switch (request) { case GCC_C_ORACLE_SYMBOL: - domain = VAR_DOMAIN; + domain = SEARCH_VFT; break; case GCC_C_ORACLE_TAG: - domain = STRUCT_DOMAIN; + domain = SEARCH_STRUCT_DOMAIN; break; case GCC_C_ORACLE_LABEL: - domain = LABEL_DOMAIN; + domain = SEARCH_LABEL_DOMAIN; break; default: gdb_assert_not_reached ("Unrecognized oracle request."); @@ -355,7 +355,7 @@ gcc_convert_symbol (void *datum, convert_symbol_sym (context, identifier, sym, domain); found = 1; } - else if (domain == VAR_DOMAIN) + else if (request == GCC_C_ORACLE_SYMBOL) { struct bound_minimal_symbol bmsym; @@ -398,8 +398,9 @@ gcc_symbol_address (void *datum, struct gcc_c_context *gcc_context, struct symbol *sym; /* We only need global functions here. */ - sym = lookup_symbol (identifier, NULL, VAR_DOMAIN, NULL).symbol; - if (sym != NULL && sym->aclass () == LOC_BLOCK) + sym = lookup_symbol (identifier, nullptr, SEARCH_FUNCTION_DOMAIN, + nullptr).symbol; + if (sym != nullptr) { if (compile_debug) gdb_printf (gdb_stdlog, diff --git a/gdb/compile/compile-cplus-symbols.c b/gdb/compile/compile-cplus-symbols.c index 4a52427a072..d36a88f93bd 100644 --- a/gdb/compile/compile-cplus-symbols.c +++ b/gdb/compile/compile-cplus-symbols.c @@ -227,7 +227,7 @@ convert_one_symbol (compile_cplus_instance *instance, static void convert_symbol_sym (compile_cplus_instance *instance, const char *identifier, struct block_symbol sym, - domain_enum domain) + domain_search_flags domain) { /* If we found a symbol and it is not in the static or global scope, then we should first convert any static or global scope @@ -355,12 +355,12 @@ gcc_cplus_convert_symbol (void *datum, This will find variables in the current scope. */ struct block_symbol sym - = lookup_symbol (identifier, instance->block (), VAR_DOMAIN, nullptr); + = lookup_symbol (identifier, instance->block (), SEARCH_VFT, nullptr); if (sym.symbol != nullptr) { found = true; - convert_symbol_sym (instance, identifier, sym, VAR_DOMAIN); + convert_symbol_sym (instance, identifier, sym, SEARCH_VFT); } /* Then use linespec.c's multi-symbol search. This should find @@ -378,7 +378,7 @@ gcc_cplus_convert_symbol (void *datum, { found = true; convert_symbol_sym (instance, identifier, it, - it.symbol->domain ()); + to_search_flags (it.symbol->domain ())); } } @@ -437,9 +437,10 @@ gcc_cplus_symbol_address (void *datum, struct gcc_cp_context *gcc_context, try { struct symbol *sym - = lookup_symbol (identifier, nullptr, VAR_DOMAIN, nullptr).symbol; + = lookup_symbol (identifier, nullptr, SEARCH_FUNCTION_DOMAIN, + nullptr).symbol; - if (sym != nullptr && sym->aclass () == LOC_BLOCK) + if (sym != nullptr) { if (compile_debug) gdb_printf (gdb_stdlog, diff --git a/gdb/compile/compile-cplus-types.c b/gdb/compile/compile-cplus-types.c index ac27e83618b..ad52c93409b 100644 --- a/gdb/compile/compile-cplus-types.c +++ b/gdb/compile/compile-cplus-types.c @@ -153,7 +153,7 @@ type_name_to_scope (const char *type_name, const struct block *block) /* Look up the resulting name. */ struct block_symbol bsymbol - = lookup_symbol (lookup_name.c_str (), block, VAR_DOMAIN, nullptr); + = lookup_symbol (lookup_name.c_str (), block, SEARCH_VFT, nullptr); if (bsymbol.symbol != nullptr) { @@ -383,7 +383,7 @@ compile_cplus_instance::new_scope (const char *type_name, struct type *type) scope_component comp = { decl_name (type->name ()).get (), - lookup_symbol (type->name (), block (), VAR_DOMAIN, nullptr) + lookup_symbol (type->name (), block (), SEARCH_VFT, nullptr) }; scope.push_back (comp); } @@ -616,7 +616,7 @@ compile_cplus_convert_struct_or_union_members const char *physname = type->field (i).loc_physname (); struct block_symbol sym = lookup_symbol (physname, instance->block (), - VAR_DOMAIN, nullptr); + SEARCH_VFT, nullptr); if (sym.symbol == nullptr) { @@ -728,7 +728,7 @@ compile_cplus_convert_struct_or_union_methods (compile_cplus_instance *instance, gcc_type method_type; struct block_symbol sym = lookup_symbol (TYPE_FN_FIELD_PHYSNAME (methods, j), - instance->block (), VAR_DOMAIN, nullptr); + instance->block (), SEARCH_VFT, nullptr); if (sym.symbol == nullptr) { diff --git a/gdb/compile/compile-object-load.c b/gdb/compile/compile-object-load.c index d1727c30657..9fd18f4e106 100644 --- a/gdb/compile/compile-object-load.c +++ b/gdb/compile/compile-object-load.c @@ -437,7 +437,7 @@ get_out_value_type (struct symbol *func_sym, struct objfile *objfile, gdb_val_sym = block_lookup_symbol (block, COMPILE_I_EXPR_VAL, symbol_name_match_type::SEARCH_NAME, - VAR_DOMAIN); + SEARCH_VFT); if (gdb_val_sym == NULL) continue; @@ -463,7 +463,7 @@ get_out_value_type (struct symbol *func_sym, struct objfile *objfile, gdb_ptr_type_sym = block_lookup_symbol (block, COMPILE_I_EXPR_PTR_TYPE, symbol_name_match_type::SEARCH_NAME, - VAR_DOMAIN); + SEARCH_VFT); if (gdb_ptr_type_sym == NULL) error (_("No \"%s\" symbol found"), COMPILE_I_EXPR_PTR_TYPE); gdb_ptr_type = gdb_ptr_type_sym->type (); @@ -652,7 +652,7 @@ compile_object_load (const compile_file_names &file_names, func_sym = lookup_global_symbol_from_objfile (objfile, GLOBAL_BLOCK, GCC_FE_WRAPPER_FUNCTION, - VAR_DOMAIN).symbol; + SEARCH_VFT).symbol; if (func_sym == NULL) error (_("Cannot find function \"%s\" in compiled module \"%s\"."), GCC_FE_WRAPPER_FUNCTION, objfile_name (objfile)); diff --git a/gdb/cp-namespace.c b/gdb/cp-namespace.c index 975e789f18a..7c1e9576800 100644 --- a/gdb/cp-namespace.c +++ b/gdb/cp-namespace.c @@ -42,7 +42,7 @@ static struct block_symbol const char *nested_name, const char *concatenated_name, const struct block *block, - const domain_enum domain, + const domain_search_flags domain, int basic_lookup, int is_in_anonymous); static struct type *cp_lookup_transparent_type_loop (const char *name, @@ -129,7 +129,7 @@ cp_is_in_anonymous (const char *symbol_name) static struct block_symbol cp_basic_lookup_symbol (const char *name, const struct block *block, - const domain_enum domain, int is_in_anonymous) + const domain_search_flags domain, int is_in_anonymous) { struct block_symbol sym; @@ -172,7 +172,7 @@ cp_basic_lookup_symbol (const char *name, const struct block *block, static struct block_symbol cp_lookup_bare_symbol (const struct language_defn *langdef, const char *name, const struct block *block, - const domain_enum domain, int search) + const domain_search_flags domain, int search) { struct block_symbol sym; @@ -192,7 +192,7 @@ cp_lookup_bare_symbol (const struct language_defn *langdef, shared libraries we could search all of them only to find out the builtin type isn't defined in any of them. This is common for types like "void". */ - if (langdef != NULL && domain == VAR_DOMAIN) + if (langdef != nullptr && (domain & SEARCH_TYPE_DOMAIN) != 0) { struct gdbarch *gdbarch; @@ -251,7 +251,7 @@ cp_lookup_bare_symbol (const struct language_defn *langdef, static struct block_symbol cp_search_static_and_baseclasses (const char *name, const struct block *block, - const domain_enum domain, + const domain_search_flags domain, unsigned int prefix_len, int is_in_anonymous) { @@ -273,9 +273,9 @@ cp_search_static_and_baseclasses (const char *name, symbol_matches_domain (which should be replaced with something else, but it's what we have today). */ block_symbol scope_sym = lookup_symbol_in_static_block (scope.c_str (), - block, VAR_DOMAIN); + block, SEARCH_VFT); if (scope_sym.symbol == NULL) - scope_sym = lookup_global_symbol (scope.c_str (), block, VAR_DOMAIN); + scope_sym = lookup_global_symbol (scope.c_str (), block, SEARCH_VFT); if (scope_sym.symbol == NULL) return {}; @@ -285,9 +285,9 @@ cp_search_static_and_baseclasses (const char *name, static variable. E.g., "print 'function()::static_var'". */ if ((scope_type->code () == TYPE_CODE_FUNC || scope_type->code () == TYPE_CODE_METHOD) - && domain == VAR_DOMAIN) + && (domain & SEARCH_VAR_DOMAIN) != 0) return lookup_symbol (nested, scope_sym.symbol->value_block (), - VAR_DOMAIN, NULL); + domain, NULL); /* Look for a symbol named NESTED in this class/namespace. The caller is assumed to have already have done a basic lookup of NAME. @@ -308,7 +308,7 @@ cp_search_static_and_baseclasses (const char *name, static struct block_symbol cp_lookup_symbol_in_namespace (const char *the_namespace, const char *name, const struct block *block, - const domain_enum domain, int search) + const domain_search_flags domain, int search) { char *concatenated_name = NULL; int is_in_anonymous; @@ -382,7 +382,7 @@ static void cp_lookup_symbol_via_imports (const char *scope, const char *name, const struct block *block, - const domain_enum domain, + const domain_search_flags domain, const int search_scope_first, const int declaration_only, const int search_parents, @@ -503,7 +503,7 @@ static struct block_symbol cp_lookup_symbol_via_imports (const char *scope, const char *name, const struct block *block, - const domain_enum domain, + const domain_search_flags domain, const int declaration_only, const int search_parents) { @@ -560,13 +560,14 @@ struct block_symbol cp_lookup_symbol_imports_or_template (const char *scope, const char *name, const struct block *block, - const domain_enum domain) + const domain_search_flags domain) { struct symbol *function = block->function (); symbol_lookup_debug_printf ("cp_lookup_symbol_imports_or_template (%s, %s, %s, %s)", - scope, name, host_address_to_string (block), domain_name (domain)); + scope, name, host_address_to_string (block), + domain_name (domain).c_str ()); if (function != NULL && function->language () == language_cplus) { @@ -646,7 +647,7 @@ cp_lookup_symbol_imports_or_template (const char *scope, static struct block_symbol cp_lookup_symbol_via_all_imports (const char *scope, const char *name, const struct block *block, - const domain_enum domain) + const domain_search_flags domain) { struct block_symbol sym; @@ -671,13 +672,13 @@ struct block_symbol cp_lookup_symbol_namespace (const char *scope, const char *name, const struct block *block, - const domain_enum domain) + const domain_search_flags domain) { struct block_symbol sym; symbol_lookup_debug_printf ("cp_lookup_symbol_namespace (%s, %s, %s, %s)", scope, name, host_address_to_string (block), - domain_name (domain)); + domain_name (domain).c_str ()); /* First, try to find the symbol in the given namespace. */ sym = cp_lookup_symbol_in_namespace (scope, name, block, domain, 1); @@ -711,7 +712,7 @@ static struct block_symbol lookup_namespace_scope (const struct language_defn *langdef, const char *name, const struct block *block, - const domain_enum domain, + const domain_search_flags domain, const char *scope, int scope_len) { @@ -768,14 +769,15 @@ struct block_symbol cp_lookup_symbol_nonlocal (const struct language_defn *langdef, const char *name, const struct block *block, - const domain_enum domain) + const domain_search_flags domain) { struct block_symbol sym; const char *scope = block == nullptr ? "" : block->scope (); symbol_lookup_debug_printf ("cp_lookup_symbol_non_local (%s, %s (scope %s), %s)", - name, host_address_to_string (block), scope, domain_name (domain)); + name, host_address_to_string (block), scope, + domain_name (domain).c_str ()); /* First, try to find the symbol in the given namespace, and all containing namespaces. */ @@ -826,7 +828,8 @@ cp_find_type_baseclass_by_name (struct type *parent_type, const char *name) static struct block_symbol find_symbol_in_baseclass (struct type *parent_type, const char *name, - const struct block *block, const domain_enum domain, + const struct block *block, + const domain_search_flags domain, int is_in_anonymous) { int i; @@ -869,7 +872,7 @@ cp_lookup_nested_symbol_1 (struct type *container_type, const char *nested_name, const char *concatenated_name, const struct block *block, - const domain_enum domain, + const domain_search_flags domain, int basic_lookup, int is_in_anonymous) { struct block_symbol sym; @@ -933,7 +936,7 @@ struct block_symbol cp_lookup_nested_symbol (struct type *parent_type, const char *nested_name, const struct block *block, - const domain_enum domain) + const domain_search_flags domain) { /* type_name_or_error provides better error reporting using the original type. */ @@ -948,7 +951,7 @@ cp_lookup_nested_symbol (struct type *parent_type, symbol_lookup_debug_printf ("cp_lookup_nested_symbol (%s, %s, %s, %s)", type_name != NULL ? type_name : "unnamed", nested_name, host_address_to_string (block), - domain_name (domain)); + domain_name (domain).c_str ()); } switch (parent_type->code ()) diff --git a/gdb/cp-support.c b/gdb/cp-support.c index e02e859b99a..6b228362d18 100644 --- a/gdb/cp-support.c +++ b/gdb/cp-support.c @@ -151,7 +151,7 @@ inspect_type (struct demangle_parse_info *info, try { - sym = lookup_symbol (name, 0, VAR_DOMAIN, 0).symbol; + sym = lookup_symbol (name, 0, SEARCH_VFT, 0).symbol; } catch (const gdb_exception &except) { @@ -505,7 +505,7 @@ replace_typedefs (struct demangle_parse_info *info, try { sym = lookup_symbol (local_name.get (), 0, - VAR_DOMAIN, 0).symbol; + SEARCH_VFT, 0).symbol; } catch (const gdb_exception &except) { @@ -1500,7 +1500,7 @@ cp_lookup_rtti_type (const char *name, const struct block *block) /* Use VAR_DOMAIN here as NAME may be a typedef. PR 18141, 18417. Classes "live" in both STRUCT_DOMAIN and VAR_DOMAIN. */ - rtti_sym = lookup_symbol (name, block, VAR_DOMAIN, NULL).symbol; + rtti_sym = lookup_symbol (name, block, SEARCH_VFT, NULL).symbol; if (rtti_sym == NULL) { diff --git a/gdb/cp-support.h b/gdb/cp-support.h index 709dca46df1..e324e47cb88 100644 --- a/gdb/cp-support.h +++ b/gdb/cp-support.h @@ -141,25 +141,25 @@ extern struct block_symbol cp_lookup_symbol_nonlocal (const struct language_defn *langdef, const char *name, const struct block *block, - const domain_enum domain); + const domain_search_flags domain); extern struct block_symbol cp_lookup_symbol_namespace (const char *the_namespace, const char *name, const struct block *block, - const domain_enum domain); + const domain_search_flags domain); extern struct block_symbol cp_lookup_symbol_imports_or_template (const char *scope, const char *name, const struct block *block, - const domain_enum domain); + const domain_search_flags domain); extern struct block_symbol cp_lookup_nested_symbol (struct type *parent_type, const char *nested_name, const struct block *block, - const domain_enum domain); + const domain_search_flags domain); struct type *cp_lookup_transparent_type (const char *name); diff --git a/gdb/d-exp.y b/gdb/d-exp.y index 6c5569a1c8d..4e04877a420 100644 --- a/gdb/d-exp.y +++ b/gdb/d-exp.y @@ -444,7 +444,7 @@ PrimaryExpression: /* Handle VAR, which could be local or global. */ sym = lookup_symbol (copy.c_str (), pstate->expression_context_block, - VAR_DOMAIN, &is_a_field_of_this); + SEARCH_VFT, &is_a_field_of_this); if (sym.symbol && sym.symbol->aclass () != LOC_TYPEDEF) { if (symbol_read_needs_frame (sym.symbol)) @@ -493,7 +493,7 @@ PrimaryExpression: sym = lookup_symbol (name.c_str (), (const struct block *) NULL, - VAR_DOMAIN, NULL); + SEARCH_VFT, NULL); pstate->push_symbol (name.c_str (), sym); } else @@ -1337,7 +1337,7 @@ classify_name (struct parser_state *par_state, const struct block *block) std::string copy = copy_name (yylval.sval); - sym = lookup_symbol (copy.c_str (), block, VAR_DOMAIN, &is_a_field_of_this); + sym = lookup_symbol (copy.c_str (), block, SEARCH_VFT, &is_a_field_of_this); if (sym.symbol && sym.symbol->aclass () == LOC_TYPEDEF) { yylval.tsym.type = sym.symbol->type (); @@ -1346,9 +1346,11 @@ classify_name (struct parser_state *par_state, const struct block *block) else if (sym.symbol == NULL) { /* Look-up first for a module name, then a type. */ - sym = lookup_symbol (copy.c_str (), block, MODULE_DOMAIN, NULL); + sym = lookup_symbol (copy.c_str (), block, SEARCH_MODULE_DOMAIN, + nullptr); if (sym.symbol == NULL) - sym = lookup_symbol (copy.c_str (), block, STRUCT_DOMAIN, NULL); + sym = lookup_symbol (copy.c_str (), block, SEARCH_STRUCT_DOMAIN, + nullptr); if (sym.symbol != NULL) { diff --git a/gdb/d-lang.c b/gdb/d-lang.c index 8d1bdd05677..ae6ea8da34e 100644 --- a/gdb/d-lang.c +++ b/gdb/d-lang.c @@ -171,7 +171,7 @@ class d_language : public language_defn struct block_symbol lookup_symbol_nonlocal (const char *name, const struct block *block, - const domain_enum domain) const override + const domain_search_flags domain) const override { return d_lookup_symbol_nonlocal (this, name, block, domain); } diff --git a/gdb/d-lang.h b/gdb/d-lang.h index f47f5df5a73..1f98a65ec88 100644 --- a/gdb/d-lang.h +++ b/gdb/d-lang.h @@ -69,10 +69,11 @@ extern const struct builtin_d_type *builtin_d_type (struct gdbarch *); /* Defined in d-namespace.c */ -extern struct block_symbol d_lookup_symbol_nonlocal (const struct language_defn *, - const char *, - const struct block *, - const domain_enum); +extern struct block_symbol d_lookup_symbol_nonlocal + (const struct language_defn *, + const char *, + const struct block *, + const domain_search_flags); extern struct block_symbol d_lookup_nested_symbol (struct type *, const char *, const struct block *); diff --git a/gdb/d-namespace.c b/gdb/d-namespace.c index 69474ba08d9..c86588c0e8b 100644 --- a/gdb/d-namespace.c +++ b/gdb/d-namespace.c @@ -78,7 +78,7 @@ d_entire_prefix_len (const char *name) static struct block_symbol d_lookup_symbol (const struct language_defn *langdef, const char *name, const struct block *block, - const domain_enum domain, int search) + const domain_search_flags domain, int search) { struct block_symbol sym; @@ -88,7 +88,7 @@ d_lookup_symbol (const struct language_defn *langdef, /* If we didn't find a definition for a builtin type in the static block, such as "ucent" which is a specialist type, search for it now. */ - if (langdef != NULL && domain == VAR_DOMAIN) + if (langdef != nullptr && (domain & SEARCH_TYPE_DOMAIN) != 0) { struct gdbarch *gdbarch; @@ -166,7 +166,7 @@ d_lookup_symbol (const struct language_defn *langdef, static struct block_symbol d_lookup_symbol_in_module (const char *module, const char *name, const struct block *block, - const domain_enum domain, int search) + const domain_search_flags domain, int search) { char *concatenated_name = NULL; @@ -198,7 +198,7 @@ d_lookup_symbol_in_module (const char *module, const char *name, static struct block_symbol lookup_module_scope (const struct language_defn *langdef, const char *name, const struct block *block, - const domain_enum domain, const char *scope, + const domain_search_flags domain, const char *scope, int scope_len) { char *module; @@ -261,7 +261,7 @@ find_symbol_in_baseclass (struct type *parent_type, const char *name, /* Search this particular base class. */ sym = d_lookup_symbol_in_module (base_name, name, block, - VAR_DOMAIN, 0); + SEARCH_VFT, 0); if (sym.symbol != NULL) break; @@ -270,14 +270,14 @@ find_symbol_in_baseclass (struct type *parent_type, const char *name, what we want is possibly there. */ std::string concatenated_name = std::string (base_name) + "." + name; sym = lookup_symbol_in_static_block (concatenated_name.c_str (), block, - VAR_DOMAIN); + SEARCH_VFT); if (sym.symbol != NULL) break; /* Nope. We now have to search all static blocks in all objfiles, even if block != NULL, because there's no guarantees as to which symtab the symbol we want is in. */ - sym = lookup_static_symbol (concatenated_name.c_str (), VAR_DOMAIN); + sym = lookup_static_symbol (concatenated_name.c_str (), SEARCH_VFT); if (sym.symbol != NULL) break; @@ -320,7 +320,7 @@ d_lookup_nested_symbol (struct type *parent_type, const char *parent_name = type_name_or_error (saved_parent_type); struct block_symbol sym = d_lookup_symbol_in_module (parent_name, nested_name, - block, VAR_DOMAIN, 0); + block, SEARCH_VFT, 0); char *concatenated_name; if (sym.symbol != NULL) @@ -337,7 +337,7 @@ d_lookup_nested_symbol (struct type *parent_type, xsnprintf (concatenated_name, size, "%s.%s", parent_name, nested_name); - sym = lookup_static_symbol (concatenated_name, VAR_DOMAIN); + sym = lookup_static_symbol (concatenated_name, SEARCH_VFT); if (sym.symbol != NULL) return sym; @@ -361,7 +361,7 @@ d_lookup_nested_symbol (struct type *parent_type, static struct block_symbol d_lookup_symbol_imports (const char *scope, const char *name, const struct block *block, - const domain_enum domain) + const domain_search_flags domain) { struct using_direct *current; struct block_symbol sym; @@ -473,7 +473,7 @@ d_lookup_symbol_imports (const char *scope, const char *name, static struct block_symbol d_lookup_symbol_module (const char *scope, const char *name, const struct block *block, - const domain_enum domain) + const domain_search_flags domain) { struct block_symbol sym; @@ -509,7 +509,7 @@ struct block_symbol d_lookup_symbol_nonlocal (const struct language_defn *langdef, const char *name, const struct block *block, - const domain_enum domain) + const domain_search_flags domain) { struct block_symbol sym; const char *scope = block == nullptr ? "" : block->scope (); diff --git a/gdb/dwarf2/ada-imported.c b/gdb/dwarf2/ada-imported.c index d1d99be6923..bfcfb779105 100644 --- a/gdb/dwarf2/ada-imported.c +++ b/gdb/dwarf2/ada-imported.c @@ -103,7 +103,7 @@ ada_alias_get_block_value (const struct symbol *sym) { const char *name = get_imported_name (sym); block_symbol real_symbol = lookup_global_symbol (name, nullptr, - VAR_DOMAIN); + SEARCH_VFT); if (real_symbol.symbol == nullptr) error (_("could not find alias '%s' for function '%s'"), name, sym->print_name ()); diff --git a/gdb/dwarf2/loc.c b/gdb/dwarf2/loc.c index 5b2d58ab44e..31fe8ed5cf6 100644 --- a/gdb/dwarf2/loc.c +++ b/gdb/dwarf2/loc.c @@ -624,7 +624,7 @@ func_get_frame_base_dwarf_block (struct symbol *framefunc, CORE_ADDR pc, value * compute_var_value (const char *name) { - struct block_symbol sym = lookup_symbol (name, nullptr, VAR_DOMAIN, + struct block_symbol sym = lookup_symbol (name, nullptr, SEARCH_VAR_DOMAIN, nullptr); if (sym.symbol != nullptr) return value_of_variable (sym.symbol, sym.block); diff --git a/gdb/eval.c b/gdb/eval.c index b859e825925..cbb0555e801 100644 --- a/gdb/eval.c +++ b/gdb/eval.c @@ -730,7 +730,7 @@ scope_operation::evaluate_funcall (struct type *expect_type, function = cp_lookup_symbol_namespace (type->name (), name.c_str (), get_selected_block (0), - VAR_DOMAIN).symbol; + SEARCH_FUNCTION_DOMAIN).symbol; if (function == NULL) error (_("No symbol \"%s\" in namespace \"%s\"."), name.c_str (), type->name ()); @@ -1105,7 +1105,8 @@ eval_op_func_static_var (struct type *expect_type, struct expression *exp, { CORE_ADDR addr = func->address (); const block *blk = block_for_pc (addr); - struct block_symbol sym = lookup_symbol (var, blk, VAR_DOMAIN, NULL); + struct block_symbol sym = lookup_symbol (var, blk, SEARCH_VAR_DOMAIN, + nullptr); if (sym.symbol == NULL) error (_("No symbol \"%s\" in specified context."), var); return evaluate_var_value (noside, sym.block, sym.symbol); diff --git a/gdb/f-exp.y b/gdb/f-exp.y index 18566afd67f..a8ab201f584 100644 --- a/gdb/f-exp.y +++ b/gdb/f-exp.y @@ -1640,11 +1640,11 @@ yylex (void) { std::string tmp = copy_name (yylval.sval); struct block_symbol result; - const domain_enum lookup_domains[] = + const domain_search_flags lookup_domains[] = { - STRUCT_DOMAIN, - VAR_DOMAIN, - MODULE_DOMAIN + SEARCH_STRUCT_DOMAIN, + SEARCH_VFT, + SEARCH_MODULE_DOMAIN }; int hextype; diff --git a/gdb/f-lang.c b/gdb/f-lang.c index fc0614e5761..78b1c61c6e2 100644 --- a/gdb/f-lang.c +++ b/gdb/f-lang.c @@ -1715,7 +1715,7 @@ f_language::search_name_hash (const char *name) const struct block_symbol f_language::lookup_symbol_nonlocal (const char *name, const struct block *block, - const domain_enum domain) const + const domain_search_flags domain) const { return cp_lookup_symbol_nonlocal (this, name, block, domain); } diff --git a/gdb/f-lang.h b/gdb/f-lang.h index 0a29380d31d..5d702fb38bc 100644 --- a/gdb/f-lang.h +++ b/gdb/f-lang.h @@ -142,7 +142,7 @@ class f_language : public language_defn struct block_symbol lookup_symbol_nonlocal (const char *name, const struct block *block, - const domain_enum domain) const override; + const domain_search_flags domain) const override; /* See language.h. */ diff --git a/gdb/f-valprint.c b/gdb/f-valprint.c index 2b7dafc4de3..d61f82662c3 100644 --- a/gdb/f-valprint.c +++ b/gdb/f-valprint.c @@ -552,7 +552,7 @@ f_language::value_print_inner (struct value *val, struct ui_file *stream, value field before printing its value. */ struct block_symbol sym = lookup_symbol (field_name, get_selected_block (nullptr), - VAR_DOMAIN, nullptr); + SEARCH_VFT, nullptr); if (sym.symbol == nullptr) error (_("failed to find symbol for name list component %s"), field_name); diff --git a/gdb/fbsd-tdep.c b/gdb/fbsd-tdep.c index d166d785736..387a0a71979 100644 --- a/gdb/fbsd-tdep.c +++ b/gdb/fbsd-tdep.c @@ -1960,8 +1960,9 @@ fbsd_fetch_rtld_offsets (struct gdbarch *gdbarch, struct fbsd_pspace_data *data) { /* Fetch offsets from debug symbols in rtld. */ struct symbol *obj_entry_sym - = lookup_symbol_in_language ("Struct_Obj_Entry", NULL, STRUCT_DOMAIN, - language_c, NULL).symbol; + = lookup_symbol_in_language ("Struct_Obj_Entry", nullptr, + SEARCH_STRUCT_DOMAIN, + language_c, nullptr).symbol; if (obj_entry_sym == NULL) error (_("Unable to find Struct_Obj_Entry symbol")); data->off_linkmap = lookup_struct_elt (obj_entry_sym->type (), diff --git a/gdb/frame.c b/gdb/frame.c index 5ac84a8d0cd..ce558bf6149 100644 --- a/gdb/frame.c +++ b/gdb/frame.c @@ -2565,7 +2565,8 @@ inside_main_func (frame_info_ptr this_frame) /* In some language (for example Fortran) there will be no minimal symbol with the name of the main function. In this case we should search the full symbols to see if we can find a match. */ - struct block_symbol bs = lookup_symbol (name, NULL, VAR_DOMAIN, 0); + struct block_symbol bs = lookup_symbol (name, nullptr, + SEARCH_VFT, nullptr); /* We might have found some unrelated symbol. For example, the Rust compiler can emit both a subprogram and a namespace with diff --git a/gdb/ft32-tdep.c b/gdb/ft32-tdep.c index cac4b9ba6a2..e97261dfdd8 100644 --- a/gdb/ft32-tdep.c +++ b/gdb/ft32-tdep.c @@ -297,7 +297,8 @@ ft32_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc) plg_end = ft32_analyze_prologue (func_addr, func_end, &cache, gdbarch); /* Found a function. */ - sym = lookup_symbol (func_name, NULL, VAR_DOMAIN, NULL).symbol; + sym = lookup_symbol (func_name, nullptr, SEARCH_FUNCTION_DOMAIN, + nullptr).symbol; /* Don't use line number debug info for assembly source files. */ if ((sym != NULL) && sym->language () != language_asm) { diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index 7011fddd695..a6ff272adef 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -1654,7 +1654,7 @@ lookup_typename (const struct language_defn *language, { struct symbol *sym; - sym = lookup_symbol_in_language (name, block, VAR_DOMAIN, + sym = lookup_symbol_in_language (name, block, SEARCH_VFT, language->la_language, NULL).symbol; if (sym != NULL && sym->aclass () == LOC_TYPEDEF) { @@ -1698,7 +1698,7 @@ lookup_struct (const char *name, const struct block *block) { struct symbol *sym; - sym = lookup_symbol (name, block, STRUCT_DOMAIN, 0).symbol; + sym = lookup_symbol (name, block, SEARCH_STRUCT_DOMAIN, 0).symbol; if (sym == NULL) { @@ -1721,7 +1721,7 @@ lookup_union (const char *name, const struct block *block) struct symbol *sym; struct type *t; - sym = lookup_symbol (name, block, STRUCT_DOMAIN, 0).symbol; + sym = lookup_symbol (name, block, SEARCH_STRUCT_DOMAIN, 0).symbol; if (sym == NULL) error (_("No union type named %s."), name); @@ -1744,7 +1744,7 @@ lookup_enum (const char *name, const struct block *block) { struct symbol *sym; - sym = lookup_symbol (name, block, STRUCT_DOMAIN, 0).symbol; + sym = lookup_symbol (name, block, SEARCH_STRUCT_DOMAIN, 0).symbol; if (sym == NULL) { error (_("No enum type named %s."), name); @@ -1771,7 +1771,8 @@ lookup_template_type (const char *name, struct type *type, nam += type->name (); nam += " >"; /* FIXME, extra space still introduced in gcc? */ - symbol *sym = lookup_symbol (nam.c_str (), block, VAR_DOMAIN, 0).symbol; + symbol *sym = lookup_symbol (nam.c_str (), block, + SEARCH_STRUCT_DOMAIN, 0).symbol; if (sym == NULL) { @@ -2993,7 +2994,8 @@ check_typedef (struct type *type) stub_noname_complaint (); return make_qualified_type (type, instance_flags, NULL); } - sym = lookup_symbol (name, 0, STRUCT_DOMAIN, 0).symbol; + sym = lookup_symbol (name, nullptr, SEARCH_STRUCT_DOMAIN, + nullptr).symbol; if (sym) type->set_target_type (sym->type ()); else /* TYPE_CODE_UNDEF */ @@ -3083,7 +3085,8 @@ check_typedef (struct type *type) stub_noname_complaint (); return make_qualified_type (type, instance_flags, NULL); } - sym = lookup_symbol (name, 0, STRUCT_DOMAIN, 0).symbol; + sym = lookup_symbol (name, nullptr, SEARCH_STRUCT_DOMAIN, + nullptr).symbol; if (sym) { /* Same as above for opaque types, we can replace the stub diff --git a/gdb/gnu-v3-abi.c b/gdb/gnu-v3-abi.c index 73b69da21e5..7b2b93fd430 100644 --- a/gdb/gnu-v3-abi.c +++ b/gdb/gnu-v3-abi.c @@ -1079,7 +1079,7 @@ gnuv3_get_typeid_type (struct gdbarch *gdbarch) struct symbol *typeinfo; struct type *typeinfo_type; - typeinfo = lookup_symbol ("std::type_info", NULL, STRUCT_DOMAIN, + typeinfo = lookup_symbol ("std::type_info", NULL, SEARCH_STRUCT_DOMAIN, NULL).symbol; if (typeinfo == NULL) { diff --git a/gdb/go-exp.y b/gdb/go-exp.y index 28bf3f0ab33..bf1282e80f3 100644 --- a/gdb/go-exp.y +++ b/gdb/go-exp.y @@ -1293,7 +1293,8 @@ package_name_p (const char *name, const struct block *block) struct symbol *sym; struct field_of_this_result is_a_field_of_this; - sym = lookup_symbol (name, block, STRUCT_DOMAIN, &is_a_field_of_this).symbol; + sym = lookup_symbol (name, block, SEARCH_STRUCT_DOMAIN, + &is_a_field_of_this).symbol; if (sym && sym->aclass () == LOC_TYPEDEF @@ -1335,7 +1336,7 @@ classify_packaged_name (const struct block *block) std::string copy = copy_name (yylval.sval); - sym = lookup_symbol (copy.c_str (), block, VAR_DOMAIN, &is_a_field_of_this); + sym = lookup_symbol (copy.c_str (), block, SEARCH_VFT, &is_a_field_of_this); if (sym.symbol) { @@ -1378,7 +1379,7 @@ classify_name (struct parser_state *par_state, const struct block *block) /* TODO: What about other types? */ - sym = lookup_symbol (copy.c_str (), block, VAR_DOMAIN, &is_a_field_of_this); + sym = lookup_symbol (copy.c_str (), block, SEARCH_VFT, &is_a_field_of_this); if (sym.symbol) { @@ -1403,7 +1404,7 @@ classify_name (struct parser_state *par_state, const struct block *block) strlen (current_package_name.get ()), copy.c_str (), copy.size ()); - sym = lookup_symbol (sval.ptr, block, VAR_DOMAIN, + sym = lookup_symbol (sval.ptr, block, SEARCH_VFT, &is_a_field_of_this); if (sym.symbol) { diff --git a/gdb/guile/scm-frame.c b/gdb/guile/scm-frame.c index 45863c587c1..155e7a67c77 100644 --- a/gdb/guile/scm-frame.c +++ b/gdb/guile/scm-frame.c @@ -936,7 +936,7 @@ gdbscm_frame_read_var (SCM self, SCM symbol_scm, SCM rest) if (block == NULL) block = get_frame_block (frame_info_ptr (frame), NULL); - lookup_sym = lookup_symbol (var_name.get (), block, VAR_DOMAIN, + lookup_sym = lookup_symbol (var_name.get (), block, SEARCH_VFT, NULL); var = lookup_sym.symbol; block = lookup_sym.block; diff --git a/gdb/guile/scm-symbol.c b/gdb/guile/scm-symbol.c index a7dd21db088..70c4895f5db 100644 --- a/gdb/guile/scm-symbol.c +++ b/gdb/guile/scm-symbol.c @@ -617,7 +617,8 @@ gdbscm_lookup_symbol (SCM name_scm, SCM rest) gdbscm_gdb_exception except {}; try { - symbol = lookup_symbol (name, block, (domain_enum) domain, + domain_search_flags flags = from_scripting_domain (domain); + symbol = lookup_symbol (name, block, flags, &is_a_field_of_this).symbol; } catch (const gdb_exception &ex) @@ -654,7 +655,8 @@ gdbscm_lookup_global_symbol (SCM name_scm, SCM rest) try { - symbol = lookup_global_symbol (name, NULL, (domain_enum) domain).symbol; + domain_search_flags flags = from_scripting_domain (domain); + symbol = lookup_global_symbol (name, NULL, flags).symbol; } catch (const gdb_exception &ex) { @@ -696,14 +698,15 @@ static const scheme_integer_constant symbol_integer_constants[] = #undef X #define DOMAIN(X) \ - { "SYMBOL_" #X "_DOMAIN", X ## _DOMAIN }, + { "SYMBOL_" #X "_DOMAIN", to_scripting_domain (X ## _DOMAIN) }, \ + { "SEARCH_" #X "_DOMAIN", to_scripting_domain (SEARCH_ ## X ## _DOMAIN) }, #include "sym-domains.def" #undef DOMAIN - /* These were never correct. */ - { "SYMBOL_VARIABLES_DOMAIN", VAR_DOMAIN }, - { "SYMBOL_FUNCTIONS_DOMAIN", FUNCTION_DOMAIN }, - { "SYMBOL_TYPES_DOMAIN", TYPE_DOMAIN }, + /* Historical. */ + { "SYMBOL_VARIABLES_DOMAIN", to_scripting_domain (SEARCH_VAR_DOMAIN) }, + { "SYMBOL_FUNCTIONS_DOMAIN", to_scripting_domain (SEARCH_FUNCTION_DOMAIN) }, + { "SYMBOL_TYPES_DOMAIN", to_scripting_domain (SEARCH_TYPE_DOMAIN) }, END_INTEGER_CONSTANTS }; diff --git a/gdb/infrun.c b/gdb/infrun.c index 70c33a9c392..2ae31e89196 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -8722,7 +8722,7 @@ insert_exception_resume_breakpoint (struct thread_info *tp, struct breakpoint *bp; vsym = lookup_symbol_search_name (sym->search_name (), - b, VAR_DOMAIN); + b, SEARCH_VAR_DOMAIN); value = read_var_value (vsym.symbol, vsym.block, frame); /* If the value was optimized out, revert to the old behavior. */ if (! value->optimized_out ()) diff --git a/gdb/language.c b/gdb/language.c index c768971be42..13b20840286 100644 --- a/gdb/language.c +++ b/gdb/language.c @@ -901,7 +901,8 @@ language_arch_info::bool_type () const { struct symbol *sym; - sym = lookup_symbol (m_bool_type_name, NULL, VAR_DOMAIN, NULL).symbol; + sym = lookup_symbol (m_bool_type_name, nullptr, SEARCH_TYPE_DOMAIN, + nullptr).symbol; if (sym != nullptr) { struct type *type = sym->type (); diff --git a/gdb/language.h b/gdb/language.h index b633b3dfa39..ccedf9abce6 100644 --- a/gdb/language.h +++ b/gdb/language.h @@ -513,7 +513,7 @@ struct language_defn virtual struct block_symbol lookup_symbol_nonlocal (const char *name, const struct block *block, - const domain_enum domain) const; + const domain_search_flags domain) const; /* Return an expression that can be used for a location watchpoint. TYPE is a pointer type that points to the memory diff --git a/gdb/linespec.c b/gdb/linespec.c index 8ec9192fb37..e840a137cfb 100644 --- a/gdb/linespec.c +++ b/gdb/linespec.c @@ -3915,7 +3915,7 @@ find_label_symbols_in_block (const struct block *block, for (struct symbol *sym : block_iterator_range (block)) { - if (sym->matches (LABEL_DOMAIN) + if (sym->domain () == LABEL_DOMAIN && cmp (sym->search_name (), name, name_len) == 0) { result->push_back ({sym, block}); @@ -3926,7 +3926,7 @@ find_label_symbols_in_block (const struct block *block, else { struct block_symbol label_sym - = lookup_symbol (name, block, LABEL_DOMAIN, 0); + = lookup_symbol (name, block, SEARCH_LABEL_DOMAIN, 0); if (label_sym.symbol != NULL) { diff --git a/gdb/m2-exp.y b/gdb/m2-exp.y index 092a8be248d..b9abbf28eb5 100644 --- a/gdb/m2-exp.y +++ b/gdb/m2-exp.y @@ -494,7 +494,7 @@ fblock : BLOCKNAME { struct symbol *sym = lookup_symbol (copy_name ($1).c_str (), pstate->expression_context_block, - VAR_DOMAIN, 0).symbol; + SEARCH_VFT, 0).symbol; $$ = sym;} ; @@ -503,7 +503,7 @@ fblock : BLOCKNAME fblock : block COLONCOLON BLOCKNAME { struct symbol *tem = lookup_symbol (copy_name ($3).c_str (), $1, - VAR_DOMAIN, 0).symbol; + SEARCH_VFT, 0).symbol; if (!tem || tem->aclass () != LOC_BLOCK) error (_("No function \"%s\" in specified context."), copy_name ($3).c_str ()); @@ -528,7 +528,7 @@ variable: DOLLAR_VARIABLE variable: block COLONCOLON NAME { struct block_symbol sym = lookup_symbol (copy_name ($3).c_str (), $1, - VAR_DOMAIN, 0); + SEARCH_VFT, 0); if (sym.symbol == 0) error (_("No symbol \"%s\" in specified context."), @@ -549,7 +549,7 @@ variable: NAME sym = lookup_symbol (name.c_str (), pstate->expression_context_block, - VAR_DOMAIN, + SEARCH_VFT, &is_a_field_of_this); pstate->push_symbol (name.c_str (), sym); @@ -927,7 +927,7 @@ yylex (void) if (lookup_symtab (tmp.c_str ())) return BLOCKNAME; sym = lookup_symbol (tmp.c_str (), pstate->expression_context_block, - VAR_DOMAIN, 0).symbol; + SEARCH_VFT, 0).symbol; if (sym && sym->aclass () == LOC_BLOCK) return BLOCKNAME; if (lookup_typename (pstate->language (), diff --git a/gdb/mi/mi-cmd-stack.c b/gdb/mi/mi-cmd-stack.c index e473be7d465..5c0b27cc7c9 100644 --- a/gdb/mi/mi-cmd-stack.c +++ b/gdb/mi/mi-cmd-stack.c @@ -636,8 +636,9 @@ list_args_or_locals (const frame_print_options &fp_opts, struct frame_arg arg, entryarg; if (sym->is_argument ()) - sym2 = lookup_symbol_search_name (sym->search_name (), - block, VAR_DOMAIN).symbol; + sym2 = (lookup_symbol_search_name + (sym->search_name (), + block, SEARCH_VAR_DOMAIN).symbol); else sym2 = sym; gdb_assert (sym2 != NULL); diff --git a/gdb/moxie-tdep.c b/gdb/moxie-tdep.c index 600fb060b1e..06ae8a46346 100644 --- a/gdb/moxie-tdep.c +++ b/gdb/moxie-tdep.c @@ -226,7 +226,8 @@ moxie_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc) plg_end = moxie_analyze_prologue (func_addr, func_end, &cache, gdbarch); /* Found a function. */ - sym = lookup_symbol (func_name, NULL, VAR_DOMAIN, NULL).symbol; + sym = lookup_symbol (func_name, nullptr, + SEARCH_FUNCTION_DOMAIN, nullptr).symbol; /* Don't use line number debug info for assembly source files. */ if (sym && sym->language () != language_asm) diff --git a/gdb/objc-lang.c b/gdb/objc-lang.c index 6af25d9c988..dfb4d2a497d 100644 --- a/gdb/objc-lang.c +++ b/gdb/objc-lang.c @@ -87,7 +87,7 @@ lookup_struct_typedef (const char *name, const struct block *block, int noerr) { struct symbol *sym; - sym = lookup_symbol (name, block, STRUCT_DOMAIN, 0).symbol; + sym = lookup_symbol (name, block, SEARCH_STRUCT_DOMAIN, 0).symbol; if (sym == NULL) { @@ -1129,7 +1129,7 @@ find_imps (const char *method, std::vector *symbol_names) add the selector itself as a symbol, if it exists. */ if (selector_case && !symbol_names->empty ()) { - struct symbol *sym = lookup_symbol (selector, NULL, VAR_DOMAIN, + struct symbol *sym = lookup_symbol (selector, NULL, SEARCH_VFT, 0).symbol; if (sym != NULL) diff --git a/gdb/objfiles.h b/gdb/objfiles.h index d5a7ab4b70e..65da9eff1a7 100644 --- a/gdb/objfiles.h +++ b/gdb/objfiles.h @@ -562,7 +562,7 @@ struct objfile contains !TYPE_OPAQUE symbol prefer its compunit. If it contains only TYPE_OPAQUE symbol(s), return at least that compunit. */ struct compunit_symtab *lookup_symbol (block_enum kind, const char *name, - domain_enum domain); + domain_search_flags domain); /* See quick_symbol_functions. */ void print_stats (bool print_bcache); diff --git a/gdb/p-exp.y b/gdb/p-exp.y index 2360a500476..2e97f70cac5 100644 --- a/gdb/p-exp.y +++ b/gdb/p-exp.y @@ -629,9 +629,10 @@ block : block COLONCOLON name std::string copy = copy_name ($3); struct symbol *tem = lookup_symbol (copy.c_str (), $1, - VAR_DOMAIN, NULL).symbol; + SEARCH_FUNCTION_DOMAIN, + nullptr).symbol; - if (!tem || tem->aclass () != LOC_BLOCK) + if (tem == nullptr) error (_("No function \"%s\" in specified context."), copy.c_str ()); $$ = tem->value_block (); } @@ -642,7 +643,7 @@ variable: block COLONCOLON name std::string copy = copy_name ($3); sym = lookup_symbol (copy.c_str (), $1, - VAR_DOMAIN, NULL); + SEARCH_VFT, NULL); if (sym.symbol == 0) error (_("No symbol \"%s\" in specified context."), copy.c_str ()); @@ -672,7 +673,7 @@ variable: qualified_name struct block_symbol sym = lookup_symbol (name.c_str (), nullptr, - VAR_DOMAIN, nullptr); + SEARCH_VFT, nullptr); pstate->push_symbol (name.c_str (), sym); } ; @@ -1400,7 +1401,7 @@ yylex (void) static const char this_name[] = "this"; if (lookup_symbol (this_name, pstate->expression_context_block, - VAR_DOMAIN, NULL).symbol) + SEARCH_VFT, NULL).symbol) { free (uptokstart); return THIS; @@ -1440,7 +1441,7 @@ yylex (void) sym = NULL; else sym = lookup_symbol (tmp.c_str (), pstate->expression_context_block, - VAR_DOMAIN, &is_a_field_of_this).symbol; + SEARCH_VFT, &is_a_field_of_this).symbol; /* second chance uppercased (as Free Pascal does). */ if (!sym && is_a_field_of_this.type == NULL && !is_a_field) { @@ -1456,7 +1457,7 @@ yylex (void) sym = NULL; else sym = lookup_symbol (tmp.c_str (), pstate->expression_context_block, - VAR_DOMAIN, &is_a_field_of_this).symbol; + SEARCH_VFT, &is_a_field_of_this).symbol; } /* Third chance Capitalized (as GPC does). */ if (!sym && is_a_field_of_this.type == NULL && !is_a_field) @@ -1479,7 +1480,7 @@ yylex (void) sym = NULL; else sym = lookup_symbol (tmp.c_str (), pstate->expression_context_block, - VAR_DOMAIN, &is_a_field_of_this).symbol; + SEARCH_VFT, &is_a_field_of_this).symbol; } if (is_a_field || (is_a_field_of_this.type != NULL)) @@ -1576,7 +1577,7 @@ yylex (void) cur_sym = lookup_symbol (ncopy, pstate->expression_context_block, - VAR_DOMAIN, NULL).symbol; + SEARCH_VFT, NULL).symbol; if (cur_sym) { if (cur_sym->aclass () == LOC_TYPEDEF) diff --git a/gdb/p-valprint.c b/gdb/p-valprint.c index fb9386293a6..bfcd7ac2aa6 100644 --- a/gdb/p-valprint.c +++ b/gdb/p-valprint.c @@ -253,7 +253,7 @@ pascal_language::value_print_inner (struct value *val, { const char *search_name = msymbol.minsym->search_name (); wsym = lookup_symbol_search_name (search_name, NULL, - VAR_DOMAIN).symbol; + SEARCH_VFT).symbol; } if (wsym) diff --git a/gdb/parse.c b/gdb/parse.c index c69b53addff..b18b24ea0d2 100644 --- a/gdb/parse.c +++ b/gdb/parse.c @@ -225,7 +225,8 @@ parser_state::push_dollar (struct stoken str) /* On some systems, such as HP-UX and hppa-linux, certain system routines have names beginning with $ or $$. Check for those, first. */ - sym = lookup_symbol (copy.c_str (), NULL, VAR_DOMAIN, NULL); + sym = lookup_symbol (copy.c_str (), nullptr, + SEARCH_VAR_DOMAIN | SEARCH_FUNCTION_DOMAIN, nullptr); if (sym.symbol) { push_new (sym); diff --git a/gdb/printcmd.c b/gdb/printcmd.c index c5e6a815580..c871907d4b5 100644 --- a/gdb/printcmd.c +++ b/gdb/printcmd.c @@ -1582,7 +1582,7 @@ info_address_command (const char *exp, int from_tty) if (exp == 0) error (_("Argument required.")); - sym = lookup_symbol (exp, get_selected_block (&context_pc), VAR_DOMAIN, + sym = lookup_symbol (exp, get_selected_block (&context_pc), SEARCH_VFT, &is_a_field_of_this).symbol; if (sym == NULL) { diff --git a/gdb/psymtab.c b/gdb/psymtab.c index 49912c4bd41..10df176ba60 100644 --- a/gdb/psymtab.c +++ b/gdb/psymtab.c @@ -1611,7 +1611,7 @@ maintenance_check_psymtabs (const char *ignore, int from_tty) sym = block_lookup_symbol (b, psym->ginfo.search_name (), symbol_name_match_type::SEARCH_NAME, - psym->domain); + to_search_flags (psym->domain)); if (!sym) { gdb_printf ("Static symbol `"); @@ -1626,7 +1626,7 @@ maintenance_check_psymtabs (const char *ignore, int from_tty) { sym = block_lookup_symbol (b, psym->ginfo.search_name (), symbol_name_match_type::SEARCH_NAME, - psym->domain); + to_search_flags (psym->domain)); if (!sym) { gdb_printf ("Global symbol `"); diff --git a/gdb/python/py-frame.c b/gdb/python/py-frame.c index 0a7e10f09ff..ba95d2b218a 100644 --- a/gdb/python/py-frame.c +++ b/gdb/python/py-frame.c @@ -514,7 +514,8 @@ frapy_read_var (PyObject *self, PyObject *args, PyObject *kw) if (!block) block = get_frame_block (frame, NULL); - lookup_sym = lookup_symbol (var_name.get (), block, VAR_DOMAIN, NULL); + lookup_sym = lookup_symbol (var_name.get (), block, + SEARCH_VFT, nullptr); var = lookup_sym.symbol; block = lookup_sym.block; } diff --git a/gdb/python/py-objfile.c b/gdb/python/py-objfile.c index bb5d0d92aba..11ef941a9f4 100644 --- a/gdb/python/py-objfile.c +++ b/gdb/python/py-objfile.c @@ -479,8 +479,9 @@ objfpy_lookup_global_symbol (PyObject *self, PyObject *args, PyObject *kw) try { + domain_search_flags flags = from_scripting_domain (domain); struct symbol *sym = lookup_global_symbol_from_objfile - (obj->objfile, GLOBAL_BLOCK, symbol_name, (domain_enum) domain).symbol; + (obj->objfile, GLOBAL_BLOCK, symbol_name, flags).symbol; if (sym == nullptr) Py_RETURN_NONE; @@ -513,8 +514,9 @@ objfpy_lookup_static_symbol (PyObject *self, PyObject *args, PyObject *kw) try { + domain_search_flags flags = from_scripting_domain (domain); struct symbol *sym = lookup_global_symbol_from_objfile - (obj->objfile, STATIC_BLOCK, symbol_name, (domain_enum) domain).symbol; + (obj->objfile, STATIC_BLOCK, symbol_name, flags).symbol; if (sym == nullptr) Py_RETURN_NONE; diff --git a/gdb/python/py-symbol.c b/gdb/python/py-symbol.c index 863e8caf4ce..3c4a112f54b 100644 --- a/gdb/python/py-symbol.c +++ b/gdb/python/py-symbol.c @@ -432,8 +432,8 @@ gdbpy_lookup_symbol (PyObject *self, PyObject *args, PyObject *kw) try { - symbol = lookup_symbol (name, block, (domain_enum) domain, - &is_a_field_of_this).symbol; + domain_search_flags flags = from_scripting_domain (domain); + symbol = lookup_symbol (name, block, flags, &is_a_field_of_this).symbol; } catch (const gdb_exception &except) { @@ -481,7 +481,8 @@ gdbpy_lookup_global_symbol (PyObject *self, PyObject *args, PyObject *kw) try { - symbol = lookup_global_symbol (name, NULL, (domain_enum) domain).symbol; + domain_search_flags flags = from_scripting_domain (domain); + symbol = lookup_global_symbol (name, NULL, flags).symbol; } catch (const gdb_exception &except) { @@ -542,13 +543,14 @@ gdbpy_lookup_static_symbol (PyObject *self, PyObject *args, PyObject *kw) try { + domain_search_flags flags = from_scripting_domain (domain); + if (block != nullptr) symbol - = lookup_symbol_in_static_block (name, block, - (domain_enum) domain).symbol; + = lookup_symbol_in_static_block (name, block, flags).symbol; if (symbol == nullptr) - symbol = lookup_static_symbol (name, (domain_enum) domain).symbol; + symbol = lookup_static_symbol (name, flags).symbol; } catch (const gdb_exception &except) { @@ -592,6 +594,8 @@ gdbpy_lookup_static_symbols (PyObject *self, PyObject *args, PyObject *kw) try { + domain_search_flags flags = from_scripting_domain (domain); + /* Expand any symtabs that contain potentially matching symbols. */ lookup_name_info lookup_name (name, symbol_name_match_type::FULL); expand_symtabs_matching (NULL, lookup_name, NULL, NULL, @@ -613,7 +617,7 @@ gdbpy_lookup_static_symbols (PyObject *self, PyObject *args, PyObject *kw) if (block != nullptr) { symbol *symbol = lookup_symbol_in_static_block - (name, block, (domain_enum) domain).symbol; + (name, block, flags).symbol; if (symbol != nullptr) { @@ -675,7 +679,9 @@ gdbpy_initialize_symbols (void) #define DOMAIN(X) \ if (PyModule_AddIntConstant (gdb_module, "SYMBOL_" #X "_DOMAIN", \ - X ## _DOMAIN) < 0) \ + to_scripting_domain (X ## _DOMAIN)) < 0 \ + || PyModule_AddIntConstant (gdb_module, "SEARCH_" #X "_DOMAIN", \ + to_scripting_domain (SEARCH_ ## X ## _DOMAIN)) < 0) \ return -1; #include "sym-domains.def" #undef DOMAIN diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c index aa106b44bd9..bbba5acd535 100644 --- a/gdb/rust-lang.c +++ b/gdb/rust-lang.c @@ -1563,7 +1563,8 @@ rust_structop::evaluate_funcall (struct type *expect_type, const struct block *block = get_selected_block (0); struct block_symbol sym = lookup_symbol (name.c_str (), block, - VAR_DOMAIN, NULL); + SEARCH_VFT, + nullptr); if (sym.symbol == NULL) error (_("Could not find function named '%s'"), name.c_str ()); @@ -1699,7 +1700,7 @@ rust_language::is_string_type_p (struct type *type) const struct block_symbol rust_language::lookup_symbol_nonlocal (const char *name, const struct block *block, - const domain_enum domain) const + const domain_search_flags domain) const { struct block_symbol result = {}; @@ -1707,7 +1708,7 @@ rust_language::lookup_symbol_nonlocal symbol_lookup_debug_printf ("rust_lookup_symbol_non_local (%s, %s (scope %s), %s)", name, host_address_to_string (block), scope, - domain_name (domain)); + domain_name (domain).c_str ()); /* Look up bare names in the block's scope. */ std::string scopedname; diff --git a/gdb/rust-lang.h b/gdb/rust-lang.h index ce1dff211b6..3fe673f1668 100644 --- a/gdb/rust-lang.h +++ b/gdb/rust-lang.h @@ -151,7 +151,7 @@ class rust_language : public language_defn struct block_symbol lookup_symbol_nonlocal (const char *name, const struct block *block, - const domain_enum domain) const override; + const domain_search_flags domain) const override; /* See language.h. */ diff --git a/gdb/rust-parse.c b/gdb/rust-parse.c index d2f6008026f..67bd0a73419 100644 --- a/gdb/rust-parse.c +++ b/gdb/rust-parse.c @@ -308,7 +308,7 @@ struct rust_parser void update_innermost_block (struct block_symbol sym); struct block_symbol lookup_symbol (const char *name, const struct block *block, - const domain_enum domain); + const domain_search_flags domain); struct type *rust_lookup_type (const char *name); /* Clear some state. This is only used for testing. */ @@ -431,7 +431,7 @@ munge_name_and_block (const char **name, const struct block **block) struct block_symbol rust_parser::lookup_symbol (const char *name, const struct block *block, - const domain_enum domain) + const domain_search_flags domain) { struct block_symbol result; @@ -454,7 +454,7 @@ rust_parser::rust_lookup_type (const char *name) const struct block *block = pstate->expression_context_block; munge_name_and_block (&name, &block); - result = ::lookup_symbol (name, block, STRUCT_DOMAIN, NULL); + result = ::lookup_symbol (name, block, SEARCH_STRUCT_DOMAIN, NULL); if (result.symbol != NULL) { update_innermost_block (result); @@ -1221,7 +1221,7 @@ rust_parser::name_to_operation (const std::string &name) { struct block_symbol sym = lookup_symbol (name.c_str (), pstate->expression_context_block, - VAR_DOMAIN); + SEARCH_VFT); if (sym.symbol != nullptr && sym.symbol->aclass () != LOC_TYPEDEF) return make_operation (sym); diff --git a/gdb/source.c b/gdb/source.c index f648adc4520..07eda33fedb 100644 --- a/gdb/source.c +++ b/gdb/source.c @@ -316,8 +316,9 @@ select_source_symtab () /* Make the default place to list be the function `main' if one exists. */ - block_symbol bsym = lookup_symbol (main_name (), 0, VAR_DOMAIN, 0); - if (bsym.symbol != nullptr && bsym.symbol->aclass () == LOC_BLOCK) + block_symbol bsym = lookup_symbol (main_name (), nullptr, + SEARCH_FUNCTION_DOMAIN, nullptr); + if (bsym.symbol != nullptr) { symtab_and_line sal = find_function_start_sal (bsym.symbol, true); if (sal.symtab == NULL) diff --git a/gdb/stack.c b/gdb/stack.c index ef565445c16..7b874265071 100644 --- a/gdb/stack.c +++ b/gdb/stack.c @@ -818,7 +818,7 @@ print_frame_args (const frame_print_options &fp_opts, struct symbol *nsym; nsym = lookup_symbol_search_name (sym->search_name (), - b, VAR_DOMAIN).symbol; + b, SEARCH_VAR_DOMAIN).symbol; gdb_assert (nsym != NULL); if (nsym->aclass () == LOC_REGISTER && !nsym->is_argument ()) @@ -2475,7 +2475,7 @@ iterate_over_block_arg_vars (const struct block *b, struct symbol *sym2 = lookup_symbol_search_name (sym->search_name (), - b, VAR_DOMAIN).symbol; + b, SEARCH_VAR_DOMAIN).symbol; cb (sym->print_name (), sym2); } } diff --git a/gdb/symfile-debug.c b/gdb/symfile-debug.c index a4da8ec28d7..e7cf25effa9 100644 --- a/gdb/symfile-debug.c +++ b/gdb/symfile-debug.c @@ -244,7 +244,8 @@ objfile::map_symtabs_matching_filename } struct compunit_symtab * -objfile::lookup_symbol (block_enum kind, const char *name, domain_enum domain) +objfile::lookup_symbol (block_enum kind, const char *name, + domain_search_flags domain) { struct compunit_symtab *retval = nullptr; @@ -252,7 +253,7 @@ objfile::lookup_symbol (block_enum kind, const char *name, domain_enum domain) gdb_printf (gdb_stdlog, "qf->lookup_symbol (%s, %d, \"%s\", %s)\n", objfile_debug_name (this), kind, name, - domain_name (domain)); + domain_name (domain).c_str ()); lookup_name_info lookup_name (name, symbol_name_match_type::FULL); @@ -281,10 +282,6 @@ objfile::lookup_symbol (block_enum kind, const char *name, domain_enum domain) return true; }; - domain_search_flags flags = to_search_flags (domain); - if (domain == VAR_DOMAIN) - flags |= SEARCH_TYPE_DOMAIN | SEARCH_FUNCTION_DOMAIN; - for (const auto &iter : qf_require_partial_symbols ()) { if (!iter->expand_symtabs_matching (this, @@ -295,7 +292,7 @@ objfile::lookup_symbol (block_enum kind, const char *name, domain_enum domain) kind == GLOBAL_BLOCK ? SEARCH_GLOBAL_BLOCK : SEARCH_STATIC_BLOCK, - flags)) + domain)) break; } diff --git a/gdb/symfile.c b/gdb/symfile.c index 7147f292535..0a90080a64f 100644 --- a/gdb/symfile.c +++ b/gdb/symfile.c @@ -1699,8 +1699,8 @@ set_initial_language (void) { const char *name = main_name (); struct symbol *sym - = lookup_symbol_in_language (name, NULL, VAR_DOMAIN, default_lang, - NULL).symbol; + = lookup_symbol_in_language (name, nullptr, SEARCH_FUNCTION_DOMAIN, + default_lang, nullptr).symbol; if (sym != NULL) lang = sym->language (); diff --git a/gdb/symtab.c b/gdb/symtab.c index 50a0f692521..4a5d6ef5792 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -84,7 +84,7 @@ static struct block_symbol lookup_symbol_aux (const char *name, symbol_name_match_type match_type, const struct block *block, - const domain_enum domain, + const domain_search_flags domain, enum language language, struct field_of_this_result *); @@ -92,13 +92,14 @@ static struct block_symbol lookup_local_symbol (const char *name, symbol_name_match_type match_type, const struct block *block, - const domain_enum domain, + const domain_search_flags domain, enum language language); static struct block_symbol lookup_symbol_in_objfile (struct objfile *objfile, enum block_enum block_index, - const char *name, const domain_enum domain); + const char *name, + const domain_search_flags domain); static void set_main_name (program_space *pspace, const char *name, language lang); @@ -170,14 +171,14 @@ struct symbol_cache_slot lookup was saved in the cache, but cache space is pretty cheap. */ const struct objfile *objfile_context; + /* The domain that was searched for initially. This must exactly + match. */ + domain_search_flags domain; + union { struct block_symbol found; - struct - { - char *name; - domain_enum domain; - } not_found; + char *name; } value; }; @@ -187,7 +188,7 @@ static void symbol_cache_clear_slot (struct symbol_cache_slot *slot) { if (slot->state == SYMBOL_SLOT_NOT_FOUND) - xfree (slot->value.not_found.name); + xfree (slot->value.name); slot->state = SYMBOL_SLOT_UNUSED; } @@ -1242,19 +1243,14 @@ matching_obj_sections (struct obj_section *obj_first, static unsigned int hash_symbol_entry (const struct objfile *objfile_context, - const char *name, domain_enum domain) + const char *name, domain_search_flags domain) { unsigned int hash = (uintptr_t) objfile_context; if (name != NULL) hash += htab_hash_string (name); - /* Because of symbol_matches_domain we need VAR_DOMAIN and STRUCT_DOMAIN - to map to the same slot. */ - if (domain == STRUCT_DOMAIN) - hash += VAR_DOMAIN * 7; - else - hash += domain * 7; + hash += domain * 7; return hash; } @@ -1264,10 +1260,9 @@ hash_symbol_entry (const struct objfile *objfile_context, static int eq_symbol_entry (const struct symbol_cache_slot *slot, const struct objfile *objfile_context, - const char *name, domain_enum domain) + const char *name, domain_search_flags domain) { const char *slot_name; - domain_enum slot_domain; if (slot->state == SYMBOL_SLOT_UNUSED) return 0; @@ -1275,16 +1270,11 @@ eq_symbol_entry (const struct symbol_cache_slot *slot, if (slot->objfile_context != objfile_context) return 0; + domain_search_flags slot_domain = slot->domain; if (slot->state == SYMBOL_SLOT_NOT_FOUND) - { - slot_name = slot->value.not_found.name; - slot_domain = slot->value.not_found.domain; - } + slot_name = slot->value.name; else - { - slot_name = slot->value.found.symbol->search_name (); - slot_domain = slot->value.found.symbol->domain (); - } + slot_name = slot->value.found.symbol->search_name (); /* NULL names match. */ if (slot_name == NULL && name == NULL) @@ -1300,18 +1290,18 @@ eq_symbol_entry (const struct symbol_cache_slot *slot, the first time through. If the slot records a found symbol, then this means using the symbol name comparison function of the symbol's language with symbol->search_name (). See - dictionary.c. It also means using symbol_matches_domain for - found symbols. See block.c. + dictionary.c. If the slot records a not-found symbol, then require a precise match. We could still be lax with whitespace like strcmp_iw though. */ + if (slot_domain != domain) + return 0; + if (slot->state == SYMBOL_SLOT_NOT_FOUND) { if (strcmp (slot_name, name) != 0) return 0; - if (slot_domain != domain) - return 0; } else { @@ -1320,9 +1310,6 @@ eq_symbol_entry (const struct symbol_cache_slot *slot, if (!symbol_matches_search_name (sym, lookup_name)) return 0; - - if (!symbol_matches_domain (sym->language (), slot_domain, domain)) - return 0; } } else @@ -1442,7 +1429,7 @@ set_symbol_cache_size_handler (const char *args, int from_tty, static struct block_symbol symbol_cache_lookup (struct symbol_cache *cache, struct objfile *objfile_context, enum block_enum block, - const char *name, domain_enum domain, + const char *name, domain_search_flags domain, struct block_symbol_cache **bsc_ptr, struct symbol_cache_slot **slot_ptr) { @@ -1473,7 +1460,7 @@ symbol_cache_lookup (struct symbol_cache *cache, block == GLOBAL_BLOCK ? "Global" : "Static", slot->state == SYMBOL_SLOT_NOT_FOUND ? " (not found)" : "", name, - domain_name (domain)); + domain_name (domain).c_str ()); ++bsc->hits; if (slot->state == SYMBOL_SLOT_NOT_FOUND) return SYMBOL_LOOKUP_FAILED; @@ -1484,7 +1471,7 @@ symbol_cache_lookup (struct symbol_cache *cache, symbol_lookup_debug_printf ("%s block symbol cache miss for %s, %s", block == GLOBAL_BLOCK ? "Global" : "Static", - name, domain_name (domain)); + name, domain_name (domain).c_str ()); ++bsc->misses; return {}; } @@ -1499,7 +1486,8 @@ symbol_cache_mark_found (struct block_symbol_cache *bsc, struct symbol_cache_slot *slot, struct objfile *objfile_context, struct symbol *symbol, - const struct block *block) + const struct block *block, + domain_search_flags domain) { if (bsc == NULL) return; @@ -1512,6 +1500,7 @@ symbol_cache_mark_found (struct block_symbol_cache *bsc, slot->objfile_context = objfile_context; slot->value.found.symbol = symbol; slot->value.found.block = block; + slot->domain = domain; } /* Mark symbol NAME, DOMAIN as not found in SLOT. @@ -1522,7 +1511,7 @@ static void symbol_cache_mark_not_found (struct block_symbol_cache *bsc, struct symbol_cache_slot *slot, struct objfile *objfile_context, - const char *name, domain_enum domain) + const char *name, domain_search_flags domain) { if (bsc == NULL) return; @@ -1533,8 +1522,8 @@ symbol_cache_mark_not_found (struct block_symbol_cache *bsc, } slot->state = SYMBOL_SLOT_NOT_FOUND; slot->objfile_context = objfile_context; - slot->value.not_found.name = xstrdup (name); - slot->value.not_found.domain = domain; + slot->value.name = xstrdup (name); + slot->domain = domain; } /* Flush the symbol cache of PSPACE. */ @@ -1619,8 +1608,8 @@ symbol_cache_dump (const struct symbol_cache *cache) case SYMBOL_SLOT_NOT_FOUND: gdb_printf (" [%4u] = %s, %s %s (not found)\n", i, host_address_to_string (slot->objfile_context), - slot->value.not_found.name, - domain_name (slot->value.not_found.domain)); + slot->value.name, + domain_name (slot->domain).c_str ()); break; case SYMBOL_SLOT_FOUND: { @@ -1983,7 +1972,8 @@ search_name_hash (enum language language, const char *search_name) struct block_symbol lookup_symbol_in_language (const char *name, const struct block *block, - const domain_enum domain, enum language lang, + const domain_search_flags domain, + enum language lang, struct field_of_this_result *is_a_field_of_this) { SYMBOL_LOOKUP_SCOPED_DEBUG_ENTER_EXIT; @@ -2001,7 +1991,7 @@ lookup_symbol_in_language (const char *name, const struct block *block, struct block_symbol lookup_symbol (const char *name, const struct block *block, - domain_enum domain, + domain_search_flags domain, struct field_of_this_result *is_a_field_of_this) { return lookup_symbol_in_language (name, block, domain, @@ -2013,7 +2003,7 @@ lookup_symbol (const char *name, const struct block *block, struct block_symbol lookup_symbol_search_name (const char *search_name, const struct block *block, - domain_enum domain) + domain_search_flags domain) { return lookup_symbol_aux (search_name, symbol_name_match_type::SEARCH_NAME, block, domain, language_asm, NULL); @@ -2038,7 +2028,7 @@ lookup_language_this (const struct language_defn *lang, sym = block_lookup_symbol (block, lang->name_of_this (), symbol_name_match_type::SEARCH_NAME, - VAR_DOMAIN); + SEARCH_VFT); if (sym != NULL) { symbol_lookup_debug_printf_v @@ -2107,7 +2097,7 @@ check_field (struct type *type, const char *name, static struct block_symbol lookup_symbol_aux (const char *name, symbol_name_match_type match_type, const struct block *block, - const domain_enum domain, enum language language, + const domain_search_flags domain, enum language language, struct field_of_this_result *is_a_field_of_this) { SYMBOL_LOOKUP_SCOPED_DEBUG_ENTER_EXIT; @@ -2126,7 +2116,7 @@ lookup_symbol_aux (const char *name, symbol_name_match_type match_type, objfile != NULL ? objfile_debug_name (objfile) : "NULL"); symbol_lookup_debug_printf ("domain name = \"%s\", language = \"%s\")", - domain_name (domain), language_str (language)); + domain_name (domain).c_str (), language_str (language)); } /* Make sure we do something sensible with is_a_field_of_this, since @@ -2156,7 +2146,7 @@ lookup_symbol_aux (const char *name, symbol_name_match_type match_type, /* Don't do this check if we are searching for a struct. It will not be found by check_field, but will be found by other means. */ - if (is_a_field_of_this != NULL && domain != STRUCT_DOMAIN) + if (is_a_field_of_this != NULL && (domain & SEARCH_STRUCT_DOMAIN) == 0) { result = lookup_language_this (langdef, block); @@ -2212,7 +2202,7 @@ static struct block_symbol lookup_local_symbol (const char *name, symbol_name_match_type match_type, const struct block *block, - const domain_enum domain, + const domain_search_flags domain, enum language language) { if (block == nullptr) @@ -2257,7 +2247,7 @@ lookup_local_symbol (const char *name, struct symbol * lookup_symbol_in_block (const char *name, symbol_name_match_type match_type, const struct block *block, - const domain_enum domain) + const domain_search_flags domain) { struct symbol *sym; @@ -2270,7 +2260,7 @@ lookup_symbol_in_block (const char *name, symbol_name_match_type match_type, ("lookup_symbol_in_block (%s, %s (objfile %s), %s)", name, host_address_to_string (block), objfile != nullptr ? objfile_debug_name (objfile) : "NULL", - domain_name (domain)); + domain_name (domain).c_str ()); } sym = block_lookup_symbol (block, name, match_type, domain); @@ -2291,7 +2281,7 @@ struct block_symbol lookup_global_symbol_from_objfile (struct objfile *main_objfile, enum block_enum block_index, const char *name, - const domain_enum domain) + const domain_search_flags domain) { gdb_assert (block_index == GLOBAL_BLOCK || block_index == STATIC_BLOCK); @@ -2315,7 +2305,7 @@ lookup_global_symbol_from_objfile (struct objfile *main_objfile, static struct block_symbol lookup_symbol_in_objfile_symtabs (struct objfile *objfile, enum block_enum block_index, const char *name, - const domain_enum domain) + const domain_search_flags domain) { gdb_assert (block_index == GLOBAL_BLOCK || block_index == STATIC_BLOCK); @@ -2323,7 +2313,7 @@ lookup_symbol_in_objfile_symtabs (struct objfile *objfile, ("lookup_symbol_in_objfile_symtabs (%s, %s, %s, %s)", objfile_debug_name (objfile), block_index == GLOBAL_BLOCK ? "GLOBAL_BLOCK" : "STATIC_BLOCK", - name, domain_name (domain)); + name, domain_name (domain).c_str ()); struct block_symbol other; other.symbol = NULL; @@ -2382,7 +2372,7 @@ lookup_symbol_in_objfile_symtabs (struct objfile *objfile, static struct block_symbol lookup_symbol_in_objfile_from_linkage_name (struct objfile *objfile, const char *linkage_name, - domain_enum domain) + domain_search_flags domain) { enum language lang = current_language->la_language; struct objfile *main_objfile; @@ -2434,7 +2424,7 @@ Internal: %s symbol `%s' found in %s psymtab but not in symtab.\n\ static struct block_symbol lookup_symbol_via_quick_fns (struct objfile *objfile, enum block_enum block_index, const char *name, - const domain_enum domain) + const domain_search_flags domain) { struct compunit_symtab *cust; const struct blockvector *bv; @@ -2445,7 +2435,7 @@ lookup_symbol_via_quick_fns (struct objfile *objfile, ("lookup_symbol_via_quick_fns (%s, %s, %s, %s)", objfile_debug_name (objfile), block_index == GLOBAL_BLOCK ? "GLOBAL_BLOCK" : "STATIC_BLOCK", - name, domain_name (domain)); + name, domain_name (domain).c_str ()); cust = objfile->lookup_symbol (block_index, name, domain); if (cust == NULL) @@ -2476,7 +2466,7 @@ lookup_symbol_via_quick_fns (struct objfile *objfile, struct block_symbol language_defn::lookup_symbol_nonlocal (const char *name, const struct block *block, - const domain_enum domain) const + const domain_search_flags domain) const { struct block_symbol result; @@ -2494,7 +2484,7 @@ language_defn::lookup_symbol_nonlocal (const char *name, shared libraries we could search all of them only to find out the builtin type isn't defined in any of them. This is common for types like "void". */ - if (domain == VAR_DOMAIN) + if ((domain & SEARCH_TYPE_DOMAIN) != 0) { struct gdbarch *gdbarch; @@ -2517,7 +2507,7 @@ language_defn::lookup_symbol_nonlocal (const char *name, struct block_symbol lookup_symbol_in_static_block (const char *name, const struct block *block, - const domain_enum domain) + const domain_search_flags domain) { if (block == nullptr) return {}; @@ -2537,7 +2527,7 @@ lookup_symbol_in_static_block (const char *name, ("lookup_symbol_in_static_block (%s, %s (objfile %s), %s)", name, host_address_to_string (block), objfile != nullptr ? objfile_debug_name (objfile) : "NULL", - domain_name (domain)); + domain_name (domain).c_str ()); } sym = lookup_symbol_in_block (name, @@ -2556,7 +2546,7 @@ lookup_symbol_in_static_block (const char *name, static struct block_symbol lookup_symbol_in_objfile (struct objfile *objfile, enum block_enum block_index, - const char *name, const domain_enum domain) + const char *name, const domain_search_flags domain) { struct block_symbol result; @@ -2566,7 +2556,7 @@ lookup_symbol_in_objfile (struct objfile *objfile, enum block_enum block_index, objfile_debug_name (objfile), block_index == GLOBAL_BLOCK ? "GLOBAL_BLOCK" : "STATIC_BLOCK", - name, domain_name (domain)); + name, domain_name (domain).c_str ()); result = lookup_symbol_in_objfile_symtabs (objfile, block_index, name, domain); @@ -2597,7 +2587,7 @@ static struct block_symbol lookup_global_or_static_symbol (const char *name, enum block_enum block_index, struct objfile *objfile, - const domain_enum domain) + const domain_search_flags domain) { struct symbol_cache *cache = get_symbol_cache (current_program_space); struct block_symbol result; @@ -2631,7 +2621,8 @@ lookup_global_or_static_symbol (const char *name, objfile); if (result.symbol != NULL) - symbol_cache_mark_found (bsc, slot, objfile, result.symbol, result.block); + symbol_cache_mark_found (bsc, slot, objfile, result.symbol, result.block, + domain); else symbol_cache_mark_not_found (bsc, slot, objfile, name, domain); @@ -2641,7 +2632,7 @@ lookup_global_or_static_symbol (const char *name, /* See symtab.h. */ struct block_symbol -lookup_static_symbol (const char *name, const domain_enum domain) +lookup_static_symbol (const char *name, const domain_search_flags domain) { return lookup_global_or_static_symbol (name, STATIC_BLOCK, nullptr, domain); } @@ -2651,7 +2642,7 @@ lookup_static_symbol (const char *name, const domain_enum domain) struct block_symbol lookup_global_symbol (const char *name, const struct block *block, - const domain_enum domain) + const domain_search_flags domain) { /* If a block was passed in, we want to search the corresponding global block first. This yields "more expected" behavior, and is @@ -2760,7 +2751,7 @@ basic_lookup_transparent_type_quick (struct objfile *objfile, const struct block *block; struct symbol *sym; - cust = objfile->lookup_symbol (block_index, name, STRUCT_DOMAIN); + cust = objfile->lookup_symbol (block_index, name, SEARCH_STRUCT_DOMAIN); if (cust == NULL) return NULL; @@ -2768,7 +2759,7 @@ basic_lookup_transparent_type_quick (struct objfile *objfile, block = bv->block (block_index); lookup_name_info lookup_name (name, symbol_name_match_type::FULL); - sym = block_find_symbol (block, lookup_name, STRUCT_DOMAIN, nullptr); + sym = block_find_symbol (block, lookup_name, SEARCH_STRUCT_DOMAIN, nullptr); if (sym == nullptr) error_in_psymtab_expansion (block_index, name, cust); gdb_assert (!TYPE_IS_OPAQUE (sym->type ())); @@ -2793,7 +2784,8 @@ basic_lookup_transparent_type_1 (struct objfile *objfile, { bv = cust->blockvector (); block = bv->block (block_index); - sym = block_find_symbol (block, lookup_name, STRUCT_DOMAIN, nullptr); + sym = block_find_symbol (block, lookup_name, SEARCH_STRUCT_DOMAIN, + nullptr); if (sym != nullptr) { gdb_assert (!TYPE_IS_OPAQUE (sym->type ())); @@ -4791,7 +4783,7 @@ global_symbol_searcher::expand_symtabs (msymbol->value_address (objfile)) == NULL) : (lookup_symbol_in_objfile_from_linkage_name (objfile, msymbol->linkage_name (), - VAR_DOMAIN) + SEARCH_VFT) .symbol == NULL)) found_msymbol = true; } @@ -4929,7 +4921,7 @@ global_symbol_searcher::add_matching_msymbols { if (lookup_symbol_in_objfile_from_linkage_name (objfile, msymbol->linkage_name (), - VAR_DOMAIN).symbol == NULL) + SEARCH_VFT).symbol == NULL) { /* Matching msymbol, add it to the results list. */ if (results->size () < m_max_search_results) diff --git a/gdb/symtab.h b/gdb/symtab.h index 80ee9e02475..414fa29e863 100644 --- a/gdb/symtab.h +++ b/gdb/symtab.h @@ -2090,7 +2090,7 @@ struct field_of_this_result extern struct block_symbol lookup_symbol_in_language (const char *, const struct block *, - const domain_enum, + const domain_search_flags, enum language, struct field_of_this_result *); @@ -2098,7 +2098,7 @@ extern struct block_symbol extern struct block_symbol lookup_symbol (const char *, const struct block *, - const domain_enum, + const domain_search_flags, struct field_of_this_result *); /* Find the definition for a specified symbol search name in domain @@ -2110,9 +2110,10 @@ extern struct block_symbol lookup_symbol (const char *, pointer, or NULL if no symbol is found. The symbol's section is fixed up if necessary. */ -extern struct block_symbol lookup_symbol_search_name (const char *search_name, - const struct block *block, - domain_enum domain); +extern struct block_symbol lookup_symbol_search_name + (const char *search_name, + const struct block *block, + domain_search_flags domain); /* Some helper functions for languages that need to write their own lookup_symbol_nonlocal functions. */ @@ -2124,13 +2125,13 @@ extern struct block_symbol lookup_symbol_search_name (const char *search_name, extern struct block_symbol lookup_symbol_in_static_block (const char *name, const struct block *block, - const domain_enum domain); + const domain_search_flags domain); /* Search all static file-level symbols for NAME from DOMAIN. Upon success fixes up the symbol's section if necessary. */ -extern struct block_symbol lookup_static_symbol (const char *name, - const domain_enum domain); +extern struct block_symbol lookup_static_symbol + (const char *name, const domain_search_flags domain); /* Lookup a symbol in all files' global blocks. @@ -2146,7 +2147,7 @@ extern struct block_symbol lookup_static_symbol (const char *name, extern struct block_symbol lookup_global_symbol (const char *name, const struct block *block, - const domain_enum domain); + const domain_search_flags domain); /* Lookup a symbol in block BLOCK. Upon success fixes up the symbol's section if necessary. */ @@ -2155,7 +2156,7 @@ extern struct symbol * lookup_symbol_in_block (const char *name, symbol_name_match_type match_type, const struct block *block, - const domain_enum domain); + const domain_search_flags domain); /* Look up the `this' symbol for LANG in BLOCK. Return the symbol if found, or NULL if not found. */ @@ -2686,7 +2687,7 @@ extern struct block_symbol lookup_global_symbol_from_objfile (struct objfile *main_objfile, enum block_enum block_index, const char *name, - const domain_enum domain); + const domain_search_flags domain); /* Return 1 if the supplied producer string matches the ARM RealView compiler (armcc). */ diff --git a/gdb/valops.c b/gdb/valops.c index 70851cd40b4..5f467e8576c 100644 --- a/gdb/valops.c +++ b/gdb/valops.c @@ -118,15 +118,9 @@ find_function_in_inferior (const char *name, struct objfile **objf_p) { struct block_symbol sym; - sym = lookup_symbol (name, 0, VAR_DOMAIN, 0); + sym = lookup_symbol (name, nullptr, SEARCH_TYPE_DOMAIN, nullptr); if (sym.symbol != NULL) { - if (sym.symbol->aclass () != LOC_BLOCK) - { - error (_("\"%s\" exists in this program but is not a function."), - name); - } - if (objf_p) *objf_p = sym.symbol->objfile (); @@ -3713,7 +3707,7 @@ value_struct_elt_for_reference (struct type *domain, int offset, { struct symbol *s = lookup_symbol (TYPE_FN_FIELD_PHYSNAME (f, j), - 0, VAR_DOMAIN, 0).symbol; + 0, SEARCH_FUNCTION_DOMAIN, 0).symbol; if (s == NULL) return NULL; @@ -3744,7 +3738,7 @@ value_struct_elt_for_reference (struct type *domain, int offset, { struct symbol *s = lookup_symbol (TYPE_FN_FIELD_PHYSNAME (f, j), - 0, VAR_DOMAIN, 0).symbol; + 0, SEARCH_FUNCTION_DOMAIN, 0).symbol; if (s == NULL) return NULL; @@ -3824,7 +3818,7 @@ value_maybe_namespace_elt (const struct type *curtype, struct value *result; sym = cp_lookup_symbol_namespace (namespace_name, name, - get_selected_block (0), VAR_DOMAIN); + get_selected_block (0), SEARCH_VFT); if (sym.symbol == NULL) return NULL; diff --git a/gdb/value.c b/gdb/value.c index 17b7c53d052..cdfbb5087c5 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -2881,7 +2881,8 @@ value_static_field (struct type *type, int fieldno) { const char *phys_name = type->field (fieldno).loc_physname (); /* type->field (fieldno).name (); */ - struct block_symbol sym = lookup_symbol (phys_name, 0, VAR_DOMAIN, 0); + struct block_symbol sym = lookup_symbol (phys_name, nullptr, + SEARCH_VAR_DOMAIN, nullptr); if (sym.symbol == NULL) { @@ -3072,7 +3073,8 @@ value_fn_field (struct value **arg1p, struct fn_field *f, struct symbol *sym; struct bound_minimal_symbol msym; - sym = lookup_symbol (physname, 0, VAR_DOMAIN, 0).symbol; + sym = lookup_symbol (physname, nullptr, SEARCH_FUNCTION_DOMAIN, + nullptr).symbol; if (sym == nullptr) { msym = lookup_bound_minimal_symbol (physname); diff --git a/gdb/xstormy16-tdep.c b/gdb/xstormy16-tdep.c index 3f47c8d68a0..b47ef60384d 100644 --- a/gdb/xstormy16-tdep.c +++ b/gdb/xstormy16-tdep.c @@ -423,7 +423,8 @@ xstormy16_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc) return plg_end; /* Found a function. */ - sym = lookup_symbol (func_name, NULL, VAR_DOMAIN, NULL).symbol; + sym = lookup_symbol (func_name, NULL, SEARCH_FUNCTION_DOMAIN, + nullptr).symbol; /* Don't use line number debug info for assembly source files. */ if (sym && sym->language () != language_asm) { From patchwork Tue Nov 21 03:53:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 80401 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 5A2413857C45 for ; Tue, 21 Nov 2023 03:54:39 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from omta034.useast.a.cloudfilter.net (omta034.useast.a.cloudfilter.net [44.202.169.33]) by sourceware.org (Postfix) with ESMTPS id 1EC6D3858C62 for ; Tue, 21 Nov 2023 03:53:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1EC6D3858C62 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 1EC6D3858C62 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=44.202.169.33 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700538805; cv=none; b=AzyrlwUeYF3AHzP3G4h2MRSapnicLonRkOmxieORgZXIYVFJHNvxXU2YWahydY75IaFIueYnQWQV8NqOH7GZiCplceX4NoojUN/++VNISIQM9x7S7SY93o6E/8mex0Jxyw1hALB09s50QC49ASGNQ/TQFX37qg6ihByyjIWMJEI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700538805; c=relaxed/simple; bh=9KxGW4c9qNmzw/iocNcwbw7DO5dSTm80z26uDwgjC5U=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=GwqlyybP+G5ERP5/7amNagHEHemEqhhw50tN0Xl2pzw8OuSCHm6gAnJoTg9LWdmnnjUgNwc1rwkryOCL3j7N72ZL4Ajr/rhKC6Ys/EXjbhVSubE57zz92HQyNOkUhYuYeBruopY05TU7MoA16dx6cDWV8TIPe++bN3sW3PZDUis= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from eig-obgw-6001a.ext.cloudfilter.net ([10.0.30.140]) by cmsmtp with ESMTPS id 5BpqrOjv8jtZ35HpGrWynq; Tue, 21 Nov 2023 03:53:26 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id 5HpBrwHykb8Qn5HpBr3fkf; Tue, 21 Nov 2023 03:53:21 +0000 X-Authority-Analysis: v=2.4 cv=IuQNzZzg c=1 sm=1 tr=0 ts=655c29b1 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=lk1wNYbFhmqovUGGJqEA:9 a=QEXdDO2ut3YA:10 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=To:In-Reply-To:References:Message-Id:Content-Transfer-Encoding: Content-Type:MIME-Version:Subject:Date:From:Sender:Reply-To:Cc:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=gZvzQWflxpTCXFB2gIHaNqtJmOO1A+cO0yER8kAfrBY=; b=jYQ9/PPGxRmQ0I2anE+wV2pQAl t6ofUyNs/gV7c/xmNEs8N8ph1AEg1S6/cd0Ah8JeK1ditLjV8fW75A9Lx/TumETzK8S3mogV/JVNm EfALiUaq12C2ldd0+o9WQHofs; 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 1r5HpA-0040be-30 for gdb-patches@sourceware.org; Mon, 20 Nov 2023 20:53:20 -0700 From: Tom Tromey Date: Mon, 20 Nov 2023 20:53:48 -0700 Subject: [PATCH 17/29] Remove some obsolete Python constants MIME-Version: 1.0 Message-Id: <20231120-submit-domain-hacks-2-v1-17-29650d01b198@tromey.com> References: <20231120-submit-domain-hacks-2-v1-0-29650d01b198@tromey.com> In-Reply-To: <20231120-submit-domain-hacks-2-v1-0-29650d01b198@tromey.com> 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: 1r5HpA-0040be-30 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: 18 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfFZOzjROLZuGtX33TAEXbNXAkbjH/7ZFIJhbgd7pR4H+7v5PWQj58SeL5lNUdvQPDVRMelkp0GlwxZ5PmNekgb/if9sw3tf/3dLxhqU1XYHDeTMZ8zBy lXPtVprkJgL0GgSadrQSrMfaHVr23+HPLU1NB1Vp4vZzYhbaiZDMHoG9jCHdQgXU795nN3RZ/HxMI3mwX4YLY3lrdxhMK7rkru0= X-Spam-Status: No, score=-3023.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_STOCKGEN, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham 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 The Python code has exported some constants, but they are no longer documented, and were never useful. This patch removes them. --- gdb/python/py-symbol.c | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/gdb/python/py-symbol.c b/gdb/python/py-symbol.c index 3c4a112f54b..bdfb4a3e594 100644 --- a/gdb/python/py-symbol.c +++ b/gdb/python/py-symbol.c @@ -686,20 +686,6 @@ gdbpy_initialize_symbols (void) #include "sym-domains.def" #undef DOMAIN - /* These remain defined for compatibility, but as they were never - correct, they are no longer documented. Eventually we can remove - them. These exist because at one time, enum search_domain and - enum domain_enum_tag were combined -- but different values were - used differently. Here we try to give them values that will make - sense if they are passed to gdb.lookup_symbol. */ - if (PyModule_AddIntConstant (gdb_module, "SYMBOL_VARIABLES_DOMAIN", - VAR_DOMAIN) < 0 - || PyModule_AddIntConstant (gdb_module, "SYMBOL_FUNCTIONS_DOMAIN", - VAR_DOMAIN) < 0 - || PyModule_AddIntConstant (gdb_module, "SYMBOL_TYPES_DOMAIN", - VAR_DOMAIN) < 0) - return -1; - return gdb_pymodule_addobject (gdb_module, "Symbol", (PyObject *) &symbol_object_type); } From patchwork Tue Nov 21 03:53:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 80404 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 B478D3858422 for ; Tue, 21 Nov 2023 03:54:55 +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 5AB693858C74 for ; Tue, 21 Nov 2023 03:53:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5AB693858C74 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 5AB693858C74 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=1700538806; cv=none; b=tkfjchYoNrfB1LgiGNcGa/Tbijbjz2d7+MOfeesH+S22onyE7qTbcFOls3gTwuK9iUuHKpIKGGYkXFqeF23TqSXdY9RLCTGwlJIjAN8BG69vtkU4wAf6jR6LikrSOG8m8gtkQ+VAiphNUlS8aYZoptzwJOWujqVuE2iTrwwxpxY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700538806; c=relaxed/simple; bh=WSpPfW9rUK270yQ0S/XlbtUxxuV7QRXa22eULKmith4=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=FTzhj8Ho8oWUtajJqhBChhyM5IuyqrnSC8CDhhmCTv8CXdxHp/RLTXxXVONYbGgX/I/JwBrMD1cuZbZIOY4M3XJI1d+iGvgVan9fxRA8vvw6+6iMb7fmXASvmw6ED5XhbeZbD0QI463xzsopgF9iMCKr3Gpwy7tmrM96CBnEvok= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from eig-obgw-5004a.ext.cloudfilter.net ([10.0.29.221]) by cmsmtp with ESMTPS id 5DYgrnj93WcCI5HpCrZVLn; Tue, 21 Nov 2023 03:53:22 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id 5HpBr8Ecb11XZ5HpBryOPg; Tue, 21 Nov 2023 03:53:21 +0000 X-Authority-Analysis: v=2.4 cv=Z+v/oVdA c=1 sm=1 tr=0 ts=655c29b1 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=erOdZxmXbWm6VKJsYvcA:9 a=QEXdDO2ut3YA:10 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=To:In-Reply-To:References:Message-Id:Content-Transfer-Encoding: Content-Type:MIME-Version:Subject:Date:From:Sender:Reply-To:Cc:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=WmngL4BhwRnYGyLc7+VTnkr88cHxfacBjCWcXESj8go=; b=N7Lc4KVi2XRppAtKQCeLtN2sEr 5Y//nMa2L1sq2bNRudZLlZMwGAnaWhaAjFzjwbO5aZQpWZKr/cM/eqk2YchaD23aE8VYJxB7Gri4M EsgwtjtsK/+Y3Pul8Zjmt8UCw; 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 1r5HpB-0040be-0D for gdb-patches@sourceware.org; Mon, 20 Nov 2023 20:53:21 -0700 From: Tom Tromey Date: Mon, 20 Nov 2023 20:53:49 -0700 Subject: [PATCH 18/29] Remove old symbol_matches_domain MIME-Version: 1.0 Message-Id: <20231120-submit-domain-hacks-2-v1-18-29650d01b198@tromey.com> References: <20231120-submit-domain-hacks-2-v1-0-29650d01b198@tromey.com> In-Reply-To: <20231120-submit-domain-hacks-2-v1-0-29650d01b198@tromey.com> 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: 1r5HpB-0040be-0D 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: 19 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfITq5dUtkO3fnQezfy5M21eRvbhoPMCwSmf8IXjSkUdzdKEVL0aBBc8YFaDSKQdwtEptth04SI1EpfiGUVXvXD6+cblkEEphhJo6lJUh+QiUwY8e3beu 0psoM2kQMo26F+RHKWfR1MSaNoiSx+t73IIBLNBbHFvRrcKN5ooO0OCxELyHfbwsXwJNqjN84dynps3G7hn8F9Z8Q0N1HH5mu60= X-Spam-Status: No, score=-3024.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham 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 Nothing calls the variant of symbol_matches_domain that accepts a domain_enum for searching, so this patch removes it and the corresponding symbol::matches. --- gdb/symtab.c | 20 -------------------- gdb/symtab.h | 11 ----------- 2 files changed, 31 deletions(-) diff --git a/gdb/symtab.c b/gdb/symtab.c index 4a5d6ef5792..874e475cd61 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -2675,26 +2675,6 @@ lookup_global_symbol (const char *name, return bs; } -bool -symbol_matches_domain (enum language symbol_language, - domain_enum symbol_domain, - domain_enum domain) -{ - /* For C++ "struct foo { ... }" also defines a typedef for "foo". - Similarly, any Ada type declaration implicitly defines a typedef. */ - if (symbol_language == language_cplus - || symbol_language == language_d - || symbol_language == language_ada - || symbol_language == language_rust) - { - if ((domain == VAR_DOMAIN || domain == STRUCT_DOMAIN) - && symbol_domain == STRUCT_DOMAIN) - return true; - } - /* For all other languages, strict match is required. */ - return (symbol_domain == domain); -} - /* See symtab.h. */ bool diff --git a/gdb/symtab.h b/gdb/symtab.h index 414fa29e863..e44420e458b 100644 --- a/gdb/symtab.h +++ b/gdb/symtab.h @@ -1236,10 +1236,6 @@ enum symbol_subclass_kind extern gdb::array_view symbol_impls; -bool symbol_matches_domain (enum language symbol_language, - domain_enum symbol_domain, - domain_enum domain); - /* This structure is space critical. See space comments at the top. */ struct symbol : public general_symbol_info, public allocate_on_obstack @@ -1286,13 +1282,6 @@ struct symbol : public general_symbol_info, public allocate_on_obstack return this->impl ().aclass; } - /* Call symbol_matches_domain on this symbol, using the symbol's - domain. */ - bool matches (domain_enum d) const - { - return symbol_matches_domain (language (), domain (), d); - } - /* Return true if this symbol's domain matches FLAGS. */ bool matches (domain_search_flags flags) const; From patchwork Tue Nov 21 03:53:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 80406 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 B46C9385801D for ; Tue, 21 Nov 2023 03:55:00 +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 7D7AE3858C78 for ; Tue, 21 Nov 2023 03:53:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7D7AE3858C78 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 7D7AE3858C78 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=1700538809; cv=none; b=uzdjWB8F5RXvQln38afjLXZeuEG+7iRuwq50BoMxGYIPQGMqqOs2Jwxy+mNCd8Q2ahkroSqRhPuucDFGxzypZ0ZMcIcTmyD+oEisl9L5NoJpOhxla7X4lYPfonIM6wY3d85cMMpKkZ0YFfstkewD6/gzUeAP+eNA/NgwEHuyTQw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700538809; c=relaxed/simple; bh=dEA20bg13wPr4RNX86IZtAqhidB2F9OWcERXF4+fYnI=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=LGH9W1C2J2xx9zk3AtUZgZGbXqlYPQGPbU0ZKmZKaqyVTBGIesCb6CY5yIl1rlCxyHNk6CImT3HwEAQzE8N2cUi/dT8mcYXkKuqenx8PvLWL1Mk1bGV7t9PmUyznnfVoxQb0zEHGZUXq9roH03xtmTy8pHg86Z+A66DgzRySOM4= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from eig-obgw-5004a.ext.cloudfilter.net ([10.0.29.221]) by cmsmtp with ESMTPS id 5BpmrnKLpWcCI5HpCrZVLs; Tue, 21 Nov 2023 03:53:22 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id 5HpBr8Ecn11XZ5HpBryOPp; Tue, 21 Nov 2023 03:53:22 +0000 X-Authority-Analysis: v=2.4 cv=Z+v/oVdA c=1 sm=1 tr=0 ts=655c29b2 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=CCpqsmhAAAAA:8 a=-1PRDyB1VGpGU6LbscAA:9 a=QEXdDO2ut3YA:10 a=ul9cdbp4aOFLsgKbc677:22 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=To:In-Reply-To:References:Message-Id:Content-Transfer-Encoding: Content-Type:MIME-Version:Subject:Date:From:Sender:Reply-To:Cc:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=NAMcodN0kmUAfS7nGGz7q+rLxbJUDKXDEAAwfCfHSGY=; b=EOqtUQXwss+iWbLr98k2SdgOBw 6KEAZvemTdUhliZXKbePlw8dxK0Rf7SD/WjWzoFxWi042lUM4Y0ofnNbSs8bi+q8JpEIOfzjys01D lyr2wbsT8nGE2X4pRuBHGvYF0; 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 1r5HpB-0040be-0j for gdb-patches@sourceware.org; Mon, 20 Nov 2023 20:53:21 -0700 From: Tom Tromey Date: Mon, 20 Nov 2023 20:53:50 -0700 Subject: [PATCH 19/29] Use the new symbol domains MIME-Version: 1.0 Message-Id: <20231120-submit-domain-hacks-2-v1-19-29650d01b198@tromey.com> References: <20231120-submit-domain-hacks-2-v1-0-29650d01b198@tromey.com> In-Reply-To: <20231120-submit-domain-hacks-2-v1-0-29650d01b198@tromey.com> 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: 1r5HpB-0040be-0j 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: 20 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfABnGVj6PoYqwr9IJnPir+aFgCFmKRijnxAqUPNoZlvM9hjPb4XvsU8kX/JDpOMxLLMhk+iqwLjwzH2cidLqEOicxULpd7rt7Bk/4Xz3aC3j+gngCCJu L3tQTHi6lBRDXdUE+Yh4pFPgxyBkghZEMLmX/1+IBQq6XlrZulOfg0cqFQUt4aEI8fTHKoKG7/20003ugGTFF34Tp6MlykFtpIw= X-Spam-Status: No, score=-3023.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_STOCKGEN, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham 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 This patch changes the DWARF reader to use the new symbol domains. It also adjusts many bits of associated code to adapt to this change. The cooked index and the .debug_names index now share some code here -- the long term goal here is to bring these two pieces of code into sync, since really they do more or less the same job, just with slightly differing inputs. The non-DWARF readers are updated on a best-effort basis. This is somewhat simpler since most of them only support C and C++. I have no way to test a few of these. I went back and forth a few times on how to handle the "tag" situation. The basic problem is that C has a special namespace for tags, which is separate from the type namespace. Other languages don't do this. So, the question is, should a DW_TAG_structure_type end up in the tag domain, or the type domain, or should it be language-dependent? I settled on making it language-dependent using a thought experiment. Suppose there was a Rust compiler that only emitted nameless DW_TAG_structure_type objects, and specified all structure type names using DW_TAG_typedef. This DWARF would be correct, in that it faithfully represents the source language -- but would not work with a purely struct-domain implementation in gdb. Therefore gdb would be wrong. Now, this approach is a little tricky for C++, which uses tags but also enters a typedef for them. I notice that some other readers -- like stabsread -- actually emit a typedef symbol as well. And, I think this is a reasonable approach. It uses more memory, but it makes the internals simpler. However, DWARF never did this for whatever reason, and so in the interest of keeping the series slightly shorter, I've left some C++-specific hacks in place here. Note that this patch includes language_minimal as a language that uses tags. I did this to avoid regressing gdb.dwarf2/debug-names-tu.exp, which doesn't specify the language for a type unit. Arguably this test case is wrong. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30164 --- gdb/ada-tasks.c | 10 +-- gdb/coffread.c | 5 +- gdb/ctfread.c | 2 +- gdb/dwarf2/cooked-index.c | 24 +------ gdb/dwarf2/index-write.c | 7 +-- gdb/dwarf2/read-debug-names.c | 40 +++--------- gdb/dwarf2/read-gdb-index.c | 32 +++++----- gdb/dwarf2/read.c | 30 +++++++-- gdb/dwarf2/tag.h | 78 +++++++++++++++++++++++ gdb/gdbtypes.c | 24 ++++--- gdb/go-exp.y | 2 +- gdb/jit.c | 2 +- gdb/language.c | 2 +- gdb/mdebugread.c | 4 +- gdb/rust-parse.c | 2 +- gdb/stabsread.c | 8 +-- gdb/sym-domains.def | 4 +- gdb/symtab.c | 104 ++++++++++--------------------- gdb/testsuite/gdb.ada/info_auto_lang.exp | 4 +- gdb/testsuite/gdb.ada/ptype-o.exp | 2 +- gdb/testsuite/gdb.fortran/info-types.exp | 2 +- gdb/xcoffread.c | 9 +-- 22 files changed, 212 insertions(+), 185 deletions(-) diff --git a/gdb/ada-tasks.c b/gdb/ada-tasks.c index b62ba779fbd..d0da6540985 100644 --- a/gdb/ada-tasks.c +++ b/gdb/ada-tasks.c @@ -520,17 +520,17 @@ ada_get_tcb_types_info (void) C-like) lookups to get the first match. */ struct symbol *atcb_sym = - lookup_symbol_in_language (atcb_name, NULL, SEARCH_STRUCT_DOMAIN, + lookup_symbol_in_language (atcb_name, NULL, SEARCH_TYPE_DOMAIN, language_c, NULL).symbol; const struct symbol *common_atcb_sym = - lookup_symbol_in_language (common_atcb_name, NULL, SEARCH_STRUCT_DOMAIN, + lookup_symbol_in_language (common_atcb_name, NULL, SEARCH_TYPE_DOMAIN, language_c, NULL).symbol; const struct symbol *private_data_sym = - lookup_symbol_in_language (private_data_name, NULL, SEARCH_STRUCT_DOMAIN, + lookup_symbol_in_language (private_data_name, NULL, SEARCH_TYPE_DOMAIN, language_c, NULL).symbol; const struct symbol *entry_call_record_sym = lookup_symbol_in_language (entry_call_record_name, NULL, - SEARCH_STRUCT_DOMAIN, + SEARCH_TYPE_DOMAIN, language_c, NULL).symbol; if (atcb_sym == NULL || atcb_sym->type () == NULL) @@ -538,7 +538,7 @@ ada_get_tcb_types_info (void) /* In Ravenscar run-time libs, the ATCB does not have a dynamic size, so the symbol name differs. */ atcb_sym = lookup_symbol_in_language (atcb_name_fixed, NULL, - SEARCH_STRUCT_DOMAIN, language_c, + SEARCH_TYPE_DOMAIN, language_c, NULL).symbol; if (atcb_sym == NULL || atcb_sym->type () == NULL) diff --git a/gdb/coffread.c b/gdb/coffread.c index 5898b3a8e08..30e72bdabeb 100644 --- a/gdb/coffread.c +++ b/gdb/coffread.c @@ -1473,7 +1473,7 @@ patch_opaque_types (struct symtab *s) but search the whole chain, as there may be several syms from different files with the same name. */ if (real_sym->aclass () == LOC_TYPEDEF - && real_sym->domain () == VAR_DOMAIN + && real_sym->domain () == TYPE_DOMAIN && real_sym->type ()->code () == TYPE_CODE_PTR && real_sym->type ()->target_type ()->length () != 0) { @@ -1544,6 +1544,7 @@ process_coff_symbol (struct coff_symbol *cs, if (ISFCN (cs->c_type)) { + sym->set_domain (FUNCTION_DOMAIN); sym->set_value_longest (sym->value_longest () + objfile->text_section_offset ()); sym->set_type @@ -1626,7 +1627,7 @@ process_coff_symbol (struct coff_symbol *cs, case C_TPDEF: sym->set_aclass_index (LOC_TYPEDEF); - sym->set_domain (VAR_DOMAIN); + sym->set_domain (TYPE_DOMAIN); /* If type has no name, give it one. */ if (sym->type ()->name () == 0) diff --git a/gdb/ctfread.c b/gdb/ctfread.c index c74ec044c18..03079355df7 100644 --- a/gdb/ctfread.c +++ b/gdb/ctfread.c @@ -505,7 +505,7 @@ new_symbol (struct ctf_context *ccp, struct type *type, ctf_id_t tid) case CTF_K_INTEGER: case CTF_K_FLOAT: sym->set_aclass_index (LOC_TYPEDEF); - sym->set_domain (VAR_DOMAIN); + sym->set_domain (TYPE_DOMAIN); break; case CTF_K_POINTER: break; diff --git a/gdb/dwarf2/cooked-index.c b/gdb/dwarf2/cooked-index.c index e451e324424..3aa5ee8f155 100644 --- a/gdb/dwarf2/cooked-index.c +++ b/gdb/dwarf2/cooked-index.c @@ -188,29 +188,7 @@ cooked_index_entry::matches (domain_search_flags kind) const if ((flags & IS_TYPE_DECLARATION) != 0) return false; - if ((kind & SEARCH_VAR_DOMAIN) != 0 - && (tag == DW_TAG_variable - || tag == DW_TAG_constant - || tag == DW_TAG_enumerator)) - return true; - - if ((kind & SEARCH_STRUCT_DOMAIN) != 0 - && (tag == DW_TAG_structure_type - || tag == DW_TAG_class_type - || tag == DW_TAG_union_type - || tag == DW_TAG_enumeration_type)) - return true; - - if ((kind & SEARCH_MODULE_DOMAIN) != 0 && tag == DW_TAG_module) - return true; - - if ((kind & SEARCH_TYPE_DOMAIN) != 0 && tag_is_type (tag)) - return true; - - if ((kind & SEARCH_FUNCTION_DOMAIN) != 0 && tag == DW_TAG_subprogram) - return true; - - return false; + return tag_matches_domain (tag, kind, per_cu->lang ()); } /* See cooked-index.h. */ diff --git a/gdb/dwarf2/index-write.c b/gdb/dwarf2/index-write.c index c9d6e633bf3..2a8247a64a6 100644 --- a/gdb/dwarf2/index-write.c +++ b/gdb/dwarf2/index-write.c @@ -1183,11 +1183,10 @@ write_cooked_index (cooked_index *table, || entry->tag == DW_TAG_constant || entry->tag == DW_TAG_enumerator) kind = GDB_INDEX_SYMBOL_KIND_VARIABLE; - else if (entry->tag == DW_TAG_module - || entry->tag == DW_TAG_common_block) - kind = GDB_INDEX_SYMBOL_KIND_OTHER; - else + else if (tag_is_type (entry->tag)) kind = GDB_INDEX_SYMBOL_KIND_TYPE; + else + kind = GDB_INDEX_SYMBOL_KIND_OTHER; add_index_entry (symtab, name, (entry->flags & IS_STATIC) != 0, kind, it->second); diff --git a/gdb/dwarf2/read-debug-names.c b/gdb/dwarf2/read-debug-names.c index da1b0e9229b..4431d8bad16 100644 --- a/gdb/dwarf2/read-debug-names.c +++ b/gdb/dwarf2/read-debug-names.c @@ -20,6 +20,7 @@ #include "defs.h" #include "read-debug-names.h" #include "dwarf2/aranges.h" +#include "dwarf2/tag.h" #include "complaints.h" #include "cp-support.h" @@ -847,38 +848,13 @@ dw2_debug_names_iterator::next () } } - domain_enum domain = UNDEF_DOMAIN; - switch (indexval.dwarf_tag) - { - case DW_TAG_variable: - domain = VAR_DOMAIN; - break; - - case DW_TAG_subprogram: - domain = FUNCTION_DOMAIN; - break; - - case DW_TAG_structure_type: - case DW_TAG_union_type: - case DW_TAG_enumeration_type: - domain = STRUCT_DOMAIN; - break; - - case DW_TAG_typedef: - domain = TYPE_DOMAIN; - break; - - case DW_TAG_label: - domain = LABEL_DOMAIN; - break; - - case DW_TAG_module: - domain = MODULE_DOMAIN; - break; - } - - domain_search_flags flags = to_search_flags (domain); - if ((flags & m_search) == 0) + /* We have to use language_cplus here, first because the CU's + language isn't set yet, and then second because C++ is the main + special case, and so this choice will match a superset of other + languages. This hack can go away once the .debug_names writer is + fixed to be more corrects. */ + if (!tag_matches_domain ((dwarf_tag) indexval.dwarf_tag, m_search, + language_cplus)) goto again; return per_cu; diff --git a/gdb/dwarf2/read-gdb-index.c b/gdb/dwarf2/read-gdb-index.c index a45c0f1a730..ba11fddbf19 100644 --- a/gdb/dwarf2/read-gdb-index.c +++ b/gdb/dwarf2/read-gdb-index.c @@ -283,29 +283,33 @@ dw2_symtab_iter_next (struct dw2_symtab_iterator *iter, /* Only check the symbol's kind if it has one. */ if (attrs_valid) { - switch (iter->domain) + switch (symbol_kind) { - case VAR_DOMAIN: - if (symbol_kind != GDB_INDEX_SYMBOL_KIND_VARIABLE - && symbol_kind != GDB_INDEX_SYMBOL_KIND_FUNCTION - /* Some types are also in VAR_DOMAIN. */ - && symbol_kind != GDB_INDEX_SYMBOL_KIND_TYPE) + case GDB_INDEX_SYMBOL_KIND_TYPE: + if ((iter->domain & (SEARCH_TYPE_DOMAIN + | SEARCH_STRUCT_DOMAIN)) == 0) continue; break; - case STRUCT_DOMAIN: - if (symbol_kind != GDB_INDEX_SYMBOL_KIND_TYPE) + + case GDB_INDEX_SYMBOL_KIND_VARIABLE: + if ((iter->domain & SEARCH_VAR_DOMAIN) == 0) continue; break; - case LABEL_DOMAIN: - if (symbol_kind != GDB_INDEX_SYMBOL_KIND_OTHER) + + case GDB_INDEX_SYMBOL_KIND_FUNCTION: + if ((iter->domain & SEARCH_FUNCTION_DOMAIN) == 0) continue; break; - case MODULE_DOMAIN: - if (symbol_kind != GDB_INDEX_SYMBOL_KIND_OTHER) + + case GDB_INDEX_SYMBOL_KIND_OTHER: + if ((iter->domain & (SEARCH_LABEL_DOMAIN + | SEARCH_MODULE_DOMAIN + | SEARCH_COMMON_BLOCK_DOMAIN)) == 0) continue; break; + default: - break; + continue; } } @@ -426,7 +430,7 @@ dw2_expand_marked_cus mask = SEARCH_FUNCTION_DOMAIN; break; case GDB_INDEX_SYMBOL_KIND_TYPE: - mask = SEARCH_TYPE_DOMAIN; + mask = SEARCH_TYPE_DOMAIN | SEARCH_STRUCT_DOMAIN; break; case GDB_INDEX_SYMBOL_KIND_OTHER: mask = SEARCH_MODULE_DOMAIN; diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 35f65bddc3f..b5e356e055e 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -5730,9 +5730,7 @@ fixup_go_packaging (struct dwarf2_cu *cu) sym = new (&objfile->objfile_obstack) symbol; sym->set_language (language_go, &objfile->objfile_obstack); sym->compute_and_set_names (saved_package_name, false, objfile->per_bfd); - /* This is not VAR_DOMAIN because we want a way to ensure a lookup of, - e.g., "main" finds the "main" module and not C's main(). */ - sym->set_domain (STRUCT_DOMAIN); + sym->set_domain (TYPE_DOMAIN); sym->set_aclass_index (LOC_TYPEDEF); sym->set_type (type); @@ -18920,7 +18918,7 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu, /* Default assumptions. Use the passed type or decode it from the die. */ - sym->set_domain (VAR_DOMAIN); + sym->set_domain (UNDEF_DOMAIN); sym->set_aclass_index (LOC_OPTIMIZED_OUT); if (type != NULL) sym->set_type (type); @@ -18972,6 +18970,7 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu, case DW_TAG_subprogram: /* SYMBOL_BLOCK_VALUE (sym) will be filled in later by finish_block. */ + sym->set_domain (FUNCTION_DOMAIN); sym->set_aclass_index (LOC_BLOCK); attr2 = dwarf2_attr (die, DW_AT_external, cu); if ((attr2 != nullptr && attr2->as_boolean ()) @@ -19016,6 +19015,7 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu, case DW_TAG_inlined_subroutine: /* SYMBOL_BLOCK_VALUE (sym) will be filled in later by finish_block. */ + sym->set_domain (FUNCTION_DOMAIN); sym->set_aclass_index (LOC_BLOCK); sym->set_is_inlined (1); list_to_add = cu->list_in_scope; @@ -19026,6 +19026,7 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu, case DW_TAG_constant: case DW_TAG_variable: case DW_TAG_member: + sym->set_domain (VAR_DOMAIN); /* Compilation with minimal debug info may result in variables with missing type entries. Change the misleading `void' type to something sensible. */ @@ -19174,6 +19175,7 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu, when we do not have enough information to show inlined frames; pretend it's a local variable in that case so that the user can still see it. */ + sym->set_domain (VAR_DOMAIN); struct context_stack *curr = cu->get_builder ()->get_current_context_stack (); if (curr != nullptr && curr->name != nullptr) @@ -19212,11 +19214,25 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu, sym->set_aclass_index (LOC_STATIC); sym->set_domain (VAR_DOMAIN); } - else + else if (cu->lang () == language_c + || cu->lang () == language_cplus + || cu->lang () == language_objc + || cu->lang () == language_opencl + || cu->lang () == language_minimal) { + /* These languages have a tag namespace. Note that + there's a special hack for C++ in the matching code, + so we don't need to enter a separate typedef for the + tag. */ sym->set_aclass_index (LOC_TYPEDEF); sym->set_domain (STRUCT_DOMAIN); } + else + { + /* Other languages don't have a tag namespace. */ + sym->set_aclass_index (LOC_TYPEDEF); + sym->set_domain (TYPE_DOMAIN); + } /* NOTE: carlton/2003-11-10: C++ class symbols shouldn't really ever be static objects: otherwise, if you try @@ -19260,10 +19276,11 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu, case DW_TAG_subrange_type: case DW_TAG_generic_subrange: sym->set_aclass_index (LOC_TYPEDEF); - sym->set_domain (VAR_DOMAIN); + sym->set_domain (TYPE_DOMAIN); list_to_add = cu->list_in_scope; break; case DW_TAG_enumerator: + sym->set_domain (VAR_DOMAIN); attr = dwarf2_attr (die, DW_AT_const_value, cu); if (attr != nullptr) { @@ -19281,6 +19298,7 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu, break; case DW_TAG_imported_declaration: case DW_TAG_namespace: + sym->set_domain (TYPE_DOMAIN); sym->set_aclass_index (LOC_TYPEDEF); list_to_add = cu->get_builder ()->get_global_symbols (); break; diff --git a/gdb/dwarf2/tag.h b/gdb/dwarf2/tag.h index 4847b703e48..082a05beb39 100644 --- a/gdb/dwarf2/tag.h +++ b/gdb/dwarf2/tag.h @@ -21,6 +21,7 @@ #define GDB_DWARF2_TAG_H #include "dwarf2.h" +#include "symtab.h" /* Return true if TAG represents a type, false otherwise. */ @@ -64,4 +65,81 @@ tag_is_type (dwarf_tag tag) } } +/* Return true if the given DWARF tag matches the specified search + domain flags. LANG may affect the result, due to the "C++ tag + hack". */ + +static inline bool +tag_matches_domain (dwarf_tag tag, domain_search_flags search, language lang) +{ + domain_search_flags flags = 0; + switch (tag) + { + case DW_TAG_variable: + case DW_TAG_enumerator: + case DW_TAG_constant: + flags = SEARCH_VAR_DOMAIN; + break; + + case DW_TAG_subprogram: + flags = SEARCH_FUNCTION_DOMAIN; + break; + + case DW_TAG_structure_type: + case DW_TAG_class_type: + case DW_TAG_union_type: + case DW_TAG_enumeration_type: + { + if (lang == language_c + || lang == language_objc + || lang == language_opencl + || lang == language_minimal) + flags = SEARCH_STRUCT_DOMAIN; + else if (lang == language_cplus) + flags = SEARCH_STRUCT_DOMAIN | SEARCH_TYPE_DOMAIN; + else + flags = SEARCH_TYPE_DOMAIN; + } + break; + + case DW_TAG_padding: + case DW_TAG_array_type: + case DW_TAG_pointer_type: + case DW_TAG_reference_type: + case DW_TAG_string_type: + case DW_TAG_subroutine_type: + case DW_TAG_ptr_to_member_type: + case DW_TAG_set_type: + case DW_TAG_subrange_type: + case DW_TAG_base_type: + case DW_TAG_const_type: + case DW_TAG_packed_type: + case DW_TAG_template_type_param: + case DW_TAG_volatile_type: + case DW_TAG_restrict_type: + case DW_TAG_interface_type: + case DW_TAG_namespace: + case DW_TAG_unspecified_type: + case DW_TAG_shared_type: + case DW_TAG_rvalue_reference_type: + case DW_TAG_coarray_type: + case DW_TAG_dynamic_type: + case DW_TAG_atomic_type: + case DW_TAG_immutable_type: + case DW_TAG_typedef: + flags = SEARCH_TYPE_DOMAIN; + break; + + case DW_TAG_label: + flags = SEARCH_LABEL_DOMAIN; + break; + + case DW_TAG_module: + flags = SEARCH_MODULE_DOMAIN; + break; + } + + return (flags & search) != 0; +} + #endif /* GDB_DWARF2_TAG_H */ diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index a6ff272adef..3e35ae8ba0a 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -2987,15 +2987,19 @@ check_typedef (struct type *type) return make_qualified_type (type, instance_flags, NULL); name = type->name (); - /* FIXME: shouldn't we look in STRUCT_DOMAIN and/or - VAR_DOMAIN as appropriate? */ if (name == NULL) { stub_noname_complaint (); return make_qualified_type (type, instance_flags, NULL); } - sym = lookup_symbol (name, nullptr, SEARCH_STRUCT_DOMAIN, - nullptr).symbol; + domain_search_flag flag + = ((type->language () == language_c + || type->language () == language_objc + || type->language () == language_opencl + || type->language () == language_minimal) + ? SEARCH_STRUCT_DOMAIN + : SEARCH_TYPE_DOMAIN); + sym = lookup_symbol (name, nullptr, flag, nullptr).symbol; if (sym) type->set_target_type (sym->type ()); else /* TYPE_CODE_UNDEF */ @@ -3076,8 +3080,6 @@ check_typedef (struct type *type) else if (type->is_stub () && !currently_reading_symtab) { const char *name = type->name (); - /* FIXME: shouldn't we look in STRUCT_DOMAIN and/or VAR_DOMAIN - as appropriate? */ struct symbol *sym; if (name == NULL) @@ -3085,8 +3087,14 @@ check_typedef (struct type *type) stub_noname_complaint (); return make_qualified_type (type, instance_flags, NULL); } - sym = lookup_symbol (name, nullptr, SEARCH_STRUCT_DOMAIN, - nullptr).symbol; + domain_search_flag flag + = ((type->language () == language_c + || type->language () == language_objc + || type->language () == language_opencl + || type->language () == language_minimal) + ? SEARCH_STRUCT_DOMAIN + : SEARCH_TYPE_DOMAIN); + sym = lookup_symbol (name, nullptr, flag, nullptr).symbol; if (sym) { /* Same as above for opaque types, we can replace the stub diff --git a/gdb/go-exp.y b/gdb/go-exp.y index bf1282e80f3..10bee0fff95 100644 --- a/gdb/go-exp.y +++ b/gdb/go-exp.y @@ -1293,7 +1293,7 @@ package_name_p (const char *name, const struct block *block) struct symbol *sym; struct field_of_this_result is_a_field_of_this; - sym = lookup_symbol (name, block, SEARCH_STRUCT_DOMAIN, + sym = lookup_symbol (name, block, SEARCH_TYPE_DOMAIN, &is_a_field_of_this).symbol; if (sym diff --git a/gdb/jit.c b/gdb/jit.c index 9e8325ab803..8a31abe15a3 100644 --- a/gdb/jit.c +++ b/gdb/jit.c @@ -581,7 +581,7 @@ finalize_symtab (struct gdb_symtab *stab, struct objfile *objfile) new_block->set_end (gdb_block_iter.end); /* The name. */ - block_name->set_domain (VAR_DOMAIN); + block_name->set_domain (FUNCTION_DOMAIN); block_name->set_aclass_index (LOC_BLOCK); block_name->set_symtab (filetab); block_name->set_type (lookup_function_type (block_type)); diff --git a/gdb/language.c b/gdb/language.c index 13b20840286..3ebd1c51b4b 100644 --- a/gdb/language.c +++ b/gdb/language.c @@ -931,7 +931,7 @@ language_arch_info::type_and_symbol::alloc_type_symbol symbol->set_is_objfile_owned (0); symbol->set_section_index (0); symbol->set_type (type); - symbol->set_domain (VAR_DOMAIN); + symbol->set_domain (TYPE_DOMAIN); symbol->set_aclass_index (LOC_TYPEDEF); return symbol; } diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c index 02cd0dc43d5..8b9a81df86d 100644 --- a/gdb/mdebugread.c +++ b/gdb/mdebugread.c @@ -753,7 +753,7 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend, break; } s = new_symbol (name); - s->set_domain (VAR_DOMAIN); + s->set_domain (FUNCTION_DOMAIN); s->set_aclass_index (LOC_BLOCK); s->set_section_index (section_index); /* Type of the return value. */ @@ -1297,7 +1297,7 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend, if (has_opaque_xref (cur_fdr, sh)) break; s = new_symbol (name); - s->set_domain (VAR_DOMAIN); + s->set_domain (TYPE_DOMAIN); s->set_aclass_index (LOC_TYPEDEF); s->set_value_block (top_stack->cur_block); s->set_type (t); diff --git a/gdb/rust-parse.c b/gdb/rust-parse.c index 67bd0a73419..390fd2c2c80 100644 --- a/gdb/rust-parse.c +++ b/gdb/rust-parse.c @@ -454,7 +454,7 @@ rust_parser::rust_lookup_type (const char *name) const struct block *block = pstate->expression_context_block; munge_name_and_block (&name, &block); - result = ::lookup_symbol (name, block, SEARCH_STRUCT_DOMAIN, NULL); + result = ::lookup_symbol (name, block, SEARCH_TYPE_DOMAIN, nullptr); if (result.symbol != NULL) { update_innermost_block (result); diff --git a/gdb/stabsread.c b/gdb/stabsread.c index 7402a26a401..f03a2b51a2d 100644 --- a/gdb/stabsread.c +++ b/gdb/stabsread.c @@ -945,7 +945,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type, /* A static function definition. */ sym->set_type (read_type (&p, objfile)); sym->set_aclass_index (LOC_BLOCK); - sym->set_domain (VAR_DOMAIN); + sym->set_domain (FUNCTION_DOMAIN); add_symbol_to_list (sym, get_file_symbols ()); /* fall into process_function_types. */ @@ -1016,7 +1016,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type, /* A global function definition. */ sym->set_type (read_type (&p, objfile)); sym->set_aclass_index (LOC_BLOCK); - sym->set_domain (VAR_DOMAIN); + sym->set_domain (FUNCTION_DOMAIN); add_symbol_to_list (sym, get_global_symbols ()); goto process_function_types; @@ -1214,7 +1214,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type, sym->set_aclass_index (LOC_TYPEDEF); sym->set_value_longest (valu); - sym->set_domain (VAR_DOMAIN); + sym->set_domain (TYPE_DOMAIN); /* C++ vagaries: we may have a type which is derived from a base type which did not have its name defined when the derived class was output. We fill in the derived class's @@ -1333,7 +1333,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type, *typedef_sym = *sym; typedef_sym->set_aclass_index (LOC_TYPEDEF); typedef_sym->set_value_longest (valu); - typedef_sym->set_domain (VAR_DOMAIN); + typedef_sym->set_domain (TYPE_DOMAIN); if (sym->type ()->name () == 0) sym->type ()->set_name (obconcat (&objfile->objfile_obstack, sym->linkage_name (), diff --git a/gdb/sym-domains.def b/gdb/sym-domains.def index cea25a5f5b3..7545631063b 100644 --- a/gdb/sym-domains.def +++ b/gdb/sym-domains.def @@ -47,7 +47,9 @@ DOMAIN (LABEL) DOMAIN (COMMON_BLOCK) /* TYPE_DOMAIN is for types and typedefs. Note that tags are not - found here, see STRUCT_DOMAIN above. */ + found here, see STRUCT_DOMAIN above. If a language does not have a + tag namespace, then all types (including structures, etc) are + here. */ DOMAIN (TYPE) diff --git a/gdb/symtab.c b/gdb/symtab.c index 874e475cd61..3d7a5a1811b 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -2680,32 +2680,10 @@ lookup_global_symbol (const char *name, bool symbol::matches (domain_search_flags flags) const { - if (language () != language_c - && language () != language_objc - && language () != language_opencl) - { - /* Only C languages distinguish tag and type namespaces. */ - if ((flags & SEARCH_TYPE_DOMAIN) != 0) - flags |= SEARCH_STRUCT_DOMAIN; - } - - if ((flags & SEARCH_FUNCTION_DOMAIN) != 0 - && domain () == VAR_DOMAIN - && aclass () == LOC_BLOCK) - return true; - - if ((flags & SEARCH_VAR_DOMAIN) != 0 - && domain () == VAR_DOMAIN) - return true; - - if ((flags & SEARCH_TYPE_DOMAIN) != 0 - && domain () == VAR_DOMAIN - && aclass () == LOC_TYPEDEF) - return true; - - if ((flags & SEARCH_STRUCT_DOMAIN) != 0 - && domain () == STRUCT_DOMAIN) - return true; + /* C++ has a typedef for every tag, and the types are in the struct + domain. */ + if (language () == language_cplus && (flags & SEARCH_TYPE_DOMAIN) != 0) + flags |= SEARCH_STRUCT_DOMAIN; return search_flags_matches (flags, m_domain); } @@ -4811,59 +4789,42 @@ global_symbol_searcher::add_matching_symbols filenames, false)))) continue; + if (!sym->matches (kind)) + continue; + if (preg.has_value () && !preg->exec (sym->natural_name (), 0, nullptr, 0) == 0) continue; - bool matches = false; - if (!matches && (kind & SEARCH_VAR_DOMAIN) != 0) + if (((sym->domain () == VAR_DOMAIN + || sym->domain () == FUNCTION_DOMAIN) + && treg.has_value () + && !treg_matches_sym_type_name (*treg, sym))) + continue; + + if ((kind & SEARCH_VAR_DOMAIN) != 0) { - if (sym->aclass () != LOC_TYPEDEF - && sym->aclass () != LOC_UNRESOLVED - && sym->aclass () != LOC_BLOCK + if (sym->aclass () == LOC_UNRESOLVED /* LOC_CONST can be used for more than just enums, e.g., c++ static const members. We only want to skip enums here. */ - && !(sym->aclass () == LOC_CONST - && (sym->type ()->code () - == TYPE_CODE_ENUM)) - && (!treg.has_value () - || treg_matches_sym_type_name (*treg, sym))) - matches = true; - } - if (!matches && (kind & SEARCH_FUNCTION_DOMAIN) != 0) - { - if (sym->aclass () == LOC_BLOCK - && (!treg.has_value () - || treg_matches_sym_type_name (*treg, - sym))) - matches = true; - } - if (!matches && (kind & SEARCH_TYPE_DOMAIN) != 0) - { - if (sym->aclass () == LOC_TYPEDEF - && sym->domain () != MODULE_DOMAIN) - matches = true; - } - if (!matches && (kind & SEARCH_MODULE_DOMAIN) != 0) - { - if (sym->domain () == MODULE_DOMAIN - && sym->line () != 0) - matches = true; + || (sym->aclass () == LOC_CONST + && (sym->type ()->code () == TYPE_CODE_ENUM))) + continue; } - if (matches) + if (sym->domain () == MODULE_DOMAIN && sym->line () == 0) + continue; + + if (result_set->size () < m_max_search_results) { - if (result_set->size () < m_max_search_results) - { - /* Match, insert if not already in the results. */ - symbol_search ss (block, sym); - if (result_set->find (ss) == result_set->end ()) - result_set->insert (ss); - } - else - return false; + /* Match, insert if not already in the results. */ + symbol_search ss (block, sym); + if (result_set->find (ss) == result_set->end ()) + result_set->insert (ss); } + else + return false; } } } @@ -5026,12 +4987,12 @@ symbol_to_info_string (struct symbol *sym, int block) gdb_assert (block == GLOBAL_BLOCK || block == STATIC_BLOCK); if (block == STATIC_BLOCK - && sym->domain () == VAR_DOMAIN - && sym->aclass () != LOC_TYPEDEF) + && (sym->domain () == VAR_DOMAIN + || sym->domain () == FUNCTION_DOMAIN)) str += "static "; /* Typedef that is not a C++ class. */ - if (sym->domain () == VAR_DOMAIN && sym->aclass () == LOC_TYPEDEF) + if (sym->domain () == TYPE_DOMAIN) { string_file tmp_stream; @@ -5050,7 +5011,8 @@ symbol_to_info_string (struct symbol *sym, int block) str += tmp_stream.string (); } /* variable, func, or typedef-that-is-c++-class. */ - else if (sym->domain () == VAR_DOMAIN || sym->domain () == STRUCT_DOMAIN) + else if (sym->domain () == VAR_DOMAIN || sym->domain () == STRUCT_DOMAIN + || sym->domain () == FUNCTION_DOMAIN) { string_file tmp_stream; diff --git a/gdb/testsuite/gdb.ada/info_auto_lang.exp b/gdb/testsuite/gdb.ada/info_auto_lang.exp index 5134643c0ca..8659d4e0491 100644 --- a/gdb/testsuite/gdb.ada/info_auto_lang.exp +++ b/gdb/testsuite/gdb.ada/info_auto_lang.exp @@ -65,8 +65,8 @@ set type_in_c(ada_syntax) [multi_line \ "${decimal}: record" \ " some_component_in_c: int;" \ "end record" ] -set type_in_ada(c_syntax) "${decimal}: struct global_pack__some_type_in_ada;" -set type_in_ada(ada_syntax) "${decimal}: global_pack.some_type_in_ada;" +set type_in_ada(c_syntax) "${decimal}: struct global_pack__some_type_in_ada" +set type_in_ada(ada_syntax) "${decimal}: global_pack.some_type_in_ada" set var_in_c(c_syntax) "${decimal}: some_type_in_c some_struct_in_c;" set var_in_c(ada_syntax) "${decimal}: some_struct_in_c: some_type_in_c;" diff --git a/gdb/testsuite/gdb.ada/ptype-o.exp b/gdb/testsuite/gdb.ada/ptype-o.exp index eae90a406a0..067627ccbff 100644 --- a/gdb/testsuite/gdb.ada/ptype-o.exp +++ b/gdb/testsuite/gdb.ada/ptype-o.exp @@ -43,5 +43,5 @@ foreach_with_prefix scenario {all minimal} { # crash. set exp ".*" } - gdb_test "ptype/o struct prog__rec" $exp + gdb_test "ptype/o prog__rec" $exp } diff --git a/gdb/testsuite/gdb.fortran/info-types.exp b/gdb/testsuite/gdb.fortran/info-types.exp index 8cd9a2ae6cb..bce4c0cf559 100644 --- a/gdb/testsuite/gdb.fortran/info-types.exp +++ b/gdb/testsuite/gdb.fortran/info-types.exp @@ -44,7 +44,7 @@ GDBInfoSymbols::check_header "All defined types:" GDBInfoSymbols::check_optional_entry "${srcfile}" "" "${character1}" GDBInfoSymbols::check_entry "${srcfile}" "" "${integer4}" GDBInfoSymbols::check_entry "${srcfile}" "" "${logical4}" -GDBInfoSymbols::check_entry "${srcfile}" "$decimal" "Type m1t1;" +GDBInfoSymbols::check_entry "${srcfile}" "$decimal" "Type m1t1" GDBInfoSymbols::check_entry "${srcfile}" "" "${real4}" # The emission of the 'Type s1' at global scope is actually not expected. The diff --git a/gdb/xcoffread.c b/gdb/xcoffread.c index e6ecf2a6de5..cc60fdf718a 100644 --- a/gdb/xcoffread.c +++ b/gdb/xcoffread.c @@ -1491,6 +1491,7 @@ process_xcoff_symbol (struct xcoff_symbol *cs, struct objfile *objfile) sym->set_linkage_name (SYMNAME_ALLOC (name, symname_alloced)); sym->set_type (builtin_type (objfile)->nodebug_text_symbol); + sym->set_domain (FUNCTION_DOMAIN); sym->set_aclass_index (LOC_BLOCK); sym2 = new (&objfile->objfile_obstack) symbol (*sym); @@ -2546,7 +2547,7 @@ scan_xcoff_symtab (minimal_symbol_reader &reader, /* Also a typedef with the same name. */ pst->add_psymbol (gdb::string_view (namestring, p - namestring), - true, VAR_DOMAIN, LOC_TYPEDEF, -1, + true, TYPE_DOMAIN, LOC_TYPEDEF, -1, psymbol_placement::STATIC, unrelocated_addr (0), psymtab_language, @@ -2561,7 +2562,7 @@ scan_xcoff_symtab (minimal_symbol_reader &reader, { pst->add_psymbol (gdb::string_view (namestring, p - namestring), - true, VAR_DOMAIN, LOC_TYPEDEF, -1, + true, TYPE_DOMAIN, LOC_TYPEDEF, -1, psymbol_placement::STATIC, unrelocated_addr (0), psymtab_language, @@ -2661,7 +2662,7 @@ scan_xcoff_symtab (minimal_symbol_reader &reader, } pst->add_psymbol (gdb::string_view (namestring, p - namestring), - true, VAR_DOMAIN, LOC_BLOCK, + true, FUNCTION_DOMAIN, LOC_BLOCK, SECT_OFF_TEXT (objfile), psymbol_placement::STATIC, unrelocated_addr (symbol.n_value), @@ -2688,7 +2689,7 @@ scan_xcoff_symtab (minimal_symbol_reader &reader, pst->add_psymbol (gdb::string_view (namestring, p - namestring), - true, VAR_DOMAIN, LOC_BLOCK, + true, FUNCTION_DOMAIN, LOC_BLOCK, SECT_OFF_TEXT (objfile), psymbol_placement::GLOBAL, unrelocated_addr (symbol.n_value), From patchwork Tue Nov 21 03:53:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 80409 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 BFD023858C54 for ; Tue, 21 Nov 2023 03:55:25 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from omta34.uswest2.a.cloudfilter.net (omta34.uswest2.a.cloudfilter.net [35.89.44.33]) by sourceware.org (Postfix) with ESMTPS id 495353858C33 for ; Tue, 21 Nov 2023 03:53:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 495353858C33 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 495353858C33 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=35.89.44.33 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700538810; cv=none; b=ewimbHIUZ+vqWI636QSUsGb6o3J1m1Uj1YQutT4PHzRZp7GJSOnIrxnLD/5GL3T65ESoCUA/qy2/sP8Elu4IjOS+olaL5h8MR+hViqkZPGbYFIF6kXQXg3phyprrYln0p+wizunFvXwZZ5nCxmmrNxFz54lHR+zwa+zPRfB7cjk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700538810; c=relaxed/simple; bh=sOth2ESS5p0M4+h/CNcoGCTFWHVHvIYnIYYGJkUNn8E=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=fZu1uVku3MOmZ/fmtROMRSJAknnsoMzDlMFMgEnnnHNRY/tvjPWHjlQrhsoco8N0Qp3PdFYCsuu8amIK85zMCEx71OOjcZLaGiSrwYYivxt3XTF5H2wR866YxdpbQCPhyZnBv096eC43Z9m5lEB/mlsg93PTEnPSTXMLXoZUKGg= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from eig-obgw-5009a.ext.cloudfilter.net ([10.0.29.176]) by cmsmtp with ESMTPS id 5C2mrSRBS8Hte5HpCrHZWt; Tue, 21 Nov 2023 03:53:22 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id 5HpBrzUKB97pz5HpBrri9U; Tue, 21 Nov 2023 03:53:22 +0000 X-Authority-Analysis: v=2.4 cv=ULDOoQTy c=1 sm=1 tr=0 ts=655c29b2 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=3LfQSaOyrCHHMfNpbn0A:9 a=QEXdDO2ut3YA:10 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=To:In-Reply-To:References:Message-Id:Content-Transfer-Encoding: Content-Type:MIME-Version:Subject:Date:From:Sender:Reply-To:Cc:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=lSOrmpJFG3gXmUmBW5ORyLHcKR8naFj/vecfqQg1mds=; b=mAJ2n9cYP+OZ0XoNoqnA5dg1Dl 1Ugt+urHtP1Zqk4CA95XeU7SDZFCLHRYHA/c4V2k0anck4dfOcXDOfG0Lnw1NVn4BOiWg6OGqoJYt +XY8O2yU0/SZwkpcOS4EYU+mJ; 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 1r5HpB-0040be-1E for gdb-patches@sourceware.org; Mon, 20 Nov 2023 20:53:21 -0700 From: Tom Tromey Date: Mon, 20 Nov 2023 20:53:51 -0700 Subject: [PATCH 20/29] Simplify some symbol searches in Ada code MIME-Version: 1.0 Message-Id: <20231120-submit-domain-hacks-2-v1-20-29650d01b198@tromey.com> References: <20231120-submit-domain-hacks-2-v1-0-29650d01b198@tromey.com> In-Reply-To: <20231120-submit-domain-hacks-2-v1-0-29650d01b198@tromey.com> 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: 1r5HpB-0040be-1E 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: 21 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfBJ/+JJ/4zsQdUdWtGE38fNEOsDWwweBZnPS7FH10qmAks5tZjx/Ds5MFNdHVCYtjhzUogJToIiS5Vpof+ii8FJ2nbzLo0CSUu438ymEt1RBxdxUpNBI mg3HyJGds26HOsy4UahkYlAnnbZqln/EFmYSO91biI6hn9fUlwEwcMreL1jWtR0puM7ZKcFycQMVHphrOQTPnrUVems8AbCq6XY= X-Spam-Status: No, score=-3024.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham 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 This changes some of the Ada code to simplify symbol searches. For example, if a function is being looked for, the search is narrowed to use SEARCH_FUNCTION_DOMAIN rather than SEARCH_VFT. In one spot, a search of the "struct" domain is removed, because Ada does not have a tag domain. --- gdb/ada-exp.y | 4 ++-- gdb/ada-lang.c | 10 ++-------- gdb/dwarf2/ada-imported.c | 2 +- 3 files changed, 5 insertions(+), 11 deletions(-) diff --git a/gdb/ada-exp.y b/gdb/ada-exp.y index df7a85f101d..613e284c166 100644 --- a/gdb/ada-exp.y +++ b/gdb/ada-exp.y @@ -1404,7 +1404,7 @@ block_lookup (const struct block *context, const char *raw_name) } std::vector syms - = ada_lookup_symbol_list (name, context, SEARCH_VFT); + = ada_lookup_symbol_list (name, context, SEARCH_FUNCTION_DOMAIN); if (context == NULL && (syms.empty () || syms[0].symbol->aclass () != LOC_BLOCK)) @@ -1483,7 +1483,7 @@ find_primitive_type (struct parser_state *par_state, const char *name) (char *) alloca (strlen (name) + sizeof ("standard__")); strcpy (expanded_name, "standard__"); strcat (expanded_name, name); - sym = ada_lookup_symbol (expanded_name, NULL, SEARCH_VFT).symbol; + sym = ada_lookup_symbol (expanded_name, NULL, SEARCH_TYPE_DOMAIN).symbol; if (sym != NULL && sym->aclass () == LOC_TYPEDEF) type = sym->type (); } diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index ad5fac05468..6efc4819088 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -7496,14 +7496,8 @@ field_alignment (struct type *type, int f) static struct symbol * ada_find_any_type_symbol (const char *name) { - struct symbol *sym; - - sym = standard_lookup (name, get_selected_block (NULL), SEARCH_VFT); - if (sym != NULL && sym->aclass () == LOC_TYPEDEF) - return sym; - - sym = standard_lookup (name, NULL, SEARCH_STRUCT_DOMAIN); - return sym; + return standard_lookup (name, get_selected_block (nullptr), + SEARCH_TYPE_DOMAIN); } /* Find a type named NAME. Ignores ambiguity. This routine will look diff --git a/gdb/dwarf2/ada-imported.c b/gdb/dwarf2/ada-imported.c index bfcfb779105..13d61a354c1 100644 --- a/gdb/dwarf2/ada-imported.c +++ b/gdb/dwarf2/ada-imported.c @@ -103,7 +103,7 @@ ada_alias_get_block_value (const struct symbol *sym) { const char *name = get_imported_name (sym); block_symbol real_symbol = lookup_global_symbol (name, nullptr, - SEARCH_VFT); + SEARCH_FUNCTION_DOMAIN); if (real_symbol.symbol == nullptr) error (_("could not find alias '%s' for function '%s'"), name, sym->print_name ()); From patchwork Tue Nov 21 03:53:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 80403 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 530D8385829E for ; Tue, 21 Nov 2023 03:54:44 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from omta034.useast.a.cloudfilter.net (omta034.useast.a.cloudfilter.net [44.202.169.33]) by sourceware.org (Postfix) with ESMTPS id B47433858C2A for ; Tue, 21 Nov 2023 03:53:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B47433858C2A 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 B47433858C2A Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=44.202.169.33 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700538806; cv=none; b=fEShLro6SwWtYAhjxs89brmQalocAg191pxqa/VxuXU0FIM3amW9Rme8I5sB4UVLtgtqg+Jnk37fFHtjQhKVonnm5R6jRynpoUaaBZNC0AR9hDvDCMejUgT3ZVz2jImKDjCG0tobl7eNFZq+IzUy27YUjtWLqNIoYk7Ch97x3DI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700538806; c=relaxed/simple; bh=Sit9Lg8LW9jljzBmoQjkR1aX/rB6vC9trME07VfKUGY=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=JuizQqzmlTscd18z9enPWFEzLzIRzYDhoJF6Rl/jeiwg8IPTtgQZJ7J7sIDKSYe0yb3/p96Rcjbdg2FhiIbU6Jr/W4gtP79T2zxsVFyX1MrInbULLAP5IqhI6Dm24vlKFXJzScTPDX04fvD4wOr0UuRRiyC9+n+8UGR4rUKZf2Q= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from eig-obgw-5008a.ext.cloudfilter.net ([10.0.29.246]) by cmsmtp with ESMTPS id 5BwgrOlYQjtZ35HpHrWyo3; Tue, 21 Nov 2023 03:53:27 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id 5HpBr9L0XkUbt5HpCrQVX6; Tue, 21 Nov 2023 03:53:22 +0000 X-Authority-Analysis: v=2.4 cv=WpU4jPTv c=1 sm=1 tr=0 ts=655c29b2 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=KeMcekxUm0Ol8IqNVy0A:9 a=QEXdDO2ut3YA:10 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=To:In-Reply-To:References:Message-Id:Content-Transfer-Encoding: Content-Type:MIME-Version:Subject:Date:From:Sender:Reply-To:Cc:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=p1zcxE/7wn6VA2VSCrVEe+jdsZTEtYScy3KA2HL91qs=; b=nW9P6bnVkrSzu8Dhx07dAie/Hx vK3l9DnyA2NDxwRYK3PaUPEZDchOEGsDfoOZxtiNgzTBFoiDD/ktuZTXvHoa+ow9cOJzl45jWMXg1 beF/jjIBGyFiB46zCvsVjxlxP; 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 1r5HpB-0040be-1d for gdb-patches@sourceware.org; Mon, 20 Nov 2023 20:53:21 -0700 From: Tom Tromey Date: Mon, 20 Nov 2023 20:53:52 -0700 Subject: [PATCH 21/29] Simplify some symbol searches in linespec.c MIME-Version: 1.0 Message-Id: <20231120-submit-domain-hacks-2-v1-21-29650d01b198@tromey.com> References: <20231120-submit-domain-hacks-2-v1-0-29650d01b198@tromey.com> In-Reply-To: <20231120-submit-domain-hacks-2-v1-0-29650d01b198@tromey.com> 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: 1r5HpB-0040be-1d 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: 22 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfFTKffQKBsw6/C+dk/jGncyDlsKPCG0QLrAQvVRNr0ucixT4qBPaZxWbX7yN/B52Wmngc6X/wwVtz8QS/o6r2oL7Oko3w/HrO8DxZvE1u3GSZbjfXYu1 PoTUtbUx3V/xGItOJlootiLRUefO99UFvnipmGITS1QCVnP3cFLZZgrvIKK+pFYRQ4bqS9GQ3KIQlOjCEO6BZw747x4/ghyH/HU= X-Spam-Status: No, score=-3024.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham 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 This simplifies some symbol searches in linespec.c. In particular, two separate searches here can now be combined into one, due to the new use of flags. Arguably the STRUCT_DOMAIN searches should perhaps not even be done. Only C really has these, and C doesn't have member functions. However, it seems relatively harmless -- and clearly compatible -- to leave this in. --- gdb/linespec.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/gdb/linespec.c b/gdb/linespec.c index e840a137cfb..c7e6c7444d5 100644 --- a/gdb/linespec.c +++ b/gdb/linespec.c @@ -3438,14 +3438,9 @@ lookup_prefix_sym (struct linespec_state *state, for (const auto &elt : file_symtabs) { if (elt == nullptr) - { - iterate_over_all_matching_symtabs (state, lookup_name, - SEARCH_STRUCT_DOMAIN, - NULL, false, collector); - iterate_over_all_matching_symtabs (state, lookup_name, - SEARCH_VFT, - NULL, false, collector); - } + iterate_over_all_matching_symtabs (state, lookup_name, + SEARCH_STRUCT_DOMAIN | SEARCH_VFT, + NULL, false, collector); else { /* Program spaces that are executing startup should have @@ -3455,10 +3450,7 @@ lookup_prefix_sym (struct linespec_state *state, gdb_assert (!pspace->executing_startup); set_current_program_space (pspace); iterate_over_file_blocks (elt, lookup_name, - SEARCH_STRUCT_DOMAIN, - collector); - iterate_over_file_blocks (elt, lookup_name, - SEARCH_VFT, + SEARCH_STRUCT_DOMAIN | SEARCH_VFT, collector); } } From patchwork Tue Nov 21 03:53:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 80408 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 6718E3858434 for ; Tue, 21 Nov 2023 03:55:12 +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 DDC2F3858C2D for ; Tue, 21 Nov 2023 03:53:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DDC2F3858C2D 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 DDC2F3858C2D 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=1700538807; cv=none; b=DPN7Dd4qYomdVRUj+JcK/2xbV225ni4+DewIXYhXjjZXNfodX/E+2IE8HPfxBZDfvhQwDAkCrIFcsWKlp9IVPYpSTVf6Sr09cC8slFEko3nZ85spHoRGpF9hpwenvNXRbU90xtn5+4CAfHRMDci785jbbdLhfouc57/jcT/T/rE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700538807; c=relaxed/simple; bh=YHTTg2vNGs8DCLF4+8LOinIJMBgZseliytWgPoWurVs=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=LC6ZyldHb2KR6y0BQIUw9HOCOUJkzfrac0vo2QrMTqxQcMfxJZ9iVuUDIUW9xt9vCp4gGPkpKay4M7Dhb6eR5mfT3i463FPUoq+d7deE+aSE9lbtnsff0HcxZWPK0Jt8//7f39gKFGd5hZIiops5TH48EnXlq4eowBtUuudQ5NE= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from eig-obgw-6008a.ext.cloudfilter.net ([10.0.30.227]) by cmsmtp with ESMTPS id 5BnFrnJkOWcCI5HpCrZVLy; Tue, 21 Nov 2023 03:53:22 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id 5HpBrVJ6r0xkr5HpCrJQLd; Tue, 21 Nov 2023 03:53:22 +0000 X-Authority-Analysis: v=2.4 cv=N7U6qkxB c=1 sm=1 tr=0 ts=655c29b2 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=8Veq67EhIFtdNKN4G4AA:9 a=QEXdDO2ut3YA:10 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=To:In-Reply-To:References:Message-Id:Content-Transfer-Encoding: Content-Type:MIME-Version:Subject:Date:From:Sender:Reply-To:Cc:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=PjInMVwPw/1PsW106yT4f4e8KEJp7t6OAiP1bWYJXpU=; b=WGQVwK7NQvVhLNnInuLI0QqKMx QiqWAU1zQTX9YVnnTcQMkymEbALzKEmx+OVU/luCVyk8KAhK2sNF1JarcLdpJhmVxQCkyAr1Daisn r8u6Kvs6UTyU84LQogNeOtIQU; 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 1r5HpB-0040be-2C for gdb-patches@sourceware.org; Mon, 20 Nov 2023 20:53:21 -0700 From: Tom Tromey Date: Mon, 20 Nov 2023 20:53:53 -0700 Subject: [PATCH 22/29] Only search for "main" as a function MIME-Version: 1.0 Message-Id: <20231120-submit-domain-hacks-2-v1-22-29650d01b198@tromey.com> References: <20231120-submit-domain-hacks-2-v1-0-29650d01b198@tromey.com> In-Reply-To: <20231120-submit-domain-hacks-2-v1-0-29650d01b198@tromey.com> 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: 1r5HpB-0040be-2C 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: 23 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfNNLrnzoinVPsFVx63DnE1P73EY5teuZM1tlgDQK1D4JXlhHY6YNxP95mclp2QF5+pt+d1NH0WW2i+NPfWGgZmyfJOYhbrVNEaW/7Idh0GP39eHnYbh4 iwhL8OrOrTnLKta2ipZxcSj6nduxDVu7UOTV7YIvMpTHr6aHk/GsZnkRhTYzuoKbi4hf+iSRQ9YmG0j1DfhxGusPqO5dVgJgkH4= X-Spam-Status: No, score=-3024.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham 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 This changes find_main_name to restrict its search to the function domain. --- gdb/symtab.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gdb/symtab.c b/gdb/symtab.c index 3d7a5a1811b..b02204cc430 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -6336,7 +6336,8 @@ find_main_name (void) [&symbol_found_p, pspace] (objfile *obj) { language lang - = obj->lookup_global_symbol_language ("main", SEARCH_VFT, + = obj->lookup_global_symbol_language ("main", + SEARCH_FUNCTION_DOMAIN, &symbol_found_p); if (symbol_found_p) { From patchwork Tue Nov 21 03:53:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 80407 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 0EEA2385842B for ; Tue, 21 Nov 2023 03:55:10 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from omta040.useast.a.cloudfilter.net (omta040.useast.a.cloudfilter.net [44.202.169.39]) by sourceware.org (Postfix) with ESMTPS id 2209B3858C30 for ; Tue, 21 Nov 2023 03:53:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2209B3858C30 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 2209B3858C30 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=44.202.169.39 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700538809; cv=none; b=A72Eb7rxzTj6/RM8AKg/vu/UgxQ+JF/+9QXCC5ZFp7+v1Q2zxiToOacpEga7yabLODmN8SaXVQdbnNFvRxA/IxFJGL7gHbqC/5ooEQUpL5/YYF3HNsJDzW4hq3zEwmXTJ5dp9Ef7lEMCyNr98NVNGbQlyb9teYktoagc+qeCdFo= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700538809; c=relaxed/simple; bh=KxjnFnti1Kp/eXbcwF9biWfdqDNfLpLKYz839xx1Y28=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=OQzM63uTQg/IIfqoOTEiwwuT+JTjNdySTx6QM90Xzbhs35DNQxoyQb1yoyLclGO3V7z2yCmO6euA/QibV5OapD6krTsC2zN+AiFyYQOx1saYlQV7OvxLNBtrSZwA3KngVPZdRPKSWqpmswc3A9KAVVRCEGGTO2HV8gjj0JIBcp0= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from eig-obgw-6001a.ext.cloudfilter.net ([10.0.30.140]) by cmsmtp with ESMTPS id 579wroRhD6nOZ5HpCrzrPj; Tue, 21 Nov 2023 03:53:23 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id 5HpCrwHzOb8Qn5HpCr3fl6; Tue, 21 Nov 2023 03:53:22 +0000 X-Authority-Analysis: v=2.4 cv=IuQNzZzg c=1 sm=1 tr=0 ts=655c29b2 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=1eGJtVPQ-MQg7gw_q08A:9 a=QEXdDO2ut3YA:10 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=To:In-Reply-To:References:Message-Id:Content-Transfer-Encoding: Content-Type:MIME-Version:Subject:Date:From:Sender:Reply-To:Cc:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=T5zHXraqhbKyqaneMVNhNp7QLSneKD7dxRjCzWSrr48=; b=CdS65kworfyurRRc0NJZCx12/t rRXMuYjF/DdFCBE7rUGj8zmeqoSwnrpOyUdhLH/f/2/HuLB0HRs5p2JX2JDxBOCw/Pue6JLYvHW41 vQ8jwS3g3TRJ/dkRgjAPZr76e; 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 1r5HpB-0040be-2d for gdb-patches@sourceware.org; Mon, 20 Nov 2023 20:53:21 -0700 From: Tom Tromey Date: Mon, 20 Nov 2023 20:53:54 -0700 Subject: [PATCH 23/29] Only look for functions in expand_symtabs_for_function MIME-Version: 1.0 Message-Id: <20231120-submit-domain-hacks-2-v1-23-29650d01b198@tromey.com> References: <20231120-submit-domain-hacks-2-v1-0-29650d01b198@tromey.com> In-Reply-To: <20231120-submit-domain-hacks-2-v1-0-29650d01b198@tromey.com> 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: 1r5HpB-0040be-2d 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: 24 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfKEe4EcG6f4MFFWTbhh3eCyKP2eZCNgmwsqcbNjS7rL0AMQhCSbgwhL6P0i8/EQbax2hJcPiwaOLYA2eakpgnq56YNl/MWQ7jJ5/kqNSBoO81Rl5AIOo pM2uNx6GYj8mHtTB4kLzB7c203T0RV9J+1J3tuWBFL/VIXIDiEE+qACsoHGHaP/tOyYvVLicQNibXpQMLTCzOvisV2mWkscYryM= X-Spam-Status: No, score=-3024.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham 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 This changes expand_symtabs_for_function to only look in the function domain. --- gdb/symfile-debug.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gdb/symfile-debug.c b/gdb/symfile-debug.c index e7cf25effa9..a21735e9868 100644 --- a/gdb/symfile-debug.c +++ b/gdb/symfile-debug.c @@ -346,7 +346,7 @@ objfile::expand_symtabs_for_function (const char *func_name) nullptr, (SEARCH_GLOBAL_BLOCK | SEARCH_STATIC_BLOCK), - SEARCH_VFT); + SEARCH_FUNCTION_DOMAIN); } void From patchwork Tue Nov 21 03:53:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 80410 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 B01953858000 for ; Tue, 21 Nov 2023 03:55:28 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from omta38.uswest2.a.cloudfilter.net (omta38.uswest2.a.cloudfilter.net [35.89.44.37]) by sourceware.org (Postfix) with ESMTPS id C33E53858409 for ; Tue, 21 Nov 2023 03:53:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C33E53858409 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 C33E53858409 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=35.89.44.37 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700538810; cv=none; b=erevqMoArq5NLRHSAq6PsJhlkzCcqYBJNNZEo75h/8dCv1P64xWtemNbBQ7acHOHYYIrTh7eRpnnsADl2kj/AGXbJdqSyZwIayUbZqIZPZmB6CwQ9+NVX+6PsweDrh2ZDvKD48zZxfeCf+087UjLpVflg99jAuxM2cyXTlX7eNI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700538810; c=relaxed/simple; bh=l4fLe1FMS/a54Ut+TRTSKviGttoBvCbR/FRKTMioyhk=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=gZj0spCx4c+lvjpfdJCo6T44BJavCQcnMmYo6WqAn2lcvyYVr4Us3RTxwTRQOUcAHPzEc92o4pUltFwYdjKpo+MZ6/XIyhByfFScHOeLo2HaOI6cgHrW9A28qUrCPJ5ayQShxHC6haGd4RR8dtNz/dJtTYLyNhzxoDx4eYFnOTw= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from eig-obgw-6009a.ext.cloudfilter.net ([10.0.30.184]) by cmsmtp with ESMTPS id 5Byur80tVKOkL5HpDrTDxO; Tue, 21 Nov 2023 03:53:23 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id 5HpCrNHyCBOcc5HpCrSvCS; Tue, 21 Nov 2023 03:53:22 +0000 X-Authority-Analysis: v=2.4 cv=J+25USrS c=1 sm=1 tr=0 ts=655c29b2 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=yUApLfCiZwldzDNlM_8A:9 a=QEXdDO2ut3YA:10 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=To:In-Reply-To:References:Message-Id:Content-Transfer-Encoding: Content-Type:MIME-Version:Subject:Date:From:Sender:Reply-To:Cc:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=uvAjFcM8sEbQ83wcTlwIqmE0sDYWiEH1T4BdydyasNk=; b=GqvtqbrWfyAgCTOMvG5fmiALpY EeUcgoJvHvt8RBUAHTvK9BRMnUnzItXMbRddjayP6i0JUEt+/UVT0O/mpU1Bh+I8DKM1NEtPs/Xnx gpjbcIy/tHOzPpZzyyazu7m6/; 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 1r5HpB-0040be-33 for gdb-patches@sourceware.org; Mon, 20 Nov 2023 20:53:21 -0700 From: Tom Tromey Date: Mon, 20 Nov 2023 20:53:55 -0700 Subject: [PATCH 24/29] Use a function-domain search in inside_main_func MIME-Version: 1.0 Message-Id: <20231120-submit-domain-hacks-2-v1-24-29650d01b198@tromey.com> References: <20231120-submit-domain-hacks-2-v1-0-29650d01b198@tromey.com> In-Reply-To: <20231120-submit-domain-hacks-2-v1-0-29650d01b198@tromey.com> 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: 1r5HpB-0040be-33 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: 25 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfL8vl3FzoCOFLRXx/IQaKatdN9C5tNMr8rjhJseT2ouATvv3Rln1lJaB3gMddEdbISPreqIR+H64xmniTxhcAC8ufguRnuOCReK1nUvgratAHt6TYEZG gJY8Fo59dFIv5AF0qF9k++XM161P0P+kLJioa8TBUz049qxcKn4rTZavxgpO+L2s1L8HCj4XRE2NJ7T1Ez2hAkgQf0UL2YxINoA= X-Spam-Status: No, score=-3024.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham 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 This changes inside_main_func to search only for functions. --- gdb/frame.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/gdb/frame.c b/gdb/frame.c index ce558bf6149..e86299491e2 100644 --- a/gdb/frame.c +++ b/gdb/frame.c @@ -2566,13 +2566,9 @@ inside_main_func (frame_info_ptr this_frame) symbol with the name of the main function. In this case we should search the full symbols to see if we can find a match. */ struct block_symbol bs = lookup_symbol (name, nullptr, - SEARCH_VFT, nullptr); + SEARCH_FUNCTION_DOMAIN, nullptr); - /* We might have found some unrelated symbol. For example, the - Rust compiler can emit both a subprogram and a namespace with - the same name in the same scope; and due to how gdb's symbol - tables currently work, we can't request the one we'd - prefer. */ + /* This lookup should always yield a block-valued symbol. */ if (bs.symbol != nullptr && bs.symbol->aclass () == LOC_BLOCK) { const struct block *block = bs.symbol->value_block (); From patchwork Tue Nov 21 03:53:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 80413 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 3925D385840C for ; Tue, 21 Nov 2023 03:55:47 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from omta040.useast.a.cloudfilter.net (omta040.useast.a.cloudfilter.net [44.202.169.39]) by sourceware.org (Postfix) with ESMTPS id 1CFEA3858C2F for ; Tue, 21 Nov 2023 03:53:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1CFEA3858C2F 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 1CFEA3858C2F Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=44.202.169.39 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700538808; cv=none; b=izp5meU6L+nnTA1h8VWZavRzD0AfM/Oh8/CNAA2PUS507UiTi6YWRm+DgTYuvKktM2QBG2e5fdfDzYHO3li6h7XFwJ3yHIfGYKkqxlpmxi+t3DBGjfxYeSNg/DCx8G6q3OBw5w2DhqXbUGEONndwobZAJVzAB/zjzCISALG4F+c= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700538808; c=relaxed/simple; bh=QvQdWMFCJ9fu4jSVWbuPAY8vWmL9UEdMdq/clSdDNj0=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=ks733AqJy5eJN822538hNnDDZl1Q9d61GzqtrCph/nEkIZ8B66GJc2cSgUrvF76m4QULp8US8RGg5tZCgnZtWkBKW1YzB4rYtgmSJcovURXWY1yMkgi7VanAjvwBPZBTVjE4aBhXR9AVZGQ1BZLvNQd0JdOjWJXLSz10PVkhwuY= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from eig-obgw-5001a.ext.cloudfilter.net ([10.0.29.139]) by cmsmtp with ESMTPS id 5Bpyrpjon6nOZ5HpDrzrPq; Tue, 21 Nov 2023 03:53:23 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id 5HpCrCu9rkTVW5HpCr6qTc; Tue, 21 Nov 2023 03:53:22 +0000 X-Authority-Analysis: v=2.4 cv=a58jSGeF c=1 sm=1 tr=0 ts=655c29b2 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=DXojhDegXKjf2IFW-d0A:9 a=QEXdDO2ut3YA:10 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=To:In-Reply-To:References:Message-Id:Content-Transfer-Encoding: Content-Type:MIME-Version:Subject:Date:From:Sender:Reply-To:Cc:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=rFn0I5IYHp1KPzASK6hYXlltAPsctdLsrMy+HhO3PG8=; b=lkAmUVA8oPvSvxkD00wFQPuEys okWxitPosbBvilqkmeB5kgoRxbH0SgcgolnJS+gone7SRGCgmhGacVGdu77N9ip68amesCsZ1+tyv WQbLOF1vjuE5FBgQDlRUQLiww; 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 1r5HpC-0040be-0L for gdb-patches@sourceware.org; Mon, 20 Nov 2023 20:53:22 -0700 From: Tom Tromey Date: Mon, 20 Nov 2023 20:53:56 -0700 Subject: [PATCH 25/29] Only search types in cp_lookup_rtti_type MIME-Version: 1.0 Message-Id: <20231120-submit-domain-hacks-2-v1-25-29650d01b198@tromey.com> References: <20231120-submit-domain-hacks-2-v1-0-29650d01b198@tromey.com> In-Reply-To: <20231120-submit-domain-hacks-2-v1-0-29650d01b198@tromey.com> 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: 1r5HpC-0040be-0L 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: 26 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfGpHMBEuBKlMKGYid3WPzQwkwD8x4cyEjU0h4El5HaQQWw5Eskcuvw+3ADsQ5zJ4uX1OwTGnuq2QSNE0+wcevzjNlSC5E/OFbbvBDBkPd0mz94wiGXjX swo50Dl7scvKPpinauEGWWd0ndqLOcl3h6p4vbIkMsRlcqUa0/vs0ZKrxxLmfYJd+R0spOWfnu8K8Q+VKtNe9ujBXxiTe2dQtME= X-Spam-Status: No, score=-3024.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham 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 This changes cp_lookup_rtti_type to only search for types -- not functions or variables. Due to the symbol-matching hack, this could just use SEARCH_TYPE_DOMAIN, but I think it's better to be clear; also I hold on to some hope that perhaps the hack can someday be removed. --- gdb/cp-support.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gdb/cp-support.c b/gdb/cp-support.c index 6b228362d18..33867d2a272 100644 --- a/gdb/cp-support.c +++ b/gdb/cp-support.c @@ -1498,9 +1498,9 @@ cp_lookup_rtti_type (const char *name, const struct block *block) struct symbol * rtti_sym; struct type * rtti_type; - /* Use VAR_DOMAIN here as NAME may be a typedef. PR 18141, 18417. - Classes "live" in both STRUCT_DOMAIN and VAR_DOMAIN. */ - rtti_sym = lookup_symbol (name, block, SEARCH_VFT, NULL).symbol; + rtti_sym = lookup_symbol (name, block, + SEARCH_TYPE_DOMAIN | SEARCH_STRUCT_DOMAIN, + nullptr).symbol; if (rtti_sym == NULL) { From patchwork Tue Nov 21 03:53:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 80417 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 D6A623858409 for ; Tue, 21 Nov 2023 03:56:19 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from omta036.useast.a.cloudfilter.net (omta036.useast.a.cloudfilter.net [44.202.169.35]) by sourceware.org (Postfix) with ESMTPS id 3C8C53858C31 for ; Tue, 21 Nov 2023 03:53:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3C8C53858C31 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 3C8C53858C31 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=44.202.169.35 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700538809; cv=none; b=o60zV2He/J46ybKLLtehOIzZrBF/D/X9zEQXRoPbyOAoHCbzNO5r13zuoRKJM+TGQkqccmt21hor7eMn+zdxxpwMB+WLJiIwSh8lVYPATCZGA+39ZpKviI9+CbebebAlSR57aHv8USfsjNecRnIMBwD0+PjR10ttvh2n0GDP8TU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700538809; c=relaxed/simple; bh=OzDpqOMVm4pNBFJ4U8NvhYK6b0x8Y5OhnUxY1SrBHLE=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=Z/ENRBvsv/7D0EBwA55ehkw+v31z01SuTFe+2J/cbCVofK7pjC4hPjVMxha+GjDeJKPRq+CQj6xyLbJaPVnhR110jLvPUxH4YIus2fe21dI1ApGa7Rre2BmPIXZEQhb5s3NEgAxlniqOuW/svwPaxYkYMiovPIHJOoyb7V2VFpc= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from eig-obgw-5009a.ext.cloudfilter.net ([10.0.29.176]) by cmsmtp with ESMTPS id 5ByurKQgFgpyE5HpDrHEhW; Tue, 21 Nov 2023 03:53:23 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id 5HpCrzUKm97pz5HpCrriA1; Tue, 21 Nov 2023 03:53:23 +0000 X-Authority-Analysis: v=2.4 cv=ULDOoQTy c=1 sm=1 tr=0 ts=655c29b3 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=cYCz3hqAlafZEMwgip4A:9 a=QEXdDO2ut3YA:10 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=To:In-Reply-To:References:Message-Id:Content-Transfer-Encoding: Content-Type:MIME-Version:Subject:Date:From:Sender:Reply-To:Cc:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=x47XoRLaVWTD7dD0+v1oWDYr1iAqxR9RT/hTPva5LkE=; b=R+b2eKbliIqdFuOKTZ8Aw/YrY2 SfKtDeKJyMtiaFg4uInu3sv9F0Ew48L+Mj739uvM8VYGKReUl68ecymMYLlrB+ZI06FIRDemxRkcz yHvSM8cfSV+Zd1gFm40k5YGQf; 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 1r5HpC-0040be-0l for gdb-patches@sourceware.org; Mon, 20 Nov 2023 20:53:22 -0700 From: Tom Tromey Date: Mon, 20 Nov 2023 20:53:57 -0700 Subject: [PATCH 26/29] Only search types in lookup_typename MIME-Version: 1.0 Message-Id: <20231120-submit-domain-hacks-2-v1-26-29650d01b198@tromey.com> References: <20231120-submit-domain-hacks-2-v1-0-29650d01b198@tromey.com> In-Reply-To: <20231120-submit-domain-hacks-2-v1-0-29650d01b198@tromey.com> 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: 1r5HpC-0040be-0l 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: 27 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfEB9o8vlyMY4Q7H20Rxum8JV3C1X6t6rUB9Od9PqIavHgSAW4G8Py4B7qIeX08QeoKgUHTp142aDX00qW7RCmqu8GrNwxUKsOaY5pdVvhtNIiWSD5/eH PPJEteYy2ar6O6KBTxmUqkggEbpX2iPSNT0UcV9b8i1RH1KjAFeTSCgX425+05si/xh9ReqZtY6PktX8UDBEALF+pJ0OVMGth40= X-Spam-Status: No, score=-3024.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham 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 This changes lookup_typename to only look for types. The check for LOC_TYPEDEF can now also be removed, because only types will appear in TYPE_DOMAIN. --- gdb/gdbtypes.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index 3e35ae8ba0a..2031653e534 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -1654,9 +1654,9 @@ lookup_typename (const struct language_defn *language, { struct symbol *sym; - sym = lookup_symbol_in_language (name, block, SEARCH_VFT, + sym = lookup_symbol_in_language (name, block, SEARCH_TYPE_DOMAIN, language->la_language, NULL).symbol; - if (sym != NULL && sym->aclass () == LOC_TYPEDEF) + if (sym != nullptr) { struct type *type = sym->type (); /* Ensure the length of TYPE is valid. */ From patchwork Tue Nov 21 03:53:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 80414 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 3C4203858430 for ; Tue, 21 Nov 2023 03:55:50 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from omta38.uswest2.a.cloudfilter.net (omta38.uswest2.a.cloudfilter.net [35.89.44.37]) by sourceware.org (Postfix) with ESMTPS id 7C2C73858428 for ; Tue, 21 Nov 2023 03:53:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7C2C73858428 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 7C2C73858428 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=35.89.44.37 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700538811; cv=none; b=hrK0910ucDS+39tyiiLa7P11f3oKs0Whgpo9BEaP7L5G1+7262l5O2/T3ILgGhUFRIvCfs3HXUx+2DkrCWjgNLojL7s+TMTotLszxTwBXHeT6mntnvJ3yi0QDHRTpQ7zOHRUW8Or21m2pIVIXqWUVFQ82+Y5dOCj2KzcKzGFzro= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700538811; c=relaxed/simple; bh=xjGbsrXCcYXrfX+oD7mpnClpionuhOGoNwvQ150IiU4=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=hk6FPvzqZd+4QBoAVBFN7vpfziZ36ofsFMW9TbgPnx+XfZSCHVI2ih7l0O/s6du8UgNw5vReNNMPn36X8lJKq//6CXHdqoaMR+44lLqwjLbqTffTVH4cUUAT3IlhbFK8IHXbh32Mkqe3KZJvXtocF/URnNDylcqBu3WsV/KhetY= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from eig-obgw-5005a.ext.cloudfilter.net ([10.0.29.234]) by cmsmtp with ESMTPS id 57cyr6okBKOkL5HpDrTDxY; Tue, 21 Nov 2023 03:53:23 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id 5HpCrBrLz1b9N5HpCrL4I4; Tue, 21 Nov 2023 03:53:23 +0000 X-Authority-Analysis: v=2.4 cv=FLYIesks c=1 sm=1 tr=0 ts=655c29b3 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=nqHERdTwHaLE-7x9c5UA:9 a=QEXdDO2ut3YA:10 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=To:In-Reply-To:References:Message-Id:Content-Transfer-Encoding: Content-Type:MIME-Version:Subject:Date:From:Sender:Reply-To:Cc:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=Tiip58YX9lRX+r8PNY0Y+oCOOPh+qcmAbR4BIR8HYwE=; b=h6dF1lkHdRtbpUGWys7IHHCPzz O+kPz8/jj5Tw35pBLGXQlzLmo6n1VZv1JqXO11XhbV1tiyrdWsj0vFkG4NbmRqrS7WAG06CC9Qi4S PJkZZUEZ6/ibSt5xCbtUs5u8v; 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 1r5HpC-0040be-1B for gdb-patches@sourceware.org; Mon, 20 Nov 2023 20:53:22 -0700 From: Tom Tromey Date: Mon, 20 Nov 2023 20:53:58 -0700 Subject: [PATCH 27/29] Only search for functions in rust_structop::evaluate_funcall MIME-Version: 1.0 Message-Id: <20231120-submit-domain-hacks-2-v1-27-29650d01b198@tromey.com> References: <20231120-submit-domain-hacks-2-v1-0-29650d01b198@tromey.com> In-Reply-To: <20231120-submit-domain-hacks-2-v1-0-29650d01b198@tromey.com> 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: 1r5HpC-0040be-1B 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: 28 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfAPYr8o1Tm7zBWfqF/Wpxddwt9WqTzA988naPq1xOdplIoDys7X02qTbtsAuF5pKo2OhN3ltBIDExtXcGiClu/KutiCfrza3TllMKQhhO2PSsOvpyz2e 2wGPILjyMZAd+k8NaMtabGSnEybI692V54v62mtdVwjL/eNXRUQGA/YL6R5Ohvg+zp8eKJ0m96PY7lhFY+eo85bc/W7aMlJJGe4= X-Spam-Status: No, score=-3024.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham 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 This changes rust_structop::evaluate_funcall to only search for functions. --- gdb/rust-lang.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c index bbba5acd535..a95409995b8 100644 --- a/gdb/rust-lang.c +++ b/gdb/rust-lang.c @@ -1563,7 +1563,7 @@ rust_structop::evaluate_funcall (struct type *expect_type, const struct block *block = get_selected_block (0); struct block_symbol sym = lookup_symbol (name.c_str (), block, - SEARCH_VFT, + SEARCH_FUNCTION_DOMAIN, nullptr); if (sym.symbol == NULL) error (_("Could not find function named '%s'"), name.c_str ()); From patchwork Tue Nov 21 03:53:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 80415 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 A34203858CDA for ; Tue, 21 Nov 2023 03:56:01 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from omta34.uswest2.a.cloudfilter.net (omta34.uswest2.a.cloudfilter.net [35.89.44.33]) by sourceware.org (Postfix) with ESMTPS id 13C653858413 for ; Tue, 21 Nov 2023 03:53:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 13C653858413 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 13C653858413 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=35.89.44.33 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700538811; cv=none; b=xltQ7P4waxeMCF0qMABhFST7E7QduHPDqFoL0vtH2Jv8KOfZgpogWN3TRjfDPNEG/XjSEu7DDvgyOquRSXthleP81l7gNDgHqCnJdBkynb6AugOd17fSMvgDbl+jJnoQCWyWoA1mkSsfk8cuEkC7+lgF9tqaarEcgiYUpPsTct4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700538811; c=relaxed/simple; bh=NyEb5sGbt8fbxetbCIhwUrR9gUcth7t/hzjGevji7zA=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=lF+eUh2R0LU74bAv4Gxgzp8c651q6qUbLGbtmjqWIwb4LOjWfdF/81tJEYo1FeqUK4GKRenTa/LQ4WBi123AzZTpHtjYTFX1Yz1KBPj4GBrQkZDb3XoVX8UAzPvNt2GL+uk6X1GBJJFgpg3Q1M7FINQE2Sq10RxgjRH5v/uBtls= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from eig-obgw-6010a.ext.cloudfilter.net ([10.0.30.248]) by cmsmtp with ESMTPS id 5BwbrSPny8Hte5HpDrHZXG; Tue, 21 Nov 2023 03:53:23 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id 5HpCrSMLu8vT05HpDrMCz4; Tue, 21 Nov 2023 03:53:23 +0000 X-Authority-Analysis: v=2.4 cv=ffi+dmcF c=1 sm=1 tr=0 ts=655c29b3 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=ABg-ZwUhIPAXn4CSIH0A:9 a=QEXdDO2ut3YA:10 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=To:In-Reply-To:References:Message-Id:Content-Transfer-Encoding: Content-Type:MIME-Version:Subject:Date:From:Sender:Reply-To:Cc:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=5hOQpaDgqe9jfKHHvCJV/c9xX8I53n7mWxggWiFxKe8=; b=nR5+OdmYcuBZ5jZ6y5JjA5txN6 7UNqNDA+eB/Tqllnf9Pkv6dQ/xfTJTrPqZ79Fjuzksv00QPnGPq0QkL9VcehDJ27YFDMrEHO1vjvL 42OGJvjoisPYArtznunjFG6gK; 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 1r5HpC-0040be-1e for gdb-patches@sourceware.org; Mon, 20 Nov 2023 20:53:22 -0700 From: Tom Tromey Date: Mon, 20 Nov 2023 20:53:59 -0700 Subject: [PATCH 28/29] Refine search in cp_search_static_and_baseclasses MIME-Version: 1.0 Message-Id: <20231120-submit-domain-hacks-2-v1-28-29650d01b198@tromey.com> References: <20231120-submit-domain-hacks-2-v1-0-29650d01b198@tromey.com> In-Reply-To: <20231120-submit-domain-hacks-2-v1-0-29650d01b198@tromey.com> 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: 1r5HpC-0040be-1e 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: 29 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfDEam2odwz2aB5MVcQounTAIB4pOpTYGYPaElVK9ZBe6WetUnk58hj9/I3TmpOsyP/LHyq4tg+iE03f85oZnWF10553mIlprQ9FUXZvQNZZ9QC13ERrY FUy53hw2QTXIE8/fWyhmKN4Qyw/9J7hODoe3J1qM/Ee4DSvR48R0NAe/pVr8hWL56u6WEkfFSqCqzERJNa0EMZUPyy6BncCoFE4= X-Spam-Status: No, score=-3024.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham 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 This changes cp_search_static_and_baseclasses to only search for types, functions, and modules. The latter two cases were discovered by regression testing. I found it somewhat surprising the Fortran name lookup ends up in this code, but did not attempt to change this. --- gdb/cp-namespace.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/gdb/cp-namespace.c b/gdb/cp-namespace.c index 7c1e9576800..933d2b10cd5 100644 --- a/gdb/cp-namespace.c +++ b/gdb/cp-namespace.c @@ -268,14 +268,19 @@ cp_search_static_and_baseclasses (const char *name, const char *nested = name + prefix_len + 2; /* Lookup the scope symbol. If none is found, there is nothing more - that can be done. SCOPE could be a namespace, so always look in - VAR_DOMAIN. This works for classes too because of - symbol_matches_domain (which should be replaced with something - else, but it's what we have today). */ - block_symbol scope_sym = lookup_symbol_in_static_block (scope.c_str (), - block, SEARCH_VFT); + that can be done. SCOPE could be a namespace, a class, or even a + function. This code is also used by Fortran, so modules are + included in the search as well. */ + block_symbol scope_sym + = lookup_symbol_in_static_block (scope.c_str (), block, + SEARCH_TYPE_DOMAIN + | SEARCH_FUNCTION_DOMAIN + | SEARCH_MODULE_DOMAIN); if (scope_sym.symbol == NULL) - scope_sym = lookup_global_symbol (scope.c_str (), block, SEARCH_VFT); + scope_sym = lookup_global_symbol (scope.c_str (), block, + SEARCH_TYPE_DOMAIN + | SEARCH_FUNCTION_DOMAIN + | SEARCH_MODULE_DOMAIN); if (scope_sym.symbol == NULL) return {}; From patchwork Tue Nov 21 03:54:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 80412 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 1D0283858438 for ; Tue, 21 Nov 2023 03:55:46 +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 B00E33858401 for ; Tue, 21 Nov 2023 03:53:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B00E33858401 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 B00E33858401 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=1700538810; cv=none; b=nUBBgbA3OjllVc9AgjgQVLqbW4ufkfaDotXslHTt7Upw7v34kyDTu55lI4hkRZaGFDHnt7euO9UrAmwNtbnCN6WMTBDcG3kIMOv5y48cku2QDk5fvh4UoA7maQBfhliVhXLpb73RNuTdhXxHhw8TBRwertnuoukzbbdTJKWV4IY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700538810; c=relaxed/simple; bh=SZOJfVqlIpyegN6Avj2I6CbYkWeLiizwOJ6AJcMXk7k=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=RU9gCK2QhHz0qEe7CaQzGIhXcogOSYpNRVPog6fZh35tlau+t5BY5FMexu9f7ZtHbwJ/qBhQh0BkhbTVzDrpCIXOrOH5cm6xX9svRd2rrIetxRrzK6GXfUANPS/NstMPPZVP9Brmq5cZE7QZx6d87KC9t77yk1C42jrDKVNgAXs= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from eig-obgw-6002a.ext.cloudfilter.net ([10.0.30.222]) by cmsmtp with ESMTPS id 5BpgrnKJqWcCI5HpDrZVME; Tue, 21 Nov 2023 03:53:23 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id 5HpCr57v3M0U25HpDrctNO; Tue, 21 Nov 2023 03:53:23 +0000 X-Authority-Analysis: v=2.4 cv=BuKOfKb5 c=1 sm=1 tr=0 ts=655c29b3 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=jKitsVYuo9LPnbjpB04A:9 a=QEXdDO2ut3YA:10 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=To:In-Reply-To:References:Message-Id:Content-Transfer-Encoding: Content-Type:MIME-Version:Subject:Date:From:Sender:Reply-To:Cc:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=MlLyFg5+IGFrSECFOhm0T0TC0bFoOspmzFkz37goxwo=; b=kUeAG5mL72QpnnzKjY6sMppct/ Si5NCdNHgKLN/OyaOofDPSwlen6sTGt4wbwFb3TcJzk0RAngSgFvTW77N/QqkG3+WSKLDK+jZ25uh 3q7Q7snzbwSVXDDaqAVDWhyJc; 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 1r5HpC-0040be-25 for gdb-patches@sourceware.org; Mon, 20 Nov 2023 20:53:22 -0700 From: Tom Tromey Date: Mon, 20 Nov 2023 20:54:00 -0700 Subject: [PATCH 29/29] Document new Python and Guile constants MIME-Version: 1.0 Message-Id: <20231120-submit-domain-hacks-2-v1-29-29650d01b198@tromey.com> References: <20231120-submit-domain-hacks-2-v1-0-29650d01b198@tromey.com> In-Reply-To: <20231120-submit-domain-hacks-2-v1-0-29650d01b198@tromey.com> 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: 1r5HpC-0040be-25 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: 30 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfO6cN58o7WuKZXUT5MCny5xyjbdcdUNWxvJ3ArSH2BTBsUOjqFjE2qsopc1aR8ujCSrNxFwiF4PfvdKiMS3Hgcp4uGwzOMKfRIpi5zqo7dtvwN94TXpW BBoK+P7RYH+I7qKCIZm9aaDsL3U37ZWJNIWJmbnv8ASiONjx2qIm0xqtGqhJEn90qgMBDwMn9hMNMMnjhrWnXXUALBVXo0Dm8WI= X-Spam-Status: No, score=-3023.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_STOCKGEN, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham 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 This documents the new Python and Guile constants introduced earlier in this series. Reviewed-By: Eli Zaretskii --- gdb/NEWS | 12 ++++++++++++ gdb/doc/guile.texi | 13 +++++++++++++ gdb/doc/python.texi | 30 +++++++++++++++++++++++++++--- 3 files changed, 52 insertions(+), 3 deletions(-) diff --git a/gdb/NEWS b/gdb/NEWS index 1073e38dfc6..93fee9a8044 100644 --- a/gdb/NEWS +++ b/gdb/NEWS @@ -57,6 +57,18 @@ show remote thread-options-packet sub-classed to create handlers for objfiles with missing debug information. + ** New constants gdb.SYMBOL_TYPE_DOMAIN, gdb.SYMBOL_FUNCTION_DOMAIN, + and gdb.SEARCH_*_DOMAIN corresponding to all the existing symbol + domains. Symbol lookup can now search in multiple domains at + once, and can also narrowly search for just a type or function. + +* Guile API + + ** New constants SYMBOL_TYPE_DOMAIN, SYMBOL_FUNCTION_DOMAIN, and + SEARCH_*_DOMAIN corresponding to all the existing symbol domains. + Symbol lookup can now search in multiple domains at once, and can + also narrowly search for just a type or function. + * New remote packets New stop reason: clone diff --git a/gdb/doc/guile.texi b/gdb/doc/guile.texi index aae0c6a5cc9..4ac3f372b0a 100644 --- a/gdb/doc/guile.texi +++ b/gdb/doc/guile.texi @@ -2802,6 +2802,14 @@ in the symbol information or in @value{GDBN}'s handling of symbols. This domain contains variables, function names, typedef names and enum type values. +@item SYMBOL_FUNCTION_DOMAIN +This domain contains functions. + +@item SYMBOL_TYPE_DOMAIN +This domain contains types. In a C-like language, types using a tag +will not appear here; in other languages, all types are in this +domain. + @item SYMBOL_STRUCT_DOMAIN This domain holds struct, union and enum type names. @@ -2822,6 +2830,11 @@ This domain contains all types. The available address class categories in @code{} are represented as constants in the @code{gdb} module: +When searching for a symbol, the desired domain constant can be passed +verbatim to the lookup function. For more complex searches, there is +a corresponding set of constants using a @samp{SEARCH_} prefix. These +may be or'd together to form a search constant. + @vtable @code @item SYMBOL_LOC_UNDEF If this is returned by address class, it indicates an error either in diff --git a/gdb/doc/python.texi b/gdb/doc/python.texi index b65991bbad0..0e8d0f4c22c 100644 --- a/gdb/doc/python.texi +++ b/gdb/doc/python.texi @@ -6088,12 +6088,22 @@ in the symbol information or in @value{GDBN}'s handling of symbols. @vindex SYMBOL_VAR_DOMAIN @item gdb.SYMBOL_VAR_DOMAIN -This domain contains variables, function names, typedef names and enum -type values. +This domain contains variables. + +@vindex SYMBOL_FUNCTION_DOMAIN +@item gdb.SYMBOL_FUNCTION_DOMAIN +This domain contains functions. + +@vindex SYMBOL_TYPE_DOMAIN +@item gdb.SYMBOL_TYPE_DOMAIN +This domain contains types. In a C-like language, types using a tag +will not appear here; in other languages, all types are in this +domain. @vindex SYMBOL_STRUCT_DOMAIN @item gdb.SYMBOL_STRUCT_DOMAIN -This domain holds struct, union and enum type names. +This domain holds struct, union and enum tag names. This domain is +only used for C-like languages. @vindex SYMBOL_LABEL_DOMAIN @item gdb.SYMBOL_LABEL_DOMAIN @@ -6108,6 +6118,20 @@ This domain contains names of Fortran module types. This domain contains names of Fortran common blocks. @end vtable +When searching for a symbol, the desired domain constant can be passed +verbatim to the lookup function. For example: +@smallexample +symbol = gdb.lookup_symbol ("name", domain=gdb.SYMBOL_VAR_DOMAIN) +@end smallexample + +For more complex searches, there is a corresponding set of constants +using a @samp{SEARCH_} prefix. These may be or'd together to form a +search constant, e.g.: +@smallexample +symbol = gdb.lookup_symbol ("name", + domain=gdb.SEARCH_VAR_DOMAIN | gdb.SEARCH_TYPE_DOMAIN) +@end smallexample + The available address class categories in @code{gdb.Symbol} are represented as constants in the @code{gdb} module: