#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;
}
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;
}
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 .
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]"),
{
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
struct dwarf2_section_info *info)
{
if (!info->readin)
- dwarf2_read_section (objfile, info);
+ info->read (objfile);
return info->size;
}
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;
}
{
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);
}
}
- dwarf2_read_section (objfile, section);
+ section->read (objfile);
const bfd_endian dwarf5_byte_order = gdbarch_byte_order (gdbarch);
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);
{
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
{
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;
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))
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;
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)
/* 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. */
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;
/* 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;
{
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);
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;
}
/* 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);
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;
: 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));
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. */
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;
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)
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;
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;
}
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]"),
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 (),
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
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"),
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"),
{
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);
{
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);
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;
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;
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));
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 "
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));
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
= 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)
/* 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. */
default:
{
complaint (_("invalid form 0x%x in `%s'"),
- form, get_section_name (section));
+ form, section->get_name ());
return NULL;
}
}
{
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;
}
}
}
- 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
= 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);