[rfc] [13/14] Push REGCACHE into core_read_registers

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[rfc] [13/14] Push REGCACHE into core_read_registers

Ulrich Weigand
Hello,

now we can push REGCACHE into the core_fns core_read_registers callback.

Bye,
Ulrich



ChangeLog:

        * gdbcore.h (struct regcache): Add forward declaration.
        (struct core_fns): Add REGCACHE argument to core_read_registers
        callback.
        * corelow.c (get_core_register_section): Add REGCACHE argument,
        use it instead of current_regcache, pass it to core_read_registers
        callback.
        (get_core_registers): Add current_regcache as parameter to
        get_core_register_section calls.

        * alpha-nat.c (fetch_osf_core_registers): Add REGCACHE argument,
        use it instead of current_regcache.
        * armnbsd-nat.c (fetch_core_registers): Likewise.
        (fetch_elfcore_registers): Likewise.
        * core-regset.c (fetch_core_registers): Likewise.
        * cris-tdep.c (fetch_core_registers): Likewise.
        * irix5-nat.c (fetch_core_registers): Likewise.
        * m68klinux-nat.c (fetch_core_registers): Likewise.
        * mips-linux-tdep.c (fetch_core_registers): Likewise.
        * win32-nat.c (fetch_elf_core_registers): Likewise.


diff -urNp gdb-orig/gdb/alpha-nat.c gdb-head/gdb/alpha-nat.c
--- gdb-orig/gdb/alpha-nat.c 2007-05-01 00:18:00.351731460 +0200
+++ gdb-head/gdb/alpha-nat.c 2007-05-01 00:18:08.451777805 +0200
@@ -47,7 +47,8 @@
  */
 
 static void
