aboutsummaryrefslogtreecommitdiff
path: root/gdb/dwarf2
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2020-09-19 11:54:49 -0600
committerTom Tromey <tom@tromey.com>2020-09-19 11:54:52 -0600
commit5bb6e9dd7090cacb02bbe9f20d8b101a59a3bf99 (patch)
tree44e0b632c75c40eb2baf10641df9635b8bd49af9 /gdb/dwarf2
parentad7277dab9ffa0f388e6e54d5248792a3f122fdc (diff)
downloadgdb-5bb6e9dd7090cacb02bbe9f20d8b101a59a3bf99.zip
gdb-5bb6e9dd7090cacb02bbe9f20d8b101a59a3bf99.tar.gz
gdb-5bb6e9dd7090cacb02bbe9f20d8b101a59a3bf99.tar.bz2
Use gdb_bfd_sections in dwarf2/read.c
This changes some functions in dwarf2/read.c to avoid bfd_map_over_sections, in favor of iteration. gdb/ChangeLog 2020-09-19 Tom Tromey <tom@tromey.com> * dwarf2/read.c (locate_dwz_sections): Change parameters. (dwarf2_get_dwz_file): Use foreach. (dwarf2_locate_dwo_sections): Change parameters. (open_and_init_dwo_file): Use foreach. (dwarf2_locate_common_dwp_sections): Change parameters. (open_and_init_dwp_file): Use foreach.
Diffstat (limited to 'gdb/dwarf2')
-rw-r--r--gdb/dwarf2/read.c50
1 files changed, 24 insertions, 26 deletions
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 8cd1ace..a339141 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -2120,10 +2120,8 @@ dwarf2_get_section_info (struct objfile *objfile,
/* A helper function to find the sections for a .dwz file. */
static void
-locate_dwz_sections (bfd *abfd, asection *sectp, void *arg)
+locate_dwz_sections (bfd *abfd, asection *sectp, dwz_file *dwz_file)
{
- struct dwz_file *dwz_file = (struct dwz_file *) arg;
-
/* Note that we only support the standard ELF names, because .dwz
is ELF-only (at the time of writing). */
if (section_is_p (sectp->name, &dwarf2_elf_names.abbrev))
@@ -2246,8 +2244,8 @@ dwarf2_get_dwz_file (dwarf2_per_bfd *per_bfd)
std::unique_ptr<struct dwz_file> result
(new struct dwz_file (std::move (dwz_bfd)));
- bfd_map_over_sections (result->dwz_bfd.get (), locate_dwz_sections,
- result.get ());
+ for (asection *sec : gdb_bfd_sections (result->dwz_bfd))
+ locate_dwz_sections (result->dwz_bfd.get (), sec, result.get ());
gdb_bfd_record_inclusion (per_bfd->obfd, result->dwz_bfd.get ());
per_bfd->dwz_file = std::move (result);
@@ -11915,9 +11913,9 @@ create_dwp_hash_table (dwarf2_per_objfile *per_objfile,
/* Update SECTIONS with the data from SECTP.
- This function is like the other "locate" section routines that are
- passed to bfd_map_over_sections, but in this context the sections to
- read comes from the DWP V1 hash table, not the full ELF section table.
+ This function is like the other "locate" section routines, but in
+ this context the sections to read comes from the DWP V1 hash table,
+ not the full ELF section table.
The result is non-zero for success, or zero if an error was found. */
@@ -12730,9 +12728,9 @@ open_dwo_file (dwarf2_per_objfile *per_objfile,
size of each of the DWO debugging sections we are interested in. */
static void
-dwarf2_locate_dwo_sections (bfd *abfd, asection *sectp, void *dwo_sections_ptr)
+dwarf2_locate_dwo_sections (bfd *abfd, asection *sectp,
+ dwo_sections *dwo_sections)
{
- struct dwo_sections *dwo_sections = (struct dwo_sections *) dwo_sections_ptr;
const struct dwop_section_names *names = &dwop_section_names;
if (section_is_p (sectp->name, &names->abbrev_dwo))
@@ -12819,8 +12817,9 @@ open_and_init_dwo_file (dwarf2_cu *cu, const char *dwo_name,
dwo_file->comp_dir = comp_dir;
dwo_file->dbfd = std::move (dbfd);
- bfd_map_over_sections (dwo_file->dbfd.get (), dwarf2_locate_dwo_sections,
- &dwo_file->sections);
+ for (asection *sec : gdb_bfd_sections (dwo_file->dbfd))
+ dwarf2_locate_dwo_sections (dwo_file->dbfd.get (), sec,
+ &dwo_file->sections);
create_cus_hash_table (per_objfile, cu, *dwo_file, dwo_file->sections.info,
dwo_file->cus);
@@ -12849,9 +12848,8 @@ open_and_init_dwo_file (dwarf2_cu *cu, const char *dwo_name,
static void
dwarf2_locate_common_dwp_sections (bfd *abfd, asection *sectp,
- void *dwp_file_ptr)
+ dwp_file *dwp_file)
{
- struct dwp_file *dwp_file = (struct dwp_file *) dwp_file_ptr;
const struct dwop_section_names *names = &dwop_section_names;
unsigned int elf_section_nr = elf_section_data (sectp)->this_idx;
@@ -13115,9 +13113,9 @@ open_and_init_dwp_file (dwarf2_per_objfile *per_objfile)
OBSTACK_CALLOC (&per_objfile->per_bfd->obstack,
dwp_file->num_sections, asection *);
- bfd_map_over_sections (dwp_file->dbfd.get (),
- dwarf2_locate_common_dwp_sections,
- dwp_file.get ());
+ for (asection *sec : gdb_bfd_sections (dwp_file->dbfd))
+ dwarf2_locate_common_dwp_sections (dwp_file->dbfd.get (), sec,
+ dwp_file.get ());
dwp_file->cus = create_dwp_hash_table (per_objfile, dwp_file.get (), 0);
@@ -13143,15 +13141,15 @@ open_and_init_dwp_file (dwarf2_per_objfile *per_objfile)
else
dwp_file->version = 2;
- if (dwp_file->version == 2)
- bfd_map_over_sections (dwp_file->dbfd.get (),
- dwarf2_locate_v2_dwp_sections,
- dwp_file.get ());
- else if (dwp_file->version == 5)
- bfd_map_over_sections (dwp_file->dbfd.get (),
- dwarf2_locate_v5_dwp_sections,
- dwp_file.get ());
-
+ for (asection *sec : gdb_bfd_sections (dwp_file->dbfd))
+ {
+ if (dwp_file->version == 2)
+ dwarf2_locate_v2_dwp_sections (dwp_file->dbfd.get (), sec,
+ dwp_file.get ());
+ else
+ dwarf2_locate_v5_dwp_sections (dwp_file->dbfd.get (), sec,
+ dwp_file.get ());
+ }
dwp_file->loaded_cus = allocate_dwp_loaded_cutus_table ();
dwp_file->loaded_tus = allocate_dwp_loaded_cutus_table ();