2000-05-18 23:43:58 +00:00
|
|
|
/* Native-dependent code for PowerPC's running NetBSD, for GDB.
|
2002-05-28 18:43:08 +00:00
|
|
|
Copyright 2002 Free Software Foundation, Inc.
|
|
|
|
Contributed by Wasabi Systems, Inc.
|
2000-05-18 23:43:58 +00:00
|
|
|
|
|
|
|
This file is part of GDB.
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
Boston, MA 02111-1307, USA. */
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/ptrace.h>
|
|
|
|
#include <machine/reg.h>
|
|
|
|
|
|
|
|
#include "defs.h"
|
|
|
|
#include "inferior.h"
|
* 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.
2004-05-11 04:55:32 +00:00
|
|
|
#include "gdb_assert.h"
|
2000-05-18 23:43:58 +00:00
|
|
|
|
2002-05-28 18:43:08 +00:00
|
|
|
#include "ppc-tdep.h"
|
|
|
|
#include "ppcnbsd-tdep.h"
|
2000-05-18 23:43:58 +00:00
|
|
|
|
2002-05-28 18:43:08 +00:00
|
|
|
/* Returns true if PT_GETREGS fetches this register. */
|
|
|
|
static int
|
|
|
|
getregs_supplies (int regno)
|
2000-05-18 23:43:58 +00:00
|
|
|
{
|
2002-05-28 18:43:08 +00:00
|
|
|
struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);
|
|
|
|
|
2004-05-13 19:27:07 +00:00
|
|
|
return ((regno >= tdep->ppc_gp0_regnum
|
|
|
|
&& regno < tdep->ppc_gp0_regnum + ppc_num_gprs)
|
2002-05-28 18:43:08 +00:00
|
|
|
|| regno == tdep->ppc_lr_regnum
|
|
|
|
|| regno == tdep->ppc_cr_regnum
|
|
|
|
|| regno == tdep->ppc_xer_regnum
|
|
|
|
|| regno == tdep->ppc_ctr_regnum
|
|
|
|
|| regno == PC_REGNUM);
|
2000-05-18 23:43:58 +00:00
|
|
|
}
|
|
|
|
|
2002-05-28 18:43:08 +00:00
|
|
|
/* Like above, but for PT_GETFPREGS. */
|
|
|
|
static int
|
|
|
|
getfpregs_supplies (int regno)
|
2000-05-18 23:43:58 +00:00
|
|
|
{
|
2002-05-28 18:43:08 +00:00
|
|
|
struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);
|
2000-05-18 23:43:58 +00:00
|
|
|
|
* 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.
2004-05-11 04:55:32 +00:00
|
|
|
/* FIXME: jimb/2004-05-05: Some PPC variants don't have floating
|
|
|
|
point registers. Traditionally, GDB's register set has still
|
|
|
|
listed the floating point registers for such machines, so this
|
|
|
|
code is harmless. However, the new E500 port actually omits the
|
|
|
|
floating point registers entirely from the register set --- they
|
|
|
|
don't even have register numbers assigned to them.
|
|
|
|
|
|
|
|
It's not clear to me how best to update this code, so this assert
|
|
|
|
will alert the first person to encounter the NetBSD/E500
|
|
|
|
combination to the problem. */
|
|
|
|
gdb_assert (ppc_floating_point_unit_p (current_gdbarch));
|
|
|
|
|
* config/rs6000/tm-rs6000.h (FP0_REGNUM): Document that this
should no longer be used in code specific to the RS6000 and its
derivatives.
* ppc-tdep.h (struct gdbarch_tdep): Add 'ppc_fp0_regnum' member.
* rs6000-tdep.c (rs6000_gdbarch_init): Initialize
tdep->ppc_fp0_regnum.
(ppc_supply_fpregset, ppc_collect_fpregset)
(rs6000_push_dummy_call, rs6000_extract_return_value)
(rs6000_dwarf2_stab_reg_to_regnum, rs6000_store_return_value)
(rs6000_frame_cache): Use tdep->ppc_fp0_regnum instead of
FP0_REGNUM.
* aix-thread.c (supply_fprs, fetch_regs_kernel_thread)
(fill_gprs64, fill_gprs32, fill_fprs, store_regs_kernel_thread):
Same.
* ppc-bdm.c (bdm_ppc_fetch_registers, bdm_ppc_fetch_registers,
bdm_ppc_store_registers): Same.
* ppc-linux-nat.c (ppc_register_u_addr, fetch_register)
(store_register, fill_fpregset): Same.
* ppc-linux-tdep.c (ppc_linux_sigtramp_cache)
(ppc_linux_supply_fpregset): Same.
* ppcnbsd-nat.c (getfpregs_supplies): Same.
* ppcnbsd-tdep.c (ppcnbsd_supply_fpreg, ppcnbsd_fill_fpreg):
Same.
* ppc-sysv-tdep.c (ppc_sysv_abi_push_dummy_call,
do_ppc_sysv_return_value, ppc64_sysv_abi_push_dummy_call,
ppc64_sysv_abi_return_value): Same.
* rs6000-nat.c (regmap, fetch_inferior_registers)
(store_inferior_registers, fetch_core_registers): Same.
2004-05-05 01:46:55 +00:00
|
|
|
return ((regno >= tdep->ppc_fp0_regnum
|
|
|
|
&& regno < tdep->ppc_fp0_regnum + ppc_num_fprs)
|
2002-05-28 18:43:08 +00:00
|
|
|
|| regno == tdep->ppc_fpscr_regnum);
|
|
|
|
}
|
2000-05-18 23:43:58 +00:00
|
|
|
|
|
|
|
void
|
2002-05-28 18:43:08 +00:00
|
|
|
fetch_inferior_registers (int regno)
|
2000-05-18 23:43:58 +00:00
|
|
|
{
|
2002-05-28 18:43:08 +00:00
|
|
|
if (regno == -1 || getregs_supplies (regno))
|
|
|
|
{
|
|
|
|
struct reg regs;
|
|
|
|
|
|
|
|
if (ptrace (PT_GETREGS, PIDGET (inferior_ptid),
|
|
|
|
(PTRACE_ARG3_TYPE) ®s, 0) == -1)
|
|
|
|
perror_with_name ("Couldn't get registers");
|
|
|
|
|
|
|
|
ppcnbsd_supply_reg ((char *) ®s, regno);
|
|
|
|
if (regno != -1)
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (regno == -1 || getfpregs_supplies (regno))
|
|
|
|
{
|
|
|
|
struct fpreg fpregs;
|
|
|
|
|
|
|
|
if (ptrace (PT_GETFPREGS, PIDGET (inferior_ptid),
|
|
|
|
(PTRACE_ARG3_TYPE) &fpregs, 0) == -1)
|
|
|
|
perror_with_name ("Couldn't get FP registers");
|
|
|
|
|
|
|
|
ppcnbsd_supply_fpreg ((char *) &fpregs, regno);
|
|
|
|
if (regno != -1)
|
|
|
|
return;
|
|
|
|
}
|
2000-05-18 23:43:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2002-05-28 18:43:08 +00:00
|
|
|
store_inferior_registers (int regno)
|
2000-05-18 23:43:58 +00:00
|
|
|
{
|
2002-05-28 18:43:08 +00:00
|
|
|
if (regno == -1 || getregs_supplies (regno))
|
|
|
|
{
|
|
|
|
struct reg regs;
|
|
|
|
|
|
|
|
if (ptrace (PT_GETREGS, PIDGET (inferior_ptid),
|
|
|
|
(PTRACE_ARG3_TYPE) ®s, 0) == -1)
|
|
|
|
perror_with_name ("Couldn't get registers");
|
|
|
|
|
|
|
|
ppcnbsd_fill_reg ((char *) ®s, regno);
|
|
|
|
|
|
|
|
if (ptrace (PT_SETREGS, PIDGET (inferior_ptid),
|
|
|
|
(PTRACE_ARG3_TYPE) ®s, 0) == -1)
|
|
|
|
perror_with_name ("Couldn't write registers");
|
|
|
|
|
|
|
|
if (regno != -1)
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (regno == -1 || getfpregs_supplies (regno))
|
|
|
|
{
|
|
|
|
struct fpreg fpregs;
|
|
|
|
|
|
|
|
if (ptrace (PT_GETFPREGS, PIDGET (inferior_ptid),
|
|
|
|
(PTRACE_ARG3_TYPE) &fpregs, 0) == -1)
|
|
|
|
perror_with_name ("Couldn't get FP registers");
|
|
|
|
|
|
|
|
ppcnbsd_fill_fpreg ((char *) &fpregs, regno);
|
|
|
|
|
|
|
|
if (ptrace (PT_SETFPREGS, PIDGET (inferior_ptid),
|
|
|
|
(PTRACE_ARG3_TYPE) &fpregs, 0) == -1)
|
|
|
|
perror_with_name ("Couldn't set FP registers");
|
|
|
|
}
|
2000-05-18 23:43:58 +00:00
|
|
|
}
|