This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[rfc] [5/8] Eliminate current_gdbarch from *-tdep.c: m68k
- From: "Ulrich Weigand" <uweigand at de dot ibm dot com>
- To: gdb-patches at sourceware dot org
- Date: Wed, 27 Aug 2008 20:03:49 +0200 (CEST)
- Subject: [rfc] [5/8] Eliminate current_gdbarch from *-tdep.c: m68k
Hello,
m68kbsd_fpreg_offset uses current_gdbarch, although the appropriate
per-regcache arch is available to the caller(s). Fixed by passing
it down.
Bye,
Ulrich
ChangeLog:
* m68k-tdep.h (m68kbsd_fpreg_offset): Add gdbarch parameter.
* m68kbsd-tdep.c (m68kbsd_fpreg_offset): Add gdbarch paramter.
Use it instead of current_gdbarch.
(m68kbsd_supply_fpregset): Update call.
* m68kbsd-nat.c (m68kbsd_supply_fpregset): Likewise.
(m68kbsd_collect_fpregset): Likewise.
diff -urNp gdb-orig/gdb/m68kbsd-nat.c gdb-head/gdb/m68kbsd-nat.c
--- gdb-orig/gdb/m68kbsd-nat.c 2008-08-26 00:05:35.000000000 +0200
+++ gdb-head/gdb/m68kbsd-nat.c 2008-08-26 00:06:38.000000000 +0200
@@ -59,12 +59,13 @@ m68kbsd_supply_gregset (struct regcache
static void
m68kbsd_supply_fpregset (struct regcache *regcache, const void *fpregs)
{
+ struct gdbarch *gdbarch = get_regcache_arch (regcache);
const char *regs = fpregs;
int regnum;
for (regnum = M68K_FP0_REGNUM; regnum <= M68K_FPI_REGNUM; regnum++)
regcache_raw_supply (regcache, regnum,
- regs + m68kbsd_fpreg_offset (regnum));
+ regs + m68kbsd_fpreg_offset (gdbarch, regnum));
}
/* Collect the general-purpose registers from REGCACHE and store them
@@ -91,13 +92,15 @@ static void
m68kbsd_collect_fpregset (struct regcache *regcache,
void *fpregs, int regnum)
{
+ struct gdbarch *gdbarch = get_regcache_arch (regcache);
char *regs = fpregs;
int i;
for (i = M68K_FP0_REGNUM; i <= M68K_FPI_REGNUM; i++)
{
if (regnum == -1 || regnum == i)
- regcache_raw_collect (regcache, i, regs + m68kbsd_fpreg_offset (i));
+ regcache_raw_collect (regcache, i,
+ regs + m68kbsd_fpreg_offset (gdbarch, i));
}
}
diff -urNp gdb-orig/gdb/m68kbsd-tdep.c gdb-head/gdb/m68kbsd-tdep.c
--- gdb-orig/gdb/m68kbsd-tdep.c 2008-08-26 00:05:35.000000000 +0200
+++ gdb-head/gdb/m68kbsd-tdep.c 2008-08-26 00:06:38.000000000 +0200
@@ -42,9 +42,9 @@
#define M68KBSD_SIZEOF_FPREGS (((8 * 3) + 3) * 4)
int
-m68kbsd_fpreg_offset (int regnum)
+m68kbsd_fpreg_offset (struct gdbarch *gdbarch, int regnum)
{
- int fp_len = TYPE_LENGTH (gdbarch_register_type (current_gdbarch, regnum));
+ int fp_len = TYPE_LENGTH (gdbarch_register_type (gdbarch, regnum));
if (regnum >= M68K_FPC_REGNUM)
return 8 * fp_len + (regnum - M68K_FPC_REGNUM) * 4;
@@ -61,6 +61,7 @@ m68kbsd_supply_fpregset (const struct re
struct regcache *regcache,
int regnum, const void *fpregs, size_t len)
{
+ struct gdbarch *gdbarch = get_regcache_arch (regcache);
const gdb_byte *regs = fpregs;
int i;
@@ -69,7 +70,8 @@ m68kbsd_supply_fpregset (const struct re
for (i = M68K_FP0_REGNUM; i <= M68K_PC_REGNUM; i++)
{
if (regnum == i || regnum == -1)
- regcache_raw_supply (regcache, i, regs + m68kbsd_fpreg_offset (i));
+ regcache_raw_supply (regcache, i,
+ regs + m68kbsd_fpreg_offset (gdbarch, i));
}
}
diff -urNp gdb-orig/gdb/m68k-tdep.h gdb-head/gdb/m68k-tdep.h
--- gdb-orig/gdb/m68k-tdep.h 2008-08-26 00:05:35.000000000 +0200
+++ gdb-head/gdb/m68k-tdep.h 2008-08-26 00:06:38.000000000 +0200
@@ -100,6 +100,6 @@ extern void m68k_svr4_init_abi (struct g
/* Functions exported from m68kbsd-tdep.c. */
-extern int m68kbsd_fpreg_offset (int regnum);
+extern int m68kbsd_fpreg_offset (struct gdbarch *gdbarch, int regnum);
#endif /* m68k-tdep.h */
--
Dr. Ulrich Weigand
GNU Toolchain for Linux on System z and Cell BE
Ulrich.Weigand@de.ibm.com