MIPS: Migrate from 'regset_from_core_section' to 'iterate_over_regset_sections'
authorAndreas Arnez <arnez@linux.vnet.ibm.com>
Fri, 29 Nov 2013 16:49:03 +0000 (16:49 +0000)
committerAndreas Krebbel <krebbel@linux.vnet.ibm.com>
Tue, 30 Sep 2014 07:14:36 +0000 (09:14 +0200)
For MIPS targets, no longer define the gdbarch method
'regset_from_core_section', but the iterator method instead.

gdb/ChangeLog:

* mips-linux-tdep.c (mips_linux_regset_from_core_section): Remove.
(mips_linux_iterate_over_regset_sections): New.
(mips_linux_init_abi): Adjust gdbarch initialization.
* mips64obsd-tdep.c (mips64obsd_regset_from_core_section): Remove.
(mips64obsd_iterate_over_regset_sections): New.
(mips64obsd_init_abi): Adjust.
* mipsnbsd-tdep.c (mipsnbsd_regset_from_core_section): Remove.
(mipsnbsd_iterate_over_regset_sections): New.
(mipsnbsd_init_abi): Adjust.

gdb/ChangeLog
gdb/mips-linux-tdep.c
gdb/mips64obsd-tdep.c
gdb/mipsnbsd-tdep.c

index fa2d4ba1e82f772776f01b74f1d9672f55e2c4cd..aa66018c8eeac7c681fda92b80232588a30809bb 100644 (file)
@@ -1,3 +1,15 @@
+2014-09-30  Andreas Arnez  <arnez@linux.vnet.ibm.com>
+
+       * mips-linux-tdep.c (mips_linux_regset_from_core_section): Remove.
+       (mips_linux_iterate_over_regset_sections): New.
+       (mips_linux_init_abi): Adjust gdbarch initialization.
+       * mips64obsd-tdep.c (mips64obsd_regset_from_core_section): Remove.
+       (mips64obsd_iterate_over_regset_sections): New.
+       (mips64obsd_init_abi): Adjust.
+       * mipsnbsd-tdep.c (mipsnbsd_regset_from_core_section): Remove.
+       (mipsnbsd_iterate_over_regset_sections): New.
+       (mipsnbsd_init_abi): Adjust.
+
 2014-09-30  Andreas Arnez  <arnez@linux.vnet.ibm.com>
 
        * m88k-tdep.c (m88k_regset_from_core_section): Remove.
index 5639870ad0e00db28ca7cf3791736ea1ad6f6f93..c2cec3d2c830bdea9eb7ced09fff7f4966b78aba 100644 (file)
@@ -636,39 +636,26 @@ static const struct regset mips64_linux_fpregset =
     NULL, mips64_supply_fpregset_wrapper, mips64_fill_fpregset_wrapper
   };
 
-static const struct regset *
-mips_linux_regset_from_core_section (struct gdbarch *gdbarch,
-                                    const char *sect_name, size_t sect_size)
+static void
+mips_linux_iterate_over_regset_sections (struct gdbarch *gdbarch,
+                                        iterate_over_regset_sections_cb *cb,
+                                        void *cb_data,
+                                        const struct regcache *regcache)
 {
-  mips_elf_gregset_t gregset;
-  mips_elf_fpregset_t fpregset;
-  mips64_elf_gregset_t gregset64;
-  mips64_elf_fpregset_t fpregset64;
-
-  if (strcmp (sect_name, ".reg") == 0)
+  if (register_size (gdbarch, MIPS_ZERO_REGNUM) == 4)
     {
-      if (sect_size == sizeof (gregset))
-       return &mips_linux_gregset;
-      else if (sect_size == sizeof (gregset64))
-       return &mips64_linux_gregset;
-      else
-       {
-         warning (_("wrong size gregset struct in core file"));
-       }
+      cb (".reg", sizeof (mips_elf_gregset_t), &mips_linux_gregset,
+         NULL, cb_data);
+      cb (".reg2", sizeof (mips_elf_fpregset_t), &mips_linux_fpregset,
+         NULL, cb_data);
     }
-  else if (strcmp (sect_name, ".reg2") == 0)
+  else
     {
-      if (sect_size == sizeof (fpregset))
-       return &mips_linux_fpregset;
-      else if (sect_size == sizeof (fpregset64))
-       return &mips64_linux_fpregset;
-      else
-       {
-         warning (_("wrong size fpregset struct in core file"));
-       }
+      cb (".reg", sizeof (mips64_elf_gregset_t), &mips64_linux_gregset,
+         NULL, cb_data);
+      cb (".reg2", sizeof (mips64_elf_fpregset_t), &mips64_linux_fpregset,
+         NULL, cb_data);
     }
-
-  return NULL;
 }
 
 static const struct target_desc *
