diff options
author | Tom Tromey <tom@tromey.com> | 2020-09-19 11:54:49 -0600 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2020-09-19 11:54:50 -0600 |
commit | 3cabfd268b2d2301a8bfcfa124c162a1d45cfc68 (patch) | |
tree | 4f6665cdd927c8f688ace1d07c4f64768811ee83 | |
parent | 1ce51eb52dca2fcd1ad4120876362ce2a53b3de6 (diff) | |
download | binutils-gdb-3cabfd268b2d2301a8bfcfa124c162a1d45cfc68.tar.gz |
Use gdb_bfd_sections in get_stap_base_address
This changes get_stap_base_address to avoid bfd_map_over_sections, in
favor of iteration.
gdb/ChangeLog
2020-09-19 Tom Tromey <tom@tromey.com>
* stap-probe.c (get_stap_base_address_1): Remove.
(get_stap_base_address): Use foreach.
-rw-r--r-- | gdb/ChangeLog | 5 | ||||
-rw-r--r-- | gdb/stap-probe.c | 18 |
2 files changed, 9 insertions, 14 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 8b898140a71..b320735fb5a 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,10 @@ 2020-09-19 Tom Tromey <tom@tromey.com> + * stap-probe.c (get_stap_base_address_1): Remove. + (get_stap_base_address): Use foreach. + +2020-09-19 Tom Tromey <tom@tromey.com> + * gdb_bfd.c (free_one_bfd_section): Remove 'abfd' and 'ignore' parameters. (gdb_bfd_close_or_warn): Use foreach. diff --git a/gdb/stap-probe.c b/gdb/stap-probe.c index 73596446cce..8af3bd7bd8c 100644 --- a/gdb/stap-probe.c +++ b/gdb/stap-probe.c @@ -1578,19 +1578,6 @@ handle_stap_probe (struct objfile *objfile, struct sdt_note *el, probesp->emplace_back (ret); } -/* Helper function which tries to find the base address of the SystemTap - base section named STAP_BASE_SECTION_NAME. */ - -static void -get_stap_base_address_1 (bfd *abfd, asection *sect, void *obj) -{ - asection **ret = (asection **) obj; - - if ((sect->flags & (SEC_DATA | SEC_ALLOC | SEC_HAS_CONTENTS)) - && sect->name && !strcmp (sect->name, STAP_BASE_SECTION_NAME)) - *ret = sect; -} - /* Helper function which iterates over every section in the BFD file, trying to find the base address of the SystemTap base section. Returns 1 if found (setting BASE to the proper value), zero otherwise. */ @@ -1600,7 +1587,10 @@ get_stap_base_address (bfd *obfd, bfd_vma *base) { asection *ret = NULL; - bfd_map_over_sections (obfd, get_stap_base_address_1, (void *) &ret); + for (asection *sect : gdb_bfd_sections (obfd)) + if ((sect->flags & (SEC_DATA | SEC_ALLOC | SEC_HAS_CONTENTS)) + && sect->name && !strcmp (sect->name, STAP_BASE_SECTION_NAME)) + ret = sect; if (ret == NULL) { |