[binutils-gdb] gdb/mips: replace bfd_map_over_sections with gdb_bfd_sections (1)

Simon Marchi simark@sourceware.org
Fri Jan 16 20:46:55 GMT 2026


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=6c7c9ad764abeb86807df13f33a2d31778a7b74f

commit 6c7c9ad764abeb86807df13f33a2d31778a7b74f
Author: Simon Marchi <simon.marchi@polymtl.ca>
Date:   Fri Jan 16 13:35:53 2026 -0500

    gdb/mips: replace bfd_map_over_sections with gdb_bfd_sections (1)
    
    Replace bfd_map_over_sections with iteration over gdb_bfd_sections.
    
    Change-Id: Ib236b364dc81f43cab8d27271d413eb61d6c703e
    Approved-By: Tom Tromey <tom@tromey.com>

Diff:
---
 gdb/mips-tdep.c | 47 ++++++++++++++++++++++++-----------------------
 1 file changed, 24 insertions(+), 23 deletions(-)

diff --git a/gdb/mips-tdep.c b/gdb/mips-tdep.c
index a3046029919..c2913c87c0e 100644
--- a/gdb/mips-tdep.c
+++ b/gdb/mips-tdep.c
@@ -7959,32 +7959,33 @@ mips_virtual_frame_pointer (struct gdbarch *gdbarch,
   *offset = 0;
 }
 
-static void
-mips_find_abi_section (bfd *abfd, asection *sect, void *obj)
+static enum mips_abi
+mips_find_abi_from_sections (bfd *abfd)
 {
-  enum mips_abi *abip = (enum mips_abi *) obj;
-  const char *name = bfd_section_name (sect);
+  for (asection *sect : gdb_bfd_sections (abfd))
+    {
+      const char *name = bfd_section_name (sect);
 
-  if (*abip != MIPS_ABI_UNKNOWN)
-    return;
+      if (!startswith (name, ".mdebug."))
+	continue;
 
-  if (!startswith (name, ".mdebug."))
-    return;
+      if (strcmp (name, ".mdebug.abi32") == 0)
+	return MIPS_ABI_O32;
+      else if (strcmp (name, ".mdebug.abiN32") == 0)
+	return MIPS_ABI_N32;
+      else if (strcmp (name, ".mdebug.abi64") == 0)
+	return MIPS_ABI_N64;
+      else if (strcmp (name, ".mdebug.abiO64") == 0)
+	return MIPS_ABI_O64;
+      else if (strcmp (name, ".mdebug.eabi32") == 0)
+	return MIPS_ABI_EABI32;
+      else if (strcmp (name, ".mdebug.eabi64") == 0)
+	return MIPS_ABI_EABI64;
+      else
+	warning (_("unsupported ABI %s."), name + 8);
+    }
 
-  if (strcmp (name, ".mdebug.abi32") == 0)
-    *abip = MIPS_ABI_O32;
-  else if (strcmp (name, ".mdebug.abiN32") == 0)
-    *abip = MIPS_ABI_N32;
-  else if (strcmp (name, ".mdebug.abi64") == 0)
-    *abip = MIPS_ABI_N64;
-  else if (strcmp (name, ".mdebug.abiO64") == 0)
-    *abip = MIPS_ABI_O64;
-  else if (strcmp (name, ".mdebug.eabi32") == 0)
-    *abip = MIPS_ABI_EABI32;
-  else if (strcmp (name, ".mdebug.eabi64") == 0)
-    *abip = MIPS_ABI_EABI64;
-  else
-    warning (_("unsupported ABI %s."), name + 8);
+  return MIPS_ABI_UNKNOWN;
 }
 
 static void
@@ -8109,7 +8110,7 @@ mips_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
 
   /* GCC creates a pseudo-section whose name describes the ABI.  */
   if (found_abi == MIPS_ABI_UNKNOWN && info.abfd != NULL)
-    bfd_map_over_sections (info.abfd, mips_find_abi_section, &found_abi);
+    found_abi = mips_find_abi_from_sections (info.abfd);
 
   /* If we have no useful BFD information, use the ABI from the last
      MIPS architecture (if there is one).  */


More information about the Gdb-cvs mailing list