From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 Content-Transfer-Encoding: 8bit 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 List-Id: 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) -- 2.39.0