From patchwork Thu Jan 23 00:56:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 37479 Received: (qmail 79489 invoked by alias); 23 Jan 2020 00:57:26 -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 79402 invoked by uid 89); 23 Jan 2020 00:57:26 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-20.9 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=complaint, UD:has_value, sk:read_in, sk:cu_debu 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:20 +0000 Received: from cm12.websitewelcome.com (cm12.websitewelcome.com [100.42.49.8]) by gateway36.websitewelcome.com (Postfix) with ESMTP id 1DE5A407358A9 for ; Wed, 22 Jan 2020 18:10:11 -0600 (CST) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id uQoAiqj0MLLpRuQoAisvC1; Wed, 22 Jan 2020 18:57:18 -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=duPxkb+DJ23moMhTjQLxYZO7fGhNj4h+/GY4PDbhpQg=; b=rzBm1+jkPVif0wSBKJkcdsqYM4 /6S2MbZeylF3PGrtDnQ6Of9U2aop1sZGr5lS0QKVpywwTaaYQElP1jDLHRY8otFBQBuHe6GMwFqW2 HnnDBtFNKGa2qmDftFVqyD8K3; Received: from 75-166-123-50.hlrn.qwest.net ([75.166.123.50]:40800 helo=bapiya.Home) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92) (envelope-from ) id 1iuQoA-004Kfy-6e; Wed, 22 Jan 2020 17:57:18 -0700 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 03/38] Change section functions to be methods of dwarf2_section_info Date: Wed, 22 Jan 2020 17:56:35 -0700 Message-Id: <20200123005710.7978-4-tom@tromey.com> In-Reply-To: <20200123005710.7978-1-tom@tromey.com> References: <20200123005710.7978-1-tom@tromey.com> This changes various section-related functions to be methods on dwarf2_section_info. I think this clarifies the role of these functions. This also changes one such function to return bool. gdb/ChangeLog 2020-01-22 Tom Tromey * dwarf2read.c (dwarf2_section_buffer_overflow_complaint) (dwarf2_section_size, dwarf2_get_section_info) (create_signatured_type_table_from_debug_names) (create_addrmap_from_aranges, read_debug_names_from_section) (get_gdb_index_contents_from_section, read_comp_unit_head) (error_check_comp_unit_head, read_abbrev_offset) (create_debug_type_hash_table, init_cu_die_reader) (read_cutu_die_from_dwo, dwarf2_build_psymtabs_hard) (read_comp_units_from_section, create_cus_hash_table) (create_dwp_hash_table, create_dwo_unit_in_dwp_v1) (create_dwp_v2_section, dwarf2_rnglists_process) (dwarf2_ranges_process, read_die_and_siblings, read_full_die) (abbrev_table_read_table, read_indirect_string_at_offset_from) (read_indirect_string_from_dwz, read_addr_index_1) (read_str_index, dwarf_decode_line_header, skip_form_bytes) (dwarf_decode_macro_bytes, dwarf_decode_macros) (fill_in_loclist_baton): Update. * dwarf2/section.h (struct dwarf2_section_info) : Declare methods. (dwarf2_read_section, get_section_name, get_section_file_name) (get_containing_section, get_section_bfd_owner) (get_section_bfd_section, get_section_name, get_section_file_name) (get_section_id, get_section_flags, dwarf2_section_empty_p): Don't declare. * dwarf2/section.c (dwarf2_section_info::get_containing_section) (dwarf2_section_info::get_bfd_owner) (dwarf2_section_info::get_bfd_section) (dwarf2_section_info::get_name) (dwarf2_section_info::get_file_name, dwarf2_section_info::get_id) (dwarf2_section_info::get_flags, dwarf2_section_info::empty) (dwarf2_section_info::read): Now methods. * dwarf-index-write.c (class debug_names): Update. Change-Id: Ic849f182f57a18bad6b1c7c3b9368005d307758a --- gdb/ChangeLog | 36 +++++++++++ gdb/dwarf-index-write.c | 3 +- gdb/dwarf2/section.c | 81 +++++++++++------------ gdb/dwarf2/section.h | 87 +++++++++++-------------- gdb/dwarf2read.c | 138 ++++++++++++++++++++-------------------- 5 files changed, 183 insertions(+), 162 deletions(-) diff --git a/gdb/dwarf-index-write.c b/gdb/dwarf-index-write.c index fd222628cf5..c43a4817b97 100644 --- a/gdb/dwarf-index-write.c +++ b/gdb/dwarf-index-write.c @@ -959,8 +959,7 @@ private: : m_abfd (dwarf2_per_objfile->objfile->obfd), m_dwarf2_per_objfile (dwarf2_per_objfile) { - dwarf2_read_section (dwarf2_per_objfile->objfile, - &dwarf2_per_objfile->str); + dwarf2_per_objfile->str.read (dwarf2_per_objfile->objfile); if (dwarf2_per_objfile->str.buffer == NULL) return; for (const gdb_byte *data = dwarf2_per_objfile->str.buffer; diff --git a/gdb/dwarf2/section.c b/gdb/dwarf2/section.c index 618ab9adf12..5e33809117d 100644 --- a/gdb/dwarf2/section.c +++ b/gdb/dwarf2/section.c @@ -30,55 +30,57 @@ #include "objfiles.h" struct dwarf2_section_info * -get_containing_section (const struct dwarf2_section_info *section) +dwarf2_section_info::get_containing_section () const { - gdb_assert (section->is_virtual); - return section->s.containing_section; + gdb_assert (is_virtual); + return s.containing_section; } struct bfd * -get_section_bfd_owner (const struct dwarf2_section_info *section) +dwarf2_section_info::get_bfd_owner () const { - if (section->is_virtual) + const dwarf2_section_info *section = this; + if (is_virtual) { - section = get_containing_section (section); + section = get_containing_section (); gdb_assert (!section->is_virtual); } return section->s.section->owner; } asection * -get_section_bfd_section (const struct dwarf2_section_info *section) +dwarf2_section_info::get_bfd_section () const { + const dwarf2_section_info *section = this; if (section->is_virtual) { - section = get_containing_section (section); + section = get_containing_section (); gdb_assert (!section->is_virtual); } return section->s.section; } const char * -get_section_name (const struct dwarf2_section_info *section) +dwarf2_section_info::get_name () const { - asection *sectp = get_section_bfd_section (section); + asection *sectp = get_bfd_section (); gdb_assert (sectp != NULL); return bfd_section_name (sectp); } const char * -get_section_file_name (const struct dwarf2_section_info *section) +dwarf2_section_info::get_file_name () const { - bfd *abfd = get_section_bfd_owner (section); + bfd *abfd = get_bfd_owner (); return bfd_get_filename (abfd); } int -get_section_id (const struct dwarf2_section_info *section) +dwarf2_section_info::get_id () const { - asection *sectp = get_section_bfd_section (section); + asection *sectp = get_bfd_section (); if (sectp == NULL) return 0; @@ -86,61 +88,60 @@ get_section_id (const struct dwarf2_section_info *section) } int -get_section_flags (const struct dwarf2_section_info *section) +dwarf2_section_info::get_flags () const { - asection *sectp = get_section_bfd_section (section); + asection *sectp = get_bfd_section (); gdb_assert (sectp != NULL); return bfd_section_flags (sectp); } -int -dwarf2_section_empty_p (const struct dwarf2_section_info *section) +bool +dwarf2_section_info::empty () const { - if (section->is_virtual) - return section->size == 0; - return section->s.section == NULL || section->size == 0; + if (is_virtual) + return size == 0; + return s.section == NULL || size == 0; } void -dwarf2_read_section (struct objfile *objfile, dwarf2_section_info *info) +dwarf2_section_info::read (struct objfile *objfile) { asection *sectp; bfd *abfd; gdb_byte *buf, *retbuf; - if (info->readin) + if (readin) return; - info->buffer = NULL; - info->readin = true; + buffer = NULL; + readin = true; - if (dwarf2_section_empty_p (info)) + if (empty ()) return; - sectp = get_section_bfd_section (info); + sectp = get_bfd_section (); /* If this is a virtual section we need to read in the real one first. */ - if (info->is_virtual) + if (is_virtual) { struct dwarf2_section_info *containing_section = - get_containing_section (info); + get_containing_section (); gdb_assert (sectp != NULL); if ((sectp->flags & SEC_RELOC) != 0) { error (_("Dwarf Error: DWP format V2 with relocations is not" " supported in section %s [in module %s]"), - get_section_name (info), get_section_file_name (info)); + get_name (), get_file_name ()); } - dwarf2_read_section (objfile, containing_section); + containing_section->read (objfile); /* Other code should have already caught virtual sections that don't fit. */ - gdb_assert (info->virtual_offset + info->size - <= containing_section->size); + gdb_assert (virtual_offset + size <= containing_section->size); /* If the real section is empty or there was a problem reading the section we shouldn't get here. */ gdb_assert (containing_section->buffer != NULL); - info->buffer = containing_section->buffer + info->virtual_offset; + buffer = containing_section->buffer + virtual_offset; return; } @@ -148,12 +149,12 @@ dwarf2_read_section (struct objfile *objfile, dwarf2_section_info *info) Otherwise we attach it to the BFD. */ if ((sectp->flags & SEC_RELOC) == 0) { - info->buffer = gdb_bfd_map_section (sectp, &info->size); + buffer = gdb_bfd_map_section (sectp, &size); return; } - buf = (gdb_byte *) obstack_alloc (&objfile->objfile_obstack, info->size); - info->buffer = buf; + buf = (gdb_byte *) obstack_alloc (&objfile->objfile_obstack, size); + buffer = buf; /* When debugging .o files, we may need to apply relocations; see http://sourceware.org/ml/gdb-patches/2002-04/msg00136.html . @@ -162,15 +163,15 @@ dwarf2_read_section (struct objfile *objfile, dwarf2_section_info *info) retbuf = symfile_relocate_debug_section (objfile, sectp, buf); if (retbuf != NULL) { - info->buffer = retbuf; + buffer = retbuf; return; } - abfd = get_section_bfd_owner (info); + abfd = get_bfd_owner (); gdb_assert (abfd != NULL); if (bfd_seek (abfd, sectp->filepos, SEEK_SET) != 0 - || bfd_bread (buf, info->size, abfd) != info->size) + || bfd_bread (buf, size, abfd) != size) { error (_("Dwarf Error: Can't read DWARF data" " in section %s [in module %s]"), diff --git a/gdb/dwarf2/section.h b/gdb/dwarf2/section.h index a1acc5f9e66..f76f1ef7bf5 100644 --- a/gdb/dwarf2/section.h +++ b/gdb/dwarf2/section.h @@ -45,6 +45,42 @@ struct dwarf2_section_info { + /* Return the name of this section. */ + const char *get_name () const; + + /* Return the containing section of this section, which must be a + virtual section. */ + struct dwarf2_section_info *get_containing_section () const; + + /* Return the bfd owner of this section. */ + struct bfd *get_bfd_owner () const; + + /* Return the bfd section of this section. + Returns NULL if the section is not present. */ + asection *get_bfd_section () const; + + /* Return the name of the file this section is in. */ + const char *get_file_name () const; + + /* Return the id of this section. + Returns 0 if this section doesn't exist. */ + int get_id () const; + + /* Return the flags of this section. This section (or containing + section if this is a virtual section) must exist. */ + int get_flags () const; + + /* Return true if this section does not exist or if it has no + contents. */ + bool empty () const; + + /* Read the contents of this section. + OBJFILE is the main object file, but not necessarily the file where + the section comes from. E.g., for DWO files the bfd of INFO is the bfd + of the DWO file. + If the section is compressed, uncompress it before returning. */ + void read (struct objfile *objfile); + union { /* If this is a real section, the bfd section. */ @@ -67,55 +103,4 @@ struct dwarf2_section_info bool is_virtual; }; -/* Read the contents of the section INFO. - OBJFILE is the main object file, but not necessarily the file where - the section comes from. E.g., for DWO files the bfd of INFO is the bfd - of the DWO file. - If the section is compressed, uncompress it before returning. */ - -extern void dwarf2_read_section (struct objfile *objfile, - dwarf2_section_info *info); - -extern const char *get_section_name (const struct dwarf2_section_info *); - -extern const char *get_section_file_name (const struct dwarf2_section_info *); - -/* Return the containing section of virtual section SECTION. */ - -extern struct dwarf2_section_info *get_containing_section - (const struct dwarf2_section_info *section); - -/* Return the bfd owner of SECTION. */ - -extern struct bfd *get_section_bfd_owner - (const struct dwarf2_section_info *section); - -/* Return the bfd section of SECTION. - Returns NULL if the section is not present. */ - -extern asection *get_section_bfd_section - (const struct dwarf2_section_info *section); - -/* Return the name of SECTION. */ - -extern const char *get_section_name - (const struct dwarf2_section_info *section); - -/* Return the name of the file SECTION is in. */ - -extern const char *get_section_file_name - (const struct dwarf2_section_info *section); - -/* Return the id of SECTION. - Returns 0 if SECTION doesn't exist. */ - -extern int get_section_id (const struct dwarf2_section_info *section); - -/* Return the flags of SECTION. - SECTION (or containing section if this is a virtual section) must exist. */ - -extern int get_section_flags (const struct dwarf2_section_info *section); - -extern int dwarf2_section_empty_p (const struct dwarf2_section_info *section); - #endif /* GDB_DWARF2_SECTION_H */ diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index 4eabda98be5..c1fdbccd8d3 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -2076,8 +2076,8 @@ dwarf2_section_buffer_overflow_complaint (struct dwarf2_section_info *section) { complaint (_("debug info runs off end of %s section" " [in module %s]"), - get_section_name (section), - get_section_file_name (section)); + section->get_name (), + section->get_file_name ()); } static void @@ -2419,7 +2419,7 @@ dwarf2_section_size (struct objfile *objfile, struct dwarf2_section_info *info) { if (!info->readin) - dwarf2_read_section (objfile, info); + info->read (objfile); return info->size; } @@ -2456,9 +2456,9 @@ dwarf2_get_section_info (struct objfile *objfile, gdb_assert_not_reached ("unexpected section"); } - dwarf2_read_section (objfile, info); + info->read (objfile); - *sectp = get_section_bfd_section (info); + *sectp = info->get_bfd_section (); *bufp = info->buffer; *sizep = info->size; } @@ -2958,8 +2958,8 @@ create_signatured_type_table_from_debug_names { struct objfile *objfile = dwarf2_per_objfile->objfile; - dwarf2_read_section (objfile, section); - dwarf2_read_section (objfile, abbrev_section); + section->read (objfile); + abbrev_section->read (objfile); gdb_assert (dwarf2_per_objfile->all_type_units.empty ()); dwarf2_per_objfile->all_type_units.reserve (map.tu_count); @@ -3092,7 +3092,7 @@ create_addrmap_from_aranges (struct dwarf2_per_objfile *dwarf2_per_objfile, } } - dwarf2_read_section (objfile, section); + section->read (objfile); const bfd_endian dwarf5_byte_order = gdbarch_byte_order (gdbarch); @@ -5219,21 +5219,21 @@ read_debug_names_from_section (struct objfile *objfile, struct dwarf2_section_info *section, mapped_debug_names &map) { - if (dwarf2_section_empty_p (section)) + if (section->empty ()) return false; /* Older elfutils strip versions could keep the section in the main executable while splitting it for the separate debug info file. */ - if ((get_section_flags (section) & SEC_HAS_CONTENTS) == 0) + if ((section->get_flags () & SEC_HAS_CONTENTS) == 0) return false; - dwarf2_read_section (objfile, section); + section->read (objfile); map.dwarf5_byte_order = gdbarch_byte_order (get_objfile_arch (objfile)); const gdb_byte *addr = section->buffer; - bfd *const abfd = get_section_bfd_owner (section); + bfd *const abfd = section->get_bfd_owner (); unsigned int bytes_read; LONGEST length = read_initial_length (abfd, addr, &bytes_read); @@ -6093,15 +6093,15 @@ get_gdb_index_contents_from_section (objfile *obj, T *section_owner) { dwarf2_section_info *section = §ion_owner->gdb_index; - if (dwarf2_section_empty_p (section)) + if (section->empty ()) return {}; /* Older elfutils strip versions could keep the section in the main executable while splitting it for the separate debug info file. */ - if ((get_section_flags (section) & SEC_HAS_CONTENTS) == 0) + if ((section->get_flags () & SEC_HAS_CONTENTS) == 0) return {}; - dwarf2_read_section (obj, section); + section->read (obj); /* dwarf2_section_info::size is a bfd_size_type, while gdb::array_view works with size_t. On 32-bit hosts, with @@ -6296,8 +6296,8 @@ read_comp_unit_head (struct comp_unit_head *cu_header, { int signed_addr; unsigned int bytes_read; - const char *filename = get_section_file_name (section); - bfd *abfd = get_section_bfd_owner (section); + const char *filename = section->get_file_name (); + bfd *abfd = section->get_bfd_owner (); cu_header->length = read_initial_length (abfd, info_ptr, &bytes_read); cu_header->initial_length_size = bytes_read; @@ -6424,7 +6424,7 @@ error_check_comp_unit_head (struct dwarf2_per_objfile *dwarf2_per_objfile, struct dwarf2_section_info *section, struct dwarf2_section_info *abbrev_section) { - const char *filename = get_section_file_name (section); + const char *filename = section->get_file_name (); if (to_underlying (header->abbrev_sect_off) >= dwarf2_section_size (dwarf2_per_objfile->objfile, abbrev_section)) @@ -6477,12 +6477,12 @@ read_abbrev_offset (struct dwarf2_per_objfile *dwarf2_per_objfile, struct dwarf2_section_info *section, sect_offset sect_off) { - bfd *abfd = get_section_bfd_owner (section); + bfd *abfd = section->get_bfd_owner (); const gdb_byte *info_ptr; unsigned int initial_length_size, offset_size; uint16_t version; - dwarf2_read_section (dwarf2_per_objfile->objfile, section); + section->read (dwarf2_per_objfile->objfile); info_ptr = section->buffer + to_underlying (sect_off); read_initial_length (abfd, info_ptr, &initial_length_size); offset_size = initial_length_size == 4 ? 4 : 8; @@ -6620,10 +6620,10 @@ create_debug_type_hash_table (struct dwarf2_per_objfile *dwarf2_per_objfile, if (dwarf_read_debug) fprintf_unfiltered (gdb_stdlog, "Reading %s for %s:\n", - get_section_name (section), - get_section_file_name (abbrev_section)); + section->get_name (), + abbrev_section->get_file_name ()); - dwarf2_read_section (objfile, section); + section->read (objfile); info_ptr = section->buffer; if (info_ptr == NULL) @@ -6631,7 +6631,7 @@ create_debug_type_hash_table (struct dwarf2_per_objfile *dwarf2_per_objfile, /* We can't set abfd until now because the section may be empty or not present, in which case the bfd is unknown. */ - abfd = get_section_bfd_owner (section); + abfd = section->get_bfd_owner (); /* We don't use cutu_reader here because we don't need to read any dies: the signature is in the header. */ @@ -7067,7 +7067,7 @@ init_cu_die_reader (struct die_reader_specs *reader, struct abbrev_table *abbrev_table) { gdb_assert (section->readin && section->buffer != NULL); - reader->abfd = get_section_bfd_owner (section); + reader->abfd = section->get_bfd_owner (); reader->cu = cu; reader->dwo_file = dwo_file; reader->die_section = section; @@ -7165,8 +7165,8 @@ read_cutu_die_from_dwo (struct dwarf2_per_cu_data *this_cu, /* Set up for reading the DWO CU/TU. */ cu->dwo_unit = dwo_unit; dwarf2_section_info *section = dwo_unit->section; - dwarf2_read_section (objfile, section); - abfd = get_section_bfd_owner (section); + section->read (objfile); + abfd = section->get_bfd_owner (); begin_info_ptr = info_ptr = (section->buffer + to_underlying (dwo_unit->sect_off)); dwo_abbrev_section = &dwo_unit->dwo_file->sections.abbrev; @@ -7249,7 +7249,7 @@ read_cutu_die_from_dwo (struct dwarf2_per_cu_data *this_cu, { fprintf_unfiltered (gdb_stdlog, "Read die from %s@0x%x of %s:\n", - get_section_name (section), + section->get_name (), (unsigned) (begin_info_ptr - section->buffer), bfd_get_filename (abfd)); dump_die (comp_unit_die, dwarf_die_debug); @@ -7399,7 +7399,7 @@ cutu_reader::cutu_reader (struct dwarf2_per_cu_data *this_cu, struct dwarf2_per_objfile *dwarf2_per_objfile = this_cu->dwarf2_per_objfile; struct objfile *objfile = dwarf2_per_objfile->objfile; struct dwarf2_section_info *section = this_cu->section; - bfd *abfd = get_section_bfd_owner (section); + bfd *abfd = section->get_bfd_owner (); struct dwarf2_cu *cu; const gdb_byte *begin_info_ptr; struct signatured_type *sig_type = NULL; @@ -7429,7 +7429,7 @@ cutu_reader::cutu_reader (struct dwarf2_per_cu_data *this_cu, } /* This is cheap if the section is already read in. */ - dwarf2_read_section (objfile, section); + section->read (objfile); begin_info_ptr = info_ptr = section->buffer + to_underlying (this_cu->sect_off); @@ -7620,7 +7620,7 @@ cutu_reader::cutu_reader (struct dwarf2_per_cu_data *this_cu, struct dwarf2_per_objfile *dwarf2_per_objfile = this_cu->dwarf2_per_objfile; struct objfile *objfile = dwarf2_per_objfile->objfile; struct dwarf2_section_info *section = this_cu->section; - bfd *abfd = get_section_bfd_owner (section); + bfd *abfd = section->get_bfd_owner (); struct dwarf2_section_info *abbrev_section; const gdb_byte *begin_info_ptr, *info_ptr; int has_children; @@ -7637,7 +7637,7 @@ cutu_reader::cutu_reader (struct dwarf2_per_cu_data *this_cu, : get_abbrev_section_for_cu (this_cu)); /* This is cheap if the section is already read in. */ - dwarf2_read_section (objfile, section); + section->read (objfile); m_new_cu.reset (new dwarf2_cu (this_cu)); @@ -8355,7 +8355,7 @@ dwarf2_build_psymtabs_hard (struct dwarf2_per_objfile *dwarf2_per_objfile) dwarf2_per_objfile->reading_partial_symbols = 1; - dwarf2_read_section (objfile, &dwarf2_per_objfile->info); + dwarf2_per_objfile->info.read (objfile); /* Any cached compilation units will be linked by the per-objfile read_in_chain. Make sure to free them when we're done. */ @@ -8434,10 +8434,10 @@ read_comp_units_from_section (struct dwarf2_per_objfile *dwarf2_per_objfile, if (dwarf_read_debug) fprintf_unfiltered (gdb_stdlog, "Reading %s for %s\n", - get_section_name (section), - get_section_file_name (section)); + section->get_name (), + section->get_file_name ()); - dwarf2_read_section (objfile, section); + section->read (objfile); info_ptr = section->buffer; @@ -11783,7 +11783,7 @@ create_cus_hash_table (struct dwarf2_per_objfile *dwarf2_per_objfile, struct objfile *objfile = dwarf2_per_objfile->objfile; const gdb_byte *info_ptr, *end_ptr; - dwarf2_read_section (objfile, §ion); + section.read (objfile); info_ptr = section.buffer; if (info_ptr == NULL) @@ -11792,8 +11792,8 @@ create_cus_hash_table (struct dwarf2_per_objfile *dwarf2_per_objfile, if (dwarf_read_debug) { fprintf_unfiltered (gdb_stdlog, "Reading %s for %s:\n", - get_section_name (§ion), - get_section_file_name (§ion)); + section.get_name (), + section.get_file_name ()); } end_ptr = info_ptr + section.size; @@ -11995,9 +11995,9 @@ create_dwp_hash_table (struct dwarf2_per_objfile *dwarf2_per_objfile, else index = &dwp_file->sections.cu_index; - if (dwarf2_section_empty_p (index)) + if (index->empty ()) return NULL; - dwarf2_read_section (objfile, index); + index->read (objfile); index_ptr = index->buffer; index_end = index_ptr + index->size; @@ -12287,8 +12287,8 @@ create_dwo_unit_in_dwp_v1 (struct dwarf2_per_objfile *dwarf2_per_objfile, } if (i < 2 - || dwarf2_section_empty_p (§ions.info_or_types) - || dwarf2_section_empty_p (§ions.abbrev)) + || sections.info_or_types.empty () + || sections.abbrev.empty ()) { error (_("Dwarf Error: bad DWP hash table, missing DWO sections" " [in module %s]"), @@ -12312,10 +12312,10 @@ create_dwo_unit_in_dwp_v1 (struct dwarf2_per_objfile *dwarf2_per_objfile, std::string virtual_dwo_name = string_printf ("virtual-dwo/%d-%d-%d-%d", - get_section_id (§ions.abbrev), - get_section_id (§ions.line), - get_section_id (§ions.loc), - get_section_id (§ions.str_offsets)); + sections.abbrev.get_id (), + sections.line.get_id (), + sections.loc.get_id (), + sections.str_offsets.get_id ()); /* Can we use an existing virtual DWO file? */ dwo_file_slot = lookup_dwo_file_slot (dwarf2_per_objfile, virtual_dwo_name.c_str (), @@ -12393,7 +12393,7 @@ create_dwp_v2_section (struct dwarf2_per_objfile *dwarf2_per_objfile, if (size == 0) return result; - sectp = get_section_bfd_section (section); + sectp = section->get_bfd_section (); /* Flag an error if the piece denoted by OFFSET,SIZE is outside the bounds of the real section. This is a pretty-rare event, so just @@ -14156,7 +14156,7 @@ dwarf2_rnglists_process (unsigned offset, struct dwarf2_cu *cu, found_base = cu->base_known; base = cu->base_address; - dwarf2_read_section (objfile, &dwarf2_per_objfile->rnglists); + dwarf2_per_objfile->rnglists.read (objfile); if (offset >= dwarf2_per_objfile->rnglists.size) { complaint (_("Offset %d out of bounds for DW_AT_ranges attribute"), @@ -14324,7 +14324,7 @@ dwarf2_ranges_process (unsigned offset, struct dwarf2_cu *cu, found_base = cu->base_known; base = cu->base_address; - dwarf2_read_section (objfile, &dwarf2_per_objfile->ranges); + dwarf2_per_objfile->ranges.read (objfile); if (offset >= dwarf2_per_objfile->ranges.size) { complaint (_("Offset %d out of bounds for DW_AT_ranges attribute"), @@ -18196,7 +18196,7 @@ read_die_and_siblings (const struct die_reader_specs *reader, { fprintf_unfiltered (gdb_stdlog, "Read die from %s@0x%x of %s:\n", - get_section_name (reader->die_section), + reader->die_section->get_name (), (unsigned) (info_ptr - reader->die_section->buffer), bfd_get_filename (reader->abfd)); dump_die (die, dwarf_die_debug); @@ -18293,7 +18293,7 @@ read_full_die (const struct die_reader_specs *reader, { fprintf_unfiltered (gdb_stdlog, "Read die from %s@0x%x of %s:\n", - get_section_name (reader->die_section), + reader->die_section->get_name (), (unsigned) (info_ptr - reader->die_section->buffer), bfd_get_filename (reader->abfd)); dump_die (*diep, dwarf_die_debug); @@ -18364,7 +18364,7 @@ abbrev_table_read_table (struct dwarf2_per_objfile *dwarf2_per_objfile, sect_offset sect_off) { struct objfile *objfile = dwarf2_per_objfile->objfile; - bfd *abfd = get_section_bfd_owner (section); + bfd *abfd = section->get_bfd_owner (); const gdb_byte *abbrev_ptr; struct abbrev_info *cur_abbrev; unsigned int abbrev_number, bytes_read, abbrev_name; @@ -18373,7 +18373,7 @@ abbrev_table_read_table (struct dwarf2_per_objfile *dwarf2_per_objfile, abbrev_table_up abbrev_table (new struct abbrev_table (sect_off)); - dwarf2_read_section (objfile, section); + section->read (objfile); abbrev_ptr = section->buffer + to_underlying (sect_off); abbrev_number = read_unsigned_leb128 (abfd, abbrev_ptr, &bytes_read); abbrev_ptr += bytes_read; @@ -19756,7 +19756,7 @@ read_indirect_string_at_offset_from (struct objfile *objfile, const char *form_name, const char *sect_name) { - dwarf2_read_section (objfile, sect); + sect->read (objfile); if (sect->buffer == NULL) error (_("%s used without %s section [in module %s]"), form_name, sect_name, bfd_get_filename (abfd)); @@ -19803,7 +19803,7 @@ static const char * read_indirect_string_from_dwz (struct objfile *objfile, struct dwz_file *dwz, LONGEST str_offset) { - dwarf2_read_section (objfile, &dwz->str); + dwz->str.read (objfile); if (dwz->str.buffer == NULL) error (_("DW_FORM_GNU_strp_alt used without .debug_str " @@ -19864,7 +19864,7 @@ read_addr_index_1 (struct dwarf2_per_objfile *dwarf2_per_objfile, const gdb_byte *info_ptr; ULONGEST addr_base_or_zero = addr_base.has_value () ? *addr_base : 0; - dwarf2_read_section (objfile, &dwarf2_per_objfile->addr); + dwarf2_per_objfile->addr.read (objfile); if (dwarf2_per_objfile->addr.buffer == NULL) error (_("DW_FORM_addr_index used without .debug_addr section [in module %s]"), objfile_name (objfile)); @@ -19967,17 +19967,17 @@ read_str_index (struct dwarf2_cu *cu, ULONGEST str_offset; static const char form_name[] = "DW_FORM_GNU_str_index or DW_FORM_strx"; - dwarf2_read_section (objfile, str_section); - dwarf2_read_section (objfile, str_offsets_section); + str_section->read (objfile); + str_offsets_section->read (objfile); if (str_section->buffer == NULL) error (_("%s used without %s section" " in CU at offset %s [in module %s]"), - form_name, get_section_name (str_section), + form_name, str_section->get_name (), sect_offset_str (cu->header.sect_off), objf_name); if (str_offsets_section->buffer == NULL) error (_("%s used without %s section" " in CU at offset %s [in module %s]"), - form_name, get_section_name (str_section), + form_name, str_section->get_name (), sect_offset_str (cu->header.sect_off), objf_name); info_ptr = (str_offsets_section->buffer + str_offsets_base @@ -20468,7 +20468,7 @@ dwarf_decode_line_header (sect_offset sect_off, struct dwarf2_cu *cu) = cu->per_cu->dwarf2_per_objfile; section = get_debug_line_section (cu); - dwarf2_read_section (dwarf2_per_objfile->objfile, section); + section->read (dwarf2_per_objfile->objfile); if (section->buffer == NULL) { if (cu->dwo_unit && cu->per_cu->is_debug_types) @@ -20480,7 +20480,7 @@ dwarf_decode_line_header (sect_offset sect_off, struct dwarf2_cu *cu) /* We can't do this until we know the section is non-empty. Only then do we know we have such a section. */ - abfd = get_section_bfd_owner (section); + abfd = section->get_bfd_owner (); /* Make sure that at least there's room for the total_length field. That could be 12 bytes long, but we're just going to fudge that. */ @@ -24478,7 +24478,7 @@ skip_form_bytes (bfd *abfd, const gdb_byte *bytes, const gdb_byte *buffer_end, default: { complaint (_("invalid form 0x%x in `%s'"), - form, get_section_name (section)); + form, section->get_name ()); return NULL; } } @@ -24821,10 +24821,10 @@ dwarf_decode_macro_bytes (struct dwarf2_cu *cu, { struct dwz_file *dwz = dwarf2_get_dwz_file (dwarf2_per_objfile); - dwarf2_read_section (objfile, &dwz->macro); + dwz->macro.read (objfile); include_section = &dwz->macro; - include_bfd = get_section_bfd_owner (include_section); + include_bfd = include_section->get_bfd_owner (); include_mac_end = dwz->macro.buffer + dwz->macro.size; is_dwz = 1; } @@ -24927,13 +24927,13 @@ dwarf_decode_macros (struct dwarf2_cu *cu, unsigned int offset, } } - dwarf2_read_section (objfile, section); + section->read (objfile); if (section->buffer == NULL) { complaint (_("missing %s section"), section_name); return; } - abfd = get_section_bfd_owner (section); + abfd = section->get_bfd_owner (); /* First pass: Find the name of the base filename. This filename is needed in order to process all macros whose definition @@ -25193,7 +25193,7 @@ fill_in_loclist_baton (struct dwarf2_cu *cu, = cu->per_cu->dwarf2_per_objfile; struct dwarf2_section_info *section = cu_debug_loc_section (cu); - dwarf2_read_section (dwarf2_per_objfile->objfile, section); + section->read (dwarf2_per_objfile->objfile); baton->per_cu = cu->per_cu; gdb_assert (baton->per_cu);