From patchwork Thu Jan 23 00:57:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 37502 Received: (qmail 83070 invoked by alias); 23 Jan 2020 00:57:55 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 80973 invoked by uid 89); 23 Jan 2020 00:57:38 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-21.2 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS autolearn=ham version=3.3.1 spammy=HX-Languages-Length:3235 X-HELO: gateway36.websitewelcome.com Received: from gateway36.websitewelcome.com (HELO gateway36.websitewelcome.com) (192.185.193.12) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 23 Jan 2020 00:57:28 +0000 Received: from cm13.websitewelcome.com (cm13.websitewelcome.com [100.42.49.6]) by gateway36.websitewelcome.com (Postfix) with ESMTP id C2156407358AA for ; Wed, 22 Jan 2020 18:10:20 -0600 (CST) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id uQoJizIGiERZguQoJirDE3; Wed, 22 Jan 2020 18:57:27 -0600 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Sender:Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding: 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=qV14tJWZTEZNn7MGWnAxB9nCwVKUq3w4ZHWsz/xONzI=; b=G9OWUMiZKF7bMC7xir0PJG7E0q 9KHOjriJ55C0wsyEcCtZBNHXXQfAs9GccgPqUC2hQA/D7dPuXs7QZWl1rg3Lbr29EgWk4jwGXc65b j3jXmC3SXXTaOppk28QVa7VGG; Received: from 75-166-123-50.hlrn.qwest.net ([75.166.123.50]:40832 helo=bapiya.Home) by box5379.bluehost.com with esmtpa (Exim 4.92) (envelope-from ) id 1iuQoJ-004KqG-Ba; Wed, 22 Jan 2020 17:57:27 -0700 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 31/38] Convert dwarf2_section_size to a method Date: Wed, 22 Jan 2020 17:57:03 -0700 Message-Id: <20200123005710.7978-32-tom@tromey.com> In-Reply-To: <20200123005710.7978-1-tom@tromey.com> References: <20200123005710.7978-1-tom@tromey.com> This changes dwarf2_section_size to be a method on dwarf2_section_info. 2020-01-22 Tom Tromey * dwarf2/read.c (dwarf2_section_size): Remove. (error_check_comp_unit_head, dwarf2_symbol_mark_computed): Update. * dwarf2/section.h (struct dwarf2_section_info) : New method. Change-Id: I12928fee5c84350ce98883e329357b86888d639b --- gdb/ChangeLog | 7 +++++++ gdb/dwarf2/read.c | 20 ++------------------ gdb/dwarf2/section.h | 13 +++++++++++++ 3 files changed, 22 insertions(+), 18 deletions(-) diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 65e39b22b4f..9db6529c4b8 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -2078,22 +2078,6 @@ dwarf2_per_objfile::locate_sections (bfd *abfd, asection *sectp, this->has_section_at_zero = true; } -/* A helper function that returns the size of a section in a safe way. - If you are positive that the section has been read before using the - size, then it is safe to refer to the dwarf2_section_info object's - "size" field directly. In other cases, you must call this - function, because for compressed sections the size field is not set - correctly until the section has been read. */ - -static bfd_size_type -dwarf2_section_size (struct objfile *objfile, - struct dwarf2_section_info *info) -{ - if (!info->readin) - info->read (objfile); - return info->size; -} - /* Fill in SECTP, BUFP and SIZEP with section info, given OBJFILE and SECTION_NAME. */ @@ -6097,7 +6081,7 @@ error_check_comp_unit_head (struct dwarf2_per_objfile *dwarf2_per_objfile, const char *filename = section->get_file_name (); if (to_underlying (header->abbrev_sect_off) - >= dwarf2_section_size (dwarf2_per_objfile->objfile, abbrev_section)) + >= abbrev_section->get_size (dwarf2_per_objfile->objfile)) error (_("Dwarf Error: bad offset (%s) in compilation unit header " "(offset %s + 6) [in module %s]"), sect_offset_str (header->abbrev_sect_off), @@ -24438,7 +24422,7 @@ dwarf2_symbol_mark_computed (const struct attribute *attr, struct symbol *sym, /* .debug_loc{,.dwo} may not exist at all, or the offset may be outside the section. If so, fall through to the complaint in the other branch. */ - && DW_UNSND (attr) < dwarf2_section_size (objfile, section)) + && DW_UNSND (attr) < section->get_size (objfile)) { struct dwarf2_loclist_baton *baton; diff --git a/gdb/dwarf2/section.h b/gdb/dwarf2/section.h index f76f1ef7bf5..8ddedcaf761 100644 --- a/gdb/dwarf2/section.h +++ b/gdb/dwarf2/section.h @@ -81,6 +81,19 @@ struct dwarf2_section_info If the section is compressed, uncompress it before returning. */ void read (struct objfile *objfile); + /* A helper function that returns the size of a section in a safe way. + If you are positive that the section has been read before using the + size, then it is safe to refer to the dwarf2_section_info object's + "size" field directly. In other cases, you must call this + function, because for compressed sections the size field is not set + correctly until the section has been read. */ + bfd_size_type get_size (struct objfile *objfile) + { + if (!readin) + read (objfile); + return size; + } + union { /* If this is a real section, the bfd section. */