aboutsummaryrefslogtreecommitdiff
path: root/gdb/ppc-linux-nat.c
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2007-08-30 13:13:59 +0000
committerAlan Modra <amodra@gmail.com>2007-08-30 13:13:59 +0000
commitf2db237aa14bae7e5e7a7c4c85e4c2c84b11a30e (patch)
tree3caf0bfdf627941ab12171b856aa042e9c9ed0be /gdb/ppc-linux-nat.c
parent2db6cde7362caa130c6f9d92a1d50f742d08c3d3 (diff)
downloadfsf-binutils-gdb-f2db237aa14bae7e5e7a7c4c85e4c2c84b11a30e.zip
fsf-binutils-gdb-f2db237aa14bae7e5e7a7c4c85e4c2c84b11a30e.tar.gz
fsf-binutils-gdb-f2db237aa14bae7e5e7a7c4c85e4c2c84b11a30e.tar.bz2
* ppc-linux-nat.c (right_fill_reg): Delete.
(supply_gregset): Use ppc_supply_gregset. (supply_fpregset): Use ppc_supply_fpregset. (fill_gregset): Use ppc_collect_gregset. (fill_fpregset): Use ppc_collect_fpregset. * ppc-linux-tdep.c (PPC_LINUX_PT_*): Don't define. (right_supply_register, ppc_linux_supply_gregset): Delete. (ppc32_linux_supply_gregset, ppc64_linux_supply_gregset): Delete. (ppc_linux_supply_fpregset): Delete. (ppc_linux_collect_gregset): New function. (ppc32_linux_reg_offsets, ppc64_linux_reg_offsets): New. (ppc32_linux_gregset, ppc64_linux_gregset): Update to use reg offsets, ppc_linux_supply_gregset, and ppc_collect_gregset. (ppc_linux_fpregset): Rename to ppc32_linux_fpregset and update. (ppc_linux_gregset, ppc_linux_fpregset): New functions. (ppc_linux_regset_from_core_section): Update. * ppc-tdep.h (ppc_linux_gregset, ppc_linux_fpregset): Declare. (ppc_linux_supply_gregset, ppc_linux_supply_fpregset): Delete. (struct ppc_reg_offsets): Add gpr_size, xr_size, fpscr_size fields. * ppcobsd-tdep.c (ppcobsd_supply_gregset): Delete FIXME and assert. (ppcobsd_collect_gregset): Likewise. (_initialize_ppcnbsd_tdep): Init gpr_size, xr_size, fpscr_size. * ppcnbsd-tdep.c (_initialize_ppcobsd_tdep): Likewise. * ppcobsd-nat.c (_initialize_ppcobsd_nat): Likewise. * rs6000-aix-tdep.c (rs6000_aix32_reg_offsets): Likewise. (rs6000_aix64_reg_offsets): Likewise. (rs6000_aix_supply_regset): Call ppc_supply_fpregset without testing ppc_floating_point_unit_p. (rs6000_aix_collect_regset): Similarly. * rs6000-tdep.c (ppc_supply_reg): Add regsize param. Adjust offset when regsize is larger than regcache register size. (ppc_collect_reg): Similarly zero pad when regsize is larger than regcache register size. (ppc_greg_offset): New function, split out from.. (ppc_supply_gregset): ..here. Separate code handling all regs from single reg case. Correct xer offset. (ppc_fpreg_offset): New function, split out from.. (ppc_supply_fpregset): ..here. Separate code handling all regs from single reg case. (ppc_collect_gregset, ppc_collect_fpregset): Likewise. (ppc_supply_fpregset, ppc_collect_fpregset): Don't assert we have a fp unit, instead return if no fp.
Diffstat (limited to 'gdb/ppc-linux-nat.c')
-rw-r--r--gdb/ppc-linux-nat.c93
1 files changed, 20 insertions, 73 deletions
diff --git a/gdb/ppc-linux-nat.c b/gdb/ppc-linux-nat.c
index 60cffc3..f0b2abb 100644
--- a/gdb/ppc-linux-nat.c
+++ b/gdb/ppc-linux-nat.c
@@ -901,101 +901,48 @@ ppc_linux_store_inferior_registers (struct regcache *regcache, int regno)
store_ppc_registers (regcache, tid);
}
+/* Functions for transferring registers between a gregset_t or fpregset_t
+ (see sys/ucontext.h) and gdb's regcache. The word size is that used
+ by the ptrace interface, not the current program's ABI. eg. If a
+ powerpc64-linux gdb is being used to debug a powerpc32-linux app, we
+ read or write 64-bit gregsets. This is to suit the host libthread_db. */
+
void
supply_gregset (struct regcache *regcache, const gdb_gregset_t *gregsetp)
{
- /* NOTE: cagney/2003-11-25: This is the word size used by the ptrace
- interface, and not the wordsize of the program's ABI. */
- int wordsize = sizeof (long);
- ppc_linux_supply_gregset (regcache, -1, gregsetp,
- sizeof (gdb_gregset_t), wordsize);
-}
+ const struct regset *regset = ppc_linux_gregset (sizeof (long));
-static void
-right_fill_reg (const struct regcache *regcache, int regnum, void *reg)
-{
- /* NOTE: cagney/2003-11-25: This is the word size used by the ptrace
- interface, and not the wordsize of the program's ABI. */
- int wordsize = sizeof (long);
- /* Right fill the register. */
- regcache_raw_collect (regcache, regnum,
- ((bfd_byte *) reg
- + wordsize
- - register_size (current_gdbarch, regnum)));
+ ppc_supply_gregset (regset, regcache, -1, gregsetp, sizeof (*gregsetp));
}
void
fill_gregset (const struct regcache *regcache,
gdb_gregset_t *gregsetp, int regno)
{
- int regi;
- elf_greg_t *regp = (elf_greg_t *) gregsetp;
- struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);
- const int elf_ngreg = 48;
+ const struct regset *regset = ppc_linux_gregset (sizeof (long));
-
- /* Start with zeros. */
- memset (regp, 0, elf_ngreg * sizeof (*regp));
-
- for (regi = 0; regi < ppc_num_gprs; regi++)
- {
- if ((regno == -1) || regno == tdep->ppc_gp0_regnum + regi)
- right_fill_reg (regcache, tdep->ppc_gp0_regnum + regi,
- (regp + PT_R0 + regi));
- }
-
- if ((regno == -1) || regno == gdbarch_pc_regnum (current_gdbarch))
- right_fill_reg (regcache, gdbarch_pc_regnum (current_gdbarch),
- regp + PT_NIP);
- if ((regno == -1) || regno == tdep->ppc_lr_regnum)
- right_fill_reg (regcache, tdep->ppc_lr_regnum, regp + PT_LNK);
- if ((regno == -1) || regno == tdep->ppc_cr_regnum)
- regcache_raw_collect (regcache, tdep->ppc_cr_regnum,
- regp + PT_CCR);
- if ((regno == -1) || regno == tdep->ppc_xer_regnum)
- regcache_raw_collect (regcache, tdep->ppc_xer_regnum,
- regp + PT_XER);
- if ((regno == -1) || regno == tdep->ppc_ctr_regnum)
- right_fill_reg (regcache, tdep->ppc_ctr_regnum, regp + PT_CTR);
-#ifdef PT_MQ
- if (((regno == -1) || regno == tdep->ppc_mq_regnum)
- && (tdep->ppc_mq_regnum != -1))
- right_fill_reg (regcache, tdep->ppc_mq_regnum, regp + PT_MQ);
-#endif
- if ((regno == -1) || regno == tdep->ppc_ps_regnum)
- right_fill_reg (regcache, tdep->ppc_ps_regnum, regp + PT_MSR);
+ if (regno == -1)
+ memset (gregsetp, 0, sizeof (*gregsetp));
+ ppc_collect_gregset (regset, regcache, regno, gregsetp, sizeof (*gregsetp));
}
void
supply_fpregset (struct regcache *regcache, const gdb_fpregset_t * fpregsetp)
{
- ppc_linux_supply_fpregset (NULL, regcache, -1, fpregsetp,
- sizeof (gdb_fpregset_t));
+ const struct regset *regset = ppc_linux_fpregset ();
+
+ ppc_supply_fpregset (regset, regcache, -1,
+ fpregsetp, sizeof (*fpregsetp));
}
-/* Given a pointer to a floating point register set in /proc format
- (fpregset_t *), update the register specified by REGNO from gdb's
- idea of the current floating point register set. If REGNO is -1,
- update them all. */
void
fill_fpregset (const struct regcache *regcache,
gdb_fpregset_t *fpregsetp, int regno)
{
- int regi;
- struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);
- bfd_byte *fpp = (void *) fpregsetp;
-
- if (ppc_floating_point_unit_p (current_gdbarch))
- {
- for (regi = 0; regi < ppc_num_fprs; regi++)
- {
- if ((regno == -1) || (regno == tdep->ppc_fp0_regnum + regi))
- regcache_raw_collect (regcache, tdep->ppc_fp0_regnum + regi,
- fpp + 8 * regi);
- }
- if (regno == -1 || regno == tdep->ppc_fpscr_regnum)
- right_fill_reg (regcache, tdep->ppc_fpscr_regnum, (fpp + 8 * 32));
- }
+ const struct regset *regset = ppc_linux_fpregset ();
+
+ ppc_collect_fpregset (regset, regcache, regno,
+ fpregsetp, sizeof (*fpregsetp));
}
void _initialize_ppc_linux_nat (void);