Use gdb_bfd_sections in get_stap_base_address
authorTom Tromey <tom@tromey.com>
Sat, 19 Sep 2020 17:54:49 +0000 (11:54 -0600)
committerTom Tromey <tom@tromey.com>
Sat, 19 Sep 2020 17:54:50 +0000 (11:54 -0600)
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.

gdb/ChangeLog
gdb/stap-probe.c

index 8b898140a71e2a922bde955821099fdc17893b68..b320735fb5a1db5e21e815b779c3b57290e2e518 100644 (file)
@@ -1,3 +1,8 @@
+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'
index 73596446cce51d94e789b1ff3584b8fec807b5a1..8af3bd7bd8cb4cc350723bd5eda767b82f8fb5a8 100644 (file)
@@ -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)
     {
This page took 0.033798 seconds and 4 git commands to generate.