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 ());