diff options
author | Jim Blandy <jimb@codesourcery.com> | 2004-05-10 17:07:02 +0000 |
---|---|---|
committer | Jim Blandy <jimb@codesourcery.com> | 2004-05-10 17:07:02 +0000 |
commit | b50447cc260634f2761777937c5101f9c3a0eee9 (patch) | |
tree | 50ffbb2c453dcf0e9791022ddc6e203a284f2c27 /gdb/rs6000-tdep.c | |
parent | c4ed68c787c9e26ce9e1b0606a7241701d927009 (diff) | |
download | gdb-b50447cc260634f2761777937c5101f9c3a0eee9.tar.gz |
* ppc-tdep.h (struct gdbarch_tdep): Change definition of
ppc_fp0_regnum and ppc_fpscr_regnum: if they are -1, then this
processor variant lacks those registers.
(ppc_floating_point_unit_p): Change description to make it clear
that this returns info about the ISA, not the ABI.
* rs6000-tdep.c (ppc_floating_point_unit_p): Decide whether to
return true or false by checking tdep->ppc_fp0_regnum and
tdep->ppc_fpscr_regnum. The original code replicated the BFD
arch/mach switching done in rs6000_gdbarch_init; it's better to
keep that logic there, and just check the results here.
(rs6000_gdbarch_init): On the E500, set tdep->ppc_fp0_regnum and
tdep->ppc_fpscr_regnum to -1 to indicate that we have no
floating-point registers.
(ppc_supply_fpregset, ppc_collect_fpregset)
(rs6000_push_dummy_call, rs6000_extract_return_value)
(rs6000_store_return_value): Assert that we have floating-point
registers.
(rs6000_dwarf2_stab_reg_to_regnum): Add FIXME.
(rs6000_frame_cache): Don't note the locations at which
floating-point registers were saved if we have no fprs.
* aix-thread.c (supply_fprs, fill_fprs): Assert that we have FP
registers.
(fetch_regs_user_thread, fetch_regs_kernel_thread)
(store_regs_user_thread, store_regs_kernel_thread): Only call
supply_fprs / fill_fprs if we actually have floating-point
registers.
(special_register_p): Check ppc_fpscr_regnum before matching
against it.
(supply_sprs64, supply_sprs32, fill_sprs64, fill_sprs32): Don't
supply / collect fpscr if we don't have it.
* ppc-bdm.c: #include "gdb_assert.h".
(bdm_ppc_fetch_registers, bdm_ppc_store_registers): Assert that we
have floating-point registers, since I can't test this code on
FP-free systems to adapt it.
* ppc-linux-nat.c (ppc_register_u_addr): Don't match against the
fpscr and floating point register numbers if they don't exist.
(fetch_register): Assert that we have floating-point registers
before we reach the code that handles them.
(store_register): Same. And use tdep instead of calling
gdbarch_tdep again.
(fill_fpregset): Don't try to collect FP registers and fpscr if we
don't have them.
(ppc_linux_sigtramp_cache): Don't record the saved locations of
fprs and fpscr if we don't have them.
(ppc_linux_supply_fpregset): Don't supply fp regs and fpscr if we
don't have them.
* ppcnbsd-nat.c: #include "gdb_assert.h".
(getfpregs_supplies): Assert that we have floating-point registers.
* ppcnbsd-tdep.c (ppcnbsd_supply_fpreg, ppcnbsd_fill_fpreg): Same.
* ppcobsd-tdep.c: #include "gdb_assert.h".
(ppcobsd_supply_gregset, ppcobsd_collect_gregset): Assert that we
have floating-point registers.
* rs6000-nat.c (regmap): Don't match against the fpscr and
floating point register numbers if they don't exist.
(fetch_inferior_registers, store_inferior_registers,
fetch_core_registers): Only fetch / store / supply the
floating-point registers and the fpscr if we have them.
* Makefile.in (ppc-bdm.o, ppc-linux-nat.o, ppcnbsd-nat.o)
(ppcobsd-tdep.o): Update dependencies.
Diffstat (limited to 'gdb/rs6000-tdep.c')
-rw-r--r-- | gdb/rs6000-tdep.c | 54 |
1 files changed, 42 insertions, 12 deletions
diff --git a/gdb/rs6000-tdep.c b/gdb/rs6000-tdep.c index 4ce8fa1ae37..5879c2cb64a 100644 --- a/gdb/rs6000-tdep.c +++ b/gdb/rs6000-tdep.c @@ -140,16 +140,16 @@ altivec_register_p (int regno) return (regno >= tdep->ppc_vr0_regnum && regno <= tdep->ppc_vrsave_regnum); } -/* Use the architectures FP registers? */ + +/* Return non-zero if the architecture described by GDBARCH has + floating-point registers (f0 --- f31 and fpscr). */ int ppc_floating_point_unit_p (struct gdbarch *gdbarch) { - const struct bfd_arch_info *info = gdbarch_bfd_arch_info (gdbarch); - if (info->arch == bfd_arch_powerpc) - return (info->mach != bfd_mach_ppc_e500); - if (info->arch == bfd_arch_rs6000) - return 1; - return 0; + struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + + return (tdep->ppc_fp0_regnum >= 0 + && tdep->ppc_fpscr_regnum >= 0); } @@ -226,6 +226,8 @@ ppc_supply_fpregset (const struct regset *regset, struct regcache *regcache, size_t offset; int i; + gdb_assert (ppc_floating_point_unit_p (gdbarch)); + offset = offsets->f0_offset; for (i = tdep->ppc_fp0_regnum; i < tdep->ppc_fp0_regnum + ppc_num_fprs; @@ -301,6 +303,8 @@ ppc_collect_fpregset (const struct regset *regset, size_t offset; int i; + gdb_assert (ppc_floating_point_unit_p (gdbarch)); + offset = offsets->f0_offset; for (i = tdep->ppc_fp0_regnum; i <= tdep->ppc_fp0_regnum + ppc_num_fprs; @@ -1190,6 +1194,11 @@ rs6000_push_dummy_call (struct gdbarch *gdbarch, CORE_ADDR func_addr, CORE_ADDR saved_sp; + /* The calling convention this function implements assumes the + processor has floating-point registers. We shouldn't be using it + on PPC variants that lack them. */ + gdb_assert (ppc_floating_point_unit_p (current_gdbarch)); + /* The first eight words of ther arguments are passed in registers. Copy them appropriately. */ ii = 0; @@ -1416,6 +1425,11 @@ rs6000_extract_return_value (struct type *valtype, char *regbuf, char *valbuf) int offset = 0; struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch); + /* The calling convention this function implements assumes the + processor has floating-point registers. We shouldn't be using it + on PPC variants that lack them. */ + gdb_assert (ppc_floating_point_unit_p (current_gdbarch)); + if (TYPE_CODE (valtype) == TYPE_CODE_FLT) { @@ -1727,6 +1741,9 @@ rs6000_dwarf2_stab_reg_to_regnum (int num) if (0 <= num && num <= 31) return tdep->ppc_gp0_regnum + num; else if (32 <= num && num <= 63) + /* FIXME: jimb/2004-05-05: What should we do when the debug info + specifies registers the architecture doesn't have? Our + callers don't check the value we return. */ return tdep->ppc_fp0_regnum + (num - 32); else if (1200 <= num && num < 1200 + 32) return tdep->ppc_ev0_regnum + (num - 1200); @@ -1765,6 +1782,11 @@ rs6000_store_return_value (struct type *type, char *valbuf) { struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch); + /* The calling convention this function implements assumes the + processor has floating-point registers. We shouldn't be using it + on PPC variants that lack them. */ + gdb_assert (ppc_floating_point_unit_p (current_gdbarch)); + if (TYPE_CODE (type) == TYPE_CODE_FLT) /* Floating point values are returned starting from FPR1 and up. @@ -2445,11 +2467,17 @@ rs6000_frame_cache (struct frame_info *next_frame, void **this_cache) { int i; CORE_ADDR fpr_addr = cache->base + fdata.fpr_offset; - for (i = fdata.saved_fpr; i < 32; i++) - { - cache->saved_regs[tdep->ppc_fp0_regnum + i].addr = fpr_addr; - fpr_addr += 8; - } + + /* If skip_prologue says floating-point registers were saved, + but the current architecture has no floating-point registers, + then that's strange. But we have no indices to even record + the addresses under, so we just ignore it. */ + if (ppc_floating_point_unit_p (gdbarch)) + for (i = fdata.saved_fpr; i < 32; i++) + { + cache->saved_regs[tdep->ppc_fp0_regnum + i].addr = fpr_addr; + fpr_addr += 8; + } } /* if != -1, fdata.saved_gpr is the smallest number of saved_gpr. @@ -2763,6 +2791,8 @@ rs6000_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) tdep->ppc_xer_regnum = 5; tdep->ppc_ev0_regnum = 7; tdep->ppc_ev31_regnum = 38; + tdep->ppc_fp0_regnum = -1; + tdep->ppc_fpscr_regnum = -1; set_gdbarch_pc_regnum (gdbarch, 0); set_gdbarch_sp_regnum (gdbarch, tdep->ppc_gp0_regnum + 1); set_gdbarch_deprecated_fp_regnum (gdbarch, tdep->ppc_gp0_regnum + 1); |