@@ -1628,8 +1615,8 @@ mips_linux_init_abi (struct gdbarch_info info,
   set_gdbarch_core_read_description (gdbarch,
                                     mips_linux_core_read_description);
 
-  set_gdbarch_regset_from_core_section (gdbarch,
-                                       mips_linux_regset_from_core_section);
+  set_gdbarch_iterate_over_regset_sections
+    (gdbarch, mips_linux_iterate_over_regset_sections);
 
   set_gdbarch_gdb_signal_from_target (gdbarch,
                                      mips_gdb_signal_from_target);
index e312e51ce087fd8c55d2204d709297cc1329ba62..11ff3579eb69f86411d076d89f76051a2ffc5791 100644 (file)
@@ -64,17 +64,15 @@ static const struct regset mips64obsd_gregset =
   mips64obsd_supply_gregset
 };
 
-/* Return the appropriate register set for the core section identified
-   by SECT_NAME and SECT_SIZE.  */
+/* Iterate over core file register note sections.  */
 
-static const struct regset *
-mips64obsd_regset_from_core_section (struct gdbarch *gdbarch,
-                                    const char *sect_name, size_t sect_size)
+static void
+mips64obsd_iterate_over_regset_sections (struct gdbarch *gdbarch,
+                                        iterate_over_regset_sections_cb *cb,
+                                        void *cb_data,
+                                        const struct regcache *regcache)
 {
-  if (strcmp (sect_name, ".reg") == 0 && sect_size >= MIPS64OBSD_NUM_REGS * 8)
-    return &mips64obsd_gregset;
-
-  return NULL;
+  cb (".reg", MIPS64OBSD_NUM_REGS * 8, &mips64obsd_gregset, NULL, cb_data);
 }
 \f
 
@@ -145,8 +143,8 @@ mips64obsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
   /* OpenBSD/mips64 only supports the n64 ABI, but the braindamaged
      way GDB works, forces us to pretend we can handle them all.  */
 
-  set_gdbarch_regset_from_core_section
-    (gdbarch, mips64obsd_regset_from_core_section);
+  set_gdbarch_iterate_over_regset_sections
+    (gdbarch, mips64obsd_iterate_over_regset_sections);
 
   tramp_frame_prepend_unwinder (gdbarch, &mips64obsd_sigframe);
 
index f8aa2107662c410575f52e47fd3550c06f3b2191..926e7d97160caa5268f17351aa20f6cb0badde60 100644 (file)
@@ -112,24 +112,20 @@ static const struct regset mipsnbsd_fpregset =
   mipsnbsd_supply_fpregset
 };
 
-/* Return the appropriate register set for the core section identified
-   by SECT_NAME and SECT_SIZE.  */
+/* Iterate over core file register note sections.  */
 
-static const struct regset *
-mipsnbsd_regset_from_core_section (struct gdbarch *gdbarch,
-                                  const char *sect_name, size_t sect_size)
+static void
+mipsnbsd_iterate_over_regset_sections (struct gdbarch *gdbarch,
+                                      iterate_over_regset_sections_cb *cb,
+                                      void *cb_data,
+                                      const struct regcache *regcache)
 {
   size_t regsize = mips_isa_regsize (gdbarch);
-  
-  if (strcmp (sect_name, ".reg") == 0
-      && sect_size >= MIPSNBSD_NUM_GREGS * regsize)
-    return &mipsnbsd_gregset;
-
-  if (strcmp (sect_name, ".reg2") == 0
-      && sect_size >= MIPSNBSD_NUM_FPREGS * regsize)
-    return &mipsnbsd_fpregset;
 
-  return NULL;
+  cb (".reg", MIPSNBSD_NUM_GREGS * regsize, &mipsnbsd_gregset,
+      NULL, cb_data);
+  cb (".reg2", MIPSNBSD_NUM_FPREGS * regsize, &mipsnbsd_fpregset,
+      NULL, cb_data);
 }
 \f
 
@@ -358,8 +354,8 @@ static void
 mipsnbsd_init_abi (struct gdbarch_info info,
                    struct gdbarch *gdbarch)
 {
-  set_gdbarch_regset_from_core_section
-    (gdbarch, mipsnbsd_regset_from_core_section);
+  set_gdbarch_iterate_over_regset_sections
+    (gdbarch, mipsnbsd_iterate_over_regset_sections);
 
   set_gdbarch_get_longjmp_target (gdbarch, mipsnbsd_get_longjmp_target);