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"
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
return ((regno >= 0 && regno <= 31)
|
|
|
|
|| 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
|
|
|
|
* 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
|
|
|
}
|