From 41d041d67127783bcb817154c71354e26dbef6d0 Mon Sep 17 00:00:00 2001 From: Mark Kettenis Date: Sun, 28 Sep 2003 13:35:44 +0000 Subject: [PATCH] * 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. --- gdb/ChangeLog | 29 +++++++++++++++++++++++++++++ gdb/amd64fbsd-nat.c | 4 ++-- gdb/go32-nat.c | 4 ++-- gdb/i386-interix-nat.c | 2 +- gdb/i386-linux-nat.c | 4 ++-- gdb/i386-nto-tdep.c | 4 ++-- gdb/i386bsd-nat.c | 8 ++++---- gdb/i386gnu-nat.c | 4 ++-- gdb/i386nbsd-tdep.c | 6 +++--- gdb/i386obsd-tdep.c | 2 +- gdb/i386v4-nat.c | 2 +- gdb/i387-tdep.c | 18 ++++++++---------- gdb/i387-tdep.h | 17 ++++++++++------- gdb/x86-64-linux-nat.c | 2 +- gdb/x86-64-linux-tdep.c | 2 +- gdb/x86-64-tdep.c | 20 +++++++++++++++----- gdb/x86-64-tdep.h | 5 +++-- 17 files changed, 87 insertions(+), 46 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index c0e544aaf66..540f279bd3d 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,32 @@ +2003-09-28 Mark Kettenis + + * 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. + 2003-09-27 Mark Kettenis * i386-tdep.h: Put opaque declarations in alphabetical diff --git a/gdb/amd64fbsd-nat.c b/gdb/amd64fbsd-nat.c index ed2d39bb742..9317108f7fe 100644 --- a/gdb/amd64fbsd-nat.c +++ b/gdb/amd64fbsd-nat.c @@ -129,7 +129,7 @@ fill_gregset (gregset_t *gregsetp, int regnum) 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); } } diff --git a/gdb/go32-nat.c b/gdb/go32-nat.c index 998927987b3..fc4df5d65f4 100644 --- a/gdb/go32-nat.c +++ b/gdb/go32-nat.c @@ -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); } } diff --git a/gdb/i386-interix-nat.c b/gdb/i386-interix-nat.c index 10e4d91c94c..91b9be29319 100644 --- a/gdb/i386-interix-nat.c +++ b/gdb/i386-interix-nat.c @@ -80,7 +80,7 @@ fill_gregset (gregset_t *gregsetp, int regno) 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 *) diff --git a/gdb/i386-linux-nat.c b/gdb/i386-linux-nat.c index e7a85fa70c7..b766eacea09 100644 --- a/gdb/i386-linux-nat.c +++ b/gdb/i386-linux-nat.c @@ -320,7 +320,7 @@ static void store_regs (int tid, int regno) {} 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 regno) {} 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 diff --git a/gdb/i386-nto-tdep.c b/gdb/i386-nto-tdep.c index 2a912a1a6d1..a80c7a47f98 100644 --- a/gdb/i386-nto-tdep.c +++ b/gdb/i386-nto-tdep.c @@ -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 diff --git a/gdb/i386bsd-nat.c b/gdb/i386bsd-nat.c index d81dc66005c..9383a1d5fea 100644 --- a/gdb/i386bsd-nat.c +++ b/gdb/i386bsd-nat.c @@ -157,7 +157,7 @@ fill_gregset (gregset_t *gregsetp, int regno) 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 } } diff --git a/gdb/i386gnu-nat.c b/gdb/i386gnu-nat.c index 3a6c7978162..dd9e32481dc 100644 --- a/gdb/i386gnu-nat.c +++ b/gdb/i386gnu-nat.c @@ -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 diff --git a/gdb/i386nbsd-tdep.c b/gdb/i386nbsd-tdep.c index 9e8d973d831..dae0a1d5e20 100644 --- a/gdb/i386nbsd-tdep.c +++ b/gdb/i386nbsd-tdep.c @@ -89,7 +89,7 @@ fetch_core_registers (char *core_reg_sect, unsigned core_reg_size, int which, 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_sect, unsigned core_reg_size, 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_sect, unsigned core_reg_size, 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: diff --git a/gdb/i386obsd-tdep.c b/gdb/i386obsd-tdep.c index 8cfaa244407..a7e944150df 100644 --- a/gdb/i386obsd-tdep.c +++ b/gdb/i386obsd-tdep.c @@ -66,7 +66,7 @@ fetch_core_registers (char *core_reg_sect, unsigned core_reg_size, int which, 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 = diff --git a/gdb/i386v4-nat.c b/gdb/i386v4-nat.c index c680dac6b52..188f01b4c12 100644 --- a/gdb/i386v4-nat.c +++ b/gdb/i386v4-nat.c @@ -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 diff --git a/gdb/i387-tdep.c b/gdb/i387-tdep.c index 63943e7b2d7..ff369f982fe 100644 --- a/gdb/i387-tdep.c +++ b/gdb/i387-tdep.c @@ -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; diff --git a/gdb/i387-tdep.h b/gdb/i387-tdep.h index 41e695b30db..377e17ac7b3 100644 --- a/gdb/i387-tdep.h +++ b/gdb/i387-tdep.h @@ -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 (struct frame_info *frame, int regnum, #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 void *fsave, int regnum); 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 diff --git a/gdb/x86-64-linux-nat.c b/gdb/x86-64-linux-nat.c index a21ac1373ff..4ed859bc727 100644 --- a/gdb/x86-64-linux-nat.c +++ b/gdb/x86-64-linux-nat.c @@ -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 diff --git a/gdb/x86-64-linux-tdep.c b/gdb/x86-64-linux-tdep.c index 2c499530115..b45ba02d02e 100644 --- a/gdb/x86-64-linux-tdep.c +++ b/gdb/x86-64-linux-tdep.c @@ -123,7 +123,7 @@ fetch_core_registers (char *core_reg_sect, unsigned core_reg_size, 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: diff --git a/gdb/x86-64-tdep.c b/gdb/x86-64-tdep.c index 13fc5d2f822..39a02b05ed3 100644 --- a/gdb/x86-64-tdep.c +++ b/gdb/x86-64-tdep.c @@ -1289,22 +1289,32 @@ x86_64_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) 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); } } diff --git a/gdb/x86-64-tdep.h b/gdb/x86-64-tdep.h index 76bb3d32564..9163405d2cf 100644 --- a/gdb/x86-64-tdep.h +++ b/gdb/x86-64-tdep.h @@ -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 -- 2.30.2