From patchwork Fri Jan 20 21:45: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: 63516 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 016913857C4F for ; Fri, 20 Jan 2023 21:46:49 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from gproxy1-pub.mail.unifiedlayer.com (gproxy1-pub.mail.unifiedlayer.com [69.89.25.95]) by sourceware.org (Postfix) with ESMTPS id 638B13858D33 for ; Fri, 20 Jan 2023 21:46:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 638B13858D33 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com Received: from cmgw11.mail.unifiedlayer.com (unknown [10.0.90.126]) by progateway3.mail.pro1.eigbox.com (Postfix) with ESMTP id AB170100417D8 for ; Fri, 20 Jan 2023 21:46:31 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id IzDTpoFmdJceRIzDTprV9H; Fri, 20 Jan 2023 21:46:31 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=Or6Kdwzt c=1 sm=1 tr=0 ts=63cb0bb7 a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=RvmDmJFTN0MA:10:nop_rcvd_month_year a=Qbun_eYptAEA:10:endurance_base64_authed_username_1 a=W2OvHrVv0EpvJfcDsfIA:9 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: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=ScPJtvw1Mahj0GcTUFntD8DEcBCkyoNYZ9jtLa6uthM=; b=VnkaDV5Es2rmB8iKinqE2kqRo+ AyuGl1MZAcCvaFXXFEjbiFP1Fxz4l6wjz6OI7sqpaBUnm20BKzHfCOLqP6/DzLPNH5lWgB1BeSEe7 yyHbhh6rA6OrvwRC88oPgDvqB; Received: from 97-122-76-186.hlrn.qwest.net ([97.122.76.186]:36374 helo=localhost.localdomain) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1pIzDT-001G7B-4B; Fri, 20 Jan 2023 14:46:31 -0700 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 01/27] Rearrange block.c to avoid a forward declaration Date: Fri, 20 Jan 2023 14:45:52 -0700 Message-Id: <20230120214618.3236224-2-tom@tromey.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230120214618.3236224-1-tom@tromey.com> References: <20230120214618.3236224-1-tom@tromey.com> MIME-Version: 1.0 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.76.186 X-Source-L: No X-Exim-ID: 1pIzDT-001G7B-4B X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-76-186.hlrn.qwest.net (localhost.localdomain) [97.122.76.186]:36374 X-Source-Auth: tom+tromey.com X-Email-Count: 2 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3027.9 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 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.29 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 Sender: "Gdb-patches" Moving block_initialize_namespace before its callers lets us avoid a forward declaration. --- gdb/block.c | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/gdb/block.c b/gdb/block.c index 167cb08e0bb..751f67d30f7 100644 --- a/gdb/block.c +++ b/gdb/block.c @@ -37,9 +37,6 @@ struct block_namespace_info : public allocate_on_obstack struct using_direct *using_decl = nullptr; }; -static void block_initialize_namespace (struct block *block, - struct obstack *obstack); - /* See block.h. */ struct objfile * @@ -305,6 +302,16 @@ block_scope (const struct block *block) return ""; } +/* If block->namespace_info () is NULL, allocate it via OBSTACK and + initialize its members to zero. */ + +static void +block_initialize_namespace (struct block *block, struct obstack *obstack) +{ + if (block->namespace_info () == NULL) + block->set_namespace_info (new (obstack) struct block_namespace_info ()); +} + /* Set BLOCK's scope member to SCOPE; if needed, allocate memory via OBSTACK. (It won't make a copy of SCOPE, however, so that already has to be allocated correctly.) */ @@ -344,16 +351,6 @@ block_set_using (struct block *block, block->namespace_info ()->using_decl = using_decl; } -/* If block->namespace_info () is NULL, allocate it via OBSTACK and - initialize its members to zero. */ - -static void -block_initialize_namespace (struct block *block, struct obstack *obstack) -{ - if (block->namespace_info () == NULL) - block->set_namespace_info (new (obstack) struct block_namespace_info ()); -} - /* Return the static block associated to BLOCK. Return NULL if block is NULL or if block is a global block. */ From patchwork Fri Jan 20 21:45: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: 63518 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 5635C383FB87 for ; Fri, 20 Jan 2023 21:47:04 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from gproxy4-pub.mail.unifiedlayer.com (gproxy4-pub.mail.unifiedlayer.com [69.89.23.142]) by sourceware.org (Postfix) with ESMTPS id 7333F3858C52 for ; Fri, 20 Jan 2023 21:46:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7333F3858C52 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com Received: from cmgw15.mail.unifiedlayer.com (unknown [10.0.90.130]) by progateway6.mail.pro1.eigbox.com (Postfix) with ESMTP id B47EB10048392 for ; Fri, 20 Jan 2023 21:46:31 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id IzDTpwSn4bwScIzDTpCfyI; Fri, 20 Jan 2023 21:46:31 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=X8KXlEfe c=1 sm=1 tr=0 ts=63cb0bb7 a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=RvmDmJFTN0MA:10:nop_rcvd_month_year a=Qbun_eYptAEA:10:endurance_base64_authed_username_1 a=I9IJ1h4ilsTHvClgnJoA:9 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: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=j4ihpKG1Ro2EWq9ZC9KgjgksqFpJOwCWmG3guQKMFYM=; b=n/jFyCNbMQPp8UjXgVVLjd/ibO Q1AF2H9fmEFsJeqwVv2WhXwo8laqGjdEOwEjgqHVg0Ux1C7ze1t5fOn6vy2Qxtje03yr/UKKtd8ye kDgn1zrNubyDnybAieudg93EH; Received: from 97-122-76-186.hlrn.qwest.net ([97.122.76.186]:36374 helo=localhost.localdomain) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1pIzDT-001G7B-Cy; Fri, 20 Jan 2023 14:46:31 -0700 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 02/27] Avoid extra allocations in block Date: Fri, 20 Jan 2023 14:45:53 -0700 Message-Id: <20230120214618.3236224-3-tom@tromey.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230120214618.3236224-1-tom@tromey.com> References: <20230120214618.3236224-1-tom@tromey.com> MIME-Version: 1.0 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.76.186 X-Source-L: No X-Exim-ID: 1pIzDT-001G7B-Cy X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-76-186.hlrn.qwest.net (localhost.localdomain) [97.122.76.186]:36374 X-Source-Auth: tom+tromey.com X-Email-Count: 3 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3027.9 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 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.29 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 Sender: "Gdb-patches" block_set_scope and block_set_using unconditionally allocate the block namespace object. However, this isn't truly needed, so arrange to only allocate when it is. --- gdb/block.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/gdb/block.c b/gdb/block.c index 751f67d30f7..f24a2b5d084 100644 --- a/gdb/block.c +++ b/gdb/block.c @@ -320,6 +320,12 @@ void block_set_scope (struct block *block, const char *scope, struct obstack *obstack) { + if (scope == nullptr || scope[0] == '\0') + { + /* Don't bother. */ + return; + } + block_initialize_namespace (block, obstack); block->namespace_info ()->scope = scope; @@ -346,6 +352,12 @@ block_set_using (struct block *block, struct using_direct *using_decl, struct obstack *obstack) { + if (using_decl == nullptr) + { + /* Don't bother. */ + return; + } + block_initialize_namespace (block, obstack); block->namespace_info ()->using_decl = using_decl; From patchwork Fri Jan 20 21:45: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: 63519 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 1081C383FBA0 for ; Fri, 20 Jan 2023 21:47:07 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from gproxy2-pub.mail.unifiedlayer.com (gproxy2-pub.mail.unifiedlayer.com [69.89.18.3]) by sourceware.org (Postfix) with ESMTPS id AB67D3858C53 for ; Fri, 20 Jan 2023 21:46:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org AB67D3858C53 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com Received: from cmgw14.mail.unifiedlayer.com (unknown [10.0.90.129]) by progateway4.mail.pro1.eigbox.com (Postfix) with ESMTP id DE30010047112 for ; Fri, 20 Jan 2023 21:46:31 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id IzDTpNXTamt0LIzDTptiy1; Fri, 20 Jan 2023 21:46:31 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=N6rsq0xB c=1 sm=1 tr=0 ts=63cb0bb7 a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=RvmDmJFTN0MA:10:nop_rcvd_month_year a=Qbun_eYptAEA:10:endurance_base64_authed_username_1 a=oX-2ca8VQ_RVukH4M_kA:9 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: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=kdBt9fnzsCeNI0Iq5MSB1RonRi/pJVrLQ8tMdJTr718=; b=qLUG6YgxYtvd5YydBDHHCttzFI dC9J+oKuSgL4eGT40Q/wU9YjT7x1VQw1x8bfu3/J6zOSarvTiGs1QWDKkGpy4WQ+MFRxCajp/uSUI RBvU0a/Sj9+w0oTUTdkEo7BCN; Received: from 97-122-76-186.hlrn.qwest.net ([97.122.76.186]:36374 helo=localhost.localdomain) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1pIzDT-001G7B-Ls; Fri, 20 Jan 2023 14:46:31 -0700 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 03/27] Don't allow NULL as an argument to block_scope Date: Fri, 20 Jan 2023 14:45:54 -0700 Message-Id: <20230120214618.3236224-4-tom@tromey.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230120214618.3236224-1-tom@tromey.com> References: <20230120214618.3236224-1-tom@tromey.com> MIME-Version: 1.0 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.76.186 X-Source-L: No X-Exim-ID: 1pIzDT-001G7B-Ls X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-76-186.hlrn.qwest.net (localhost.localdomain) [97.122.76.186]:36374 X-Source-Auth: tom+tromey.com X-Email-Count: 4 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3027.9 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 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.29 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 Sender: "Gdb-patches" block_scope has special behavior when the block is NULL. Remove this and patch up the callers instead. --- gdb/d-namespace.c | 2 +- gdb/rust-lang.h | 5 ++--- gdb/rust-parse.c | 4 +++- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/gdb/d-namespace.c b/gdb/d-namespace.c index b6184034d5d..2978e5fecaf 100644 --- a/gdb/d-namespace.c +++ b/gdb/d-namespace.c @@ -511,7 +511,7 @@ d_lookup_symbol_nonlocal (const struct language_defn *langdef, const domain_enum domain) { struct block_symbol sym; - const char *scope = block_scope (block); + const char *scope = block == nullptr ? "" : block_scope (block); sym = lookup_module_scope (langdef, name, block, domain, scope, 0); if (sym.symbol != NULL) diff --git a/gdb/rust-lang.h b/gdb/rust-lang.h index 89e03550fb7..497342d4ef3 100644 --- a/gdb/rust-lang.h +++ b/gdb/rust-lang.h @@ -148,17 +148,16 @@ class rust_language : public language_defn { struct block_symbol result = {}; + const char *scope = block == nullptr ? "" : block_scope (block); symbol_lookup_debug_printf ("rust_lookup_symbol_non_local (%s, %s (scope %s), %s)", - name, host_address_to_string (block), block_scope (block), + name, host_address_to_string (block), scope, domain_name (domain)); /* Look up bare names in the block's scope. */ std::string scopedname; if (name[cp_find_first_component (name)] == '\0') { - const char *scope = block_scope (block); - if (scope[0] != '\0') { scopedname = std::string (scope) + "::" + name; diff --git a/gdb/rust-parse.c b/gdb/rust-parse.c index 489be4b87e3..72b843ef40c 100644 --- a/gdb/rust-parse.c +++ b/gdb/rust-parse.c @@ -373,7 +373,9 @@ rust_parser::crate_name (const std::string &name) std::string rust_parser::super_name (const std::string &ident, unsigned int n_supers) { - const char *scope = block_scope (pstate->expression_context_block); + const char *scope = ""; + if (pstate->expression_context_block != nullptr) + scope = block_scope (pstate->expression_context_block); int offset; if (scope[0] == '\0') From patchwork Fri Jan 20 21:45: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: 63521 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 39F8F38493D4 for ; Fri, 20 Jan 2023 21:47:22 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from gproxy2-pub.mail.unifiedlayer.com (gproxy2-pub.mail.unifiedlayer.com [69.89.18.3]) by sourceware.org (Postfix) with ESMTPS id D65603858C62 for ; Fri, 20 Jan 2023 21:46:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D65603858C62 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com Received: from cmgw15.mail.unifiedlayer.com (unknown [10.0.90.130]) by progateway4.mail.pro1.eigbox.com (Postfix) with ESMTP id 323041004710E for ; Fri, 20 Jan 2023 21:46:32 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id IzDUpwSnNbwScIzDUpCfyb; Fri, 20 Jan 2023 21:46:32 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=X8KXlEfe c=1 sm=1 tr=0 ts=63cb0bb8 a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=RvmDmJFTN0MA:10:nop_rcvd_month_year a=Qbun_eYptAEA:10:endurance_base64_authed_username_1 a=hJuDmB6aOOJFbzMtTE8A:9 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: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=gngnjvY9YU5oP3vSz9/clgtPzGXsKHObGLa8tvn6lE8=; b=ADav/IOfOBJ25vjiM0OAuEhY4L To/qgXuIgfBpPYad9nhhDwDMnX0zCGp51jro9kwTN71hBZhnFBFEnU+kqPEJt66SGQsxyYgAIYp7T C8sFfa3muWaZq3eLRdgLl8xqi; Received: from 97-122-76-186.hlrn.qwest.net ([97.122.76.186]:36374 helo=localhost.localdomain) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1pIzDT-001G7B-Uj; Fri, 20 Jan 2023 14:46:32 -0700 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 04/27] Don't allow NULL as an argument to block_using Date: Fri, 20 Jan 2023 14:45:55 -0700 Message-Id: <20230120214618.3236224-5-tom@tromey.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230120214618.3236224-1-tom@tromey.com> References: <20230120214618.3236224-1-tom@tromey.com> MIME-Version: 1.0 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.76.186 X-Source-L: No X-Exim-ID: 1pIzDT-001G7B-Uj X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-76-186.hlrn.qwest.net (localhost.localdomain) [97.122.76.186]:36374 X-Source-Auth: tom+tromey.com X-Email-Count: 5 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3027.9 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 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.29 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 Sender: "Gdb-patches" block_using has special behavior when the block is NULL. Remove this. No caller seems to be affected. --- gdb/block.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gdb/block.c b/gdb/block.c index f24a2b5d084..97a0214e037 100644 --- a/gdb/block.c +++ b/gdb/block.c @@ -337,7 +337,7 @@ block_set_scope (struct block *block, const char *scope, struct using_direct * block_using (const struct block *block) { - if (block == NULL || block->namespace_info () == NULL) + if (block->namespace_info () == NULL) return NULL; else return block->namespace_info ()->using_decl; From patchwork Fri Jan 20 21:45: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: 63517 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 93E383854381 for ; Fri, 20 Jan 2023 21:46:58 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from alt-proxy28.mail.unifiedlayer.com (alt-proxy28.mail.unifiedlayer.com [74.220.216.123]) by sourceware.org (Postfix) with ESMTPS id 541423858C54 for ; Fri, 20 Jan 2023 21:46:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 541423858C54 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com Received: from cmgw13.mail.unifiedlayer.com (unknown [10.0.90.128]) by progateway1.mail.pro1.eigbox.com (Postfix) with ESMTP id 947F610040228 for ; Fri, 20 Jan 2023 21:46:32 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id IzDUpfnMjNX2aIzDUpTFxL; Fri, 20 Jan 2023 21:46:32 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=NMAQR22g c=1 sm=1 tr=0 ts=63cb0bb8 a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=RvmDmJFTN0MA:10:nop_rcvd_month_year a=Qbun_eYptAEA:10:endurance_base64_authed_username_1 a=TOjmDAImc5F25ATAshwA:9 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: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=eIx14nMSAkmBhDG4yv+iyt7xyVJInwMrrXr6KP7qvzo=; b=IMkJejSKXC/EzSrubYuNZkdSRd kS/51Ymn6X7FIhivj1GBGYaL3tzpSBonx5PaOcQ5fsVrE4Q3HEXxxKCWLd9ljZjrwNx01mP3zkSs0 srvHc0HOeV1rSpMtBiw11XGGY; Received: from 97-122-76-186.hlrn.qwest.net ([97.122.76.186]:36374 helo=localhost.localdomain) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1pIzDU-001G7B-7r; Fri, 20 Jan 2023 14:46:32 -0700 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 05/27] Don't allow NULL as an argument to block_static_block Date: Fri, 20 Jan 2023 14:45:56 -0700 Message-Id: <20230120214618.3236224-6-tom@tromey.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230120214618.3236224-1-tom@tromey.com> References: <20230120214618.3236224-1-tom@tromey.com> MIME-Version: 1.0 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.76.186 X-Source-L: No X-Exim-ID: 1pIzDU-001G7B-7r X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-76-186.hlrn.qwest.net (localhost.localdomain) [97.122.76.186]:36374 X-Source-Auth: tom+tromey.com X-Email-Count: 6 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3027.9 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 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.29 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 Sender: "Gdb-patches" block_static_block has special behavior when the block is NULL. Remove this and patch up the callers instead. --- gdb/ada-lang.c | 6 +++++- gdb/block.c | 4 ++-- gdb/compile/compile-c-symbols.c | 8 ++++++-- gdb/compile/compile-cplus-symbols.c | 4 +++- gdb/cp-support.c | 6 +++++- gdb/symtab.c | 13 +++++++++---- 6 files changed, 30 insertions(+), 11 deletions(-) diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 40f85914a56..dfcd9a5fcd1 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -13815,7 +13815,11 @@ class ada_language : public language_defn { struct block_symbol sym; - sym = ada_lookup_symbol (name, block_static_block (block), domain); + sym = ada_lookup_symbol (name, + (block == nullptr + ? nullptr + : block_static_block (block)), + domain); if (sym.symbol != NULL) return sym; diff --git a/gdb/block.c b/gdb/block.c index 97a0214e037..d21729f069d 100644 --- a/gdb/block.c +++ b/gdb/block.c @@ -364,12 +364,12 @@ block_set_using (struct block *block, } /* Return the static block associated to BLOCK. Return NULL if block - is NULL or if block is a global block. */ + is a global block. */ const struct block * block_static_block (const struct block *block) { - if (block == NULL || block->superblock () == NULL) + if (block->superblock () == NULL) return NULL; while (block->superblock ()->superblock () != NULL) diff --git a/gdb/compile/compile-c-symbols.c b/gdb/compile/compile-c-symbols.c index 00ac4523f86..79490b811c3 100644 --- a/gdb/compile/compile-c-symbols.c +++ b/gdb/compile/compile-c-symbols.c @@ -212,7 +212,6 @@ static void convert_symbol_sym (compile_c_instance *context, const char *identifier, struct block_symbol sym, domain_enum domain) { - const struct block *static_block; int is_local_symbol; /* If we found a symbol and it is not in the static or global @@ -227,7 +226,9 @@ convert_symbol_sym (compile_c_instance *context, const char *identifier, } */ - static_block = block_static_block (sym.block); + const struct block *static_block = nullptr; + if (sym.block != nullptr) + static_block = block_static_block (sym.block); /* STATIC_BLOCK is NULL if FOUND_BLOCK is the global block. */ is_local_symbol = (sym.block != static_block && static_block != NULL); if (is_local_symbol) @@ -613,6 +614,9 @@ generate_c_for_variable_locations (compile_instance *compiler, const struct block *block, CORE_ADDR pc) { + if (block == nullptr) + return {}; + const struct block *static_block = block_static_block (block); /* If we're already in the static or global block, there is nothing diff --git a/gdb/compile/compile-cplus-symbols.c b/gdb/compile/compile-cplus-symbols.c index 2df68b7dd32..45a76eef303 100644 --- a/gdb/compile/compile-cplus-symbols.c +++ b/gdb/compile/compile-cplus-symbols.c @@ -239,7 +239,9 @@ convert_symbol_sym (compile_cplus_instance *instance, } */ - const struct block *static_block = block_static_block (sym.block); + const struct block *static_block = nullptr; + if (sym.block != nullptr) + static_block = block_static_block (sym.block); /* STATIC_BLOCK is NULL if FOUND_BLOCK is the global block. */ bool is_local_symbol = (sym.block != static_block && static_block != nullptr); if (is_local_symbol) diff --git a/gdb/cp-support.c b/gdb/cp-support.c index b7ed2101b78..08f7c2b4140 100644 --- a/gdb/cp-support.c +++ b/gdb/cp-support.c @@ -1306,7 +1306,8 @@ add_symbol_overload_list_namespace (const char *func_name, } /* Look in the static block. */ - block = block_static_block (get_selected_block (0)); + block = get_selected_block (0); + block = block == nullptr ? nullptr : block_static_block (block); if (block) add_symbol_overload_list_block (name, block, overload_list); @@ -1456,6 +1457,9 @@ add_symbol_overload_list_qualified (const char *func_name, add_symbol_overload_list_block (func_name, b, overload_list); surrounding_static_block = block_static_block (get_selected_block (0)); + surrounding_static_block = (surrounding_static_block == nullptr + ? nullptr + : block_static_block (surrounding_static_block)); /* Go through the symtabs and check the externs and statics for symbols which match. */ diff --git a/gdb/symtab.c b/gdb/symtab.c index b3445133c8c..0e522b2c7f9 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -2179,13 +2179,15 @@ lookup_local_symbol (const char *name, const domain_enum domain, enum language language) { + if (block == nullptr) + return {}; + struct symbol *sym; const struct block *static_block = block_static_block (block); const char *scope = block_scope (block); - /* Check if either no block is specified or it's a global block. */ - - if (static_block == NULL) + /* Check if it's a global block. */ + if (static_block == nullptr) return {}; while (block != static_block) @@ -2484,6 +2486,9 @@ lookup_symbol_in_static_block (const char *name, const struct block *block, const domain_enum domain) { + if (block == nullptr) + return {}; + const struct block *static_block = block_static_block (block); struct symbol *sym; @@ -5855,7 +5860,7 @@ default_collect_symbol_completion_matches_break_on visible from current context. */ b = get_selected_block (0); - surrounding_static_block = block_static_block (b); + surrounding_static_block = b == nullptr ? nullptr : block_static_block (b); surrounding_global_block = block_global_block (b); if (surrounding_static_block != NULL) while (b != surrounding_static_block) From patchwork Fri Jan 20 21:45: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: 63524 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 D2E3F3889E3C for ; Fri, 20 Jan 2023 21:47:39 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from outbound-ss-820.bluehost.com (outbound-ss-820.bluehost.com [69.89.24.241]) by sourceware.org (Postfix) with ESMTPS id BDDE53858C5E for ; Fri, 20 Jan 2023 21:46:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BDDE53858C5E Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com Received: from cmgw14.mail.unifiedlayer.com (unknown [10.0.90.129]) by progateway2.mail.pro1.eigbox.com (Postfix) with ESMTP id C3E631004854D for ; Fri, 20 Jan 2023 21:46:32 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id IzDUpNXUAmt0LIzDUptiya; Fri, 20 Jan 2023 21:46:32 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=N6rsq0xB c=1 sm=1 tr=0 ts=63cb0bb8 a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=RvmDmJFTN0MA:10:nop_rcvd_month_year a=Qbun_eYptAEA:10:endurance_base64_authed_username_1 a=0ydof0_9mls9fT3IddIA:9 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: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=O/0DxLVET0zhguCzx8I5tuNawImrh1P2uRz766UW1z8=; b=FGxiudDvclwUc2wr7nqkJSlBT/ IuYsQ+nxCYQMUXkY6NpROnXH9MQKp5Xb6wqV7ZnqkSeXX0ohonxWeNnRYDrczFBEWt2N8o5a/z5er 6kZhP9T+/+o5SmHxHnA0VvHN+; Received: from 97-122-76-186.hlrn.qwest.net ([97.122.76.186]:36374 helo=localhost.localdomain) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1pIzDU-001G7B-Gr; Fri, 20 Jan 2023 14:46:32 -0700 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 06/27] Don't allow NULL as an argument to block_global_block Date: Fri, 20 Jan 2023 14:45:57 -0700 Message-Id: <20230120214618.3236224-7-tom@tromey.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230120214618.3236224-1-tom@tromey.com> References: <20230120214618.3236224-1-tom@tromey.com> MIME-Version: 1.0 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.76.186 X-Source-L: No X-Exim-ID: 1pIzDU-001G7B-Gr X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-76-186.hlrn.qwest.net (localhost.localdomain) [97.122.76.186]:36374 X-Source-Auth: tom+tromey.com X-Email-Count: 7 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3027.9 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 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.29 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 Sender: "Gdb-patches" block_global_block has special behavior when the block is NULL. Remove this and patch up the callers instead. --- gdb/block.c | 6 +----- gdb/cp-support.c | 15 ++++++++------- gdb/symtab.c | 5 +++-- 3 files changed, 12 insertions(+), 14 deletions(-) diff --git a/gdb/block.c b/gdb/block.c index d21729f069d..5751a6b6f84 100644 --- a/gdb/block.c +++ b/gdb/block.c @@ -378,15 +378,11 @@ block_static_block (const struct block *block) return block; } -/* Return the static block associated to BLOCK. Return NULL if block - is NULL. */ +/* Return the static block associated to BLOCK. */ const struct block * block_global_block (const struct block *block) { - if (block == NULL) - return NULL; - while (block->superblock () != NULL) block = block->superblock (); diff --git a/gdb/cp-support.c b/gdb/cp-support.c index 08f7c2b4140..38225a6d9ba 100644 --- a/gdb/cp-support.c +++ b/gdb/cp-support.c @@ -1308,14 +1308,15 @@ add_symbol_overload_list_namespace (const char *func_name, /* Look in the static block. */ block = get_selected_block (0); block = block == nullptr ? nullptr : block_static_block (block); - if (block) - add_symbol_overload_list_block (name, block, overload_list); - - /* Look in the global block. */ - block = block_global_block (block); - if (block) - add_symbol_overload_list_block (name, block, overload_list); + if (block != nullptr) + { + add_symbol_overload_list_block (name, block, overload_list); + /* Look in the global block. */ + block = block_global_block (block); + if (block) + add_symbol_overload_list_block (name, block, overload_list); + } } /* Search the namespace of the given type and namespace of and public diff --git a/gdb/symtab.c b/gdb/symtab.c index 0e522b2c7f9..924bd5d8ec0 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -2623,7 +2623,8 @@ lookup_global_symbol (const char *name, /* If a block was passed in, we want to search the corresponding global block first. This yields "more expected" behavior, and is needed to support 'FILENAME'::VARIABLE lookups. */ - const struct block *global_block = block_global_block (block); + const struct block *global_block + = block == nullptr ? nullptr : block_global_block (block); symbol *sym = NULL; if (global_block != nullptr) { @@ -5861,7 +5862,7 @@ default_collect_symbol_completion_matches_break_on b = get_selected_block (0); surrounding_static_block = b == nullptr ? nullptr : block_static_block (b); - surrounding_global_block = block_global_block (b); + surrounding_global_block = b == nullptr : nullptr : block_global_block (b); if (surrounding_static_block != NULL) while (b != surrounding_static_block) { From patchwork Fri Jan 20 21:45: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: 63526 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 D7CFF389367B for ; Fri, 20 Jan 2023 21:47:44 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from outbound-ss-820.bluehost.com (outbound-ss-820.bluehost.com [69.89.24.241]) by sourceware.org (Postfix) with ESMTPS id C68BB3858C5F for ; Fri, 20 Jan 2023 21:46:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C68BB3858C5F Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com Received: from cmgw12.mail.unifiedlayer.com (unknown [10.0.90.127]) by progateway2.mail.pro1.eigbox.com (Postfix) with ESMTP id 39A6A10048556 for ; Fri, 20 Jan 2023 21:46:33 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id IzDVp991iiOW0IzDVpygB0; Fri, 20 Jan 2023 21:46:33 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=S5kcfKgP c=1 sm=1 tr=0 ts=63cb0bb9 a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=RvmDmJFTN0MA:10:nop_rcvd_month_year a=Qbun_eYptAEA:10:endurance_base64_authed_username_1 a=B7ctNqcWuW6iLNlA5o8A:9 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: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=hIQFiFctXLndvGtrdCHKDzLAKGwDBHIFhFSMRoyFwuw=; b=FPrpbxOkT6gjCZ95pY0/peqe8Z 3WoIkJBWqavSe0Rx8DEQ5Sbm2vha+9d32ZMw4Zaviw+MqcVpHSRwB0GDjDbSU8ySGENnaseQweMbX m/ass6bVcZNWA/enW3Rils9FG; Received: from 97-122-76-186.hlrn.qwest.net ([97.122.76.186]:36374 helo=localhost.localdomain) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1pIzDU-001G7B-Qi; Fri, 20 Jan 2023 14:46:32 -0700 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 07/27] Convert block_objfile to method Date: Fri, 20 Jan 2023 14:45:58 -0700 Message-Id: <20230120214618.3236224-8-tom@tromey.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230120214618.3236224-1-tom@tromey.com> References: <20230120214618.3236224-1-tom@tromey.com> MIME-Version: 1.0 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.76.186 X-Source-L: No X-Exim-ID: 1pIzDU-001G7B-Qi X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-76-186.hlrn.qwest.net (localhost.localdomain) [97.122.76.186]:36374 X-Source-Auth: tom+tromey.com X-Email-Count: 8 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3027.9 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 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.29 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 Sender: "Gdb-patches" This converts block_objfile to be a method. This was mostly written by script. --- gdb/ada-exp.y | 2 +- gdb/block.c | 12 ++++++------ gdb/block.h | 8 ++++---- gdb/cp-support.c | 2 +- gdb/expop.h | 2 +- gdb/printcmd.c | 2 +- gdb/symtab.c | 10 +++++----- gdb/varobj.c | 2 +- 8 files changed, 20 insertions(+), 20 deletions(-) diff --git a/gdb/ada-exp.y b/gdb/ada-exp.y index 2f466e4de0a..9e9ff8d75d4 100644 --- a/gdb/ada-exp.y +++ b/gdb/ada-exp.y @@ -1699,7 +1699,7 @@ write_var_or_type (struct parser_state *par_state, { struct objfile *objfile = nullptr; if (block != nullptr) - objfile = block_objfile (block); + objfile = block->objfile (); struct bound_minimal_symbol msym = ada_lookup_simple_minsym (decoded_name.c_str (), objfile); diff --git a/gdb/block.c b/gdb/block.c index 5751a6b6f84..d7d5f0bf19e 100644 --- a/gdb/block.c +++ b/gdb/block.c @@ -40,14 +40,14 @@ struct block_namespace_info : public allocate_on_obstack /* See block.h. */ struct objfile * -block_objfile (const struct block *block) +block::objfile () const { const struct global_block *global_block; - if (block->function () != nullptr) - return block->function ()->objfile (); + if (function () != nullptr) + return function ()->objfile (); - global_block = (struct global_block *) block_global_block (block); + global_block = (struct global_block *) block_global_block (this); return global_block->compunit_symtab->objfile (); } @@ -59,7 +59,7 @@ block_gdbarch (const struct block *block) if (block->function () != nullptr) return block->function ()->arch (); - return block_objfile (block)->arch (); + return block->objfile ()->arch (); } /* See block.h. */ @@ -434,7 +434,7 @@ set_block_compunit_symtab (struct block *block, struct compunit_symtab *cu) struct dynamic_prop * block_static_link (const struct block *block) { - struct objfile *objfile = block_objfile (block); + struct objfile *objfile = block->objfile (); /* Only objfile-owned blocks that materialize top function scopes can have static links. */ diff --git a/gdb/block.h b/gdb/block.h index 379359f07be..2243c9a2a52 100644 --- a/gdb/block.h +++ b/gdb/block.h @@ -204,6 +204,10 @@ struct block return this->ranges ()[0].start (); } + /* Return the objfile of this block. */ + + struct objfile *objfile () const; + /* Addresses in the executable code that are in this block. */ CORE_ADDR m_start; @@ -331,10 +335,6 @@ struct blockvector struct block *m_blocks[1]; }; -/* Return the objfile of BLOCK, which must be non-NULL. */ - -extern struct objfile *block_objfile (const struct block *block); - /* Return the architecture of BLOCK, which must be non-NULL. */ extern struct gdbarch *block_gdbarch (const struct block *block); diff --git a/gdb/cp-support.c b/gdb/cp-support.c index 38225a6d9ba..be4a636336d 100644 --- a/gdb/cp-support.c +++ b/gdb/cp-support.c @@ -1466,7 +1466,7 @@ add_symbol_overload_list_qualified (const char *func_name, symbols which match. */ const block *block = get_selected_block (0); - struct objfile *current_objfile = block ? block_objfile (block) : nullptr; + struct objfile *current_objfile = block ? block->objfile () : nullptr; gdbarch_iterate_over_objfiles_in_search_order (current_objfile ? current_objfile->arch () : target_gdbarch (), diff --git a/gdb/expop.h b/gdb/expop.h index de74e88998f..03e8b8aae1d 100644 --- a/gdb/expop.h +++ b/gdb/expop.h @@ -231,7 +231,7 @@ check_objfile (struct symbol *sym, struct objfile *objfile) static inline bool check_objfile (const struct block *block, struct objfile *objfile) { - return check_objfile (block_objfile (block), objfile); + return check_objfile (block->objfile (), objfile); } static inline bool diff --git a/gdb/printcmd.c b/gdb/printcmd.c index 7f3551327a8..e3ee847a955 100644 --- a/gdb/printcmd.c +++ b/gdb/printcmd.c @@ -2355,7 +2355,7 @@ clear_dangling_display_expressions (struct objfile *objfile) struct objfile *bl_objf = nullptr; if (d->block != nullptr) { - bl_objf = block_objfile (d->block); + bl_objf = d->block->objfile (); if (bl_objf->separate_debug_objfile_backlink != nullptr) bl_objf = bl_objf->separate_debug_objfile_backlink; } diff --git a/gdb/symtab.c b/gdb/symtab.c index 924bd5d8ec0..60bed9f0b4b 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -1994,7 +1994,7 @@ lookup_language_this (const struct language_defn *lang, symbol_lookup_debug_printf_v ("lookup_language_this (%s, %s (objfile %s))", lang->name (), host_address_to_string (block), - objfile_debug_name (block_objfile (block))); + objfile_debug_name (block->objfile ())); while (block) { @@ -2082,7 +2082,7 @@ lookup_symbol_aux (const char *name, symbol_name_match_type match_type, if (symbol_lookup_debug) { struct objfile *objfile = (block == nullptr - ? nullptr : block_objfile (block)); + ? nullptr : block->objfile ()); symbol_lookup_debug_printf ("demangled symbol name = \"%s\", block @ %s (objfile %s)", @@ -2228,7 +2228,7 @@ lookup_symbol_in_block (const char *name, symbol_name_match_type match_type, if (symbol_lookup_debug) { struct objfile *objfile - = block == nullptr ? nullptr : block_objfile (block); + = block == nullptr ? nullptr : block->objfile (); symbol_lookup_debug_printf_v ("lookup_symbol_in_block (%s, %s (objfile %s), %s)", @@ -2498,7 +2498,7 @@ lookup_symbol_in_static_block (const char *name, if (symbol_lookup_debug) { struct objfile *objfile = (block == nullptr - ? nullptr : block_objfile (block)); + ? nullptr : block->objfile ()); symbol_lookup_debug_printf ("lookup_symbol_in_static_block (%s, %s (objfile %s), %s)", @@ -2638,7 +2638,7 @@ lookup_global_symbol (const char *name, struct objfile *objfile = nullptr; if (block != nullptr) { - objfile = block_objfile (block); + objfile = block->objfile (); if (objfile->separate_debug_objfile_backlink != nullptr) objfile = objfile->separate_debug_objfile_backlink; } diff --git a/gdb/varobj.c b/gdb/varobj.c index eb47ecada3e..58a3ad5041a 100644 --- a/gdb/varobj.c +++ b/gdb/varobj.c @@ -2397,7 +2397,7 @@ varobj_invalidate_if_uses_objfile (struct objfile *objfile) { if (var->root->valid_block != nullptr) { - struct objfile *bl_objfile = block_objfile (var->root->valid_block); + struct objfile *bl_objfile = var->root->valid_block->objfile (); if (bl_objfile->separate_debug_objfile_backlink != nullptr) bl_objfile = bl_objfile->separate_debug_objfile_backlink; From patchwork Fri Jan 20 21:45: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: 63522 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 AD42838493CA for ; Fri, 20 Jan 2023 21:47:24 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from alt-proxy28.mail.unifiedlayer.com (alt-proxy28.mail.unifiedlayer.com [74.220.216.123]) by sourceware.org (Postfix) with ESMTPS id E9D153858C00 for ; Fri, 20 Jan 2023 21:46:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E9D153858C00 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com Received: from cmgw12.mail.unifiedlayer.com (unknown [10.0.90.127]) by progateway1.mail.pro1.eigbox.com (Postfix) with ESMTP id 5CAB3100400F9 for ; Fri, 20 Jan 2023 21:46:33 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id IzDVp991viOW0IzDVpygBD; Fri, 20 Jan 2023 21:46:33 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=S5kcfKgP c=1 sm=1 tr=0 ts=63cb0bb9 a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=RvmDmJFTN0MA:10:nop_rcvd_month_year a=Qbun_eYptAEA:10:endurance_base64_authed_username_1 a=-hahWWqg_23KX-hwVqQA:9 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: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=ztdm0UqrMWrBgnRhX1gMaLwko1kSeeK4xWVOlJOo0kA=; b=yF9po1ITG9Z8IYYbP9m46/qfUj DhKu9AHMNIOUwjVWPzOgPmIkARihKCs6YnmFDO2xcftpYoCicRNnYNcmF02guIfr9iCamsfl7tjkP jqIJCyGw+abLGfA75+5PTYyXn; Received: from 97-122-76-186.hlrn.qwest.net ([97.122.76.186]:36374 helo=localhost.localdomain) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1pIzDV-001G7B-3o; Fri, 20 Jan 2023 14:46:33 -0700 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 08/27] Convert block_gdbarch to method Date: Fri, 20 Jan 2023 14:45:59 -0700 Message-Id: <20230120214618.3236224-9-tom@tromey.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230120214618.3236224-1-tom@tromey.com> References: <20230120214618.3236224-1-tom@tromey.com> MIME-Version: 1.0 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.76.186 X-Source-L: No X-Exim-ID: 1pIzDV-001G7B-3o X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-76-186.hlrn.qwest.net (localhost.localdomain) [97.122.76.186]:36374 X-Source-Auth: tom+tromey.com X-Email-Count: 9 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3027.9 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 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.29 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 Sender: "Gdb-patches" This converts block_gdbarch to be a method. This was mostly written by script. --- gdb/ada-lang.c | 2 +- gdb/block.c | 8 ++++---- gdb/block.h | 8 ++++---- gdb/cp-namespace.c | 2 +- gdb/d-namespace.c | 2 +- gdb/symtab.c | 2 +- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index dfcd9a5fcd1..8fdf5fcef5a 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -13842,7 +13842,7 @@ class ada_language : public language_defn if (block == NULL) gdbarch = target_gdbarch (); else - gdbarch = block_gdbarch (block); + gdbarch = block->gdbarch (); sym.symbol = language_lookup_primitive_type_as_symbol (this, gdbarch, name); if (sym.symbol != NULL) diff --git a/gdb/block.c b/gdb/block.c index d7d5f0bf19e..b9c48e79d46 100644 --- a/gdb/block.c +++ b/gdb/block.c @@ -54,12 +54,12 @@ block::objfile () const /* See block. */ struct gdbarch * -block_gdbarch (const struct block *block) +block::gdbarch () const { - if (block->function () != nullptr) - return block->function ()->arch (); + if (function () != nullptr) + return function ()->arch (); - return block->objfile ()->arch (); + return objfile ()->arch (); } /* See block.h. */ diff --git a/gdb/block.h b/gdb/block.h index 2243c9a2a52..b9f1ba81b50 100644 --- a/gdb/block.h +++ b/gdb/block.h @@ -208,6 +208,10 @@ struct block struct objfile *objfile () const; + /* Return the architecture of this block. */ + + struct gdbarch *gdbarch () const; + /* Addresses in the executable code that are in this block. */ CORE_ADDR m_start; @@ -335,10 +339,6 @@ struct blockvector struct block *m_blocks[1]; }; -/* Return the architecture of BLOCK, which must be non-NULL. */ - -extern struct gdbarch *block_gdbarch (const struct block *block); - extern struct symbol *block_linkage_function (const struct block *); extern struct symbol *block_containing_function (const struct block *); diff --git a/gdb/cp-namespace.c b/gdb/cp-namespace.c index b1c54c57da6..97b7a653e33 100644 --- a/gdb/cp-namespace.c +++ b/gdb/cp-namespace.c @@ -197,7 +197,7 @@ cp_lookup_bare_symbol (const struct language_defn *langdef, if (block == NULL) gdbarch = target_gdbarch (); else - gdbarch = block_gdbarch (block); + gdbarch = block->gdbarch (); sym.symbol = language_lookup_primitive_type_as_symbol (langdef, gdbarch, name); sym.block = NULL; diff --git a/gdb/d-namespace.c b/gdb/d-namespace.c index 2978e5fecaf..aaef1dfae1f 100644 --- a/gdb/d-namespace.c +++ b/gdb/d-namespace.c @@ -94,7 +94,7 @@ d_lookup_symbol (const struct language_defn *langdef, if (block == NULL) gdbarch = target_gdbarch (); else - gdbarch = block_gdbarch (block); + gdbarch = block->gdbarch (); sym.symbol = language_lookup_primitive_type_as_symbol (langdef, gdbarch, name); sym.block = NULL; diff --git a/gdb/symtab.c b/gdb/symtab.c index 60bed9f0b4b..78f56d9d377 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -2468,7 +2468,7 @@ language_defn::lookup_symbol_nonlocal (const char *name, if (block == NULL) gdbarch = target_gdbarch (); else - gdbarch = block_gdbarch (block); + gdbarch = block->gdbarch (); result.symbol = language_lookup_primitive_type_as_symbol (this, gdbarch, name); result.block = NULL; From patchwork Fri Jan 20 21:46: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: 63520 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 EFC3A3881D2B for ; Fri, 20 Jan 2023 21:47:15 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from progateway7-pub.mail.pro1.eigbox.com (gproxy5-pub.mail.unifiedlayer.com [67.222.38.55]) by sourceware.org (Postfix) with ESMTPS id 500023858401 for ; Fri, 20 Jan 2023 21:46:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 500023858401 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com Received: from cmgw10.mail.unifiedlayer.com (unknown [10.0.90.125]) by progateway7.mail.pro1.eigbox.com (Postfix) with ESMTP id A919D10048174 for ; Fri, 20 Jan 2023 21:46:33 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id IzDVpicmgFqSRIzDVp2c9D; Fri, 20 Jan 2023 21:46:33 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=c6Ru/Txl c=1 sm=1 tr=0 ts=63cb0bb9 a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=RvmDmJFTN0MA:10:nop_rcvd_month_year a=Qbun_eYptAEA:10:endurance_base64_authed_username_1 a=I_E5aphFeQbykE197SwA:9 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: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=cVtpXuuBPfE4jKUwlvWIIskTQl/6ySboVwneL338AFk=; b=kSvOQ7SW/YPgZ02Z5AOoGzJK/n dA2lw+zhrj8Prj5kSrl0J8qPQthyTSZVrVSbvXL206HQakYQAlfGqZvdWwANwrgfE7dxd4rPCzorj MSBsazaqBwBQd0luTC+S0E6cn; Received: from 97-122-76-186.hlrn.qwest.net ([97.122.76.186]:36374 helo=localhost.localdomain) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1pIzDV-001G7B-Cp; Fri, 20 Jan 2023 14:46:33 -0700 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 09/27] Convert block_inlined_p to method Date: Fri, 20 Jan 2023 14:46:00 -0700 Message-Id: <20230120214618.3236224-10-tom@tromey.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230120214618.3236224-1-tom@tromey.com> References: <20230120214618.3236224-1-tom@tromey.com> MIME-Version: 1.0 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.76.186 X-Source-L: No X-Exim-ID: 1pIzDV-001G7B-Cp X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-76-186.hlrn.qwest.net (localhost.localdomain) [97.122.76.186]:36374 X-Source-Auth: tom+tromey.com X-Email-Count: 10 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3027.9 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 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.29 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 Sender: "Gdb-patches" This converts block_inlined_p to be a method. This was mostly written by script. --- gdb/block.c | 12 ++++++------ gdb/block.h | 6 ++++-- gdb/blockframe.c | 2 +- gdb/findvar.c | 2 +- gdb/inline-frame.c | 4 ++-- gdb/symtab.c | 8 ++++---- 6 files changed, 18 insertions(+), 16 deletions(-) diff --git a/gdb/block.c b/gdb/block.c index b9c48e79d46..574086aa4f6 100644 --- a/gdb/block.c +++ b/gdb/block.c @@ -77,7 +77,7 @@ contained_in (const struct block *a, const struct block *b, return true; /* If A is a function block, then A cannot be contained in B, except if A was inlined. */ - if (!allow_nested && a->function () != NULL && !block_inlined_p (a)) + if (!allow_nested && a->function () != NULL && !a->inlined_p ()) return false; a = a->superblock (); } @@ -95,7 +95,7 @@ contained_in (const struct block *a, const struct block *b, struct symbol * block_linkage_function (const struct block *bl) { - while ((bl->function () == NULL || block_inlined_p (bl)) + while ((bl->function () == NULL || bl->inlined_p ()) && bl->superblock () != NULL) bl = bl->superblock (); @@ -116,12 +116,12 @@ block_containing_function (const struct block *bl) return bl->function (); } -/* Return one if BL represents an inlined function. */ +/* See block.h. */ -int -block_inlined_p (const struct block *bl) +bool +block::inlined_p () const { - return bl->function () != NULL && bl->function ()->is_inlined (); + return function () != nullptr && function ()->is_inlined (); } /* A helper function that checks whether PC is in the blockvector BL. diff --git a/gdb/block.h b/gdb/block.h index b9f1ba81b50..ab343b44698 100644 --- a/gdb/block.h +++ b/gdb/block.h @@ -212,6 +212,10 @@ struct block struct gdbarch *gdbarch () const; + /* Return true if BL represents an inlined function. */ + + bool inlined_p () const; + /* Addresses in the executable code that are in this block. */ CORE_ADDR m_start; @@ -343,8 +347,6 @@ extern struct symbol *block_linkage_function (const struct block *); extern struct symbol *block_containing_function (const struct block *); -extern int block_inlined_p (const struct block *block); - /* Return true if block A is lexically nested within block B, or if a and b have the same pc range. Return false otherwise. If ALLOW_NESTED is true, then block A is considered to be in block B diff --git a/gdb/blockframe.c b/gdb/blockframe.c index 071254824b0..2796fc99154 100644 --- a/gdb/blockframe.c +++ b/gdb/blockframe.c @@ -72,7 +72,7 @@ get_frame_block (frame_info_ptr frame, CORE_ADDR *addr_in_block) while (inline_count > 0) { - if (block_inlined_p (bl)) + if (bl->inlined_p ()) inline_count--; bl = bl->superblock (); diff --git a/gdb/findvar.c b/gdb/findvar.c index 02d498d8c58..656f982be2d 100644 --- a/gdb/findvar.c +++ b/gdb/findvar.c @@ -533,7 +533,7 @@ get_hosting_frame (struct symbol *var, const struct block *var_block, if (frame == NULL) { if (var_block->function () - && !block_inlined_p (var_block) + && !var_block->inlined_p () && var_block->function ()->print_name ()) error (_("No frame is currently executing in block %s."), var_block->function ()->print_name ()); diff --git a/gdb/inline-frame.c b/gdb/inline-frame.c index f02f6353c64..21431a280fa 100644 --- a/gdb/inline-frame.c +++ b/gdb/inline-frame.c @@ -228,7 +228,7 @@ inline_frame_sniffer (const struct frame_unwind *self, cur_block = frame_block; while (cur_block->superblock ()) { - if (block_inlined_p (cur_block)) + if (cur_block->inlined_p ()) depth++; else if (cur_block->function () != NULL) break; @@ -357,7 +357,7 @@ skip_inline_frames (thread_info *thread, bpstat *stop_chain) cur_block = frame_block; while (cur_block->superblock ()) { - if (block_inlined_p (cur_block)) + if (cur_block->inlined_p ()) { /* See comments in inline_frame_this_id about this use of BLOCK_ENTRY_PC. */ diff --git a/gdb/symtab.c b/gdb/symtab.c index 78f56d9d377..530de418e53 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -2206,7 +2206,7 @@ lookup_local_symbol (const char *name, return blocksym; } - if (block->function () != NULL && block_inlined_p (block)) + if (block->function () != NULL && block->inlined_p ()) break; block = block->superblock (); } @@ -3927,7 +3927,7 @@ skip_prologue_sal (struct symtab_and_line *sal) function_block = NULL; while (b != NULL) { - if (b->function () != NULL && block_inlined_p (b)) + if (b->function () != NULL && b->inlined_p ()) function_block = b; else if (b->function () != NULL) break; @@ -4023,7 +4023,7 @@ skip_prologue_using_sal (struct gdbarch *gdbarch, CORE_ADDR func_addr) bl = block_for_pc (prologue_sal.end); while (bl) { - if (block_inlined_p (bl)) + if (bl->inlined_p ()) break; if (bl->function ()) { @@ -5886,7 +5886,7 @@ default_collect_symbol_completion_matches_break_on /* Stop when we encounter an enclosing function. Do not stop for non-inlined functions - the locals of the enclosing function are in scope for a nested function. */ - if (b->function () != NULL && block_inlined_p (b)) + if (b->function () != NULL && b->inlined_p ()) break; b = b->superblock (); } From patchwork Fri Jan 20 21:46:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 63531 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 3E3A538AA262 for ; Fri, 20 Jan 2023 21:48:21 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from gproxy3-pub.mail.unifiedlayer.com (gproxy3-pub.mail.unifiedlayer.com [69.89.30.42]) by sourceware.org (Postfix) with ESMTPS id A2B353858C36 for ; Fri, 20 Jan 2023 21:46:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A2B353858C36 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com Received: from cmgw10.mail.unifiedlayer.com (unknown [10.0.90.125]) by progateway5.mail.pro1.eigbox.com (Postfix) with ESMTP id 1249C1004A27F for ; Fri, 20 Jan 2023 21:46:37 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id IzDYpicodFqSRIzDZp2cBD; Fri, 20 Jan 2023 21:46:37 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=c6Ru/Txl c=1 sm=1 tr=0 ts=63cb0bbd a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=RvmDmJFTN0MA:10:nop_rcvd_month_year a=Qbun_eYptAEA:10:endurance_base64_authed_username_1 a=Ss0_TLysQ42YSIft7JYA:9 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: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=2c53lFiY+YwV5Vj67iRdkB08cPGLWlgu0UePneFvdJM=; b=PSiMSC4fzt/Oq34A3aX0HfcjZa VfJP/a2XYRV+mjFZoZihj6RzaQgw1o3xqARCMGeEz4HC8zoqjwfmX+CYRE1cK4ZxawGmx1RtTP0ak 7UyiT9SbAWcHccmqhR/rfRF7I; Received: from 97-122-76-186.hlrn.qwest.net ([97.122.76.186]:60138 helo=localhost.localdomain) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1pIzDY-001GGF-Iu; Fri, 20 Jan 2023 14:46:36 -0700 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 10/27] Convert more block functions to methods Date: Fri, 20 Jan 2023 14:46:01 -0700 Message-Id: <20230120214618.3236224-11-tom@tromey.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230120214618.3236224-1-tom@tromey.com> References: <20230120214618.3236224-1-tom@tromey.com> MIME-Version: 1.0 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.76.186 X-Source-L: No X-Exim-ID: 1pIzDY-001GGF-Iu X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-76-186.hlrn.qwest.net (localhost.localdomain) [97.122.76.186]:60138 X-Source-Auth: tom+tromey.com X-Email-Count: 11 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3027.9 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 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.29 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 Sender: "Gdb-patches" This converts block_scope, block_set_scope, block_using, and block_set_using to be methods. These are all done at once to make it easier to also convert block_initialize_namespace at the same time. This was mostly written by script. --- gdb/ada-lang.c | 2 +- gdb/block.c | 63 +++++++++++++++++++--------------------------- gdb/block.h | 48 +++++++++++++++++++++-------------- gdb/buildsym.c | 9 +++---- gdb/cp-namespace.c | 6 ++--- gdb/cp-support.c | 2 +- gdb/d-namespace.c | 4 +-- gdb/dbxread.c | 4 +-- gdb/dwarf2/read.c | 4 +-- gdb/rust-lang.c | 2 +- gdb/rust-lang.h | 2 +- gdb/rust-parse.c | 2 +- gdb/symtab.c | 2 +- 13 files changed, 74 insertions(+), 76 deletions(-) diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 8fdf5fcef5a..7830fff6d8e 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -5428,7 +5428,7 @@ ada_add_block_renamings (std::vector &result, symbol_name_matcher_ftype *name_match = ada_get_symbol_name_matcher (lookup_name); - for (renaming = block_using (block); + for (renaming = block->get_using (); renaming != NULL; renaming = renaming->next) { diff --git a/gdb/block.c b/gdb/block.c index 574086aa4f6..fc523332a3d 100644 --- a/gdb/block.c +++ b/gdb/block.c @@ -285,40 +285,36 @@ block_for_pc (CORE_ADDR pc) /* Now come some functions designed to deal with C++ namespace issues. The accessors are safe to use even in the non-C++ case. */ -/* This returns the namespace that BLOCK is enclosed in, or "" if it - isn't enclosed in a namespace at all. This travels the chain of - superblocks looking for a scope, if necessary. */ +/* See block.h. */ const char * -block_scope (const struct block *block) +block::scope () const { - for (; block != NULL; block = block->superblock ()) + for (const block *block = this; + block != nullptr; + block = block->superblock ()) { - if (block->namespace_info () != NULL - && block->namespace_info ()->scope != NULL) - return block->namespace_info ()->scope; + if (block->m_namespace_info != nullptr + && block->m_namespace_info->scope != nullptr) + return block->m_namespace_info->scope; } return ""; } -/* If block->namespace_info () is NULL, allocate it via OBSTACK and - initialize its members to zero. */ +/* See block.h. */ -static void -block_initialize_namespace (struct block *block, struct obstack *obstack) +void +block::initialize_namespace (struct obstack *obstack) { - if (block->namespace_info () == NULL) - block->set_namespace_info (new (obstack) struct block_namespace_info ()); + if (m_namespace_info == nullptr) + m_namespace_info = new (obstack) struct block_namespace_info; } -/* Set BLOCK's scope member to SCOPE; if needed, allocate memory via - OBSTACK. (It won't make a copy of SCOPE, however, so that already - has to be allocated correctly.) */ +/* See block.h. */ void -block_set_scope (struct block *block, const char *scope, - struct obstack *obstack) +block::set_scope (const char *scope, struct obstack *obstack) { if (scope == nullptr || scope[0] == '\0') { @@ -326,31 +322,25 @@ block_set_scope (struct block *block, const char *scope, return; } - block_initialize_namespace (block, obstack); - - block->namespace_info ()->scope = scope; + initialize_namespace (obstack); + m_namespace_info->scope = scope; } -/* This returns the using directives list associated with BLOCK, if - any. */ +/* See block.h. */ struct using_direct * -block_using (const struct block *block) +block::get_using () const { - if (block->namespace_info () == NULL) - return NULL; + if (m_namespace_info == nullptr) + return nullptr; else - return block->namespace_info ()->using_decl; + return m_namespace_info->using_decl; } -/* Set BLOCK's using member to USING; if needed, allocate memory via - OBSTACK. (It won't make a copy of USING, however, so that already - has to be allocated correctly.) */ +/* See block.h. */ void -block_set_using (struct block *block, - struct using_direct *using_decl, - struct obstack *obstack) +block::set_using (struct using_direct *using_decl, struct obstack *obstack) { if (using_decl == nullptr) { @@ -358,9 +348,8 @@ block_set_using (struct block *block, return; } - block_initialize_namespace (block, obstack); - - block->namespace_info ()->using_decl = using_decl; + initialize_namespace (obstack); + m_namespace_info->using_decl = using_decl; } /* Return the static block associated to BLOCK. Return NULL if block diff --git a/gdb/block.h b/gdb/block.h index ab343b44698..680b7d0161e 100644 --- a/gdb/block.h +++ b/gdb/block.h @@ -147,14 +147,6 @@ struct block void set_multidict (multidictionary *multidict) { m_multidict = multidict; } - /* Return this block's namespace info. */ - block_namespace_info *namespace_info () const - { return m_namespace_info; } - - /* Set this block's namespace info. */ - void set_namespace_info (block_namespace_info *namespace_info) - { m_namespace_info = namespace_info; } - /* Return a view on this block's ranges. */ gdb::array_view ranges () { @@ -216,6 +208,29 @@ struct block bool inlined_p () const; + /* This returns the namespace that this block is enclosed in, or "" + if it isn't enclosed in a namespace at all. This travels the + chain of superblocks looking for a scope, if necessary. */ + + const char *scope () const; + + /* Set this block's scope member to SCOPE; if needed, allocate + memory via OBSTACK. (It won't make a copy of SCOPE, however, so + that already has to be allocated correctly.) */ + + void set_scope (const char *scope, struct obstack *obstack); + + /* This returns the using directives list associated with this + block, if any. */ + + struct using_direct *get_using () const; + + /* Set this block's using member to USING; if needed, allocate + memory via OBSTACK. (It won't make a copy of USING, however, so + that already has to be allocated correctly.) */ + + void set_using (struct using_direct *using_decl, struct obstack *obstack); + /* Addresses in the executable code that are in this block. */ CORE_ADDR m_start; @@ -248,6 +263,12 @@ struct block startaddr and endaddr above. */ struct blockranges *m_ranges; + +private: + + /* If the namespace_info is NULL, allocate it via OBSTACK and + initialize its members to zero. */ + void initialize_namespace (struct obstack *obstack); }; /* The global block is singled out so that we can provide a back-link @@ -373,17 +394,6 @@ extern const struct block *block_for_pc (CORE_ADDR); extern const struct block *block_for_pc_sect (CORE_ADDR, struct obj_section *); -extern const char *block_scope (const struct block *block); - -extern void block_set_scope (struct block *block, const char *scope, - struct obstack *obstack); - -extern struct using_direct *block_using (const struct block *block); - -extern void block_set_using (struct block *block, - struct using_direct *using_decl, - struct obstack *obstack); - extern const struct block *block_static_block (const struct block *block); extern const struct block *block_global_block (const struct block *block); diff --git a/gdb/buildsym.c b/gdb/buildsym.c index adab927235c..fd76e56599d 100644 --- a/gdb/buildsym.c +++ b/gdb/buildsym.c @@ -371,11 +371,10 @@ buildsym_compunit::finish_block_internal opblock = pblock; } - block_set_using (block, - (is_global - ? m_global_using_directives - : m_local_using_directives), - &m_objfile->objfile_obstack); + block->set_using ((is_global + ? m_global_using_directives + : m_local_using_directives), + &m_objfile->objfile_obstack); if (is_global) m_global_using_directives = NULL; else diff --git a/gdb/cp-namespace.c b/gdb/cp-namespace.c index 97b7a653e33..2d44b7bc047 100644 --- a/gdb/cp-namespace.c +++ b/gdb/cp-namespace.c @@ -413,7 +413,7 @@ cp_lookup_symbol_via_imports (const char *scope, /* Go through the using directives. If any of them add new names to the namespace we're searching in, see if we can find a match by applying them. */ - for (current = block_using (block); + for (current = block->get_using (); current != NULL; current = current->next) { @@ -769,7 +769,7 @@ cp_lookup_symbol_nonlocal (const struct language_defn *langdef, const domain_enum domain) { struct block_symbol sym; - const char *scope = block_scope (block); + const char *scope = block == nullptr ? "" : block->scope (); symbol_lookup_debug_printf ("cp_lookup_symbol_non_local (%s, %s (scope %s), %s)", @@ -1025,7 +1025,7 @@ cp_lookup_transparent_type (const char *name) /* If that doesn't work and we're within a namespace, look there instead. */ - scope = block_scope (get_selected_block (0)); + scope = get_selected_block (0)->scope (); if (scope[0] == '\0') return NULL; diff --git a/gdb/cp-support.c b/gdb/cp-support.c index be4a636336d..76407fdeb2f 100644 --- a/gdb/cp-support.c +++ b/gdb/cp-support.c @@ -1402,7 +1402,7 @@ add_symbol_overload_list_using (const char *func_name, for (block = get_selected_block (0); block != NULL; block = block->superblock ()) - for (current = block_using (block); + for (current = block->get_using (); current != NULL; current = current->next) { diff --git a/gdb/d-namespace.c b/gdb/d-namespace.c index aaef1dfae1f..6153e5b3239 100644 --- a/gdb/d-namespace.c +++ b/gdb/d-namespace.c @@ -375,7 +375,7 @@ d_lookup_symbol_imports (const char *scope, const char *name, the module we're searching in, see if we can find a match by applying them. */ - for (current = block_using (block); + for (current = block->get_using (); current != NULL; current = current->next) { @@ -511,7 +511,7 @@ d_lookup_symbol_nonlocal (const struct language_defn *langdef, const domain_enum domain) { struct block_symbol sym; - const char *scope = block == nullptr ? "" : block_scope (block); + const char *scope = block == nullptr ? "" : block->scope (); sym = lookup_module_scope (langdef, name, block, domain, scope, 0); if (sym.symbol != NULL) diff --git a/gdb/dbxread.c b/gdb/dbxread.c index ab0734f0218..dbfbf9a6574 100644 --- a/gdb/dbxread.c +++ b/gdb/dbxread.c @@ -2362,8 +2362,8 @@ cp_set_block_scope (const struct symbol *symbol, const char *name = symbol->demangled_name (); unsigned int prefix_len = cp_entire_prefix_len (name); - block_set_scope (block, obstack_strndup (obstack, name, prefix_len), - obstack); + block->set_scope (obstack_strndup (obstack, name, prefix_len), + obstack); } } diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index cd937f24ee7..9789f871eb9 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -12195,8 +12195,8 @@ read_func_scope (struct die_info *die, struct dwarf2_cu *cu) || cu->lang () == language_d || cu->lang () == language_rust) && cu->processing_has_namespace_info) - block_set_scope (block, determine_prefix (die, cu), - &objfile->objfile_obstack); + block->set_scope (determine_prefix (die, cu), + &objfile->objfile_obstack); /* If we have address ranges, record them. */ dwarf2_record_block_ranges (die, block, baseaddr, cu); diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c index 6653f7a9c64..24fb514831f 100644 --- a/gdb/rust-lang.c +++ b/gdb/rust-lang.c @@ -58,7 +58,7 @@ rust_last_path_segment (const char *path) std::string rust_crate_for_block (const struct block *block) { - const char *scope = block_scope (block); + const char *scope = block->scope (); if (scope[0] == '\0') return std::string (); diff --git a/gdb/rust-lang.h b/gdb/rust-lang.h index 497342d4ef3..37a22e7a404 100644 --- a/gdb/rust-lang.h +++ b/gdb/rust-lang.h @@ -148,7 +148,7 @@ class rust_language : public language_defn { struct block_symbol result = {}; - const char *scope = block == nullptr ? "" : block_scope (block); + const char *scope = block == nullptr ? "" : block->scope (); symbol_lookup_debug_printf ("rust_lookup_symbol_non_local (%s, %s (scope %s), %s)", name, host_address_to_string (block), scope, diff --git a/gdb/rust-parse.c b/gdb/rust-parse.c index 72b843ef40c..9074d651d85 100644 --- a/gdb/rust-parse.c +++ b/gdb/rust-parse.c @@ -375,7 +375,7 @@ rust_parser::super_name (const std::string &ident, unsigned int n_supers) { const char *scope = ""; if (pstate->expression_context_block != nullptr) - scope = block_scope (pstate->expression_context_block); + scope = pstate->expression_context_block->scope (); int offset; if (scope[0] == '\0') diff --git a/gdb/symtab.c b/gdb/symtab.c index 530de418e53..71b9ebe9efc 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -2184,7 +2184,7 @@ lookup_local_symbol (const char *name, struct symbol *sym; const struct block *static_block = block_static_block (block); - const char *scope = block_scope (block); + const char *scope = block->scope (); /* Check if it's a global block. */ if (static_block == nullptr) From patchwork Fri Jan 20 21:46:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 63528 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 5098F38983A4 for ; Fri, 20 Jan 2023 21:48:04 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from progateway7-pub.mail.pro1.eigbox.com (gproxy5-pub.mail.unifiedlayer.com [67.222.38.55]) by sourceware.org (Postfix) with ESMTPS id D418838582BE for ; Fri, 20 Jan 2023 21:46:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D418838582BE Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com Received: from cmgw13.mail.unifiedlayer.com (unknown [10.0.90.128]) by progateway7.mail.pro1.eigbox.com (Postfix) with ESMTP id 2FDBB10047406 for ; Fri, 20 Jan 2023 21:46:37 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id IzDZpfnPoNX2aIzDZpTG0O; Fri, 20 Jan 2023 21:46:37 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=NMAQR22g c=1 sm=1 tr=0 ts=63cb0bbd a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=RvmDmJFTN0MA:10:nop_rcvd_month_year a=Qbun_eYptAEA:10:endurance_base64_authed_username_1 a=hHD9YuAlLdXUJyrACvcA:9 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: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=SVdvXeHu245IBNAJibFB0mXlHVOxchP+OkTZD1hrZbo=; b=hxt2Q4rFngNZP3bOU7DvgRSKHW 6MDCplLFcAb5FXCLe6+bYeq+WYPCeK8oKIEK9WZ7o6gcjEtb9KtsTQz+WVAQqfarPlC1YWiM1tZkx Ugd2A74hT2k4E8+6iaxdmpvP9; Received: from 97-122-76-186.hlrn.qwest.net ([97.122.76.186]:60138 helo=localhost.localdomain) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1pIzDY-001GGF-TM; Fri, 20 Jan 2023 14:46:36 -0700 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 11/27] Convert block_linkage_function to method Date: Fri, 20 Jan 2023 14:46:02 -0700 Message-Id: <20230120214618.3236224-12-tom@tromey.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230120214618.3236224-1-tom@tromey.com> References: <20230120214618.3236224-1-tom@tromey.com> MIME-Version: 1.0 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.76.186 X-Source-L: No X-Exim-ID: 1pIzDY-001GGF-TM X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-76-186.hlrn.qwest.net (localhost.localdomain) [97.122.76.186]:60138 X-Source-Auth: tom+tromey.com X-Email-Count: 12 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3027.9 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 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.29 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 Sender: "Gdb-patches" This converts block_linkage_function to be a method. This was mostly written by script. --- gdb/ada-lang.c | 2 +- gdb/ax-gdb.c | 2 +- gdb/block.c | 10 ++++------ gdb/block.h | 9 +++++++-- gdb/blockframe.c | 4 ++-- gdb/breakpoint.c | 2 +- gdb/compile/compile-loc2c.c | 2 +- gdb/dwarf2/expr.c | 2 +- gdb/dwarf2/loc.c | 6 +++--- gdb/parse.c | 2 +- 10 files changed, 22 insertions(+), 19 deletions(-) diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 7830fff6d8e..2602700e0ce 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -5309,7 +5309,7 @@ remove_irrelevant_renamings (std::vector *syms, if (current_block == NULL) return; - current_function = block_linkage_function (current_block); + current_function = current_block->linkage_function (); if (current_function == NULL) return; diff --git a/gdb/ax-gdb.c b/gdb/ax-gdb.c index fc214e7dfe1..f4f9b150c46 100644 --- a/gdb/ax-gdb.c +++ b/gdb/ax-gdb.c @@ -1887,7 +1887,7 @@ op_this_operation::do_generate_ax (struct expression *exp, const struct language_defn *lang; b = block_for_pc (ax->scope); - func = block_linkage_function (b); + func = b->linkage_function (); lang = language_def (func->language ()); sym = lookup_language_this (lang, b).symbol; diff --git a/gdb/block.c b/gdb/block.c index fc523332a3d..dca6ff36f3b 100644 --- a/gdb/block.c +++ b/gdb/block.c @@ -86,15 +86,13 @@ contained_in (const struct block *a, const struct block *b, return false; } - -/* Return the symbol for the function which contains a specified - lexical block, described by a struct block BL. The return value - will not be an inlined function; the containing function will be - returned instead. */ +/* See block.h. */ struct symbol * -block_linkage_function (const struct block *bl) +block::linkage_function () const { + const block *bl = this; + while ((bl->function () == NULL || bl->inlined_p ()) && bl->superblock () != NULL) bl = bl->superblock (); diff --git a/gdb/block.h b/gdb/block.h index 680b7d0161e..d1f4409d863 100644 --- a/gdb/block.h +++ b/gdb/block.h @@ -231,6 +231,13 @@ struct block void set_using (struct using_direct *using_decl, struct obstack *obstack); + /* Return the symbol for the function which contains a specified + lexical block, described by a struct block. The return value + will not be an inlined function; the containing function will be + returned instead. */ + + struct symbol *linkage_function () const; + /* Addresses in the executable code that are in this block. */ CORE_ADDR m_start; @@ -364,8 +371,6 @@ struct blockvector struct block *m_blocks[1]; }; -extern struct symbol *block_linkage_function (const struct block *); - extern struct symbol *block_containing_function (const struct block *); /* Return true if block A is lexically nested within block B, or if a diff --git a/gdb/blockframe.c b/gdb/blockframe.c index 2796fc99154..65183b1946b 100644 --- a/gdb/blockframe.c +++ b/gdb/blockframe.c @@ -91,7 +91,7 @@ get_pc_function_start (CORE_ADDR pc) bl = block_for_pc (pc); if (bl) { - struct symbol *symbol = block_linkage_function (bl); + struct symbol *symbol = bl->linkage_function (); if (symbol) { @@ -139,7 +139,7 @@ find_pc_sect_function (CORE_ADDR pc, struct obj_section *section) if (b == 0) return 0; - return block_linkage_function (b); + return b->linkage_function (); } /* Return the function containing pc value PC. diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index 00cc2ab401c..475a16e8d73 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -9194,7 +9194,7 @@ resolve_sal_pc (struct symtab_and_line *sal) sal->symtab->compunit ()); if (bv != NULL) { - sym = block_linkage_function (b); + sym = b->linkage_function (); if (sym != NULL) { fixup_symbol_section (sym, sal->symtab->compunit ()->objfile ()); diff --git a/gdb/compile/compile-loc2c.c b/gdb/compile/compile-loc2c.c index 517cf89b9d2..853535258dc 100644 --- a/gdb/compile/compile-loc2c.c +++ b/gdb/compile/compile-loc2c.c @@ -892,7 +892,7 @@ do_compile_dwarf_expr_to_c (int indent, string_file *stream, if (!b) error (_("No block found for address")); - framefunc = block_linkage_function (b); + framefunc = b->linkage_function (); if (!framefunc) error (_("No function found for block")); diff --git a/gdb/dwarf2/expr.c b/gdb/dwarf2/expr.c index eecd18f59c9..5d597bfa9a6 100644 --- a/gdb/dwarf2/expr.c +++ b/gdb/dwarf2/expr.c @@ -771,7 +771,7 @@ dwarf_expr_context::get_frame_base (const gdb_byte **start, /* Use block_linkage_function, which returns a real (not inlined) function, instead of get_frame_function, which may return an inlined function. */ - symbol *framefunc = block_linkage_function (bl); + symbol *framefunc = bl->linkage_function (); /* If we found a frame-relative symbol then it was certainly within some function associated with a frame. If we can't find the frame, diff --git a/gdb/dwarf2/loc.c b/gdb/dwarf2/loc.c index fe91d609f19..92003c39d0e 100644 --- a/gdb/dwarf2/loc.c +++ b/gdb/dwarf2/loc.c @@ -451,7 +451,7 @@ dwarf2_find_location_expression (struct dwarf2_loclist_baton *baton, struct symbol *pc_func = NULL; if (pc_block) - pc_func = block_linkage_function (pc_block); + pc_func = pc_block->linkage_function (); if (pc_func && pc == pc_func->value_block ()->entry_pc ()) { @@ -2647,7 +2647,7 @@ dwarf2_compile_expr_to_ax (struct agent_expr *expr, struct axs_value *loc, if (!b) error (_("No block found for address")); - framefunc = block_linkage_function (b); + framefunc = b->linkage_function (); if (!framefunc) error (_("No function found for block")); @@ -3173,7 +3173,7 @@ locexpr_describe_location_piece (struct symbol *symbol, struct ui_file *stream, error (_("No block found for address for symbol \"%s\"."), symbol->print_name ()); - framefunc = block_linkage_function (b); + framefunc = b->linkage_function (); if (!framefunc) error (_("No function found for block for symbol \"%s\"."), diff --git a/gdb/parse.c b/gdb/parse.c index 2f7d58061ab..4c20b91f238 100644 --- a/gdb/parse.c +++ b/gdb/parse.c @@ -488,7 +488,7 @@ parse_exp_in_context (const char **stringptr, CORE_ADDR pc, the current frame language to parse the expression. That's why we do the following language detection only if the context block has been specifically provided. */ - struct symbol *func = block_linkage_function (block); + struct symbol *func = block->linkage_function (); if (func != NULL) lang = language_def (func->language ()); From patchwork Fri Jan 20 21:46:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 63523 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 64F79388A40F for ; Fri, 20 Jan 2023 21:47:33 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from gproxy2-pub.mail.unifiedlayer.com (gproxy2-pub.mail.unifiedlayer.com [69.89.18.3]) by sourceware.org (Postfix) with ESMTPS id 093083857803 for ; Fri, 20 Jan 2023 21:46:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 093083857803 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com Received: from cmgw15.mail.unifiedlayer.com (unknown [10.0.90.130]) by progateway4.mail.pro1.eigbox.com (Postfix) with ESMTP id 6CE151004710D for ; Fri, 20 Jan 2023 21:46:37 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id IzDZpwSqYbwScIzDZpCg1j; Fri, 20 Jan 2023 21:46:37 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=X8KXlEfe c=1 sm=1 tr=0 ts=63cb0bbd a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=RvmDmJFTN0MA:10:nop_rcvd_month_year a=Qbun_eYptAEA:10:endurance_base64_authed_username_1 a=UkEzC5QpeHEhf0a9RZ4A:9 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: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=gwskDxyOOWhuOavedyaQUl2Z78CsL3Bu+k4tNGsrT70=; b=BF40uWtlYQ0b+gTNtXoSUATKzJ 966Bkp/+N60iV6Yc7V2tdUfm5Lojbr24qKZ46uvxkaC2g1gQfYkwlp9ORZ5eFBGGYp3iDbJfz5N/b mM0WQhnWigYI3zbwHQHbvqCDe; Received: from 97-122-76-186.hlrn.qwest.net ([97.122.76.186]:60138 helo=localhost.localdomain) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1pIzDZ-001GGF-5R; Fri, 20 Jan 2023 14:46:37 -0700 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 12/27] Convert block_containing_function to method Date: Fri, 20 Jan 2023 14:46:03 -0700 Message-Id: <20230120214618.3236224-13-tom@tromey.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230120214618.3236224-1-tom@tromey.com> References: <20230120214618.3236224-1-tom@tromey.com> MIME-Version: 1.0 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.76.186 X-Source-L: No X-Exim-ID: 1pIzDZ-001GGF-5R X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-76-186.hlrn.qwest.net (localhost.localdomain) [97.122.76.186]:60138 X-Source-Auth: tom+tromey.com X-Email-Count: 13 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3027.9 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 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.29 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 Sender: "Gdb-patches" This converts block_containing_function to be a method. This was mostly written by script. --- gdb/block.c | 9 ++++----- gdb/block.h | 9 +++++++-- gdb/blockframe.c | 2 +- gdb/linespec.c | 2 +- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/gdb/block.c b/gdb/block.c index dca6ff36f3b..31916ce48dc 100644 --- a/gdb/block.c +++ b/gdb/block.c @@ -100,14 +100,13 @@ block::linkage_function () const return bl->function (); } -/* Return the symbol for the function which contains a specified - block, described by a struct block BL. The return value will be - the closest enclosing function, which might be an inline - function. */ +/* See block.h. */ struct symbol * -block_containing_function (const struct block *bl) +block::containing_function () const { + const block *bl = this; + while (bl->function () == NULL && bl->superblock () != NULL) bl = bl->superblock (); diff --git a/gdb/block.h b/gdb/block.h index d1f4409d863..9f1ba935abb 100644 --- a/gdb/block.h +++ b/gdb/block.h @@ -238,6 +238,13 @@ struct block struct symbol *linkage_function () const; + /* Return the symbol for the function which contains a specified + block, described by a struct block. The return value will be the + closest enclosing function, which might be an inline + function. */ + + struct symbol *containing_function () const; + /* Addresses in the executable code that are in this block. */ CORE_ADDR m_start; @@ -371,8 +378,6 @@ struct blockvector struct block *m_blocks[1]; }; -extern struct symbol *block_containing_function (const struct block *); - /* Return true if block A is lexically nested within block B, or if a and b have the same pc range. Return false otherwise. If ALLOW_NESTED is true, then block A is considered to be in block B diff --git a/gdb/blockframe.c b/gdb/blockframe.c index 65183b1946b..7c9faf487a7 100644 --- a/gdb/blockframe.c +++ b/gdb/blockframe.c @@ -162,7 +162,7 @@ find_pc_sect_containing_function (CORE_ADDR pc, struct obj_section *section) if (bl == nullptr) return nullptr; - return block_containing_function (bl); + return bl->containing_function (); } /* These variables are used to cache the most recent result of diff --git a/gdb/linespec.c b/gdb/linespec.c index d3def7ae070..61da545eb2e 100644 --- a/gdb/linespec.c +++ b/gdb/linespec.c @@ -2128,7 +2128,7 @@ create_sals_line_offset (struct linespec_state *self, if (filter[i]) { struct symbol *sym = (blocks[i] - ? block_containing_function (blocks[i]) + ? blocks[i]->containing_function () : NULL); if (self->funfirstline) From patchwork Fri Jan 20 21:46:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 63525 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 D32393893679 for ; Fri, 20 Jan 2023 21:47:44 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from alt-proxy28.mail.unifiedlayer.com (alt-proxy28.mail.unifiedlayer.com [74.220.216.123]) by sourceware.org (Postfix) with ESMTPS id 5E806385735E for ; Fri, 20 Jan 2023 21:46:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5E806385735E Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com Received: from cmgw12.mail.unifiedlayer.com (unknown [10.0.90.127]) by progateway1.mail.pro1.eigbox.com (Postfix) with ESMTP id D35221003FD9D for ; Fri, 20 Jan 2023 21:46:37 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id IzDZp994SiOW0IzDZpygDm; Fri, 20 Jan 2023 21:46:37 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=S5kcfKgP c=1 sm=1 tr=0 ts=63cb0bbd a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=RvmDmJFTN0MA:10:nop_rcvd_month_year a=Qbun_eYptAEA:10:endurance_base64_authed_username_1 a=Ab0uQ1DXlzr8lSvP7hYA:9 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: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=ythRX9FoGLofUMOb+YfVzqKQcqqxgBjqd/tLhHJlEl4=; b=WeNnVM60Yw4tzpHKFCuTPu6hO5 EzBu8xKQnjyNnngZ5Jaqtb3S3X//hf4v1wxg4aoByRPClD4Y8W9rqDI/WgkdwRXVoRsO2+s1HfpNe q14G0O+4w9C6OtzdiheG4YVaz; Received: from 97-122-76-186.hlrn.qwest.net ([97.122.76.186]:60138 helo=localhost.localdomain) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1pIzDZ-001GGF-Ej; Fri, 20 Jan 2023 14:46:37 -0700 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 13/27] Convert block_static_block and block_global_block to methods Date: Fri, 20 Jan 2023 14:46:04 -0700 Message-Id: <20230120214618.3236224-14-tom@tromey.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230120214618.3236224-1-tom@tromey.com> References: <20230120214618.3236224-1-tom@tromey.com> MIME-Version: 1.0 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.76.186 X-Source-L: No X-Exim-ID: 1pIzDZ-001GGF-Ej X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-76-186.hlrn.qwest.net (localhost.localdomain) [97.122.76.186]:60138 X-Source-Auth: tom+tromey.com X-Email-Count: 14 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3027.9 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 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.29 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 Sender: "Gdb-patches" This converts block_static_block and block_global_block to be methods. This was mostly written by script. It was simpler to convert them at the same time because they're often used near each other. --- gdb/ada-lang.c | 2 +- gdb/block.c | 18 ++++++++++-------- gdb/block.h | 13 +++++++++---- gdb/compile/compile-c-symbols.c | 6 +++--- gdb/compile/compile-cplus-symbols.c | 4 ++-- gdb/cp-namespace.c | 2 +- gdb/cp-support.c | 8 ++++---- gdb/findvar.c | 6 +++--- gdb/guile/scm-block.c | 4 ++-- gdb/python/py-block.c | 4 ++-- gdb/rust-parse.c | 2 +- gdb/symtab.c | 10 +++++----- 12 files changed, 43 insertions(+), 36 deletions(-) diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 2602700e0ce..57676f0de95 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -13818,7 +13818,7 @@ class ada_language : public language_defn sym = ada_lookup_symbol (name, (block == nullptr ? nullptr - : block_static_block (block)), + : block->static_block ()), domain); if (sym.symbol != NULL) return sym; diff --git a/gdb/block.c b/gdb/block.c index 31916ce48dc..c0d6ed7da97 100644 --- a/gdb/block.c +++ b/gdb/block.c @@ -47,7 +47,7 @@ block::objfile () const if (function () != nullptr) return function ()->objfile (); - global_block = (struct global_block *) block_global_block (this); + global_block = (struct global_block *) this->global_block (); return global_block->compunit_symtab->objfile (); } @@ -349,26 +349,28 @@ block::set_using (struct using_direct *using_decl, struct obstack *obstack) m_namespace_info->using_decl = using_decl; } -/* Return the static block associated to BLOCK. Return NULL if block - is a global block. */ +/* See block.h. */ const struct block * -block_static_block (const struct block *block) +block::static_block () const { - if (block->superblock () == NULL) - return NULL; + if (superblock () == nullptr) + return nullptr; + const block *block = this; while (block->superblock ()->superblock () != NULL) block = block->superblock (); return block; } -/* Return the static block associated to BLOCK. */ +/* See block.h. */ const struct block * -block_global_block (const struct block *block) +block::global_block () const { + const block *block = this; + while (block->superblock () != NULL) block = block->superblock (); diff --git a/gdb/block.h b/gdb/block.h index 9f1ba935abb..9ce8ef51945 100644 --- a/gdb/block.h +++ b/gdb/block.h @@ -245,6 +245,15 @@ struct block struct symbol *containing_function () const; + /* Return the static block associated with this block. Return NULL + if block is a global block. */ + + const struct block *static_block () const; + + /* Return the static block associated with block. */ + + const struct block *global_block () const; + /* Addresses in the executable code that are in this block. */ CORE_ADDR m_start; @@ -404,10 +413,6 @@ extern const struct block *block_for_pc (CORE_ADDR); extern const struct block *block_for_pc_sect (CORE_ADDR, struct obj_section *); -extern const struct block *block_static_block (const struct block *block); - -extern const struct block *block_global_block (const struct block *block); - extern struct block *allocate_block (struct obstack *obstack); extern struct block *allocate_global_block (struct obstack *obstack); diff --git a/gdb/compile/compile-c-symbols.c b/gdb/compile/compile-c-symbols.c index 79490b811c3..678cbcd5c44 100644 --- a/gdb/compile/compile-c-symbols.c +++ b/gdb/compile/compile-c-symbols.c @@ -228,7 +228,7 @@ convert_symbol_sym (compile_c_instance *context, const char *identifier, const struct block *static_block = nullptr; if (sym.block != nullptr) - static_block = block_static_block (sym.block); + static_block = sym.block->static_block (); /* STATIC_BLOCK is NULL if FOUND_BLOCK is the global block. */ is_local_symbol = (sym.block != static_block && static_block != NULL); if (is_local_symbol) @@ -239,7 +239,7 @@ convert_symbol_sym (compile_c_instance *context, const char *identifier, /* If the outer symbol is in the static block, we ignore it, as it cannot be referenced. */ if (global_sym.symbol != NULL - && global_sym.block != block_static_block (global_sym.block)) + && global_sym.block != global_sym.block->static_block ()) { if (compile_debug) gdb_printf (gdb_stdlog, @@ -617,7 +617,7 @@ generate_c_for_variable_locations (compile_instance *compiler, if (block == nullptr) return {}; - const struct block *static_block = block_static_block (block); + const struct block *static_block = block->static_block (); /* If we're already in the static or global block, there is nothing to write. */ diff --git a/gdb/compile/compile-cplus-symbols.c b/gdb/compile/compile-cplus-symbols.c index 45a76eef303..eff04406fb5 100644 --- a/gdb/compile/compile-cplus-symbols.c +++ b/gdb/compile/compile-cplus-symbols.c @@ -241,7 +241,7 @@ convert_symbol_sym (compile_cplus_instance *instance, const struct block *static_block = nullptr; if (sym.block != nullptr) - static_block = block_static_block (sym.block); + static_block = sym.block->static_block (); /* STATIC_BLOCK is NULL if FOUND_BLOCK is the global block. */ bool is_local_symbol = (sym.block != static_block && static_block != nullptr); if (is_local_symbol) @@ -252,7 +252,7 @@ convert_symbol_sym (compile_cplus_instance *instance, /* If the outer symbol is in the static block, we ignore it, as it cannot be referenced. */ if (global_sym.symbol != nullptr - && global_sym.block != block_static_block (global_sym.block)) + && global_sym.block != global_sym.block->static_block ()) { if (compile_debug) gdb_printf (gdb_stdlog, diff --git a/gdb/cp-namespace.c b/gdb/cp-namespace.c index 2d44b7bc047..14d807694b7 100644 --- a/gdb/cp-namespace.c +++ b/gdb/cp-namespace.c @@ -141,7 +141,7 @@ cp_basic_lookup_symbol (const char *name, const struct block *block, but should be treated as local to a single file nonetheless. So we only search the current file's global block. */ - const struct block *global_block = block_global_block (block); + const struct block *global_block = block->global_block (); if (global_block != NULL) { diff --git a/gdb/cp-support.c b/gdb/cp-support.c index 76407fdeb2f..cdaf5fd3e8e 100644 --- a/gdb/cp-support.c +++ b/gdb/cp-support.c @@ -1307,13 +1307,13 @@ add_symbol_overload_list_namespace (const char *func_name, /* Look in the static block. */ block = get_selected_block (0); - block = block == nullptr ? nullptr : block_static_block (block); + block = block == nullptr ? nullptr : block->static_block (); if (block != nullptr) { add_symbol_overload_list_block (name, block, overload_list); /* Look in the global block. */ - block = block_global_block (block); + block = block->global_block (); if (block) add_symbol_overload_list_block (name, block, overload_list); } @@ -1457,10 +1457,10 @@ add_symbol_overload_list_qualified (const char *func_name, b = b->superblock ()) add_symbol_overload_list_block (func_name, b, overload_list); - surrounding_static_block = block_static_block (get_selected_block (0)); + surrounding_static_block = get_selected_block (0); surrounding_static_block = (surrounding_static_block == nullptr ? nullptr - : block_static_block (surrounding_static_block)); + : surrounding_static_block->static_block ()); /* Go through the symtabs and check the externs and statics for symbols which match. */ diff --git a/gdb/findvar.c b/gdb/findvar.c index 656f982be2d..586ceb9dc72 100644 --- a/gdb/findvar.c +++ b/gdb/findvar.c @@ -460,8 +460,8 @@ get_hosting_frame (struct symbol *var, const struct block *var_block, tests that embed global/static symbols with null location lists. We want to get instead of when evaluating them so return a frame instead of raising an error. */ - else if (var_block == block_global_block (var_block) - || var_block == block_static_block (var_block)) + else if (var_block == var_block->global_block () + || var_block == var_block->static_block ()) return frame; /* We have to handle the "my_func::my_local_var" notation. This requires us @@ -486,7 +486,7 @@ get_hosting_frame (struct symbol *var, const struct block *var_block, /* If we failed to find the proper frame, fallback to the heuristic method below. */ - else if (frame_block == block_global_block (frame_block)) + else if (frame_block == frame_block->global_block ()) { frame = NULL; break; diff --git a/gdb/guile/scm-block.c b/gdb/guile/scm-block.c index 02cd3ff9a43..c9d847a4d60 100644 --- a/gdb/guile/scm-block.c +++ b/gdb/guile/scm-block.c @@ -438,7 +438,7 @@ gdbscm_block_global_block (SCM self) const struct block *block = b_smob->block; const struct block *global_block; - global_block = block_global_block (block); + global_block = block->global_block (); return bkscm_scm_from_block (global_block, b_smob->objfile); } @@ -458,7 +458,7 @@ gdbscm_block_static_block (SCM self) if (block->superblock () == NULL) return SCM_BOOL_F; - static_block = block_static_block (block); + static_block = block->static_block (); return bkscm_scm_from_block (static_block, b_smob->objfile); } diff --git a/gdb/python/py-block.c b/gdb/python/py-block.c index c399a01c4fb..bd2ce7fc181 100644 --- a/gdb/python/py-block.c +++ b/gdb/python/py-block.c @@ -188,7 +188,7 @@ blpy_get_global_block (PyObject *self, void *closure) BLPY_REQUIRE_VALID (self, block); - global_block = block_global_block (block); + global_block = block->global_block (); return block_to_block_object (global_block, self_obj->objfile); @@ -210,7 +210,7 @@ blpy_get_static_block (PyObject *self, void *closure) if (block->superblock () == NULL) Py_RETURN_NONE; - static_block = block_static_block (block); + static_block = block->static_block (); return block_to_block_object (static_block, self_obj->objfile); } diff --git a/gdb/rust-parse.c b/gdb/rust-parse.c index 9074d651d85..545d0141183 100644 --- a/gdb/rust-parse.c +++ b/gdb/rust-parse.c @@ -421,7 +421,7 @@ munge_name_and_block (const char **name, const struct block **block) if (startswith (*name, "::")) { *name += 2; - *block = block_static_block (*block); + *block = (*block)->static_block (); } } diff --git a/gdb/symtab.c b/gdb/symtab.c index 71b9ebe9efc..dd9cc7d5163 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -2183,7 +2183,7 @@ lookup_local_symbol (const char *name, return {}; struct symbol *sym; - const struct block *static_block = block_static_block (block); + const struct block *static_block = block->static_block (); const char *scope = block->scope (); /* Check if it's a global block. */ @@ -2489,7 +2489,7 @@ lookup_symbol_in_static_block (const char *name, if (block == nullptr) return {}; - const struct block *static_block = block_static_block (block); + const struct block *static_block = block->static_block (); struct symbol *sym; if (static_block == NULL) @@ -2624,7 +2624,7 @@ lookup_global_symbol (const char *name, global block first. This yields "more expected" behavior, and is needed to support 'FILENAME'::VARIABLE lookups. */ const struct block *global_block - = block == nullptr ? nullptr : block_global_block (block); + = block == nullptr ? nullptr : block->global_block (); symbol *sym = NULL; if (global_block != nullptr) { @@ -5861,8 +5861,8 @@ default_collect_symbol_completion_matches_break_on visible from current context. */ b = get_selected_block (0); - surrounding_static_block = b == nullptr ? nullptr : block_static_block (b); - surrounding_global_block = b == nullptr : nullptr : block_global_block (b); + surrounding_static_block = b == nullptr ? nullptr : b->static_block (); + surrounding_global_block = b == nullptr ? nullptr : b->global_block (); if (surrounding_static_block != NULL) while (b != surrounding_static_block) { From patchwork Fri Jan 20 21:46:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 63527 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 9FBCF38983A2 for ; Fri, 20 Jan 2023 21:48:01 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from gproxy3-pub.mail.unifiedlayer.com (gproxy3-pub.mail.unifiedlayer.com [69.89.30.42]) by sourceware.org (Postfix) with ESMTPS id 8BD2F385AC39 for ; Fri, 20 Jan 2023 21:46:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8BD2F385AC39 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com Received: from cmgw15.mail.unifiedlayer.com (unknown [10.0.90.130]) by progateway5.mail.pro1.eigbox.com (Postfix) with ESMTP id 0A6CF1004A83C for ; Fri, 20 Jan 2023 21:46:38 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id IzDZpwSqsbwScIzDapCg23; Fri, 20 Jan 2023 21:46:38 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=X8KXlEfe c=1 sm=1 tr=0 ts=63cb0bbe a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=RvmDmJFTN0MA:10:nop_rcvd_month_year a=Qbun_eYptAEA:10:endurance_base64_authed_username_1 a=G8Rx7z2txpoW---cwZQA:9 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: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=8MJjvwRCPFBoEII1ljXCXoS6UJHjjR8V858ds8LjfhA=; b=P3ufsmYSpGGOOIRzfxlOg9Y4Uk eDqKUM2Jij062nnAbAs4wJeb6jdLidL4Q9YIx8Uoo7BFu4+HLZNwB4vcfW4PwBrg6D4HHLuOOkmvZ pyD30OodXe1m7BrlpzFLDA71d; Received: from 97-122-76-186.hlrn.qwest.net ([97.122.76.186]:60138 helo=localhost.localdomain) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1pIzDZ-001GGF-Nm; Fri, 20 Jan 2023 14:46:37 -0700 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 14/27] Convert set_block_compunit_symtab to method Date: Fri, 20 Jan 2023 14:46:05 -0700 Message-Id: <20230120214618.3236224-15-tom@tromey.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230120214618.3236224-1-tom@tromey.com> References: <20230120214618.3236224-1-tom@tromey.com> MIME-Version: 1.0 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.76.186 X-Source-L: No X-Exim-ID: 1pIzDZ-001GGF-Nm X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-76-186.hlrn.qwest.net (localhost.localdomain) [97.122.76.186]:60138 X-Source-Auth: tom+tromey.com X-Email-Count: 15 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3027.9 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 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.29 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 Sender: "Gdb-patches" This converts set_block_compunit_symtab to be a method. This was mostly written by script. --- gdb/block.c | 8 ++++---- gdb/block.h | 7 ++++--- gdb/buildsym.c | 2 +- gdb/jit.c | 2 +- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/gdb/block.c b/gdb/block.c index c0d6ed7da97..3cd90dcb4ed 100644 --- a/gdb/block.c +++ b/gdb/block.c @@ -404,15 +404,15 @@ allocate_global_block (struct obstack *obstack) return &bl->block; } -/* Set the compunit of the global block. */ +/* See block.h. */ void -set_block_compunit_symtab (struct block *block, struct compunit_symtab *cu) +block::set_compunit_symtab (struct compunit_symtab *cu) { struct global_block *gb; - gdb_assert (block->superblock () == NULL); - gb = (struct global_block *) block; + gdb_assert (superblock () == NULL); + gb = (struct global_block *) this; gdb_assert (gb->compunit_symtab == NULL); gb->compunit_symtab = cu; } diff --git a/gdb/block.h b/gdb/block.h index 9ce8ef51945..ce8c9679a07 100644 --- a/gdb/block.h +++ b/gdb/block.h @@ -254,6 +254,10 @@ struct block const struct block *global_block () const; + /* Set the compunit of this block, which must be a global block. */ + + void set_compunit_symtab (struct compunit_symtab *); + /* Addresses in the executable code that are in this block. */ CORE_ADDR m_start; @@ -417,9 +421,6 @@ extern struct block *allocate_block (struct obstack *obstack); extern struct block *allocate_global_block (struct obstack *obstack); -extern void set_block_compunit_symtab (struct block *, - struct compunit_symtab *); - /* Return a property to evaluate the static link associated to BLOCK. In the context of nested functions (available in Pascal, Ada and GNU C, for diff --git a/gdb/buildsym.c b/gdb/buildsym.c index fd76e56599d..7a009c2f626 100644 --- a/gdb/buildsym.c +++ b/gdb/buildsym.c @@ -970,7 +970,7 @@ buildsym_compunit::end_compunit_symtab_with_blockvector { struct block *b = blockvector->global_block (); - set_block_compunit_symtab (b, cu); + b->set_compunit_symtab (cu); } cu->set_block_line_section (section); diff --git a/gdb/jit.c b/gdb/jit.c index 48bfef0a026..f584438c229 100644 --- a/gdb/jit.c +++ b/gdb/jit.c @@ -623,7 +623,7 @@ finalize_symtab (struct gdb_symtab *stab, struct objfile *objfile) bv->set_block (i, new_block); if (i == GLOBAL_BLOCK) - set_block_compunit_symtab (new_block, cust); + new_block->set_compunit_symtab (cust); } /* Fill up the superblock fields for the real blocks, using the From patchwork Fri Jan 20 21:46:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 63535 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 1F08E393BA56 for ; Fri, 20 Jan 2023 21:48:39 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from progateway7-pub.mail.pro1.eigbox.com (gproxy5-pub.mail.unifiedlayer.com [67.222.38.55]) by sourceware.org (Postfix) with ESMTPS id D5B573858031 for ; Fri, 20 Jan 2023 21:46:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D5B573858031 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com Received: from cmgw10.mail.unifiedlayer.com (unknown [10.0.90.125]) by progateway7.mail.pro1.eigbox.com (Postfix) with ESMTP id 4F4CF10047427 for ; Fri, 20 Jan 2023 21:46:38 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id IzDapicpUFqSRIzDap2cC0; Fri, 20 Jan 2023 21:46:38 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=c6Ru/Txl c=1 sm=1 tr=0 ts=63cb0bbe a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=RvmDmJFTN0MA:10:nop_rcvd_month_year a=Qbun_eYptAEA:10:endurance_base64_authed_username_1 a=J5fIvHI6Pr9BaEm0oNIA:9 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: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=RX5rWOpeP+szorpsPIg80vevZgxw6+/pH9TsBfs5aFM=; b=KCENXyh8EdxnGDbFQY6lMOVLR7 20AU6kRyJ1uo6KW5/ux3DOVQ7yZ6LbjdiAxWxj/kHN/WQNwtfCbm0GALi/B7YW5QPqZJXxD2SS0xb pN0t5uqAJcy9Z2jqI48rY8rF8; Received: from 97-122-76-186.hlrn.qwest.net ([97.122.76.186]:60138 helo=localhost.localdomain) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1pIzDa-001GGF-0o; Fri, 20 Jan 2023 14:46:38 -0700 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 15/27] Convert block_static_link to method Date: Fri, 20 Jan 2023 14:46:06 -0700 Message-Id: <20230120214618.3236224-16-tom@tromey.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230120214618.3236224-1-tom@tromey.com> References: <20230120214618.3236224-1-tom@tromey.com> MIME-Version: 1.0 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.76.186 X-Source-L: No X-Exim-ID: 1pIzDa-001GGF-0o X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-76-186.hlrn.qwest.net (localhost.localdomain) [97.122.76.186]:60138 X-Source-Auth: tom+tromey.com X-Email-Count: 16 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3027.9 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 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.29 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 Sender: "Gdb-patches" This converts block_static_link to be a method. This was mostly written by script. --- gdb/block.c | 8 ++++---- gdb/block.h | 24 +++++++++++++----------- gdb/findvar.c | 2 +- 3 files changed, 18 insertions(+), 16 deletions(-) diff --git a/gdb/block.c b/gdb/block.c index 3cd90dcb4ed..8aa0e676894 100644 --- a/gdb/block.c +++ b/gdb/block.c @@ -420,16 +420,16 @@ block::set_compunit_symtab (struct compunit_symtab *cu) /* See block.h. */ struct dynamic_prop * -block_static_link (const struct block *block) +block::static_link () const { - struct objfile *objfile = block->objfile (); + struct objfile *objfile = this->objfile (); /* Only objfile-owned blocks that materialize top function scopes can have static links. */ - if (objfile == NULL || block->function () == NULL) + if (objfile == NULL || function () == NULL) return NULL; - return (struct dynamic_prop *) objfile_lookup_static_link (objfile, block); + return (struct dynamic_prop *) objfile_lookup_static_link (objfile, this); } /* Return the compunit of the global block. */ diff --git a/gdb/block.h b/gdb/block.h index ce8c9679a07..9bc80490d7c 100644 --- a/gdb/block.h +++ b/gdb/block.h @@ -258,6 +258,19 @@ struct block void set_compunit_symtab (struct compunit_symtab *); + /* Return a property to evaluate the static link associated to this + block. + + In the context of nested functions (available in Pascal, Ada and + GNU C, for instance), a static link (as in DWARF's + DW_AT_static_link attribute) for a function is a way to get the + frame corresponding to the enclosing function. + + Note that only objfile-owned and function-level blocks can have a + static link. Return NULL if there is no such property. */ + + struct dynamic_prop *static_link () const; + /* Addresses in the executable code that are in this block. */ CORE_ADDR m_start; @@ -421,17 +434,6 @@ extern struct block *allocate_block (struct obstack *obstack); extern struct block *allocate_global_block (struct obstack *obstack); -/* Return a property to evaluate the static link associated to BLOCK. - - In the context of nested functions (available in Pascal, Ada and GNU C, for - instance), a static link (as in DWARF's DW_AT_static_link attribute) for a - function is a way to get the frame corresponding to the enclosing function. - - Note that only objfile-owned and function-level blocks can have a static - link. Return NULL if there is no such property. */ - -extern struct dynamic_prop *block_static_link (const struct block *block); - /* A block iterator. This structure should be treated as though it were opaque; it is only defined here because we want to support stack allocation of iterators. */ diff --git a/gdb/findvar.c b/gdb/findvar.c index 586ceb9dc72..8564047290e 100644 --- a/gdb/findvar.c +++ b/gdb/findvar.c @@ -498,7 +498,7 @@ get_hosting_frame (struct symbol *var, const struct block *var_block, else if (frame_block->function ()) { const struct dynamic_prop *static_link - = block_static_link (frame_block); + = frame_block->static_link (); int could_climb_up = 0; if (static_link != NULL) From patchwork Fri Jan 20 21:46:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 63529 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 648BA3881D01 for ; Fri, 20 Jan 2023 21:48:04 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from alt-proxy28.mail.unifiedlayer.com (alt-proxy28.mail.unifiedlayer.com [74.220.216.123]) by sourceware.org (Postfix) with ESMTPS id 24964385840C for ; Fri, 20 Jan 2023 21:46:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 24964385840C Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com Received: from cmgw12.mail.unifiedlayer.com (unknown [10.0.90.127]) by progateway1.mail.pro1.eigbox.com (Postfix) with ESMTP id 90E151003FBA4 for ; Fri, 20 Jan 2023 21:46:38 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id IzDap994uiOW0IzDapygEB; Fri, 20 Jan 2023 21:46:38 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=S5kcfKgP c=1 sm=1 tr=0 ts=63cb0bbe a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=RvmDmJFTN0MA:10:nop_rcvd_month_year a=Qbun_eYptAEA:10:endurance_base64_authed_username_1 a=rZQGfaXeXV2KTLFHH24A:9 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: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=wVBTzlYkn/fdoV+0xJamGK4WE3FDBjf89lEoFnxNoks=; b=K+k/77aYcCwfWBHN4Qw8UGJV2I 6E/5b57gurMTFWihFyElFeX60j6eL45tZNJF9akmDsm8lidDS5ZcOf3givF0yEGdPXHueMx7bRMOE H8Iee3CIqAC1xu8ArSj+LnDzj; Received: from 97-122-76-186.hlrn.qwest.net ([97.122.76.186]:60138 helo=localhost.localdomain) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1pIzDa-001GGF-AR; Fri, 20 Jan 2023 14:46:38 -0700 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 16/27] Store 'name' in block_iterator Date: Fri, 20 Jan 2023 14:46:07 -0700 Message-Id: <20230120214618.3236224-17-tom@tromey.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230120214618.3236224-1-tom@tromey.com> References: <20230120214618.3236224-1-tom@tromey.com> MIME-Version: 1.0 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.76.186 X-Source-L: No X-Exim-ID: 1pIzDa-001GGF-AR X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-76-186.hlrn.qwest.net (localhost.localdomain) [97.122.76.186]:60138 X-Source-Auth: tom+tromey.com X-Email-Count: 17 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3027.9 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 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.29 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 Sender: "Gdb-patches" This changes the block_iterator to store the 'name' that is used by block_iter_match_next. This avoids any problem where the name could be passed inconsistently, and also makes the subsequent patches easier to understand. --- gdb/ada-lang.c | 2 +- gdb/block.c | 22 ++++++++++++---------- gdb/block.h | 10 ++++++---- 3 files changed, 19 insertions(+), 15 deletions(-) diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 57676f0de95..c04d75590fb 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -6087,7 +6087,7 @@ ada_add_block_symbols (std::vector &result, found_sym = false; for (sym = block_iter_match_first (block, lookup_name, &iter); sym != NULL; - sym = block_iter_match_next (lookup_name, &iter)) + sym = block_iter_match_next (&iter)) { if (symbol_matches_domain (sym->language (), sym->domain (), domain)) { diff --git a/gdb/block.c b/gdb/block.c index 8aa0e676894..e56c95013b8 100644 --- a/gdb/block.c +++ b/gdb/block.c @@ -453,12 +453,14 @@ get_block_compunit_symtab (const struct block *block) static void initialize_block_iterator (const struct block *block, - struct block_iterator *iter) + struct block_iterator *iter, + const lookup_name_info *name = nullptr) { enum block_enum which; struct compunit_symtab *cu; iter->idx = -1; + iter->name = name; if (block->superblock () == NULL) { @@ -585,7 +587,6 @@ block_iterator_next (struct block_iterator *iterator) static struct symbol * block_iter_match_step (struct block_iterator *iterator, - const lookup_name_info &name, int first) { struct symbol *sym; @@ -605,11 +606,11 @@ block_iter_match_step (struct block_iterator *iterator, return NULL; block = cust->blockvector ()->block (iterator->which); - sym = mdict_iter_match_first (block->multidict (), name, + sym = mdict_iter_match_first (block->multidict (), *iterator->name, &iterator->mdict_iter); } else - sym = mdict_iter_match_next (name, &iterator->mdict_iter); + sym = mdict_iter_match_next (*iterator->name, &iterator->mdict_iter); if (sym != NULL) return sym; @@ -629,25 +630,26 @@ block_iter_match_first (const struct block *block, const lookup_name_info &name, struct block_iterator *iterator) { - initialize_block_iterator (block, iterator); + initialize_block_iterator (block, iterator, &name); if (iterator->which == FIRST_LOCAL_BLOCK) return mdict_iter_match_first (block->multidict (), name, &iterator->mdict_iter); - return block_iter_match_step (iterator, name, 1); + return block_iter_match_step (iterator, 1); } /* See block.h. */ struct symbol * -block_iter_match_next (const lookup_name_info &name, - struct block_iterator *iterator) +block_iter_match_next (struct block_iterator *iterator) { + gdb_assert (iterator->name != nullptr); + if (iterator->which == FIRST_LOCAL_BLOCK) - return mdict_iter_match_next (name, &iterator->mdict_iter); + return mdict_iter_match_next (*iterator->name, &iterator->mdict_iter); - return block_iter_match_step (iterator, name, 0); + return block_iter_match_step (iterator, 0); } /* See block.h. */ diff --git a/gdb/block.h b/gdb/block.h index 9bc80490d7c..5fc41c6df02 100644 --- a/gdb/block.h +++ b/gdb/block.h @@ -449,6 +449,9 @@ struct block_iterator const struct block *block; } d; + /* If we're trying to match a name, this will be non-NULL. */ + const lookup_name_info *name; + /* If we're iterating over a single block, this is always -1. Otherwise, it holds the index of the current "included" symtab in the canonical symtab (that is, d.symtab->includes[idx]), with -1 @@ -493,10 +496,9 @@ extern struct symbol *block_iter_match_first (const struct block *block, symbols. Don't call this if you've previously received NULL from block_iterator_match_first or block_iterator_match_next on this iteration. And don't call it unless ITERATOR was created by a - previous call to block_iter_match_first with the same NAME. */ + previous call to block_iter_match_first. */ -extern struct symbol *block_iter_match_next - (const lookup_name_info &name, struct block_iterator *iterator); +extern struct symbol *block_iter_match_next (struct block_iterator *iterator); /* Return true if symbol A is the best match possible for DOMAIN. */ @@ -574,7 +576,7 @@ extern int block_find_non_opaque_type_preferred (struct symbol *sym, #define ALL_BLOCK_SYMBOLS_WITH_NAME(block, name, iter, sym) \ for ((sym) = block_iter_match_first ((block), (name), &(iter)); \ (sym) != NULL; \ - (sym) = block_iter_match_next ((name), &(iter))) + (sym) = block_iter_match_next (&(iter))) /* Given a vector of pairs, allocate and build an obstack allocated blockranges struct for a block. */ From patchwork Fri Jan 20 21:46:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 63532 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 82350392AC14 for ; Fri, 20 Jan 2023 21:48:22 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from gproxy3-pub.mail.unifiedlayer.com (gproxy3-pub.mail.unifiedlayer.com [69.89.30.42]) by sourceware.org (Postfix) with ESMTPS id AE21B385B513 for ; Fri, 20 Jan 2023 21:46:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org AE21B385B513 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com Received: from cmgw12.mail.unifiedlayer.com (unknown [10.0.90.127]) by progateway5.mail.pro1.eigbox.com (Postfix) with ESMTP id DCD541004A844 for ; Fri, 20 Jan 2023 21:46:38 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id IzDap9956iOW0IzDapygEN; Fri, 20 Jan 2023 21:46:38 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=S5kcfKgP c=1 sm=1 tr=0 ts=63cb0bbe a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=RvmDmJFTN0MA:10:nop_rcvd_month_year a=Qbun_eYptAEA:10:endurance_base64_authed_username_1 a=mTsGrRJ_k39uHTPAlbMA:9 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: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=Vy5C6aq2eK6V2ijAeZMBkBV0NjCJmWJK49u6xHWxwRc=; b=WkgRFcQa04bNEGNakLirQwnoUP EiP/6rxqcPGE2h5dUg5HhqBhCp2ssXJh5eOyGwWBVhoCsbC+94V+geZeMsy4/mQLl+VU1LjXct4V/ SS7TG4e366yqqUStENdyrCAAG; Received: from 97-122-76-186.hlrn.qwest.net ([97.122.76.186]:60138 helo=localhost.localdomain) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1pIzDa-001GGF-Ks; Fri, 20 Jan 2023 14:46:38 -0700 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 17/27] Combine both styles of block iterator Date: Fri, 20 Jan 2023 14:46:08 -0700 Message-Id: <20230120214618.3236224-18-tom@tromey.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230120214618.3236224-1-tom@tromey.com> References: <20230120214618.3236224-1-tom@tromey.com> MIME-Version: 1.0 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.76.186 X-Source-L: No X-Exim-ID: 1pIzDa-001GGF-Ks X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-76-186.hlrn.qwest.net (localhost.localdomain) [97.122.76.186]:60138 X-Source-Auth: tom+tromey.com X-Email-Count: 18 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3027.9 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 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.29 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 Sender: "Gdb-patches" This merges the two styles of block iterator, having the initialization API decide which to use based on an optional parameter. --- gdb/ada-lang.c | 4 ++-- gdb/block.c | 54 ++++++++++++++++++++------------------------------ gdb/block.h | 30 ++++++++-------------------- 3 files changed, 32 insertions(+), 56 deletions(-) diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index c04d75590fb..4d2873cfde4 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -6085,9 +6085,9 @@ ada_add_block_symbols (std::vector &result, arg_sym = NULL; found_sym = false; - for (sym = block_iter_match_first (block, lookup_name, &iter); + for (sym = block_iterator_first (block, &iter, &lookup_name); sym != NULL; - sym = block_iter_match_next (&iter)) + sym = block_iterator_next (&iter)) { if (symbol_matches_domain (sym->language (), sym->domain (), domain)) { diff --git a/gdb/block.c b/gdb/block.c index e56c95013b8..e7a51af8cea 100644 --- a/gdb/block.c +++ b/gdb/block.c @@ -556,31 +556,6 @@ block_iterator_step (struct block_iterator *iterator, int first) } } -/* See block.h. */ - -struct symbol * -block_iterator_first (const struct block *block, - struct block_iterator *iterator) -{ - initialize_block_iterator (block, iterator); - - if (iterator->which == FIRST_LOCAL_BLOCK) - return mdict_iterator_first (block->multidict (), &iterator->mdict_iter); - - return block_iterator_step (iterator, 1); -} - -/* See block.h. */ - -struct symbol * -block_iterator_next (struct block_iterator *iterator) -{ - if (iterator->which == FIRST_LOCAL_BLOCK) - return mdict_iterator_next (&iterator->mdict_iter); - - return block_iterator_step (iterator, 0); -} - /* Perform a single step for a "match" block iterator, iterating across symbol tables as needed. Returns the next symbol, or NULL when iteration is complete. */ @@ -626,14 +601,23 @@ block_iter_match_step (struct block_iterator *iterator, /* See block.h. */ struct symbol * -block_iter_match_first (const struct block *block, - const lookup_name_info &name, - struct block_iterator *iterator) +block_iterator_first (const struct block *block, + struct block_iterator *iterator, + const lookup_name_info *name) { - initialize_block_iterator (block, iterator, &name); + initialize_block_iterator (block, iterator, name); + + if (name == nullptr) + { + if (iterator->which == FIRST_LOCAL_BLOCK) + return mdict_iterator_first (block->multidict (), + &iterator->mdict_iter); + + return block_iterator_step (iterator, 1); + } if (iterator->which == FIRST_LOCAL_BLOCK) - return mdict_iter_match_first (block->multidict (), name, + return mdict_iter_match_first (block->multidict (), *name, &iterator->mdict_iter); return block_iter_match_step (iterator, 1); @@ -642,9 +626,15 @@ block_iter_match_first (const struct block *block, /* See block.h. */ struct symbol * -block_iter_match_next (struct block_iterator *iterator) +block_iterator_next (struct block_iterator *iterator) { - gdb_assert (iterator->name != nullptr); + if (iterator->name == nullptr) + { + if (iterator->which == FIRST_LOCAL_BLOCK) + return mdict_iterator_next (&iterator->mdict_iter); + + return block_iterator_step (iterator, 0); + } if (iterator->which == FIRST_LOCAL_BLOCK) return mdict_iter_match_next (*iterator->name, &iterator->mdict_iter); diff --git a/gdb/block.h b/gdb/block.h index 5fc41c6df02..03aeebddc6b 100644 --- a/gdb/block.h +++ b/gdb/block.h @@ -471,10 +471,13 @@ struct block_iterator }; /* Initialize ITERATOR to point at the first symbol in BLOCK, and - return that first symbol, or NULL if BLOCK is empty. */ + return that first symbol, or NULL if BLOCK is empty. If NAME is + not NULL, only return symbols matching that name. */ -extern struct symbol *block_iterator_first (const struct block *block, - struct block_iterator *iterator); +extern struct symbol *block_iterator_first + (const struct block *block, + struct block_iterator *iterator, + const lookup_name_info *name = nullptr); /* Advance ITERATOR, and return the next symbol, or NULL if there are no more symbols. Don't call this if you've previously received @@ -483,23 +486,6 @@ extern struct symbol *block_iterator_first (const struct block *block, extern struct symbol *block_iterator_next (struct block_iterator *iterator); -/* Initialize ITERATOR to point at the first symbol in BLOCK whose - search_name () matches NAME, and return that first symbol, or - NULL if there are no such symbols. */ - -extern struct symbol *block_iter_match_first (const struct block *block, - const lookup_name_info &name, - struct block_iterator *iterator); - -/* Advance ITERATOR to point at the next symbol in BLOCK whose - search_name () matches NAME, or NULL if there are no more such - symbols. Don't call this if you've previously received NULL from - block_iterator_match_first or block_iterator_match_next on this - iteration. And don't call it unless ITERATOR was created by a - previous call to block_iter_match_first. */ - -extern struct symbol *block_iter_match_next (struct block_iterator *iterator); - /* Return true if symbol A is the best match possible for DOMAIN. */ extern bool best_symbol (struct symbol *a, const domain_enum domain); @@ -574,9 +560,9 @@ extern int block_find_non_opaque_type_preferred (struct symbol *sym, current symbol. */ #define ALL_BLOCK_SYMBOLS_WITH_NAME(block, name, iter, sym) \ - for ((sym) = block_iter_match_first ((block), (name), &(iter)); \ + for ((sym) = block_iterator_first ((block), &(iter), &(name)); \ (sym) != NULL; \ - (sym) = block_iter_match_next (&(iter))) + (sym) = block_iterator_next (&(iter))) /* Given a vector of pairs, allocate and build an obstack allocated blockranges struct for a block. */ From patchwork Fri Jan 20 21:46:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 63540 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 E69E4388B6BF for ; Fri, 20 Jan 2023 21:48:55 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from progateway7-pub.mail.pro1.eigbox.com (gproxy5-pub.mail.unifiedlayer.com [67.222.38.55]) by sourceware.org (Postfix) with ESMTPS id B38903858017 for ; Fri, 20 Jan 2023 21:46:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B38903858017 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com Received: from cmgw10.mail.unifiedlayer.com (unknown [10.0.90.125]) by progateway7.mail.pro1.eigbox.com (Postfix) with ESMTP id 35C5A1004742A for ; Fri, 20 Jan 2023 21:46:39 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id IzDbpicpyFqSRIzDbp2cCU; Fri, 20 Jan 2023 21:46:39 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=c6Ru/Txl c=1 sm=1 tr=0 ts=63cb0bbf a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=RvmDmJFTN0MA:10:nop_rcvd_month_year a=Qbun_eYptAEA:10:endurance_base64_authed_username_1 a=1mjjgI5fTrsUeT8PmPUA:9 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: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=moGmDb8KLobaerTvExgK+A2eYMXwhq2VjwZXaTY+QUY=; b=VTX72j6Jzh1Ori9qaGv12moWDJ pftLv7yrOJNX4bAhCjI066couO1/HlEr/lx/LBS1HmaoqdR6KVuE5zmcSapEz/kGtjdu+20o1aAcV DmDABw6gtakXefdVOhokFvpU0; Received: from 97-122-76-186.hlrn.qwest.net ([97.122.76.186]:60138 helo=localhost.localdomain) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1pIzDa-001GGF-TQ; Fri, 20 Jan 2023 14:46:38 -0700 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 18/27] Introduce a block iterator wrapper Date: Fri, 20 Jan 2023 14:46:09 -0700 Message-Id: <20230120214618.3236224-19-tom@tromey.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230120214618.3236224-1-tom@tromey.com> References: <20230120214618.3236224-1-tom@tromey.com> MIME-Version: 1.0 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.76.186 X-Source-L: No X-Exim-ID: 1pIzDa-001GGF-TQ X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-76-186.hlrn.qwest.net (localhost.localdomain) [97.122.76.186]:60138 X-Source-Auth: tom+tromey.com X-Email-Count: 19 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3027.9 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 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.29 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 Sender: "Gdb-patches" This introduces a C++-style iterator that wraps the existing block_iterator. It also adds a range adapter. These will be used in a later patch. --- gdb/block.h | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/gdb/block.h b/gdb/block.h index 03aeebddc6b..7341d03a07e 100644 --- a/gdb/block.h +++ b/gdb/block.h @@ -486,6 +486,56 @@ extern struct symbol *block_iterator_first extern struct symbol *block_iterator_next (struct block_iterator *iterator); +/* An iterator that wraps a block_iterator. The naming here is + unfortunate, but block_iterator was named before gdb switched to + C++. */ +struct block_iterator_wrapper +{ + typedef block_iterator_wrapper self_type; + typedef struct symbol *value_type; + + explicit block_iterator_wrapper (const struct block *block, + const lookup_name_info *name = nullptr) + : m_sym (block_iterator_first (block, &m_iter, name)) + { + } + + block_iterator_wrapper () + : m_sym (nullptr) + { + } + + value_type operator* () const + { + return m_sym; + } + + bool operator== (const self_type &other) const + { + return m_sym == other.m_sym; + } + + bool operator!= (const self_type &other) const + { + return m_sym != other.m_sym; + } + + self_type &operator++ () + { + m_sym = block_iterator_next (&m_iter); + return *this; + } + +private: + + struct symbol *m_sym; + struct block_iterator m_iter; +}; + +/* An iterator range for block_iterator_wrapper. */ + +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); From patchwork Fri Jan 20 21:46:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 63542 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 C94AF3858C5E for ; Fri, 20 Jan 2023 21:49:10 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from alt-proxy28.mail.unifiedlayer.com (alt-proxy28.mail.unifiedlayer.com [74.220.216.123]) by sourceware.org (Postfix) with ESMTPS id F031B3857BB3 for ; Fri, 20 Jan 2023 21:46:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org F031B3857BB3 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com Received: from cmgw13.mail.unifiedlayer.com (unknown [10.0.90.128]) by progateway1.mail.pro1.eigbox.com (Postfix) with ESMTP id 6B21A1003FBD0 for ; Fri, 20 Jan 2023 21:46:39 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id IzDbpfnR5NX2aIzDbpTG1e; Fri, 20 Jan 2023 21:46:39 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=NMAQR22g c=1 sm=1 tr=0 ts=63cb0bbf a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=RvmDmJFTN0MA:10:nop_rcvd_month_year a=Qbun_eYptAEA:10:endurance_base64_authed_username_1 a=8bGJB5VeUK7IXM0ZKesA:9 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: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=aJ1tUA517jMyYaAuQzEm4RuCU9PTG/lpuF0NqNLhAVw=; b=MTJMBKuFDsPzZ07zdc9cYdilE9 xEm6Gx1znq/PvhlxDFQqIls5ikAHWHW+LvpT/TBgow/Mge+0TcS9wVB99G0OP2/4TyfHLf6dqUXj/ VOWRN7QdRTJGOglZd4ejLbJLn; Received: from 97-122-76-186.hlrn.qwest.net ([97.122.76.186]:60138 helo=localhost.localdomain) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1pIzDb-001GGF-5y; Fri, 20 Jan 2023 14:46:39 -0700 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 19/27] Convert explicit iterator uses to foreach Date: Fri, 20 Jan 2023 14:46:10 -0700 Message-Id: <20230120214618.3236224-20-tom@tromey.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230120214618.3236224-1-tom@tromey.com> References: <20230120214618.3236224-1-tom@tromey.com> MIME-Version: 1.0 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.76.186 X-Source-L: No X-Exim-ID: 1pIzDb-001GGF-5y X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-76-186.hlrn.qwest.net (localhost.localdomain) [97.122.76.186]:60138 X-Source-Auth: tom+tromey.com X-Email-Count: 20 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3027.9 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 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.29 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 Sender: "Gdb-patches" This converts most existing explicit uses of block_iterator to use foreach with the range iterator instead. --- gdb/ada-lang.c | 8 +++----- gdb/compile/compile-c-symbols.c | 7 +------ gdb/guile/scm-block.c | 7 +------ 3 files changed, 5 insertions(+), 17 deletions(-) diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 4d2873cfde4..b5e9f2ecff6 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -6076,18 +6076,14 @@ ada_add_block_symbols (std::vector &result, const lookup_name_info &lookup_name, domain_enum domain, struct objfile *objfile) { - struct block_iterator iter; /* A matching argument symbol, if any. */ struct symbol *arg_sym; /* Set true when we find a matching non-argument symbol. */ bool found_sym; - struct symbol *sym; arg_sym = NULL; found_sym = false; - for (sym = block_iterator_first (block, &iter, &lookup_name); - sym != NULL; - sym = block_iterator_next (&iter)) + for (struct symbol *sym : block_iterator_range (block, &lookup_name)) { if (symbol_matches_domain (sym->language (), sym->domain (), domain)) { @@ -6125,6 +6121,8 @@ ada_add_block_symbols (std::vector &result, const std::string &ada_lookup_name = lookup_name.ada ().lookup_name (); const char *name = ada_lookup_name.c_str (); size_t name_len = ada_lookup_name.size (); + struct symbol *sym; + struct block_iterator iter; ALL_BLOCK_SYMBOLS (block, iter, sym) { diff --git a/gdb/compile/compile-c-symbols.c b/gdb/compile/compile-c-symbols.c index 678cbcd5c44..e7d565bcd77 100644 --- a/gdb/compile/compile-c-symbols.c +++ b/gdb/compile/compile-c-symbols.c @@ -633,14 +633,9 @@ generate_c_for_variable_locations (compile_instance *compiler, while (1) { - struct symbol *sym; - struct block_iterator iter; - /* Iterate over symbols in this block, generating code to compute the location of each local variable. */ - for (sym = block_iterator_first (block, &iter); - sym != NULL; - sym = block_iterator_next (&iter)) + for (struct symbol *sym : block_iterator_range (block)) { if (!symbol_seen (symhash.get (), sym)) generate_c_for_for_one_variable (compiler, stream, gdbarch, diff --git a/gdb/guile/scm-block.c b/gdb/guile/scm-block.c index c9d847a4d60..02b7a48be37 100644 --- a/gdb/guile/scm-block.c +++ b/gdb/guile/scm-block.c @@ -501,20 +501,15 @@ gdbscm_block_symbols (SCM self) block_smob *b_smob = bkscm_get_valid_block_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME); const struct block *block = b_smob->block; - struct block_iterator iter; - struct symbol *sym; SCM result; result = SCM_EOL; - sym = block_iterator_first (block, &iter); - - while (sym != NULL) + for (struct symbol *sym : block_iterator_range (block)) { SCM s_scm = syscm_scm_from_symbol (sym); result = scm_cons (s_scm, result); - sym = block_iterator_next (&iter); } return scm_reverse_x (result, SCM_EOL); From patchwork Fri Jan 20 21:46:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 63533 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 BF42A393BA54 for ; Fri, 20 Jan 2023 21:48:23 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from outbound-ss-820.bluehost.com (outbound-ss-820.bluehost.com [69.89.24.241]) by sourceware.org (Postfix) with ESMTPS id A3209385B50D for ; Fri, 20 Jan 2023 21:46:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A3209385B50D Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com Received: from cmgw11.mail.unifiedlayer.com (unknown [10.0.90.126]) by progateway2.mail.pro1.eigbox.com (Postfix) with ESMTP id D8A5010048535 for ; Fri, 20 Jan 2023 21:46:41 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id IzDdpoFsWJceRIzDdprVF7; Fri, 20 Jan 2023 21:46:41 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=Or6Kdwzt c=1 sm=1 tr=0 ts=63cb0bc1 a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=RvmDmJFTN0MA:10:nop_rcvd_month_year a=Qbun_eYptAEA:10:endurance_base64_authed_username_1 a=aDYKaIEL3NOihMrxle4A:9 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: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=C37ThrxjuH1v1FoshSybIMG2xFn+O2t1fIuVUvZRmaI=; b=EA4KUtFCF5/9CwWXuzUA4IDdXb ZNnjLFZihBBjZesWXq5xWYVu0qtlOYYhV3RtiH7pNV0UkVa3HFvKifqCZ91r53FhiagVod7+RLcdO 8kyu6zN94kNdWPqAsZjdvoSJ/; Received: from 97-122-76-186.hlrn.qwest.net ([97.122.76.186]:60144 helo=localhost.localdomain) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1pIzDd-001GNx-I3; Fri, 20 Jan 2023 14:46:41 -0700 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 20/27] Remove ALL_BLOCK_SYMBOLS_WITH_NAME Date: Fri, 20 Jan 2023 14:46:11 -0700 Message-Id: <20230120214618.3236224-21-tom@tromey.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230120214618.3236224-1-tom@tromey.com> References: <20230120214618.3236224-1-tom@tromey.com> MIME-Version: 1.0 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.76.186 X-Source-L: No X-Exim-ID: 1pIzDd-001GNx-I3 X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-76-186.hlrn.qwest.net (localhost.localdomain) [97.122.76.186]:60144 X-Source-Auth: tom+tromey.com X-Email-Count: 21 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3027.9 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 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.29 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 Sender: "Gdb-patches" This removes ALL_BLOCK_SYMBOLS_WITH_NAME in favor of foreach. --- gdb/block.c | 12 +++--------- gdb/block.h | 10 ---------- gdb/cp-support.c | 5 +---- gdb/python/py-block.c | 22 ++++++++-------------- gdb/symtab.c | 5 +---- 5 files changed, 13 insertions(+), 41 deletions(-) diff --git a/gdb/block.c b/gdb/block.c index e7a51af8cea..0870793dcd4 100644 --- a/gdb/block.c +++ b/gdb/block.c @@ -692,16 +692,13 @@ block_lookup_symbol (const struct block *block, const char *name, symbol_name_match_type match_type, const domain_enum domain) { - struct block_iterator iter; - struct symbol *sym; - lookup_name_info lookup_name (name, match_type); if (!block->function ()) { struct symbol *other = NULL; - ALL_BLOCK_SYMBOLS_WITH_NAME (block, lookup_name, iter, sym) + for (struct symbol *sym : block_iterator_range (block, &lookup_name)) { /* See comment related to PR gcc/debug/91507 in block_lookup_symbol_primary. */ @@ -730,7 +727,7 @@ block_lookup_symbol (const struct block *block, const char *name, struct symbol *sym_found = NULL; - ALL_BLOCK_SYMBOLS_WITH_NAME (block, lookup_name, iter, sym) + for (struct symbol *sym : block_iterator_range (block, &lookup_name)) { if (symbol_matches_domain (sym->language (), sym->domain (), domain)) @@ -815,16 +812,13 @@ block_find_symbol (const struct block *block, const char *name, const domain_enum domain, block_symbol_matcher_ftype *matcher, void *data) { - struct block_iterator iter; - struct symbol *sym; - lookup_name_info lookup_name (name, symbol_name_match_type::FULL); /* Verify BLOCK is STATIC_BLOCK or GLOBAL_BLOCK. */ gdb_assert (block->superblock () == NULL || block->superblock ()->superblock () == NULL); - ALL_BLOCK_SYMBOLS_WITH_NAME (block, lookup_name, iter, sym) + for (struct symbol *sym : block_iterator_range (block, &lookup_name)) { /* MATCHER is deliberately called second here so that it never sees a non-domain-matching symbol. */ diff --git a/gdb/block.h b/gdb/block.h index 7341d03a07e..35c41377f2c 100644 --- a/gdb/block.h +++ b/gdb/block.h @@ -604,16 +604,6 @@ extern int block_find_non_opaque_type_preferred (struct symbol *sym, (sym); \ (sym) = block_iterator_next (&(iter))) -/* Macro to loop through all symbols in BLOCK with a name that matches - NAME, in no particular order. ITER helps keep track of the - iteration, and must be a struct block_iterator. SYM points to the - current symbol. */ - -#define ALL_BLOCK_SYMBOLS_WITH_NAME(block, name, iter, sym) \ - for ((sym) = block_iterator_first ((block), &(iter), &(name)); \ - (sym) != NULL; \ - (sym) = block_iterator_next (&(iter))) - /* Given a vector of pairs, allocate and build an obstack allocated blockranges struct for a block. */ struct blockranges *make_blockranges (struct objfile *objfile, diff --git a/gdb/cp-support.c b/gdb/cp-support.c index cdaf5fd3e8e..52510543f00 100644 --- a/gdb/cp-support.c +++ b/gdb/cp-support.c @@ -1273,12 +1273,9 @@ add_symbol_overload_list_block (const char *name, const struct block *block, std::vector *overload_list) { - struct block_iterator iter; - struct symbol *sym; - lookup_name_info lookup_name (name, symbol_name_match_type::FULL); - ALL_BLOCK_SYMBOLS_WITH_NAME (block, lookup_name, iter, sym) + for (struct symbol *sym : block_iterator_range (block, &lookup_name)) overload_list_add_symbol (sym, name, overload_list); } diff --git a/gdb/python/py-block.c b/gdb/python/py-block.c index bd2ce7fc181..da33d4cdd94 100644 --- a/gdb/python/py-block.c +++ b/gdb/python/py-block.c @@ -265,24 +265,18 @@ blpy_getitem (PyObject *self, PyObject *key) lookup_name_info lookup_name (name.get(), symbol_name_match_type::FULL); - /* We use ALL_BLOCK_SYMBOLS_WITH_NAME instead of block_lookup_symbol so - that we can look up symbols irrespective of the domain, matching the - iterator. It would be confusing if the iterator returns symbols you - can't find via getitem. */ - struct block_iterator iter; - struct symbol *sym = nullptr; - ALL_BLOCK_SYMBOLS_WITH_NAME (block, lookup_name, iter, sym) + /* We use an iterator instead of block_lookup_symbol so that we can + look up symbols irrespective of the domain, matching the + iterator. It would be confusing if the iterator returns symbols + you can't find via getitem. */ + for (struct symbol *sym : block_iterator_range (block, &lookup_name)) { /* Just stop at the first match */ - break; + return symbol_to_symbol_object (sym); } - if (sym == nullptr) - { - PyErr_SetObject (PyExc_KeyError, key); - return nullptr; - } - return symbol_to_symbol_object (sym); + PyErr_SetObject (PyExc_KeyError, key); + return nullptr; } static void diff --git a/gdb/symtab.c b/gdb/symtab.c index dd9cc7d5163..511299233ad 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -2797,10 +2797,7 @@ iterate_over_symbols (const struct block *block, const domain_enum domain, gdb::function_view callback) { - struct block_iterator iter; - struct symbol *sym; - - ALL_BLOCK_SYMBOLS_WITH_NAME (block, name, iter, sym) + for (struct symbol *sym : block_iterator_range (block, &name)) { if (symbol_matches_domain (sym->language (), sym->domain (), domain)) { From patchwork Fri Jan 20 21:46:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 63539 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 31DC5394B022 for ; Fri, 20 Jan 2023 21:48:55 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from gproxy3-pub.mail.unifiedlayer.com (gproxy3-pub.mail.unifiedlayer.com [69.89.30.42]) by sourceware.org (Postfix) with ESMTPS id ACC473858434 for ; Fri, 20 Jan 2023 21:46:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org ACC473858434 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com Received: from cmgw13.mail.unifiedlayer.com (unknown [10.0.90.128]) by progateway5.mail.pro1.eigbox.com (Postfix) with ESMTP id 2CF0D1004A84D for ; Fri, 20 Jan 2023 21:46:42 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id IzDepfnSZNX2aIzDepTG37; Fri, 20 Jan 2023 21:46:42 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=NMAQR22g c=1 sm=1 tr=0 ts=63cb0bc2 a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=RvmDmJFTN0MA:10:nop_rcvd_month_year a=Qbun_eYptAEA:10:endurance_base64_authed_username_1 a=u7aU1g9GHqODsqPTMMkA:9 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: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=FTJUBs8eZTcRK4TtbA6IZAmORZ0/bA0sYYbprUnWYlk=; b=oCTP8Ve9aYqkR8UveM1gmb69IF rmHEVnnVajySAtO3s6zztUTu77XnpxEKwNkeg4nNEDqdj463zCi9qCNziFpRNnb7SjlPcyNeiHw4R h4619PNisKGgTzJjAWNiFGBfb; Received: from 97-122-76-186.hlrn.qwest.net ([97.122.76.186]:60144 helo=localhost.localdomain) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1pIzDd-001GNx-SD; Fri, 20 Jan 2023 14:46:41 -0700 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 21/27] Remove ALL_BLOCK_SYMBOLS Date: Fri, 20 Jan 2023 14:46:12 -0700 Message-Id: <20230120214618.3236224-22-tom@tromey.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230120214618.3236224-1-tom@tromey.com> References: <20230120214618.3236224-1-tom@tromey.com> MIME-Version: 1.0 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.76.186 X-Source-L: No X-Exim-ID: 1pIzDd-001GNx-SD X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-76-186.hlrn.qwest.net (localhost.localdomain) [97.122.76.186]:60144 X-Source-Auth: tom+tromey.com X-Email-Count: 22 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3027.9 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 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.29 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 Sender: "Gdb-patches" This removes ALL_BLOCK_SYMBOLS in favor of foreach. --- gdb/ada-lang.c | 21 ++++++--------------- gdb/block.h | 9 --------- gdb/buildsym.c | 2 +- gdb/coffread.c | 5 +---- gdb/f-valprint.c | 4 +--- gdb/infrun.c | 4 +--- gdb/linespec.c | 4 +--- gdb/mdebugread.c | 9 ++------- gdb/mi/mi-cmd-stack.c | 4 +--- gdb/stack.c | 19 ++++++------------- gdb/symtab.c | 34 ++++++++++++++-------------------- gdb/tracepoint.c | 4 +--- 12 files changed, 35 insertions(+), 84 deletions(-) diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index b5e9f2ecff6..137925db81b 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -6121,10 +6121,8 @@ ada_add_block_symbols (std::vector &result, const std::string &ada_lookup_name = lookup_name.ada ().lookup_name (); const char *name = ada_lookup_name.c_str (); size_t name_len = ada_lookup_name.size (); - struct symbol *sym; - struct block_iterator iter; - ALL_BLOCK_SYMBOLS (block, iter, sym) + for (struct symbol *sym : block_iterator_range (block)) { if (symbol_matches_domain (sym->language (), sym->domain (), domain)) @@ -13069,10 +13067,7 @@ ada_add_exceptions_from_frame (compiled_regex *preg, while (block != 0) { - struct block_iterator iter; - struct symbol *sym; - - ALL_BLOCK_SYMBOLS (block, iter, sym) + for (struct symbol *sym : block_iterator_range (block)) { switch (sym->aclass ()) { @@ -13154,10 +13149,8 @@ ada_add_global_exceptions (compiled_regex *preg, for (i = GLOBAL_BLOCK; i <= STATIC_BLOCK; i++) { const struct block *b = bv->block (i); - struct block_iterator iter; - struct symbol *sym; - ALL_BLOCK_SYMBOLS (b, iter, sym) + for (struct symbol *sym : block_iterator_range (b)) if (ada_is_non_standard_exception_sym (sym) && name_matches_regex (sym->natural_name (), preg)) { @@ -13659,9 +13652,7 @@ class ada_language : public language_defn const char *text, const char *word, enum type_code code) const override { - struct symbol *sym; const struct block *b, *surrounding_static_block = 0; - struct block_iterator iter; gdb_assert (code == TYPE_CODE_UNDEF); @@ -13721,7 +13712,7 @@ class ada_language : public language_defn if (!b->superblock ()) surrounding_static_block = b; /* For elmin of dups */ - ALL_BLOCK_SYMBOLS (b, iter, sym) + for (struct symbol *sym : block_iterator_range (b)) { if (completion_skip_symbol (mode, sym)) continue; @@ -13742,7 +13733,7 @@ class ada_language : public language_defn { QUIT; b = s->blockvector ()->global_block (); - ALL_BLOCK_SYMBOLS (b, iter, sym) + for (struct symbol *sym : block_iterator_range (b)) { if (completion_skip_symbol (mode, sym)) continue; @@ -13764,7 +13755,7 @@ class ada_language : public language_defn /* Don't do this block twice. */ if (b == surrounding_static_block) continue; - ALL_BLOCK_SYMBOLS (b, iter, sym) + for (struct symbol *sym : block_iterator_range (b)) { if (completion_skip_symbol (mode, sym)) continue; diff --git a/gdb/block.h b/gdb/block.h index 35c41377f2c..6ccf3766d8f 100644 --- a/gdb/block.h +++ b/gdb/block.h @@ -595,15 +595,6 @@ extern int block_find_non_opaque_type (struct symbol *sym, void *data); extern int block_find_non_opaque_type_preferred (struct symbol *sym, void *data); -/* Macro to loop through all symbols in BLOCK, in no particular - order. ITER helps keep track of the iteration, and must be a - struct block_iterator. SYM points to the current symbol. */ - -#define ALL_BLOCK_SYMBOLS(block, iter, sym) \ - for ((sym) = block_iterator_first ((block), &(iter)); \ - (sym); \ - (sym) = block_iterator_next (&(iter))) - /* Given a vector of pairs, allocate and build an obstack allocated blockranges struct for a block. */ struct blockranges *make_blockranges (struct objfile *objfile, diff --git a/gdb/buildsym.c b/gdb/buildsym.c index 7a009c2f626..9d45938f8e9 100644 --- a/gdb/buildsym.c +++ b/gdb/buildsym.c @@ -998,7 +998,7 @@ buildsym_compunit::end_compunit_symtab_with_blockvector /* Note that we only want to fix up symbols from the local blocks, not blocks coming from included symtabs. That is why - we use ALL_DICT_SYMBOLS here and not ALL_BLOCK_SYMBOLS. */ + we use ALL_DICT_SYMBOLS here and not a block iterator. */ ALL_DICT_SYMBOLS (block->multidict (), miter, sym) if (sym->symtab () == NULL) sym->set_symtab (symtab); diff --git a/gdb/coffread.c b/gdb/coffread.c index 4950a7324c8..69c9772f429 100644 --- a/gdb/coffread.c +++ b/gdb/coffread.c @@ -1495,12 +1495,9 @@ patch_type (struct type *type, struct type *real_type) static void patch_opaque_types (struct symtab *s) { - struct block_iterator iter; - struct symbol *real_sym; - /* Go through the per-file symbols only. */ const struct block *b = s->compunit ()->blockvector ()->static_block (); - ALL_BLOCK_SYMBOLS (b, iter, real_sym) + for (struct symbol *real_sym : block_iterator_range (b)) { /* Find completed typedefs to use to fix opaque ones. Remove syms from the chain when their types are stored, diff --git a/gdb/f-valprint.c b/gdb/f-valprint.c index 55dbcc8309f..fe0ee288a8e 100644 --- a/gdb/f-valprint.c +++ b/gdb/f-valprint.c @@ -600,13 +600,11 @@ static void info_common_command_for_block (const struct block *block, const char *comname, int *any_printed) { - struct block_iterator iter; - struct symbol *sym; struct value_print_options opts; get_user_print_options (&opts); - ALL_BLOCK_SYMBOLS (block, iter, sym) + for (struct symbol *sym : block_iterator_range (block)) if (sym->domain () == COMMON_BLOCK_DOMAIN) { const struct common_block *common = sym->value_common_block (); diff --git a/gdb/infrun.c b/gdb/infrun.c index edfb5ab0a91..42fc95fb0ed 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -8069,8 +8069,6 @@ check_exception_resume (struct execution_control_state *ecs, try { const struct block *b; - struct block_iterator iter; - struct symbol *sym; int argno = 0; /* The exception breakpoint is a thread-specific breakpoint on @@ -8088,7 +8086,7 @@ check_exception_resume (struct execution_control_state *ecs, handler. */ b = func->value_block (); - ALL_BLOCK_SYMBOLS (b, iter, sym) + for (struct symbol *sym : block_iterator_range (b)) { if (!sym->is_argument ()) continue; diff --git a/gdb/linespec.c b/gdb/linespec.c index 61da545eb2e..bf1e5ee9727 100644 --- a/gdb/linespec.c +++ b/gdb/linespec.c @@ -3900,14 +3900,12 @@ find_label_symbols_in_block (const struct block *block, { if (completion_mode) { - struct block_iterator iter; - struct symbol *sym; size_t name_len = strlen (name); int (*cmp) (const char *, const char *, size_t); cmp = case_sensitivity == case_sensitive_on ? strncmp : strncasecmp; - ALL_BLOCK_SYMBOLS (block, iter, sym) + for (struct symbol *sym : block_iterator_range (block)) { if (symbol_matches_domain (sym->language (), sym->domain (), LABEL_DOMAIN) diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c index 8dc836a0f6e..7fa25ae3183 100644 --- a/gdb/mdebugread.c +++ b/gdb/mdebugread.c @@ -1183,19 +1183,16 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend, type. Set that from the type of the parameter symbols. */ int nparams = top_stack->numargs; int iparams; - struct symbol *sym; if (nparams > 0) { - struct block_iterator iter; - ftype->set_num_fields (nparams); ftype->set_fields ((struct field *) TYPE_ALLOC (ftype, nparams * sizeof (struct field))); iparams = 0; - ALL_BLOCK_SYMBOLS (cblock, iter, sym) + for (struct symbol *sym : block_iterator_range (cblock)) { if (iparams == nparams) break; @@ -4455,12 +4452,10 @@ static struct symbol * mylookup_symbol (const char *name, const struct block *block, domain_enum domain, enum address_class theclass) { - struct block_iterator iter; int inc; - struct symbol *sym; inc = name[0]; - ALL_BLOCK_SYMBOLS (block, iter, sym) + for (struct symbol *sym : block_iterator_range (block)) { if (sym->linkage_name ()[0] == inc && sym->domain () == domain diff --git a/gdb/mi/mi-cmd-stack.c b/gdb/mi/mi-cmd-stack.c index 21bcf73ed24..30322b6fc56 100644 --- a/gdb/mi/mi-cmd-stack.c +++ b/gdb/mi/mi-cmd-stack.c @@ -571,8 +571,6 @@ list_args_or_locals (const frame_print_options &fp_opts, frame_info_ptr fi, int skip_unavailable) { const struct block *block; - struct symbol *sym; - struct block_iterator iter; struct type *type; const char *name_of_result; struct ui_out *uiout = current_uiout; @@ -598,7 +596,7 @@ list_args_or_locals (const frame_print_options &fp_opts, while (block != 0) { - ALL_BLOCK_SYMBOLS (block, iter, sym) + for (struct symbol *sym : block_iterator_range (block)) { int print_me = 0; diff --git a/gdb/stack.c b/gdb/stack.c index 0fd797836dc..0ffb1b512e1 100644 --- a/gdb/stack.c +++ b/gdb/stack.c @@ -758,10 +758,8 @@ print_frame_args (const frame_print_options &fp_opts, if (func) { const struct block *b = func->value_block (); - struct block_iterator iter; - struct symbol *sym; - ALL_BLOCK_SYMBOLS (b, iter, sym) + for (struct symbol *sym : block_iterator_range (b)) { struct frame_arg arg, entryarg; @@ -2237,10 +2235,7 @@ static void iterate_over_block_locals (const struct block *b, iterate_over_block_arg_local_vars_cb cb) { - struct block_iterator iter; - struct symbol *sym; - - ALL_BLOCK_SYMBOLS (b, iter, sym) + for (struct symbol *sym : block_iterator_range (b)) { switch (sym->aclass ()) { @@ -2486,10 +2481,7 @@ void iterate_over_block_arg_vars (const struct block *b, iterate_over_block_arg_local_vars_cb cb) { - struct block_iterator iter; - struct symbol *sym, *sym2; - - ALL_BLOCK_SYMBOLS (b, iter, sym) + for (struct symbol *sym : block_iterator_range (b)) { /* Don't worry about things which aren't arguments. */ if (sym->is_argument ()) @@ -2505,8 +2497,9 @@ iterate_over_block_arg_vars (const struct block *b, float). There are also LOC_ARG/LOC_REGISTER pairs which are not combined in symbol-reading. */ - sym2 = lookup_symbol_search_name (sym->search_name (), - b, VAR_DOMAIN).symbol; + struct symbol *sym2 + = lookup_symbol_search_name (sym->search_name (), + b, VAR_DOMAIN).symbol; cb (sym->print_name (), sym2); } } diff --git a/gdb/symtab.c b/gdb/symtab.c index 511299233ad..3ab26f3a003 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -2906,23 +2906,25 @@ find_pc_sect_compunit_symtab (CORE_ADDR pc, struct obj_section *section) if (section != 0) { - struct symbol *sym = NULL; - struct block_iterator iter; + struct symbol *found_sym = nullptr; for (int b_index = GLOBAL_BLOCK; - b_index <= STATIC_BLOCK && sym == NULL; + b_index <= STATIC_BLOCK && found_sym == nullptr; ++b_index) { const struct block *b = bv->block (b_index); - ALL_BLOCK_SYMBOLS (b, iter, sym) + for (struct symbol *sym : block_iterator_range (b)) { fixup_symbol_section (sym, obj_file); if (matching_obj_sections (sym->obj_section (obj_file), section)) - break; + { + found_sym = sym; + break; + } } } - if (sym == NULL) + if (found_sym == nullptr) continue; /* No symbol in this symtab matches section. */ } @@ -2973,10 +2975,8 @@ find_symbol_at_address (CORE_ADDR address) for (int i = GLOBAL_BLOCK; i <= STATIC_BLOCK; ++i) { const struct block *b = bv->block (i); - struct block_iterator iter; - struct symbol *sym; - ALL_BLOCK_SYMBOLS (b, iter, sym) + for (struct symbol *sym : block_iterator_range (b)) { if (sym->aclass () == LOC_STATIC && sym->value_address () == addr) @@ -4739,11 +4739,9 @@ global_symbol_searcher::add_matching_symbols for (block_enum block : { GLOBAL_BLOCK, STATIC_BLOCK }) { - struct block_iterator iter; - struct symbol *sym; const struct block *b = bv->block (block); - ALL_BLOCK_SYMBOLS (b, iter, sym) + for (struct symbol *sym : block_iterator_range (b)) { struct symtab *real_symtab = sym->symtab (); @@ -5703,8 +5701,6 @@ add_symtab_completions (struct compunit_symtab *cust, const char *text, const char *word, enum type_code code) { - struct symbol *sym; - struct block_iterator iter; int i; if (cust == NULL) @@ -5715,7 +5711,7 @@ add_symtab_completions (struct compunit_symtab *cust, QUIT; const struct block *b = cust->blockvector ()->block (i); - ALL_BLOCK_SYMBOLS (b, iter, sym) + for (struct symbol *sym : block_iterator_range (b)) { if (completion_skip_symbol (mode, sym)) continue; @@ -5741,10 +5737,8 @@ default_collect_symbol_completion_matches_break_on frees them. I'm not going to worry about this; hopefully there won't be that many. */ - struct symbol *sym; const struct block *b; const struct block *surrounding_static_block, *surrounding_global_block; - struct block_iterator iter; /* The symbol we are completing on. Points in same buffer as text. */ const char *sym_text; @@ -5865,7 +5859,7 @@ default_collect_symbol_completion_matches_break_on { QUIT; - ALL_BLOCK_SYMBOLS (b, iter, sym) + for (struct symbol *sym : block_iterator_range (b)) { if (code == TYPE_CODE_UNDEF) { @@ -5893,12 +5887,12 @@ default_collect_symbol_completion_matches_break_on if (code == TYPE_CODE_UNDEF) { if (surrounding_static_block != NULL) - ALL_BLOCK_SYMBOLS (surrounding_static_block, iter, sym) + for (struct symbol *sym : block_iterator_range (surrounding_static_block)) completion_list_add_fields (tracker, sym, lookup_name, sym_text, word); if (surrounding_global_block != NULL) - ALL_BLOCK_SYMBOLS (surrounding_global_block, iter, sym) + for (struct symbol *sym : block_iterator_range (surrounding_global_block)) completion_list_add_fields (tracker, sym, lookup_name, sym_text, word); } diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c index 7e172dfb3fc..ad16b1e9d42 100644 --- a/gdb/tracepoint.c +++ b/gdb/tracepoint.c @@ -2459,12 +2459,10 @@ tfind_outside_command (const char *args, int from_tty) static void info_scope_command (const char *args_in, int from_tty) { - struct symbol *sym; struct bound_minimal_symbol msym; const struct block *block; const char *symname; const char *save_args = args_in; - struct block_iterator iter; int j, count = 0; struct gdbarch *gdbarch; int regno; @@ -2492,7 +2490,7 @@ info_scope_command (const char *args_in, int from_tty) while (block != 0) { QUIT; /* Allow user to bail out with ^C. */ - ALL_BLOCK_SYMBOLS (block, iter, sym) + for (struct symbol *sym : block_iterator_range (block)) { QUIT; /* Allow user to bail out with ^C. */ if (count == 0) From patchwork Fri Jan 20 21:46:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 63537 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 0C29B3887F79 for ; Fri, 20 Jan 2023 21:48:40 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from outbound-ss-820.bluehost.com (outbound-ss-820.bluehost.com [69.89.24.241]) by sourceware.org (Postfix) with ESMTPS id 092C13857400 for ; Fri, 20 Jan 2023 21:46:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 092C13857400 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com Received: from cmgw12.mail.unifiedlayer.com (unknown [10.0.90.127]) by progateway2.mail.pro1.eigbox.com (Postfix) with ESMTP id 8087610046B5D for ; Fri, 20 Jan 2023 21:46:42 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id IzDep9971iOW0IzDepygGG; Fri, 20 Jan 2023 21:46:42 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=S5kcfKgP c=1 sm=1 tr=0 ts=63cb0bc2 a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=RvmDmJFTN0MA:10:nop_rcvd_month_year a=Qbun_eYptAEA:10:endurance_base64_authed_username_1 a=ihFeAXQEJiG3-ZByjdkA:9 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: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=hJ9g+J1zb30HJoFXgc/MYwjp1rHIDhHIoJkOkGG8tyk=; b=sCYeR3fue5txITJPQn6PhLrecA 5nQAwlBVhUCOemkzlMiSAU41vZkcOBREp8jz5Mj2g+dmq3uM9LBiZak7v6aPfmipGVIm24Qs5iP/W 1CXyAFjsfhGyBZBVLjPS8LeI7; Received: from 97-122-76-186.hlrn.qwest.net ([97.122.76.186]:60144 helo=localhost.localdomain) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1pIzDe-001GNx-5R; Fri, 20 Jan 2023 14:46:42 -0700 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 22/27] Fix memory leak in mdebugread.c Date: Fri, 20 Jan 2023 14:46:13 -0700 Message-Id: <20230120214618.3236224-23-tom@tromey.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230120214618.3236224-1-tom@tromey.com> References: <20230120214618.3236224-1-tom@tromey.com> MIME-Version: 1.0 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.76.186 X-Source-L: No X-Exim-ID: 1pIzDe-001GNx-5R X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-76-186.hlrn.qwest.net (localhost.localdomain) [97.122.76.186]:60144 X-Source-Auth: tom+tromey.com X-Email-Count: 23 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3027.9 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 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.29 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 Sender: "Gdb-patches" mdebugread.c allocates blocks on the heap. However, this is a memory leak if the corresponding objfile is ever destroyed. This patch changes this code to use allocate_block instead, fixing a FIXME from 2003. I don't know how to test this patch. --- gdb/mdebugread.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c index 7fa25ae3183..b6a0b3c07df 100644 --- a/gdb/mdebugread.c +++ b/gdb/mdebugread.c @@ -236,7 +236,8 @@ static struct type *new_type (char *); enum block_type { FUNCTION_BLOCK, NON_FUNCTION_BLOCK }; -static struct block *new_block (enum block_type, enum language); +static struct block *new_block (struct objfile *objfile, + enum block_type, enum language); static struct compunit_symtab *new_symtab (const char *, int, struct objfile *); @@ -794,7 +795,7 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend, s->type ()->set_is_prototyped (true); /* Create and enter a new lexical context. */ - b = new_block (FUNCTION_BLOCK, s->language ()); + b = new_block (objfile, FUNCTION_BLOCK, s->language ()); s->set_value_block (b); b->set_function (s); b->set_start (sh->value); @@ -1125,7 +1126,7 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend, } top_stack->blocktype = stBlock; - b = new_block (NON_FUNCTION_BLOCK, psymtab_language); + b = new_block (objfile, NON_FUNCTION_BLOCK, psymtab_language); b->set_start (sh->value + top_stack->procadr); b->set_superblock (top_stack->cur_block); top_stack->cur_block = b; @@ -4622,8 +4623,8 @@ new_symtab (const char *name, int maxlines, struct objfile *objfile) /* All symtabs must have at least two blocks. */ bv = new_bvect (2); - bv->set_block (GLOBAL_BLOCK, new_block (NON_FUNCTION_BLOCK, lang)); - bv->set_block (STATIC_BLOCK, new_block (NON_FUNCTION_BLOCK, lang)); + bv->set_block (GLOBAL_BLOCK, new_block (objfile, NON_FUNCTION_BLOCK, lang)); + bv->set_block (STATIC_BLOCK, new_block (objfile, NON_FUNCTION_BLOCK, lang)); bv->static_block ()->set_superblock (bv->global_block ()); cust->set_blockvector (bv); @@ -4710,12 +4711,10 @@ new_bvect (int nblocks) linearly; otherwise, store them hashed. */ static struct block * -new_block (enum block_type type, enum language language) +new_block (struct objfile *objfile, enum block_type type, + enum language language) { - /* FIXME: carlton/2003-09-11: This should use allocate_block to - allocate the block. Which, in turn, suggests that the block - should be allocated on an obstack. */ - struct block *retval = XCNEW (struct block); + struct block *retval = allocate_block (&objfile->objfile_obstack); if (type == FUNCTION_BLOCK) retval->set_multidict (mdict_create_linear_expandable (language)); From patchwork Fri Jan 20 21:46:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 63534 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 7334838A8163 for ; Fri, 20 Jan 2023 21:48:26 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from alt-proxy28.mail.unifiedlayer.com (alt-proxy28.mail.unifiedlayer.com [74.220.216.123]) by sourceware.org (Postfix) with ESMTPS id 8FC3B385828E for ; Fri, 20 Jan 2023 21:46:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8FC3B385828E Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com Received: from cmgw13.mail.unifiedlayer.com (unknown [10.0.90.128]) by progateway1.mail.pro1.eigbox.com (Postfix) with ESMTP id C48D51003FA98 for ; Fri, 20 Jan 2023 21:46:42 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id IzDepfnStNX2aIzDepTG3R; Fri, 20 Jan 2023 21:46:42 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=NMAQR22g c=1 sm=1 tr=0 ts=63cb0bc2 a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=RvmDmJFTN0MA:10:nop_rcvd_month_year a=Qbun_eYptAEA:10:endurance_base64_authed_username_1 a=mamhUVz35NT_mB4T-c0A:9 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: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=l47ZZgWoL08aqu0MZsOPmfp2IjP1Vj609mU5ZmdyDyY=; b=wFxwCobECSykdGolHYRHi4b+kZ 1Zt2ynfM/2UJZMp+OS3Z9+P41u9hLDc2+A/4ne1vbOVdl+Xjrp3yxbpOrWRa0DQUjyrGEF1qsJU1q cIAIOGeFS3EOC8OneYvje2W7f; Received: from 97-122-76-186.hlrn.qwest.net ([97.122.76.186]:60144 helo=localhost.localdomain) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1pIzDe-001GNx-Fp; Fri, 20 Jan 2023 14:46:42 -0700 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 23/27] Use 'new' for block and global_block Date: Fri, 20 Jan 2023 14:46:14 -0700 Message-Id: <20230120214618.3236224-24-tom@tromey.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230120214618.3236224-1-tom@tromey.com> References: <20230120214618.3236224-1-tom@tromey.com> MIME-Version: 1.0 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.76.186 X-Source-L: No X-Exim-ID: 1pIzDe-001GNx-Fp X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-76-186.hlrn.qwest.net (localhost.localdomain) [97.122.76.186]:60144 X-Source-Auth: tom+tromey.com X-Email-Count: 24 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3027.9 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 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.29 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 Sender: "Gdb-patches" This changes block and global_block to add initializers, and then to use 'new' for allocation. --- gdb/block.c | 6 ++---- gdb/block.h | 20 ++++++++++---------- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/gdb/block.c b/gdb/block.c index 0870793dcd4..8f15cdf23f8 100644 --- a/gdb/block.c +++ b/gdb/block.c @@ -389,9 +389,7 @@ block::global_block () const struct block * allocate_block (struct obstack *obstack) { - struct block *bl = OBSTACK_ZALLOC (obstack, struct block); - - return bl; + return new (obstack) struct block; } /* Allocate a global block. */ @@ -399,7 +397,7 @@ allocate_block (struct obstack *obstack) struct block * allocate_global_block (struct obstack *obstack) { - struct global_block *bl = OBSTACK_ZALLOC (obstack, struct global_block); + struct global_block *bl = new (obstack) struct global_block; return &bl->block; } diff --git a/gdb/block.h b/gdb/block.h index 6ccf3766d8f..9a60140581d 100644 --- a/gdb/block.h +++ b/gdb/block.h @@ -105,7 +105,7 @@ struct blockranges This implies that within the body of one function the blocks appear in the order of a depth-first tree walk. */ -struct block +struct block : public allocate_on_obstack { /* Return this block's start address. */ CORE_ADDR start () const @@ -273,13 +273,13 @@ struct block /* Addresses in the executable code that are in this block. */ - CORE_ADDR m_start; - CORE_ADDR m_end; + CORE_ADDR m_start = 0; + CORE_ADDR m_end = 0; /* The symbol that names this block, if the block is the body of a function (real or inlined); otherwise, zero. */ - struct symbol *m_function; + struct symbol *m_function = nullptr; /* The `struct block' for the containing block, or 0 if none. @@ -287,22 +287,22 @@ struct block case of C) is the STATIC_BLOCK. The superblock of the STATIC_BLOCK is the GLOBAL_BLOCK. */ - const struct block *m_superblock; + const struct block *m_superblock = nullptr; /* This is used to store the symbols in the block. */ - struct multidictionary *m_multidict; + struct multidictionary *m_multidict = nullptr; /* Contains information about namespace-related info relevant to this block: using directives and the current namespace scope. */ - struct block_namespace_info *m_namespace_info; + struct block_namespace_info *m_namespace_info = nullptr; /* Address ranges for blocks with non-contiguous ranges. If this is NULL, then there is only one range which is specified by startaddr and endaddr above. */ - struct blockranges *m_ranges; + struct blockranges *m_ranges = nullptr; private: @@ -314,7 +314,7 @@ struct block /* The global block is singled out so that we can provide a back-link to the compunit symtab. */ -struct global_block +struct global_block : public allocate_on_obstack { /* The block. */ @@ -322,7 +322,7 @@ struct global_block /* This holds a pointer to the compunit symtab holding this block. */ - struct compunit_symtab *compunit_symtab; + struct compunit_symtab *compunit_symtab = nullptr; }; struct blockvector From patchwork Fri Jan 20 21:46:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 63530 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 6609638983A0 for ; Fri, 20 Jan 2023 21:48:07 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from progateway7-pub.mail.pro1.eigbox.com (gproxy5-pub.mail.unifiedlayer.com [67.222.38.55]) by sourceware.org (Postfix) with ESMTPS id 9AEE7385B521 for ; Fri, 20 Jan 2023 21:46:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9AEE7385B521 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com Received: from cmgw10.mail.unifiedlayer.com (unknown [10.0.90.125]) by progateway7.mail.pro1.eigbox.com (Postfix) with ESMTP id 15CB010047409 for ; Fri, 20 Jan 2023 21:46:43 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id IzDfpics5FqSRIzDfp2cEZ; Fri, 20 Jan 2023 21:46:43 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=c6Ru/Txl c=1 sm=1 tr=0 ts=63cb0bc3 a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=RvmDmJFTN0MA:10:nop_rcvd_month_year a=Qbun_eYptAEA:10:endurance_base64_authed_username_1 a=TQBj472Df4Cp-_jPd6YA:9 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: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=FJobpgYuLqwgz4fR/1lP+3UlVgcalbRpdVI4lVXrtUM=; b=QRhfGBUN3uIvV3cMsGVt4yRL8G ZGjpYjMQxywanHxhOV/UNIx9Sov18mT1pb2ATK2r7yAfiEozJh4bUezNbXsG1+qY4hXRHO1G0DW4B NOKYPWJIznTiFXpLIbiPjHKde; Received: from 97-122-76-186.hlrn.qwest.net ([97.122.76.186]:60144 helo=localhost.localdomain) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1pIzDe-001GNx-Q6; Fri, 20 Jan 2023 14:46:42 -0700 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 24/27] Have global_block inherit from block Date: Fri, 20 Jan 2023 14:46:15 -0700 Message-Id: <20230120214618.3236224-25-tom@tromey.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230120214618.3236224-1-tom@tromey.com> References: <20230120214618.3236224-1-tom@tromey.com> MIME-Version: 1.0 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.76.186 X-Source-L: No X-Exim-ID: 1pIzDe-001GNx-Q6 X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-76-186.hlrn.qwest.net (localhost.localdomain) [97.122.76.186]:60144 X-Source-Auth: tom+tromey.com X-Email-Count: 25 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3027.9 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 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.29 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 Sender: "Gdb-patches" This changes global_block to inherit from block, which is what was always intended. --- gdb/block.c | 4 +--- gdb/block.h | 6 +----- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/gdb/block.c b/gdb/block.c index 8f15cdf23f8..1698ee51e7b 100644 --- a/gdb/block.c +++ b/gdb/block.c @@ -397,9 +397,7 @@ allocate_block (struct obstack *obstack) struct block * allocate_global_block (struct obstack *obstack) { - struct global_block *bl = new (obstack) struct global_block; - - return &bl->block; + return new (obstack) struct global_block; } /* See block.h. */ diff --git a/gdb/block.h b/gdb/block.h index 9a60140581d..3d71e7daab1 100644 --- a/gdb/block.h +++ b/gdb/block.h @@ -314,12 +314,8 @@ struct block : public allocate_on_obstack /* The global block is singled out so that we can provide a back-link to the compunit symtab. */ -struct global_block : public allocate_on_obstack +struct global_block : public block { - /* The block. */ - - struct block block; - /* This holds a pointer to the compunit symtab holding this block. */ struct compunit_symtab *compunit_symtab = nullptr; From patchwork Fri Jan 20 21:46:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 63536 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 51F543948462 for ; Fri, 20 Jan 2023 21:48:39 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from gproxy4-pub.mail.unifiedlayer.com (gproxy4-pub.mail.unifiedlayer.com [69.89.23.142]) by sourceware.org (Postfix) with ESMTPS id DC21D385B524 for ; Fri, 20 Jan 2023 21:46:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DC21D385B524 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com Received: from cmgw15.mail.unifiedlayer.com (unknown [10.0.90.130]) by progateway6.mail.pro1.eigbox.com (Postfix) with ESMTP id 5BE4B100476C6 for ; Fri, 20 Jan 2023 21:46:43 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id IzDfpwStvbwScIzDfpCg54; Fri, 20 Jan 2023 21:46:43 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=X8KXlEfe c=1 sm=1 tr=0 ts=63cb0bc3 a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=RvmDmJFTN0MA:10:nop_rcvd_month_year a=Qbun_eYptAEA:10:endurance_base64_authed_username_1 a=uTLsh3KIjzS3uoR6qUoA:9 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: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=leaGDhUkOo2sQPgUhXT2sgoYms5Td5EominPMtj2Tbw=; b=DCZS0mPpfYJGVS0+z9qT+jo5xm GW2OwQeOvKosLIOgrSzrdHx/Wh40pqpSN+xSbHQxzYp9ArTRZUO30nqxgHgRgP2bKENgNVHGUKTkZ UXj9xsV6vcHRkmqqw+F0BmO+9; Received: from 97-122-76-186.hlrn.qwest.net ([97.122.76.186]:60144 helo=localhost.localdomain) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1pIzDf-001GNx-3d; Fri, 20 Jan 2023 14:46:43 -0700 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 25/27] Remove allocate_block and allocate_global_block Date: Fri, 20 Jan 2023 14:46:16 -0700 Message-Id: <20230120214618.3236224-26-tom@tromey.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230120214618.3236224-1-tom@tromey.com> References: <20230120214618.3236224-1-tom@tromey.com> MIME-Version: 1.0 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.76.186 X-Source-L: No X-Exim-ID: 1pIzDf-001GNx-3d X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-76-186.hlrn.qwest.net (localhost.localdomain) [97.122.76.186]:60144 X-Source-Auth: tom+tromey.com X-Email-Count: 26 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3027.9 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 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.29 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 Sender: "Gdb-patches" This removes allocate_block and allocate_global_block in favor of simply calling 'new'. --- gdb/block.c | 23 ----------------------- gdb/block.h | 4 ---- gdb/buildsym.c | 7 ++++--- gdb/jit.c | 9 +++++---- gdb/mdebugread.c | 2 +- 5 files changed, 10 insertions(+), 35 deletions(-) diff --git a/gdb/block.c b/gdb/block.c index 1698ee51e7b..334d8180448 100644 --- a/gdb/block.c +++ b/gdb/block.c @@ -377,29 +377,6 @@ block::global_block () const return block; } -/* Allocate a block on OBSTACK, and initialize its elements to - zero/NULL. This is useful for creating "dummy" blocks that don't - correspond to actual source files. - - Warning: it sets the block's BLOCK_MULTIDICT to NULL, which isn't a - valid value. If you really don't want the block to have a - dictionary, then you should subsequently set its BLOCK_MULTIDICT to - dict_create_linear (obstack, NULL). */ - -struct block * -allocate_block (struct obstack *obstack) -{ - return new (obstack) struct block; -} - -/* Allocate a global block. */ - -struct block * -allocate_global_block (struct obstack *obstack) -{ - return new (obstack) struct global_block; -} - /* See block.h. */ void diff --git a/gdb/block.h b/gdb/block.h index 3d71e7daab1..7c40bae9af2 100644 --- a/gdb/block.h +++ b/gdb/block.h @@ -426,10 +426,6 @@ extern const struct block *block_for_pc (CORE_ADDR); extern const struct block *block_for_pc_sect (CORE_ADDR, struct obj_section *); -extern struct block *allocate_block (struct obstack *obstack); - -extern struct block *allocate_global_block (struct obstack *obstack); - /* A block iterator. This structure should be treated as though it were opaque; it is only defined here because we want to support stack allocation of iterators. */ diff --git a/gdb/buildsym.c b/gdb/buildsym.c index 9d45938f8e9..303eed52282 100644 --- a/gdb/buildsym.c +++ b/gdb/buildsym.c @@ -211,9 +211,10 @@ buildsym_compunit::finish_block_internal struct pending_block *pblock; struct pending_block *opblock; - block = (is_global - ? allocate_global_block (&m_objfile->objfile_obstack) - : allocate_block (&m_objfile->objfile_obstack)); + if (is_global) + block = new (&m_objfile->objfile_obstack) global_block; + else + block = new (&m_objfile->objfile_obstack) struct block; if (symbol) { diff --git a/gdb/jit.c b/gdb/jit.c index f584438c229..0b089bc6a82 100644 --- a/gdb/jit.c +++ b/gdb/jit.c @@ -567,7 +567,7 @@ finalize_symtab (struct gdb_symtab *stab, struct objfile *objfile) int block_idx = FIRST_LOCAL_BLOCK; for (gdb_block &gdb_block_iter : stab->blocks) { - struct block *new_block = allocate_block (&objfile->objfile_obstack); + struct block *new_block = new (&objfile->objfile_obstack) block; struct symbol *block_name = new (&objfile->objfile_obstack) symbol; struct type *block_type = arch_type (objfile->arch (), TYPE_CODE_VOID, @@ -609,9 +609,10 @@ finalize_symtab (struct gdb_symtab *stab, struct objfile *objfile) { struct block *new_block; - new_block = (i == GLOBAL_BLOCK - ? allocate_global_block (&objfile->objfile_obstack) - : allocate_block (&objfile->objfile_obstack)); + if (i == GLOBAL_BLOCK) + new_block = new (&objfile->objfile_obstack) global_block; + else + new_block = new (&objfile->objfile_obstack) block; new_block->set_multidict (mdict_create_linear (&objfile->objfile_obstack, NULL)); new_block->set_superblock (block_iter); diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c index b6a0b3c07df..18b59cff6bf 100644 --- a/gdb/mdebugread.c +++ b/gdb/mdebugread.c @@ -4714,7 +4714,7 @@ static struct block * new_block (struct objfile *objfile, enum block_type type, enum language language) { - struct block *retval = allocate_block (&objfile->objfile_obstack); + struct block *retval = new (&objfile->objfile_obstack) block; if (type == FUNCTION_BLOCK) retval->set_multidict (mdict_create_linear_expandable (language)); From patchwork Fri Jan 20 21:46:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 63541 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 42C73383FB8B for ; Fri, 20 Jan 2023 21:49:10 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from alt-proxy28.mail.unifiedlayer.com (alt-proxy28.mail.unifiedlayer.com [74.220.216.123]) by sourceware.org (Postfix) with ESMTPS id 2AD1F385B52C for ; Fri, 20 Jan 2023 21:46:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2AD1F385B52C Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com Received: from cmgw13.mail.unifiedlayer.com (unknown [10.0.90.128]) by progateway1.mail.pro1.eigbox.com (Postfix) with ESMTP id 9CD661003F8D1 for ; Fri, 20 Jan 2023 21:46:43 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id IzDfpfnTRNX2aIzDfpTG3z; Fri, 20 Jan 2023 21:46:43 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=NMAQR22g c=1 sm=1 tr=0 ts=63cb0bc3 a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=RvmDmJFTN0MA:10:nop_rcvd_month_year a=Qbun_eYptAEA:10:endurance_base64_authed_username_1 a=ESW8IDrhvFBtNhbpZigA:9 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: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=L6yPcg3stflXO/Noxa+5mU4IMJq9yhaTIN+4fIWKF0s=; b=lcDen9QD1sI+UHxISGMpCtw5z2 s8lVI/ZrHf/ViJVdH9M0vV2twfCupxP5yGQ9WX56vCaZEkRW0eYWog5kveAzvegdDX9eXvYQzxCli /M9dvOJ5oRXHexjvNrYjfhqH0; Received: from 97-122-76-186.hlrn.qwest.net ([97.122.76.186]:60144 helo=localhost.localdomain) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1pIzDf-001GNx-CA; Fri, 20 Jan 2023 14:46:43 -0700 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 26/27] Make block members 'private' Date: Fri, 20 Jan 2023 14:46:17 -0700 Message-Id: <20230120214618.3236224-27-tom@tromey.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230120214618.3236224-1-tom@tromey.com> References: <20230120214618.3236224-1-tom@tromey.com> MIME-Version: 1.0 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.76.186 X-Source-L: No X-Exim-ID: 1pIzDf-001GNx-CA X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-76-186.hlrn.qwest.net (localhost.localdomain) [97.122.76.186]:60144 X-Source-Auth: tom+tromey.com X-Email-Count: 27 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3027.9 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 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.29 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 Sender: "Gdb-patches" This changes block to make the data members 'private'. --- gdb/block.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/gdb/block.h b/gdb/block.h index 7c40bae9af2..32e3c9ebcfd 100644 --- a/gdb/block.h +++ b/gdb/block.h @@ -271,6 +271,12 @@ struct block : public allocate_on_obstack struct dynamic_prop *static_link () const; +private: + + /* If the namespace_info is NULL, allocate it via OBSTACK and + initialize its members to zero. */ + void initialize_namespace (struct obstack *obstack); + /* Addresses in the executable code that are in this block. */ CORE_ADDR m_start = 0; @@ -303,12 +309,6 @@ struct block : public allocate_on_obstack startaddr and endaddr above. */ struct blockranges *m_ranges = nullptr; - -private: - - /* If the namespace_info is NULL, allocate it via OBSTACK and - initialize its members to zero. */ - void initialize_namespace (struct obstack *obstack); }; /* The global block is singled out so that we can provide a back-link From patchwork Fri Jan 20 21:46:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 63538 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 1C3EA388B6AF for ; Fri, 20 Jan 2023 21:48:54 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from gproxy1-pub.mail.unifiedlayer.com (gproxy1-pub.mail.unifiedlayer.com [69.89.25.95]) by sourceware.org (Postfix) with ESMTPS id 743BF385B536 for ; Fri, 20 Jan 2023 21:46:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 743BF385B536 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com Received: from cmgw11.mail.unifiedlayer.com (unknown [10.0.90.126]) by progateway3.mail.pro1.eigbox.com (Postfix) with ESMTP id E4E4310048113 for ; Fri, 20 Jan 2023 21:46:43 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id IzDfpoFtiJceRIzDfprVGH; Fri, 20 Jan 2023 21:46:43 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=Or6Kdwzt c=1 sm=1 tr=0 ts=63cb0bc3 a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=RvmDmJFTN0MA:10:nop_rcvd_month_year a=Qbun_eYptAEA:10:endurance_base64_authed_username_1 a=PklsFC0oVL0Hh13o5MkA:9 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: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=n9aQr110ChO0E83Qn95fMfXKncTVLkZEtSXYiylIAFk=; b=mYK6OhIV8cgVg3l4d542LJoaw6 NYHTsJcjhvyeeBsYVtmJb8ZrKQJq3Mi4eBo3eIdJ3pE8htBG7HwKe41bOhG7K2bRBbwwiFZ3MtCWx EgXG1jmQbxKs2IVlw4Y2e9cin; Received: from 97-122-76-186.hlrn.qwest.net ([97.122.76.186]:60144 helo=localhost.localdomain) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1pIzDf-001GNx-LF; Fri, 20 Jan 2023 14:46:43 -0700 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 27/27] Convert contained_in to method Date: Fri, 20 Jan 2023 14:46:18 -0700 Message-Id: <20230120214618.3236224-28-tom@tromey.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230120214618.3236224-1-tom@tromey.com> References: <20230120214618.3236224-1-tom@tromey.com> MIME-Version: 1.0 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.76.186 X-Source-L: No X-Exim-ID: 1pIzDf-001GNx-LF X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-76-186.hlrn.qwest.net (localhost.localdomain) [97.122.76.186]:60144 X-Source-Auth: tom+tromey.com X-Email-Count: 28 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3027.9 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 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.29 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 Sender: "Gdb-patches" This converts contained_in to be a method of block. --- gdb/block.c | 7 +++---- gdb/block.h | 19 +++++++++---------- gdb/blockframe.c | 2 +- gdb/breakpoint.c | 2 +- gdb/frame.c | 2 +- gdb/inline-frame.c | 2 +- gdb/parse.c | 2 +- gdb/printcmd.c | 6 +++--- 8 files changed, 20 insertions(+), 22 deletions(-) diff --git a/gdb/block.c b/gdb/block.c index 334d8180448..4e40247b79c 100644 --- a/gdb/block.c +++ b/gdb/block.c @@ -65,15 +65,14 @@ block::gdbarch () const /* See block.h. */ bool -contained_in (const struct block *a, const struct block *b, - bool allow_nested) +block::contains (const struct block *a, bool allow_nested) const { - if (!a || !b) + if (a == nullptr) return false; do { - if (a == b) + if (a == this) return true; /* If A is a function block, then A cannot be contained in B, except if A was inlined. */ diff --git a/gdb/block.h b/gdb/block.h index 32e3c9ebcfd..cdcee0844ec 100644 --- a/gdb/block.h +++ b/gdb/block.h @@ -271,6 +271,15 @@ struct block : public allocate_on_obstack struct dynamic_prop *static_link () const; + /* Return true if block A is lexically nested within this block, or + if A and this block have the same pc range. Return false + otherwise. If ALLOW_NESTED is true, then block A is considered + to be in this block if A is in a nested function in this block's + function. If ALLOW_NESTED is false (the default), then blocks in + nested functions are not considered to be contained. */ + + bool contains (const struct block *a, bool allow_nested = false) const; + private: /* If the namespace_info is NULL, allocate it via OBSTACK and @@ -400,16 +409,6 @@ struct blockvector struct block *m_blocks[1]; }; -/* Return true if block A is lexically nested within block B, or if a - and b have the same pc range. Return false otherwise. If - ALLOW_NESTED is true, then block A is considered to be in block B - if A is in a nested function in B's function. If ALLOW_NESTED is - false (the default), then blocks in nested functions are not - considered to be contained. */ - -extern bool contained_in (const struct block *a, const struct block *b, - bool allow_nested = false); - extern const struct blockvector *blockvector_for_pc (CORE_ADDR, const struct block **); diff --git a/gdb/blockframe.c b/gdb/blockframe.c index 7c9faf487a7..633a9674d97 100644 --- a/gdb/blockframe.c +++ b/gdb/blockframe.c @@ -469,7 +469,7 @@ block_innermost_frame (const struct block *block) while (frame != NULL) { const struct block *frame_block = get_frame_block (frame, NULL); - if (frame_block != NULL && contained_in (frame_block, block)) + if (frame_block != NULL && block->contains (frame_block)) return frame; frame = get_prev_frame (frame); diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index 475a16e8d73..f6aa3940429 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -5142,7 +5142,7 @@ watchpoint_check (bpstat *bs) function = get_frame_function (fr); if (function == NULL - || !contained_in (b->exp_valid_block, function->value_block ())) + || !function->value_block ()->contains (b->exp_valid_block)) within_current_scope = false; } diff --git a/gdb/frame.c b/gdb/frame.c index 2f9622ad2b2..2e29348110e 100644 --- a/gdb/frame.c +++ b/gdb/frame.c @@ -848,7 +848,7 @@ frame_id_inner (struct gdbarch *gdbarch, struct frame_id l, struct frame_id r) /* This will return true if LB and RB are the same block, or if the block with the smaller depth lexically encloses the block with the greater depth. */ - inner = contained_in (lb, rb); + inner = rb->contains (lb); } else /* Only return non-zero when strictly inner than. Note that, per diff --git a/gdb/inline-frame.c b/gdb/inline-frame.c index 21431a280fa..80765d5cca5 100644 --- a/gdb/inline-frame.c +++ b/gdb/inline-frame.c @@ -293,7 +293,7 @@ block_starting_point_at (CORE_ADDR pc, const struct block *block) if (new_block == NULL) return 1; - if (new_block == block || contained_in (new_block, block)) + if (new_block == block || block->contains (new_block)) return 0; /* The immediately preceding address belongs to a different block, diff --git a/gdb/parse.c b/gdb/parse.c index 4c20b91f238..f2917b30740 100644 --- a/gdb/parse.c +++ b/gdb/parse.c @@ -86,7 +86,7 @@ innermost_block_tracker::update (const struct block *b, { if ((m_types & t) != 0 && (m_innermost_block == NULL - || contained_in (b, m_innermost_block))) + || m_innermost_block->contains (b))) m_innermost_block = b; } diff --git a/gdb/printcmd.c b/gdb/printcmd.c index e3ee847a955..74e2f5160ba 100644 --- a/gdb/printcmd.c +++ b/gdb/printcmd.c @@ -2123,8 +2123,8 @@ do_one_display (struct display *d) if (d->block) { if (d->pspace == current_program_space) - within_current_scope = contained_in (get_selected_block (0), d->block, - true); + within_current_scope = d->block->contains (get_selected_block (0), + true); else within_current_scope = 0; } @@ -2282,7 +2282,7 @@ Num Enb Expression\n")); else if (d->format.format) gdb_printf ("/%c ", d->format.format); gdb_puts (d->exp_string.c_str ()); - if (d->block && !contained_in (get_selected_block (0), d->block, true)) + if (d->block && !d->block->contains (get_selected_block (0), true)) gdb_printf (_(" (cannot be evaluated in the current context)")); gdb_printf ("\n"); }