This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
[PATCH] Add regcache argument to i387_supply_fsave & friends
- From: Mark Kettenis <kettenis at chello dot nl>
- To: gdb-patches at sources dot redhat dot com
- Date: Sun, 28 Sep 2003 15:35:48 +0200 (CEST)
- Subject: [PATCH] Add regcache argument to i387_supply_fsave & friends
This makes the dependency of these functions on the regcache object
explicit.
Tested on i386-unknown-freebsd4.7, x86-64-unknown-freebsd5.1,
x86-64-pc-linux-gnu native and i386-netbsd cross.
I sincerely hope this doesn't break any of the targets that I cannot test.
Committed,
Mark
Index: ChangeLog
from Mark Kettenis <kettenis@gnu.org>
* i387-tdep.c (i387_supply_fsave, i387_supply_fxsave): Add
regcache argument and reverse the order of the other two
arguments. Remove local regcache variable. Determine
architecture from REGCACHE. Update comments.
* x86-64-tdep.c (x86_64_supply_fxsave): Add regcache argument and
reverse the order of the other two arguments. Remove local
regcache variable. Determine architecture from REGCACHE. Update
comments.
* i387-tdep.h (i387_supply_fsave, i387_supply_fxsave): Adjust
prototypes. Update comments.
* x86-64-tdep.c (x86_64_supply_fxsave): Adjust prototype. Adjust
comment.
* amd64fbsd-nat.c (supply_fpregset, fetch_inferior_registers):
Update.
* go32-nat.c (fetch_register, go32_fetch_registers): Update.
* i386-interix-nat.c (supply_fpregset): Update.
* i386-linux-nat.c (supply_fpregset, supply_fpxregset): Update.
* i386-nto-tdep.c (i386nto_supply_fpregset): Update.
* i386gnu-nat.c (fetch_fpregs, supply_fpregset): Update.
* i386bsd-nat.c (supply_fpregset, fetch_inferior_registers): Update.
* i386nbsd-tdep.c (fetch_core_registers, fetch_elfcore_registers):
Update.
* i386obsd-tdep.c (fetch_core_registers): Update.
* i386v4-nat.c (supply_fpregset): Update.
* x86-64-linux-nat.c (supply_fpregset): Update.
* x86-64-linux-tdep.c (fetch_core_registers): Update.
Index: amd64fbsd-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/amd64fbsd-nat.c,v
retrieving revision 1.6
diff -u -p -r1.6 amd64fbsd-nat.c
--- amd64fbsd-nat.c 15 Sep 2003 20:05:17 -0000 1.6
+++ amd64fbsd-nat.c 28 Sep 2003 13:26:49 -0000
@@ -129,7 +129,7 @@ fill_gregset (gregset_t *gregsetp, int r
void
supply_fpregset (fpregset_t *fpregsetp)
{
- x86_64_supply_fxsave ((const char *) fpregsetp, -1);
+ x86_64_supply_fxsave (current_regcache, -1, fpregsetp);
}
/* Fill register REGNUM (if it is a floating-point register) in
@@ -169,7 +169,7 @@ fetch_inferior_registers (int regnum)
(PTRACE_ARG3_TYPE) &fpregs, 0) == -1)
perror_with_name ("Couldn't get floating point status");
- x86_64_supply_fxsave ((const char *) &fpregs, -1);
+ x86_64_supply_fxsave (current_regcache, -1, &fpregs);
}
}
Index: go32-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/go32-nat.c,v
retrieving revision 1.35
diff -u -p -r1.35 go32-nat.c
--- go32-nat.c 23 Aug 2003 08:56:45 -0000 1.35
+++ go32-nat.c 28 Sep 2003 13:26:50 -0000
@@ -468,7 +468,7 @@ fetch_register (int regno)
if (regno < FP0_REGNUM)
supply_register (regno, (char *) &a_tss + regno_mapping[regno].tss_ofs);
else if (i386_fp_regnum_p (regno) || i386_fpc_regnum_p (regno))
- i387_supply_fsave ((const char *) &npx, regno);
+ i387_supply_fsave (current_regcache, regno, &npx);
else
internal_error (__FILE__, __LINE__,
"Invalid register no. %d in fetch_register.", regno);
@@ -483,7 +483,7 @@ go32_fetch_registers (int regno)
{
for (regno = 0; regno < FP0_REGNUM; regno++)
fetch_register (regno);
- i387_supply_fsave ((const char *) &npx, -1);
+ i387_supply_fsave (current_regcache, -1, &npx);
}
}
Index: i386-interix-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/i386-interix-nat.c,v
retrieving revision 1.2
diff -u -p -r1.2 i386-interix-nat.c
--- i386-interix-nat.c 23 Aug 2003 08:56:45 -0000 1.2
+++ i386-interix-nat.c 28 Sep 2003 13:26:50 -0000
@@ -80,7 +80,7 @@ fill_gregset (gregset_t *gregsetp, int r
void
supply_fpregset (fpregset_t *fpregsetp)
{
- i387_supply_fsave ((const char *) fpregsetp, -1);
+ i387_supply_fsave (current_regcache, -1, fpregsetp);
}
/* Given a pointer to a floating point register set in (fpregset_t *)
Index: i386-linux-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/i386-linux-nat.c,v
retrieving revision 1.51
diff -u -p -r1.51 i386-linux-nat.c
--- i386-linux-nat.c 31 Aug 2003 15:18:58 -0000 1.51
+++ i386-linux-nat.c 28 Sep 2003 13:26:50 -0000
@@ -320,7 +320,7 @@ static void store_regs (int tid, int reg
void
supply_fpregset (elf_fpregset_t *fpregsetp)
{
- i387_supply_fsave ((const char *) fpregsetp, -1);
+ i387_supply_fsave (current_regcache, -1, fpregsetp);
dummy_sse_values ();
}
@@ -385,7 +385,7 @@ static void store_fpregs (int tid, int r
void
supply_fpxregset (elf_fpxregset_t *fpxregsetp)
{
- i387_supply_fxsave ((const char *) fpxregsetp, -1);
+ i387_supply_fxsave (current_regcache, -1, fpxregsetp);
}
/* Fill register REGNO (if it is a floating-point or SSE register) in
Index: i386-nto-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/i386-nto-tdep.c,v
retrieving revision 1.6
diff -u -p -r1.6 i386-nto-tdep.c
--- i386-nto-tdep.c 23 Aug 2003 08:56:45 -0000 1.6
+++ i386-nto-tdep.c 28 Sep 2003 13:26:50 -0000
@@ -87,9 +87,9 @@ static void
i386nto_supply_fpregset (char *fpregs)
{
if (nto_cpuinfo_valid && nto_cpuinfo_flags | X86_CPU_FXSR)
- i387_supply_fxsave (fpregs, -1);
+ i387_supply_fxsave (current_regcache, -1, fpregs);
else
- i387_supply_fsave (fpregs, -1);
+ i387_supply_fsave (current_regcache, -1, fpregs);
}
static void
Index: i386bsd-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/i386bsd-nat.c,v
retrieving revision 1.22
diff -u -p -r1.22 i386bsd-nat.c
--- i386bsd-nat.c 23 Aug 2003 08:56:45 -0000 1.22
+++ i386bsd-nat.c 28 Sep 2003 13:26:50 -0000
@@ -157,7 +157,7 @@ fill_gregset (gregset_t *gregsetp, int r
void
supply_fpregset (fpregset_t *fpregsetp)
{
- i387_supply_fsave ((const char *) fpregsetp, -1);
+ i387_supply_fsave (current_regcache, -1, fpregsetp);
}
/* Fill register REGNO (if it is a floating-point register) in
@@ -200,7 +200,7 @@ fetch_inferior_registers (int regno)
(PTRACE_ARG3_TYPE) xmmregs, 0) == 0)
{
have_ptrace_xmmregs = 1;
- i387_supply_fxsave (xmmregs, -1);
+ i387_supply_fxsave (current_regcache, -1, xmmregs);
}
else
{
@@ -208,14 +208,14 @@ fetch_inferior_registers (int regno)
(PTRACE_ARG3_TYPE) &fpregs, 0) == -1)
perror_with_name ("Couldn't get floating point status");
- i387_supply_fsave ((const char *) &fpregs, -1);
+ i387_supply_fsave (current_regcache, -1, &fpregs);
}
#else
if (ptrace (PT_GETFPREGS, PIDGET (inferior_ptid),
(PTRACE_ARG3_TYPE) &fpregs, 0) == -1)
perror_with_name ("Couldn't get floating point status");
- i387_supply_fsave ((const char *) &fpregs, -1);
+ i387_supply_fsave (current_regcache, -1, &fpregs);
#endif
}
}
Index: i386gnu-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/i386gnu-nat.c,v
retrieving revision 1.15
diff -u -p -r1.15 i386gnu-nat.c
--- i386gnu-nat.c 17 Sep 2003 14:24:30 -0000 1.15
+++ i386gnu-nat.c 28 Sep 2003 13:26:51 -0000
@@ -89,7 +89,7 @@ fetch_fpregs (struct proc *thread)
}
/* Supply the floating-point registers. */
- i387_supply_fsave (state.hw_state, -1);
+ i387_supply_fsave (current_regcache, -1, state.hw_state);
}
#ifdef HAVE_SYS_PROCFS_H
@@ -106,7 +106,7 @@ supply_gregset (gdb_gregset_t *gregs)
void
supply_fpregset (gdb_fpregset_t *fpregs)
{
- i387_supply_fsave ((const char *) fpregs, -1);
+ i387_supply_fsave (current_regcache, -1, fpregs);
}
#endif
Index: i386nbsd-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/i386nbsd-tdep.c,v
retrieving revision 1.15
diff -u -p -r1.15 i386nbsd-tdep.c
--- i386nbsd-tdep.c 23 Aug 2003 08:56:45 -0000 1.15
+++ i386nbsd-tdep.c 28 Sep 2003 13:26:51 -0000
@@ -89,7 +89,7 @@ fetch_core_registers (char *core_reg_sec
i386nbsd_supply_reg (regs, -1);
/* Floating point registers. */
- i387_supply_fsave (fsave, -1);
+ i387_supply_fsave (current_regcache, -1, fsave);
}
static void
@@ -109,7 +109,7 @@ fetch_elfcore_registers (char *core_reg_
if (core_reg_size != 108)
warning ("Wrong size FP register set in core file.");
else
- i387_supply_fsave (core_reg_sect, -1);
+ i387_supply_fsave (current_regcache, -1, core_reg_sect);
break;
case 3: /* "Extended" floating point registers. This is gdb-speak
@@ -117,7 +117,7 @@ fetch_elfcore_registers (char *core_reg_
if (core_reg_size != 512)
warning ("Wrong size XMM register set in core file.");
else
- i387_supply_fxsave (core_reg_sect, -1);
+ i387_supply_fxsave (current_regcache, -1, core_reg_sect);
break;
default:
Index: i386obsd-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/i386obsd-tdep.c,v
retrieving revision 1.5
diff -u -p -r1.5 i386obsd-tdep.c
--- i386obsd-tdep.c 23 Aug 2003 08:56:45 -0000 1.5
+++ i386obsd-tdep.c 28 Sep 2003 13:26:51 -0000
@@ -66,7 +66,7 @@ fetch_core_registers (char *core_reg_sec
i386obsd_supply_reg (regs, -1);
/* Floating point registers. */
- i387_supply_fsave (fsave, -1);
+ i387_supply_fsave (current_regcache, -1, fsave);
}
static struct core_fns i386obsd_core_fns =
Index: i386v4-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/i386v4-nat.c,v
retrieving revision 1.12
diff -u -p -r1.12 i386v4-nat.c
--- i386v4-nat.c 23 Aug 2003 08:56:45 -0000 1.12
+++ i386v4-nat.c 28 Sep 2003 13:26:51 -0000
@@ -139,7 +139,7 @@ supply_fpregset (fpregset_t *fpregsetp)
if (FP0_REGNUM == 0)
return;
- i387_supply_fsave ((const char *) fpregsetp, -1);
+ i387_supply_fsave (current_regcache, -1, fpregsetp);
}
/* Fill register REGNO (if it is a floating-point register) in
Index: i387-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/i387-tdep.c,v
retrieving revision 1.36
diff -u -p -r1.36 i387-tdep.c
--- i387-tdep.c 27 Sep 2003 21:57:56 -0000 1.36
+++ i387-tdep.c 28 Sep 2003 13:26:53 -0000
@@ -378,15 +378,14 @@ static int fsave_offset[] =
(fsave + fsave_offset[regnum - I387_ST0_REGNUM])
-/* Fill register REGNUM in GDB's register cache with the appropriate
- value from *FSAVE. This function masks off any of the reserved
- bits in *FSAVE. */
+/* Fill register REGNUM in REGCACHE with the appropriate value from
+ *FSAVE. This function masks off any of the reserved bits in
+ *FSAVE. */
void
-i387_supply_fsave (const void *fsave, int regnum)
+i387_supply_fsave (struct regcache *regcache, int regnum, const void *fsave)
{
- struct regcache *regcache = current_regcache;
- struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);
+ struct gdbarch_tdep *tdep = gdbarch_tdep (get_regcache_arch (regcache));
const char *regs = fsave;
int i;
@@ -524,15 +523,14 @@ static int fxsave_offset[] =
static int i387_tag (const unsigned char *raw);
-/* Fill register REGNUM in GDB's register cache with the appropriate
+/* Fill register REGNUM in REGCACHE with the appropriate
floating-point or SSE register value from *FXSAVE. This function
masks off any of the reserved bits in *FXSAVE. */
void
-i387_supply_fxsave (const void *fxsave, int regnum)
+i387_supply_fxsave (struct regcache *regcache, int regnum, const void *fxsave)
{
- struct regcache *regcache = current_regcache;
- struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);
+ struct gdbarch_tdep *tdep = gdbarch_tdep (get_regcache_arch (regcache));
const char *regs = fxsave;
int i;
Index: i387-tdep.h
===================================================================
RCS file: /cvs/src/src/gdb/i387-tdep.h,v
retrieving revision 1.8
diff -u -p -r1.8 i387-tdep.h
--- i387-tdep.h 27 Sep 2003 21:57:56 -0000 1.8
+++ i387-tdep.h 28 Sep 2003 13:26:53 -0000
@@ -23,9 +23,10 @@
#define I387_TDEP_H
struct gdbarch;
-struct ui_file;
struct frame_info;
+struct regcache;
struct type;
+struct ui_file;
/* Because the number of general-purpose registers is different for
AMD64, the floating-point registers and SSE registers get shifted.
@@ -73,11 +74,12 @@ extern void i387_value_to_register (stru
#define I387_SIZEOF_FSAVE 108
#define I387_SIZEOF_FXSAVE 512
-/* Fill register REGNUM in GDB's register cache with the appropriate
- value from *FSAVE. This function masks off any of the reserved
- bits in *FSAVE. */
+/* Fill register REGNUM in REGCACHE with the appropriate value from
+ *FSAVE. This function masks off any of the reserved bits in
+ *FSAVE. */
-extern void i387_supply_fsave (const void *fsave, int regnum);
+extern void i387_supply_fsave (struct regcache *regcache, int regnum,
+ const void *fsave);
/* Fill register REGNUM (if it is a floating-point register) in *FSAVE
with the value in GDB's register cache. If REGNUM is -1, do this
@@ -86,11 +88,12 @@ extern void i387_supply_fsave (const voi
extern void i387_fill_fsave (void *fsave, int regnum);
-/* Fill register REGNUM in GDB's register cache with the appropriate
+/* Fill register REGNUM in REGCACHE with the appropriate
floating-point or SSE register value from *FXSAVE. This function
masks off any of the reserved bits in *FXSAVE. */
-extern void i387_supply_fxsave (const void *fxsave, int regnum);
+extern void i387_supply_fxsave (struct regcache *regcache, int regnum,
+ const void *fxsave);
/* Fill register REGNUM (if it is a floating-point or SSE register) in
*FXSAVE with the value in GDB's register cache. If REGNUM is -1, do
Index: x86-64-linux-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/x86-64-linux-nat.c,v
retrieving revision 1.29
diff -u -p -r1.29 x86-64-linux-nat.c
--- x86-64-linux-nat.c 31 Aug 2003 15:18:58 -0000 1.29
+++ x86-64-linux-nat.c 28 Sep 2003 13:26:53 -0000
@@ -166,7 +166,7 @@ store_regs (int tid, int regnum)
void
supply_fpregset (elf_fpregset_t *fpregsetp)
{
- x86_64_supply_fxsave ((const char *) fpregsetp, -1);
+ x86_64_supply_fxsave (current_regcache, -1, fpregsetp);
}
/* Fill register REGNUM (if it is a floating-point or SSE register) in
Index: x86-64-linux-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/x86-64-linux-tdep.c,v
retrieving revision 1.22
diff -u -p -r1.22 x86-64-linux-tdep.c
--- x86-64-linux-tdep.c 29 Aug 2003 15:31:10 -0000 1.22
+++ x86-64-linux-tdep.c 28 Sep 2003 13:26:53 -0000
@@ -123,7 +123,7 @@ fetch_core_registers (char *core_reg_sec
if (core_reg_size != 512)
warning ("Wrong size XMM register set in core file.");
else
- x86_64_supply_fxsave (core_reg_sect, -1);
+ x86_64_supply_fxsave (current_regcache, -1, core_reg_sect);
break;
default:
Index: x86-64-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/x86-64-tdep.c,v
retrieving revision 1.93
diff -u -p -r1.93 x86-64-tdep.c
--- x86-64-tdep.c 27 Sep 2003 21:57:56 -0000 1.93
+++ x86-64-tdep.c 28 Sep 2003 13:26:53 -0000
@@ -1289,22 +1289,32 @@ x86_64_init_abi (struct gdbarch_info inf
bits of these pointers (instead of just the 16-bits of the segment
selector). */
-/* Fill register REGNUM in GDB's register cache with the appropriate
+/* The 64-bit FXSAVE format differs from the 32-bit format in the
+ sense that the instruction pointer and data pointer are simply
+ 64-bit offsets into the code segment and the data segment instead
+ of a selector offset pair. The functions below store the upper 32
+ bits of these pointers (instead of just the 16-bits of the segment
+ selector). */
+
+/* Fill register REGNUM in REGCACHE with the appropriate
floating-point or SSE register value from *FXSAVE. If REGNUM is
-1, do this for all registers. This function masks off any of the
reserved bits in *FXSAVE. */
void
-x86_64_supply_fxsave (const char *fxsave, int regnum)
+x86_64_supply_fxsave (struct regcache *regcache, int regnum,
+ const void *fxsave)
{
- i387_supply_fxsave (fxsave, regnum);
+ i387_supply_fxsave (regcache, regnum, fxsave);
if (fxsave)
{
+ const char *regs = fxsave;
+
if (regnum == -1 || regnum == I387_FISEG_REGNUM)
- supply_register (I387_FISEG_REGNUM, fxsave + 12);
+ regcache_raw_supply (regcache, I387_FISEG_REGNUM, regs + 12);
if (regnum == -1 || regnum == I387_FOSEG_REGNUM)
- supply_register (I387_FOSEG_REGNUM, fxsave + 20);
+ regcache_raw_supply (regcache, I387_FOSEG_REGNUM, regs + 20);
}
}
Index: x86-64-tdep.h
===================================================================
RCS file: /cvs/src/src/gdb/x86-64-tdep.h,v
retrieving revision 1.18
diff -u -p -r1.18 x86-64-tdep.h
--- x86-64-tdep.h 23 Aug 2003 13:58:18 -0000 1.18
+++ x86-64-tdep.h 28 Sep 2003 13:26:53 -0000
@@ -48,12 +48,13 @@ struct frame_info;
void x86_64_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch);
-/* Fill register REGNUM in GDB's register cache with the appropriate
+/* Fill register REGNUM in REGCACHE with the appropriate
floating-point or SSE register value from *FXSAVE. If REGNUM is
-1, do this for all registers. This function masks off any of the
reserved bits in *FXSAVE. */
-void x86_64_supply_fxsave (const char *fxsave, int regnum);
+extern void x86_64_supply_fxsave (struct regcache *regcache, int regnum,
+ const void *fxsave);
/* Fill register REGNUM (if it is a floating-point or SSE register) in
*FXSAVE with the value in GDB's register cache. If REGNUM is -1, do