-fetch_osf_core_registers (char *core_reg_sect, unsigned core_reg_size,
+fetch_osf_core_registers (struct regcache *regcache,
+  char *core_reg_sect, unsigned core_reg_size,
   int which, CORE_ADDR reg_addr)
 {
   int regno;
@@ -90,7 +91,7 @@ fetch_osf_core_registers (char *core_reg
     {
       if (CANNOT_FETCH_REGISTER (regno))
  {
-  regcache_raw_supply (current_regcache, regno, NULL);
+  regcache_raw_supply (regcache, regno, NULL);
   continue;
  }
       addr = 8 * core_reg_mapping[regno];
@@ -99,7 +100,7 @@ fetch_osf_core_registers (char *core_reg
   /* ??? UNIQUE is a new addition.  Don't generate an error.  */
   if (regno == ALPHA_UNIQUE_REGNUM)
     {
-      regcache_raw_supply (current_regcache, regno, NULL);
+      regcache_raw_supply (regcache, regno, NULL);
       continue;
     }
   if (bad_reg < 0)
@@ -107,7 +108,7 @@ fetch_osf_core_registers (char *core_reg
  }
       else
  {
-  regcache_raw_supply (current_regcache, regno, core_reg_sect + addr);
+  regcache_raw_supply (regcache, regno, core_reg_sect + addr);
  }
     }
   if (bad_reg >= 0)
diff -urNp gdb-orig/gdb/armnbsd-nat.c gdb-head/gdb/armnbsd-nat.c
--- gdb-orig/gdb/armnbsd-nat.c 2007-05-01 00:10:30.226316537 +0200
+++ gdb-head/gdb/armnbsd-nat.c 2007-05-01 00:18:08.456777095 +0200
@@ -414,19 +414,21 @@ struct md_core
 };
 
 static void
-fetch_core_registers (char *core_reg_sect, unsigned core_reg_size,
+fetch_core_registers (struct regcache *regcache,
+      char *core_reg_sect, unsigned core_reg_size,
       int which, CORE_ADDR ignore)
 {
   struct md_core *core_reg = (struct md_core *) core_reg_sect;
   int regno;
   CORE_ADDR r_pc;
 
-  arm_supply_gregset (current_regcache, &core_reg->intreg);
-  arm_supply_fparegset (current_regcache, &core_reg->freg);
+  arm_supply_gregset (regcache, &core_reg->intreg);
+  arm_supply_fparegset (regcache, &core_reg->freg);
 }
 
 static void
-fetch_elfcore_registers (char *core_reg_sect, unsigned core_reg_size,
+fetch_elfcore_registers (struct regcache *regcache,
+ char *core_reg_sect, unsigned core_reg_size,
  int which, CORE_ADDR ignore)
 {
   struct reg gregset;
@@ -442,7 +444,7 @@ fetch_elfcore_registers (char *core_reg_
   /* The memcpy may be unnecessary, but we can't really be sure
      of the alignment of the data in the core file.  */
   memcpy (&gregset, core_reg_sect, sizeof (gregset));
-  arm_supply_gregset (current_regcache, &gregset);
+  arm_supply_gregset (regcache, &gregset);
  }
       break;
 
@@ -454,7 +456,7 @@ fetch_elfcore_registers (char *core_reg_
   /* The memcpy may be unnecessary, but we can't really be sure
      of the alignment of the data in the core file.  */
   memcpy (&fparegset, core_reg_sect, sizeof (fparegset));
-  arm_supply_fparegset (current_regcache, &fparegset);
+  arm_supply_fparegset (regcache, &fparegset);
  }
       break;
 
diff -urNp gdb-orig/gdb/corelow.c gdb-head/gdb/corelow.c
--- gdb-orig/gdb/corelow.c 2007-04-30 23:02:41.185235042 +0200
+++ gdb-head/gdb/corelow.c 2007-05-01 00:18:08.461776385 +0200
@@ -417,7 +417,8 @@ core_detach (char *args, int from_tty)
    have a section by the appropriate name.  Otherwise, just do nothing.  */
 
 static void
-get_core_register_section (char *name,
+get_core_register_section (struct regcache *regcache,
+   char *name,
    int which,
    char *human_name,
    int required)
@@ -464,12 +465,12 @@ get_core_register_section (char *name,
   return;
  }
 
-      regset->supply_regset (regset, current_regcache, -1, contents, size);
+      regset->supply_regset (regset, regcache, -1, contents, size);
       return;
     }
 
   gdb_assert (core_vec);
-  core_vec->core_read_registers (contents, size, which,
+  core_vec->core_read_registers (regcache, contents, size, which,
  ((CORE_ADDR)
   bfd_section_vma (core_bfd, section)));
 }
@@ -494,9 +495,12 @@ get_core_registers (int regno)
       return;
     }
 
-  get_core_register_section (".reg", 0, "general-purpose", 1);
-  get_core_register_section (".reg2", 2, "floating-point", 0);
-  get_core_register_section (".reg-xfp", 3, "extended floating-point", 0);
+  get_core_register_section (current_regcache,
+     ".reg", 0, "general-purpose", 1);
+  get_core_register_section (current_regcache,
+     ".reg2", 2, "floating-point", 0);
+  get_core_register_section (current_regcache,
+     ".reg-xfp", 3, "extended floating-point", 0);
 
   deprecated_registers_fetched ();
 }
diff -urNp gdb-orig/gdb/core-regset.c gdb-head/gdb/core-regset.c
--- gdb-orig/gdb/core-regset.c 2007-05-01 00:18:00.365729473 +0200
+++ gdb-head/gdb/core-regset.c 2007-05-01 00:18:08.466775676 +0200
@@ -60,7 +60,8 @@
    REG_ADDR is ignored.  */
 
 static void
-fetch_core_registers (char *core_reg_sect, unsigned core_reg_size, int which,
+fetch_core_registers (struct regcache *regcache,
+      char *core_reg_sect, unsigned core_reg_size, int which,
       CORE_ADDR reg_addr)
 {
   gdb_gregset_t gregset;
@@ -74,7 +75,7 @@ fetch_core_registers (char *core_reg_sec
       else
  {
   memcpy (&gregset, core_reg_sect, sizeof (gregset));
-  supply_gregset (current_regcache, (const gdb_gregset_t *) &gregset);
+  supply_gregset (regcache, (const gdb_gregset_t *) &gregset);
  }
       break;
 
@@ -85,7 +86,7 @@ fetch_core_registers (char *core_reg_sec
  {
   memcpy (&fpregset, core_reg_sect, sizeof (fpregset));
   if (FP0_REGNUM >= 0)
-    supply_fpregset (current_regcache, (const gdb_fpregset_t *) &fpregset);
+    supply_fpregset (regcache, (const gdb_fpregset_t *) &fpregset);
  }
       break;
 
diff -urNp gdb-orig/gdb/cris-tdep.c gdb-head/gdb/cris-tdep.c
--- gdb-orig/gdb/cris-tdep.c 2007-05-01 00:10:32.648371491 +0200
+++ gdb-head/gdb/cris-tdep.c 2007-05-01 00:18:08.476774257 +0200
@@ -3887,7 +3887,8 @@ cris_supply_gregset (struct regcache *re
     regsets, until multi-arch core support is ready.  */
 
 static void
-fetch_core_registers (char *core_reg_sect, unsigned core_reg_size,
+fetch_core_registers (struct regcache *regcache,
+      char *core_reg_sect, unsigned core_reg_size,
                       int which, CORE_ADDR reg_addr)
 {
   elf_gregset_t gregset;
@@ -3903,7 +3904,7 @@ fetch_core_registers (char *core_reg_sec
       else
         {
           memcpy (&gregset, core_reg_sect, sizeof (gregset));
-          cris_supply_gregset (current_regcache, &gregset);
+          cris_supply_gregset (regcache, &gregset);
         }
 
     default:
diff -urNp gdb-orig/gdb/gdbcore.h gdb-head/gdb/gdbcore.h
--- gdb-orig/gdb/gdbcore.h 2007-04-30 23:02:41.241227096 +0200
+++ gdb-head/gdb/gdbcore.h 2007-05-01 00:18:08.516768580 +0200
@@ -26,6 +26,7 @@
 #define GDBCORE_H 1
 
 struct type;
+struct regcache;
 
 #include "bfd.h"
 
@@ -168,8 +169,8 @@ struct core_fns
 
     int (*core_sniffer) (struct core_fns *, bfd *);
 
-    /* Extract the register values out of the core file and store them where
-       `read_register' will find them.
+    /* Extract the register values out of the core file and supply them
+       into REGCACHE.
 
        CORE_REG_SECT points to the register values themselves, read into
        memory.
@@ -189,7 +190,8 @@ struct core_fns
        registers in a large upage-plus-stack ".reg" section.  Original upage
        address X is at location core_reg_sect+x+reg_addr. */
 
-    void (*core_read_registers) (char *core_reg_sect,
+    void (*core_read_registers) (struct regcache *regcache,
+ char *core_reg_sect,
  unsigned core_reg_size,
  int which, CORE_ADDR reg_addr);
 
diff -urNp gdb-orig/gdb/irix5-nat.c gdb-head/gdb/irix5-nat.c
--- gdb-orig/gdb/irix5-nat.c 2007-05-01 00:18:00.405723796 +0200
+++ gdb-head/gdb/irix5-nat.c 2007-05-01 00:18:08.531766451 +0200
@@ -40,7 +40,8 @@
 #include "gregset.h"
 #include "mips-tdep.h"
 
-static void fetch_core_registers (char *, unsigned int, int, CORE_ADDR);
+static void fetch_core_registers (struct regcache *, char *,
+  unsigned int, int, CORE_ADDR);
 
 /* Size of elements in jmpbuf */
 
@@ -242,7 +243,8 @@ get_longjmp_target (CORE_ADDR *pc)
    REG_ADDR is also unused.  */
 
 static void
-fetch_core_registers (char *core_reg_sect, unsigned core_reg_size,
+fetch_core_registers (struct regcache *regcache,
+      char *core_reg_sect, unsigned core_reg_size,
       int which, CORE_ADDR reg_addr)
 {
   char *srcp = core_reg_sect;
@@ -259,7 +261,7 @@ fetch_core_registers (char *core_reg_sec
 
   for (regno = 0; regno < NUM_REGS; regno++)
     {
-      regcache_raw_supply (current_regcache, regno, srcp);
+      regcache_raw_supply (regcache, regno, srcp);
       srcp += regsize;
     }
 }
diff -urNp gdb-orig/gdb/m68klinux-nat.c gdb-head/gdb/m68klinux-nat.c
--- gdb-orig/gdb/m68klinux-nat.c 2007-05-01 00:18:00.425720957 +0200
+++ gdb-head/gdb/m68klinux-nat.c 2007-05-01 00:18:08.536765741 +0200
@@ -528,7 +528,8 @@ m68k_linux_store_inferior_registers (int
    REG_ADDR isn't used on GNU/Linux.  */
 
 static void
-fetch_core_registers (char *core_reg_sect, unsigned core_reg_size,
+fetch_core_registers (struct regcache *regcache,
+      char *core_reg_sect, unsigned core_reg_size,
       int which, CORE_ADDR reg_addr)
 {
   elf_gregset_t gregset;
@@ -542,7 +543,7 @@ fetch_core_registers (char *core_reg_sec
       else
  {
   memcpy (&gregset, core_reg_sect, sizeof (gregset));
-  supply_gregset (current_regcache, (const elf_gregset_t *) &gregset);
+  supply_gregset (regcache, (const elf_gregset_t *) &gregset);
  }
       break;
 
@@ -552,7 +553,7 @@ fetch_core_registers (char *core_reg_sec
       else
  {
   memcpy (&fpregset, core_reg_sect, sizeof (fpregset));
-  supply_fpregset (current_regcache, (const elf_fpregset_t *) &fpregset);
+  supply_fpregset (regcache, (const elf_fpregset_t *) &fpregset);
  }
       break;
 
diff -urNp gdb-orig/gdb/mips-linux-tdep.c gdb-head/gdb/mips-linux-tdep.c
--- gdb-orig/gdb/mips-linux-tdep.c 2007-05-01 00:10:38.841422691 +0200
+++ gdb-head/gdb/mips-linux-tdep.c 2007-05-01 00:18:08.542764890 +0200
@@ -472,7 +472,8 @@ mips64_fill_fpregset (const struct regca
     regsets, until multi-arch core support is ready.  */
 
 static void
-fetch_core_registers (char *core_reg_sect, unsigned core_reg_size,
+fetch_core_registers (struct regcache *regcache,
+      char *core_reg_sect, unsigned core_reg_size,
       int which, CORE_ADDR reg_addr)
 {
   mips_elf_gregset_t gregset;
@@ -485,13 +486,13 @@ fetch_core_registers (char *core_reg_sec
       if (core_reg_size == sizeof (gregset))
  {
   memcpy ((char *) &gregset, core_reg_sect, sizeof (gregset));
-  mips_supply_gregset (current_regcache,
+  mips_supply_gregset (regcache,
        (const mips_elf_gregset_t *) &gregset);
  }
       else if (core_reg_size == sizeof (gregset64))
  {
   memcpy ((char *) &gregset64, core_reg_sect, sizeof (gregset64));
-  mips64_supply_gregset (current_regcache,
+  mips64_supply_gregset (regcache,
  (const mips64_elf_gregset_t *) &gregset64);
  }
       else
@@ -504,14 +505,14 @@ fetch_core_registers (char *core_reg_sec
       if (core_reg_size == sizeof (fpregset))
  {
   memcpy ((char *) &fpregset, core_reg_sect, sizeof (fpregset));
-  mips_supply_fpregset (current_regcache,
+  mips_supply_fpregset (regcache,
  (const mips_elf_fpregset_t *) &fpregset);
  }
       else if (core_reg_size == sizeof (fpregset64))
  {
   memcpy ((char *) &fpregset64, core_reg_sect,
   sizeof (fpregset64));
-  mips64_supply_fpregset (current_regcache,
+  mips64_supply_fpregset (regcache,
   (const mips64_elf_fpregset_t *) &fpregset64);
  }
       else
diff -urNp gdb-orig/gdb/win32-nat.c gdb-head/gdb/win32-nat.c
--- gdb-orig/gdb/win32-nat.c 2007-04-30 23:02:41.264223832 +0200
+++ gdb-head/gdb/win32-nat.c 2007-05-01 00:18:08.550763754 +0200
@@ -2244,7 +2244,8 @@ win32_current_sos (void)
 }
 
 static void
-fetch_elf_core_registers (char *core_reg_sect,
+fetch_elf_core_registers (struct regcache *regcache,
+  char *core_reg_sect,
   unsigned core_reg_size,
   int which,
   CORE_ADDR reg_addr)
@@ -2256,7 +2257,7 @@ fetch_elf_core_registers (char *core_reg
       return;
     }
   for (r = 0; r < NUM_REGS; r++)
-    regcache_raw_supply (current_regcache, r, core_reg_sect + mappings[r]);
+    regcache_raw_supply (regcache, r, core_reg_sect + mappings[r]);
 }
 
 static int
--
  Dr. Ulrich Weigand
  GNU Toolchain for Linux on System z and Cell BE
  [hidden email]