From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>
Subject: [PATCH 07/13] Use gdb_bfd_sections in dwarf2/read.c
Date: Fri, 28 Aug 2020 10:23:43 -0600 [thread overview]
Message-ID: <20200828162349.987-8-tom@tromey.com> (raw)
In-Reply-To: <20200828162349.987-1-tom@tromey.com>
This changes some functions in dwarf2/read.c to avoid
bfd_map_over_sections, in favor of iteration.
gdb/ChangeLog
2020-08-28 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.
---
gdb/ChangeLog | 9 +++++++++
gdb/dwarf2/read.c | 50 +++++++++++++++++++++++------------------------
2 files changed, 33 insertions(+), 26 deletions(-)
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 0ac8533263a..1da71c48084 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);
@@ -11923,9 +11921,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. */
@@ -12738,9 +12736,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))
@@ -12827,8 +12825,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);
@@ -12857,9 +12856,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;
@@ -13123,9 +13121,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);
@@ -13151,15 +13149,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 ();
--
2.17.2
next prev parent reply other threads:[~2020-08-28 16:23 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-28 16:23 [PATCH 00/13] Use gdb_bfd_sections in more places Tom Tromey
2020-08-28 16:23 ` [PATCH 01/13] Add a new overload of gdb_bfd_sections Tom Tromey
2020-08-28 16:34 ` Simon Marchi
2020-08-28 19:25 ` Tom Tromey
2020-08-28 16:23 ` [PATCH 02/13] Use gdb_bfd_sections in core_target_open Tom Tromey
2020-08-28 16:23 ` [PATCH 03/13] Use gdb_bfd_sections in gdb_bfd_close_or_warn Tom Tromey
2020-08-28 16:23 ` [PATCH 04/13] Use gdb_bfd_sections in get_stap_base_address Tom Tromey
2020-08-28 17:06 ` Simon Marchi
2020-08-28 16:23 ` [PATCH 05/13] Use gdb_bfd_sections in build_objfile_section_table Tom Tromey
2020-08-28 16:23 ` [PATCH 06/13] Use gdb_bfd_sections in symfile.c Tom Tromey
2020-08-28 17:00 ` Simon Marchi
2020-08-28 17:06 ` Simon Marchi
2020-08-28 16:23 ` Tom Tromey [this message]
2020-08-28 16:23 ` [PATCH 08/13] Use gdb_bfd_sections in ELF osabi tag sniffing Tom Tromey
2020-08-28 16:23 ` [PATCH 09/13] Use gdb_bfd_sections in gcore_memory_sections Tom Tromey
2020-08-28 16:23 ` [PATCH 10/13] Use gdb_bfd_sections in restore_command Tom Tromey
2020-08-28 17:12 ` Simon Marchi
2020-08-29 15:47 ` Tom Tromey
2020-08-29 15:49 ` Simon Marchi
2020-08-28 16:23 ` [PATCH 11/13] Use gdb_bfd_sections in elf_symfile_read Tom Tromey
2020-08-28 16:23 ` [PATCH 12/13] Use gdb_bfd_sections in build_section_table Tom Tromey
2020-08-28 16:23 ` [PATCH 13/13] Use gdb_bfd_sections in generic_load Tom Tromey
2020-08-28 17:14 ` [PATCH 00/13] Use gdb_bfd_sections in more places Simon Marchi
2020-08-31 18:19 ` John Baldwin
2020-09-19 18:07 ` Tom Tromey
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200828162349.987-8-tom@tromey.com \
--to=tom@tromey.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox