From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gateway36.websitewelcome.com (gateway36.websitewelcome.com [192.185.197.22]) by sourceware.org (Postfix) with ESMTPS id A4289385E019 for ; Sun, 22 Mar 2020 18:45:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org A4289385E019 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=tom@tromey.com Received: from cm13.websitewelcome.com (cm13.websitewelcome.com [100.42.49.6]) by gateway36.websitewelcome.com (Postfix) with ESMTP id 95078400C6C5F for ; Sun, 22 Mar 2020 13:01:39 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id G5bCjQ0z0VQh0G5bCjeUTu; Sun, 22 Mar 2020 13:45:26 -0500 X-Authority-Reason: nr=8 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=n6q4hPfXwkDTOrJTbswrY6gAZzwaln7/YVu95VMkRow=; b=wHOsFRwX18Gyf/f+skaj8DdbV1 LeqoZ2EKEtW+vnVPWia5syy8FF6mM/DkLtR1nVCr11pR7HM5Dt3bODp96qBMAtQ/xNZDLUfmmM+yv bpUpb7S6MFGvUiG5JGggr9U05; Received: from 97-118-117-21.hlrn.qwest.net ([97.118.117.21]:48304 helo=bapiya.Home) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92) (envelope-from ) id 1jG5bC-000LNS-2y; Sun, 22 Mar 2020 12:45:26 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 04/22] Split dwarf_decode_macros into two overloads Date: Sun, 22 Mar 2020 12:45:05 -0600 Message-Id: <20200322184523.28959-5-tom@tromey.com> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20200322184523.28959-1-tom@tromey.com> References: <20200322184523.28959-1-tom@tromey.com> 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.118.117.21 X-Source-L: No X-Exim-ID: 1jG5bC-000LNS-2y X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-118-117-21.hlrn.qwest.net (bapiya.Home) [97.118.117.21]:48304 X-Source-Auth: tom+tromey.com X-Email-Count: 5 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-22.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, JMQ_SPF_NEUTRAL, RCVD_IN_ABUSEAT, RCVD_IN_DNSWL_NONE, RCVD_IN_SBL_CSS, SPF_HELO_PASS, SPF_NEUTRAL, TXREP, URIBL_CSS, URIBL_CSS_A autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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: , X-List-Received-Date: Sun, 22 Mar 2020 18:45:28 -0000 This splits dwarf_decode_macros into two overloads -- one that's suitable for splitting into a separate file, and one that finds the correct section and should remain in dwarf2/read.c. gdb/ChangeLog 2020-03-22 Tom Tromey * dwarf2/read.c (dwarf_decode_macros): Split into two overloads. --- gdb/ChangeLog | 4 ++ gdb/dwarf2/read.c | 102 +++++++++++++++++++++++++++------------------- 2 files changed, 63 insertions(+), 43 deletions(-) diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 1410dd48a2f..2d126461c74 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -23753,56 +23753,18 @@ dwarf_decode_macro_bytes (struct dwarf2_per_objfile *dwarf2_per_objfile, } static void -dwarf_decode_macros (struct dwarf2_cu *cu, unsigned int offset, - int section_is_gnu) +dwarf_decode_macros (struct dwarf2_per_objfile *dwarf2_per_objfile, + buildsym_compunit *builder, dwarf2_section_info *section, + struct line_header *lh, unsigned int offset_size, + unsigned int offset, int section_is_gnu) { - struct dwarf2_per_objfile *dwarf2_per_objfile - = cu->per_cu->dwarf2_per_objfile; - struct objfile *objfile = dwarf2_per_objfile->objfile; - struct line_header *lh = cu->line_header; bfd *abfd; const gdb_byte *mac_ptr, *mac_end; struct macro_source_file *current_file = 0; enum dwarf_macro_record_type macinfo_type; - unsigned int offset_size = cu->header.offset_size; const gdb_byte *opcode_definitions[256]; void **slot; - struct dwarf2_section_info *section; - const char *section_name; - if (cu->dwo_unit != NULL) - { - if (section_is_gnu) - { - section = &cu->dwo_unit->dwo_file->sections.macro; - section_name = ".debug_macro.dwo"; - } - else - { - section = &cu->dwo_unit->dwo_file->sections.macinfo; - section_name = ".debug_macinfo.dwo"; - } - } - else - { - if (section_is_gnu) - { - section = &dwarf2_per_objfile->macro; - section_name = ".debug_macro"; - } - else - { - section = &dwarf2_per_objfile->macinfo; - section_name = ".debug_macinfo"; - } - } - - section->read (objfile); - if (section->buffer == NULL) - { - complaint (_("missing %s section"), section_name); - return; - } abfd = section->get_bfd_owner (); /* First pass: Find the name of the base filename. @@ -23827,7 +23789,6 @@ dwarf_decode_macros (struct dwarf2_cu *cu, unsigned int offset, return; } - buildsym_compunit *builder = cu->get_builder (); do { /* Do we at least have room for a macinfo type byte? */ @@ -23949,6 +23910,61 @@ dwarf_decode_macros (struct dwarf2_cu *cu, unsigned int offset, include_hash.get ()); } +/* An overload of dwarf_decode_macros that finds the correct section + and ensures it is read in before calling the other overload. */ + +static void +dwarf_decode_macros (struct dwarf2_cu *cu, unsigned int offset, + int section_is_gnu) +{ + struct dwarf2_per_objfile *dwarf2_per_objfile + = cu->per_cu->dwarf2_per_objfile; + struct objfile *objfile = dwarf2_per_objfile->objfile; + struct line_header *lh = cu->line_header; + unsigned int offset_size = cu->header.offset_size; + struct dwarf2_section_info *section; + const char *section_name; + + if (cu->dwo_unit != NULL) + { + if (section_is_gnu) + { + section = &cu->dwo_unit->dwo_file->sections.macro; + section_name = ".debug_macro.dwo"; + } + else + { + section = &cu->dwo_unit->dwo_file->sections.macinfo; + section_name = ".debug_macinfo.dwo"; + } + } + else + { + if (section_is_gnu) + { + section = &dwarf2_per_objfile->macro; + section_name = ".debug_macro"; + } + else + { + section = &dwarf2_per_objfile->macinfo; + section_name = ".debug_macinfo"; + } + } + + section->read (objfile); + if (section->buffer == NULL) + { + complaint (_("missing %s section"), section_name); + return; + } + + buildsym_compunit *builder = cu->get_builder (); + + dwarf_decode_macros (dwarf2_per_objfile, builder, section, lh, + offset_size, offset, section_is_gnu); +} + /* Return the .debug_loc section to use for CU. For DWO files use .debug_loc.dwo. */ -- 2.17.2