2000-02-22 01:20:32 +00:00
|
|
|
/* PPC linux native support.
|
2001-03-06 08:22:02 +00:00
|
|
|
Copyright 1988, 1989, 1991, 1992, 1994, 1996, 2000, 2001
|
|
|
|
Free Software Foundation, Inc.
|
2000-02-22 01:20:32 +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 "defs.h"
|
|
|
|
#include "frame.h"
|
|
|
|
#include "inferior.h"
|
|
|
|
#include "gdbcore.h"
|
2001-03-01 01:39:22 +00:00
|
|
|
#include "regcache.h"
|
2000-02-22 01:20:32 +00:00
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <signal.h>
|
|
|
|
#include <sys/user.h>
|
|
|
|
#include <sys/ioctl.h>
|
|
|
|
#include <sys/wait.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <sys/procfs.h>
|
2001-12-20 23:31:27 +00:00
|
|
|
#include <sys/ptrace.h>
|
2000-02-22 01:20:32 +00:00
|
|
|
|
2000-05-26 Michael Snyder <msnyder@seadog.cygnus.com>
* gregset.h: New file. Typedefs for gdb_gregset_t and
gdb_fpregset_t, prototypes for supply_gregset and friends.
* procfs.c: Include gregset.h. Delete local prototypes for
supply_gregset etc., and local typedef gdb_gregset_t etc.
* sol-thread.c: Include gregset.h, delete local prototypes,
add appropriate casts to gdb_gregset_t.
* uw-thread.c, lin-thread.c, core-sol2.c, core-regset.c,
sparc-tdep.c, ptx4-nat.c, ppc-linux-nat.c, mipsv4-nat.c,
m88k-nat.c, m68klinux-nat.c, m68k-tdep.c, irix5-nat.c,
irix4-nat.c, ia64-linux-nat.c, i386v4-nat.c, cxux-nat.c,
arm-linux-nat.c, alpha-nat.c: Include gregset.h.
* config/nm-linux.h: Define GDB_GREGSET_T, GDB_FPREGET_T.
* config/sparc/tm-sun4sol2.h: Ditto.
2000-05-26 23:22:41 +00:00
|
|
|
/* Prototypes for supply_gregset etc. */
|
|
|
|
#include "gregset.h"
|
2001-11-30 02:14:08 +00:00
|
|
|
#include "ppc-tdep.h"
|
2000-05-26 Michael Snyder <msnyder@seadog.cygnus.com>
* gregset.h: New file. Typedefs for gdb_gregset_t and
gdb_fpregset_t, prototypes for supply_gregset and friends.
* procfs.c: Include gregset.h. Delete local prototypes for
supply_gregset etc., and local typedef gdb_gregset_t etc.
* sol-thread.c: Include gregset.h, delete local prototypes,
add appropriate casts to gdb_gregset_t.
* uw-thread.c, lin-thread.c, core-sol2.c, core-regset.c,
sparc-tdep.c, ptx4-nat.c, ppc-linux-nat.c, mipsv4-nat.c,
m88k-nat.c, m68klinux-nat.c, m68k-tdep.c, irix5-nat.c,
irix4-nat.c, ia64-linux-nat.c, i386v4-nat.c, cxux-nat.c,
arm-linux-nat.c, alpha-nat.c: Include gregset.h.
* config/nm-linux.h: Define GDB_GREGSET_T, GDB_FPREGET_T.
* config/sparc/tm-sun4sol2.h: Ditto.
2000-05-26 23:22:41 +00:00
|
|
|
|
2001-12-20 23:31:27 +00:00
|
|
|
#ifndef PT_READ_U
|
|
|
|
#define PT_READ_U PTRACE_PEEKUSR
|
|
|
|
#endif
|
|
|
|
#ifndef PT_WRITE_U
|
|
|
|
#define PT_WRITE_U PTRACE_POKEUSR
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Default the type of the ptrace transfer to int. */
|
|
|
|
#ifndef PTRACE_XFER_TYPE
|
|
|
|
#define PTRACE_XFER_TYPE int
|
|
|
|
#endif
|
|
|
|
|
2000-02-22 01:20:32 +00:00
|
|
|
int
|
2000-07-30 01:48:28 +00:00
|
|
|
kernel_u_size (void)
|
2000-02-22 01:20:32 +00:00
|
|
|
{
|
|
|
|
return (sizeof (struct user));
|
|
|
|
}
|
|
|
|
|
2001-11-30 02:14:08 +00:00
|
|
|
/* *INDENT-OFF* */
|
|
|
|
/* registers layout, as presented by the ptrace interface:
|
|
|
|
PT_R0, PT_R1, PT_R2, PT_R3, PT_R4, PT_R5, PT_R6, PT_R7,
|
|
|
|
PT_R8, PT_R9, PT_R10, PT_R11, PT_R12, PT_R13, PT_R14, PT_R15,
|
|
|
|
PT_R16, PT_R17, PT_R18, PT_R19, PT_R20, PT_R21, PT_R22, PT_R23,
|
|
|
|
PT_R24, PT_R25, PT_R26, PT_R27, PT_R28, PT_R29, PT_R30, PT_R31,
|
|
|
|
PT_FPR0, PT_FPR0 + 2, PT_FPR0 + 4, PT_FPR0 + 6, PT_FPR0 + 8, PT_FPR0 + 10, PT_FPR0 + 12, PT_FPR0 + 14,
|
|
|
|
PT_FPR0 + 16, PT_FPR0 + 18, PT_FPR0 + 20, PT_FPR0 + 22, PT_FPR0 + 24, PT_FPR0 + 26, PT_FPR0 + 28, PT_FPR0 + 30,
|
|
|
|
PT_FPR0 + 32, PT_FPR0 + 34, PT_FPR0 + 36, PT_FPR0 + 38, PT_FPR0 + 40, PT_FPR0 + 42, PT_FPR0 + 44, PT_FPR0 + 46,
|
|
|
|
PT_FPR0 + 48, PT_FPR0 + 50, PT_FPR0 + 52, PT_FPR0 + 54, PT_FPR0 + 56, PT_FPR0 + 58, PT_FPR0 + 60, PT_FPR0 + 62,
|
|
|
|
PT_NIP, PT_MSR, PT_CCR, PT_LNK, PT_CTR, PT_XER, PT_MQ */
|
|
|
|
/* *INDENT_ON * */
|
2000-02-22 01:20:32 +00:00
|
|
|
|
2001-12-20 23:31:27 +00:00
|
|
|
static int
|
|
|
|
ppc_register_u_addr (int regno)
|
2000-02-22 01:20:32 +00:00
|
|
|
{
|
2001-11-30 02:14:08 +00:00
|
|
|
int u_addr = -1;
|
|
|
|
|
|
|
|
/* General purpose registers occupy 1 slot each in the buffer */
|
2001-12-09 Elena Zannoni <ezannoni@redhat.com>
* config/rs6000/tm-rs6000.h (STAB_REG_TO_REGNUM): Remove
definition, it is now multiarched.
* ppc-tdep.h (struct gdbarch_tdep): Move from rs6000-tdep.c. Add
fields for special register numbers.
* rs6000-tdep.c (rs6000_gdbarch_init): Initialize new tdep special
regnum fields.
(rs6000_saved_pc_after_call): Use gdbarch_tdep registers fields
instead of hardcoded macros.
(branch_dest, rs6000_pop_frame, rs6000_fix_call_dummy,
ppc_push_return_address, rs6000_frame_saved_pc,
frame_get_saved_regs, rs6000_frame_chain,
rs6000_store_return_value): Ditto.
(rs6000_stab_reg_to_regnum): New function.
* ppcnbsd-nat.c (fetch_inferior_registers,
store_inferior_registers, fetch_core_registers): Ditto.
* ppc-linux-tdep.c (ppc_linux_in_sigtramp,
ppc_linux_frame_init_saved_regs): Ditto.
* ppc-linux-nat.c (ppc_register_u_addr, supply_gregset,
fill_gregset): Ditto.
* ppc-bdm.c (bdm_ppc_fetch_registers, bdm_ppc_store_registers):
Ditto.
2001-12-09 21:39:53 +00:00
|
|
|
if (regno >= gdbarch_tdep (current_gdbarch)->ppc_gp0_regnum
|
|
|
|
&& regno <= gdbarch_tdep (current_gdbarch)->ppc_gplast_regnum )
|
2001-12-20 23:31:27 +00:00
|
|
|
u_addr = ((PT_R0 + regno) * 4);
|
2001-11-30 02:14:08 +00:00
|
|
|
|
|
|
|
/* Floating point regs: 2 slots each */
|
|
|
|
if (regno >= FP0_REGNUM && regno <= FPLAST_REGNUM)
|
2001-12-20 23:31:27 +00:00
|
|
|
u_addr = ((PT_FPR0 + (regno - FP0_REGNUM) * 2) * 4);
|
2001-11-30 02:14:08 +00:00
|
|
|
|
|
|
|
/* UISA special purpose registers: 1 slot each */
|
|
|
|
if (regno == PC_REGNUM)
|
2001-12-20 23:31:27 +00:00
|
|
|
u_addr = PT_NIP * 4;
|
2001-12-09 Elena Zannoni <ezannoni@redhat.com>
* config/rs6000/tm-rs6000.h (STAB_REG_TO_REGNUM): Remove
definition, it is now multiarched.
* ppc-tdep.h (struct gdbarch_tdep): Move from rs6000-tdep.c. Add
fields for special register numbers.
* rs6000-tdep.c (rs6000_gdbarch_init): Initialize new tdep special
regnum fields.
(rs6000_saved_pc_after_call): Use gdbarch_tdep registers fields
instead of hardcoded macros.
(branch_dest, rs6000_pop_frame, rs6000_fix_call_dummy,
ppc_push_return_address, rs6000_frame_saved_pc,
frame_get_saved_regs, rs6000_frame_chain,
rs6000_store_return_value): Ditto.
(rs6000_stab_reg_to_regnum): New function.
* ppcnbsd-nat.c (fetch_inferior_registers,
store_inferior_registers, fetch_core_registers): Ditto.
* ppc-linux-tdep.c (ppc_linux_in_sigtramp,
ppc_linux_frame_init_saved_regs): Ditto.
* ppc-linux-nat.c (ppc_register_u_addr, supply_gregset,
fill_gregset): Ditto.
* ppc-bdm.c (bdm_ppc_fetch_registers, bdm_ppc_store_registers):
Ditto.
2001-12-09 21:39:53 +00:00
|
|
|
if (regno == gdbarch_tdep (current_gdbarch)->ppc_lr_regnum)
|
2001-12-20 23:31:27 +00:00
|
|
|
u_addr = PT_LNK * 4;
|
2001-12-09 Elena Zannoni <ezannoni@redhat.com>
* config/rs6000/tm-rs6000.h (STAB_REG_TO_REGNUM): Remove
definition, it is now multiarched.
* ppc-tdep.h (struct gdbarch_tdep): Move from rs6000-tdep.c. Add
fields for special register numbers.
* rs6000-tdep.c (rs6000_gdbarch_init): Initialize new tdep special
regnum fields.
(rs6000_saved_pc_after_call): Use gdbarch_tdep registers fields
instead of hardcoded macros.
(branch_dest, rs6000_pop_frame, rs6000_fix_call_dummy,
ppc_push_return_address, rs6000_frame_saved_pc,
frame_get_saved_regs, rs6000_frame_chain,
rs6000_store_return_value): Ditto.
(rs6000_stab_reg_to_regnum): New function.
* ppcnbsd-nat.c (fetch_inferior_registers,
store_inferior_registers, fetch_core_registers): Ditto.
* ppc-linux-tdep.c (ppc_linux_in_sigtramp,
ppc_linux_frame_init_saved_regs): Ditto.
* ppc-linux-nat.c (ppc_register_u_addr, supply_gregset,
fill_gregset): Ditto.
* ppc-bdm.c (bdm_ppc_fetch_registers, bdm_ppc_store_registers):
Ditto.
2001-12-09 21:39:53 +00:00
|
|
|
if (regno == gdbarch_tdep (current_gdbarch)->ppc_cr_regnum)
|
2001-12-20 23:31:27 +00:00
|
|
|
u_addr = PT_CCR * 4;
|
2001-12-09 Elena Zannoni <ezannoni@redhat.com>
* config/rs6000/tm-rs6000.h (STAB_REG_TO_REGNUM): Remove
definition, it is now multiarched.
* ppc-tdep.h (struct gdbarch_tdep): Move from rs6000-tdep.c. Add
fields for special register numbers.
* rs6000-tdep.c (rs6000_gdbarch_init): Initialize new tdep special
regnum fields.
(rs6000_saved_pc_after_call): Use gdbarch_tdep registers fields
instead of hardcoded macros.
(branch_dest, rs6000_pop_frame, rs6000_fix_call_dummy,
ppc_push_return_address, rs6000_frame_saved_pc,
frame_get_saved_regs, rs6000_frame_chain,
rs6000_store_return_value): Ditto.
(rs6000_stab_reg_to_regnum): New function.
* ppcnbsd-nat.c (fetch_inferior_registers,
store_inferior_registers, fetch_core_registers): Ditto.
* ppc-linux-tdep.c (ppc_linux_in_sigtramp,
ppc_linux_frame_init_saved_regs): Ditto.
* ppc-linux-nat.c (ppc_register_u_addr, supply_gregset,
fill_gregset): Ditto.
* ppc-bdm.c (bdm_ppc_fetch_registers, bdm_ppc_store_registers):
Ditto.
2001-12-09 21:39:53 +00:00
|
|
|
if (regno == gdbarch_tdep (current_gdbarch)->ppc_xer_regnum)
|
2001-12-20 23:31:27 +00:00
|
|
|
u_addr = PT_XER * 4;
|
2001-12-09 Elena Zannoni <ezannoni@redhat.com>
* config/rs6000/tm-rs6000.h (STAB_REG_TO_REGNUM): Remove
definition, it is now multiarched.
* ppc-tdep.h (struct gdbarch_tdep): Move from rs6000-tdep.c. Add
fields for special register numbers.
* rs6000-tdep.c (rs6000_gdbarch_init): Initialize new tdep special
regnum fields.
(rs6000_saved_pc_after_call): Use gdbarch_tdep registers fields
instead of hardcoded macros.
(branch_dest, rs6000_pop_frame, rs6000_fix_call_dummy,
ppc_push_return_address, rs6000_frame_saved_pc,
frame_get_saved_regs, rs6000_frame_chain,
rs6000_store_return_value): Ditto.
(rs6000_stab_reg_to_regnum): New function.
* ppcnbsd-nat.c (fetch_inferior_registers,
store_inferior_registers, fetch_core_registers): Ditto.
* ppc-linux-tdep.c (ppc_linux_in_sigtramp,
ppc_linux_frame_init_saved_regs): Ditto.
* ppc-linux-nat.c (ppc_register_u_addr, supply_gregset,
fill_gregset): Ditto.
* ppc-bdm.c (bdm_ppc_fetch_registers, bdm_ppc_store_registers):
Ditto.
2001-12-09 21:39:53 +00:00
|
|
|
if (regno == gdbarch_tdep (current_gdbarch)->ppc_ctr_regnum)
|
2001-12-20 23:31:27 +00:00
|
|
|
u_addr = PT_CTR * 4;
|
2001-12-09 Elena Zannoni <ezannoni@redhat.com>
* config/rs6000/tm-rs6000.h (STAB_REG_TO_REGNUM): Remove
definition, it is now multiarched.
* ppc-tdep.h (struct gdbarch_tdep): Move from rs6000-tdep.c. Add
fields for special register numbers.
* rs6000-tdep.c (rs6000_gdbarch_init): Initialize new tdep special
regnum fields.
(rs6000_saved_pc_after_call): Use gdbarch_tdep registers fields
instead of hardcoded macros.
(branch_dest, rs6000_pop_frame, rs6000_fix_call_dummy,
ppc_push_return_address, rs6000_frame_saved_pc,
frame_get_saved_regs, rs6000_frame_chain,
rs6000_store_return_value): Ditto.
(rs6000_stab_reg_to_regnum): New function.
* ppcnbsd-nat.c (fetch_inferior_registers,
store_inferior_registers, fetch_core_registers): Ditto.
* ppc-linux-tdep.c (ppc_linux_in_sigtramp,
ppc_linux_frame_init_saved_regs): Ditto.
* ppc-linux-nat.c (ppc_register_u_addr, supply_gregset,
fill_gregset): Ditto.
* ppc-bdm.c (bdm_ppc_fetch_registers, bdm_ppc_store_registers):
Ditto.
2001-12-09 21:39:53 +00:00
|
|
|
if (regno == gdbarch_tdep (current_gdbarch)->ppc_mq_regnum)
|
2001-12-20 23:31:27 +00:00
|
|
|
u_addr = PT_MQ * 4;
|
2001-12-09 Elena Zannoni <ezannoni@redhat.com>
* config/rs6000/tm-rs6000.h (STAB_REG_TO_REGNUM): Remove
definition, it is now multiarched.
* ppc-tdep.h (struct gdbarch_tdep): Move from rs6000-tdep.c. Add
fields for special register numbers.
* rs6000-tdep.c (rs6000_gdbarch_init): Initialize new tdep special
regnum fields.
(rs6000_saved_pc_after_call): Use gdbarch_tdep registers fields
instead of hardcoded macros.
(branch_dest, rs6000_pop_frame, rs6000_fix_call_dummy,
ppc_push_return_address, rs6000_frame_saved_pc,
frame_get_saved_regs, rs6000_frame_chain,
rs6000_store_return_value): Ditto.
(rs6000_stab_reg_to_regnum): New function.
* ppcnbsd-nat.c (fetch_inferior_registers,
store_inferior_registers, fetch_core_registers): Ditto.
* ppc-linux-tdep.c (ppc_linux_in_sigtramp,
ppc_linux_frame_init_saved_regs): Ditto.
* ppc-linux-nat.c (ppc_register_u_addr, supply_gregset,
fill_gregset): Ditto.
* ppc-bdm.c (bdm_ppc_fetch_registers, bdm_ppc_store_registers):
Ditto.
2001-12-09 21:39:53 +00:00
|
|
|
if (regno == gdbarch_tdep (current_gdbarch)->ppc_ps_regnum)
|
2001-12-20 23:31:27 +00:00
|
|
|
u_addr = PT_MSR * 4;
|
2001-11-30 02:14:08 +00:00
|
|
|
|
|
|
|
return u_addr;
|
2000-02-22 01:20:32 +00:00
|
|
|
}
|
|
|
|
|
2001-12-20 23:31:27 +00:00
|
|
|
static int
|
|
|
|
ppc_ptrace_cannot_fetch_store_register (int regno)
|
|
|
|
{
|
|
|
|
return (ppc_register_u_addr (regno) == -1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
fetch_register (int regno)
|
|
|
|
{
|
|
|
|
/* This isn't really an address. But ptrace thinks of it as one. */
|
|
|
|
char mess[128]; /* For messages */
|
|
|
|
register int i;
|
|
|
|
unsigned int offset; /* Offset of registers within the u area. */
|
|
|
|
char *buf = alloca (MAX_REGISTER_RAW_SIZE);
|
|
|
|
int tid;
|
|
|
|
CORE_ADDR regaddr = ppc_register_u_addr (regno);
|
|
|
|
|
|
|
|
if (regaddr == -1)
|
|
|
|
{
|
|
|
|
memset (buf, '\0', REGISTER_RAW_SIZE (regno)); /* Supply zeroes */
|
|
|
|
supply_register (regno, buf);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Overload thread id onto process id */
|
|
|
|
if ((tid = TIDGET (inferior_ptid)) == 0)
|
|
|
|
tid = PIDGET (inferior_ptid); /* no thread id, just use process id */
|
|
|
|
|
|
|
|
for (i = 0; i < REGISTER_RAW_SIZE (regno); i += sizeof (PTRACE_XFER_TYPE))
|
|
|
|
{
|
|
|
|
errno = 0;
|
|
|
|
*(PTRACE_XFER_TYPE *) & buf[i] = ptrace (PT_READ_U, tid,
|
|
|
|
(PTRACE_ARG3_TYPE) regaddr, 0);
|
|
|
|
regaddr += sizeof (PTRACE_XFER_TYPE);
|
|
|
|
if (errno != 0)
|
|
|
|
{
|
|
|
|
sprintf (mess, "reading register %s (#%d)",
|
|
|
|
REGISTER_NAME (regno), regno);
|
|
|
|
perror_with_name (mess);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
supply_register (regno, buf);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
fetch_ppc_registers (void)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int last_register = gdbarch_tdep (current_gdbarch)->ppc_mq_regnum;
|
|
|
|
|
|
|
|
for (i = 0; i <= last_register; i++)
|
|
|
|
fetch_register (i);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Fetch registers from the child process. Fetch all registers if
|
|
|
|
regno == -1, otherwise fetch all general registers or all floating
|
|
|
|
point registers depending upon the value of regno. */
|
|
|
|
void
|
|
|
|
fetch_inferior_registers (int regno)
|
|
|
|
{
|
|
|
|
if (regno == -1)
|
|
|
|
fetch_ppc_registers ();
|
|
|
|
else
|
|
|
|
fetch_register (regno);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Store one register. */
|
|
|
|
static void
|
|
|
|
store_register (int regno)
|
|
|
|
{
|
|
|
|
/* This isn't really an address. But ptrace thinks of it as one. */
|
|
|
|
CORE_ADDR regaddr = ppc_register_u_addr (regno);
|
|
|
|
char mess[128]; /* For messages */
|
|
|
|
register int i;
|
|
|
|
unsigned int offset; /* Offset of registers within the u area. */
|
|
|
|
int tid;
|
|
|
|
char *buf = alloca (MAX_REGISTER_RAW_SIZE);
|
|
|
|
|
|
|
|
if (regaddr == -1)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Overload thread id onto process id */
|
|
|
|
if ((tid = TIDGET (inferior_ptid)) == 0)
|
|
|
|
tid = PIDGET (inferior_ptid); /* no thread id, just use process id */
|
|
|
|
|
|
|
|
regcache_collect (regno, buf);
|
|
|
|
for (i = 0; i < REGISTER_RAW_SIZE (regno); i += sizeof (PTRACE_XFER_TYPE))
|
|
|
|
{
|
|
|
|
errno = 0;
|
|
|
|
ptrace (PT_WRITE_U, tid, (PTRACE_ARG3_TYPE) regaddr,
|
|
|
|
*(PTRACE_XFER_TYPE *) & buf[i]);
|
|
|
|
regaddr += sizeof (PTRACE_XFER_TYPE);
|
|
|
|
if (errno != 0)
|
|
|
|
{
|
|
|
|
sprintf (mess, "writing register %s (#%d)",
|
|
|
|
REGISTER_NAME (regno), regno);
|
|
|
|
perror_with_name (mess);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
store_ppc_registers (void)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int last_register = gdbarch_tdep (current_gdbarch)->ppc_mq_regnum;
|
|
|
|
|
|
|
|
for (i = 0; i <= last_register; i++)
|
|
|
|
store_register (i);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
store_inferior_registers (int regno)
|
|
|
|
{
|
|
|
|
if (regno >= 0)
|
|
|
|
store_register (regno);
|
|
|
|
else
|
|
|
|
store_ppc_registers ();
|
|
|
|
}
|
|
|
|
|
2000-02-22 18:47:41 +00:00
|
|
|
void
|
2000-09-30 05:41:39 +00:00
|
|
|
supply_gregset (gdb_gregset_t *gregsetp)
|
2000-02-22 01:20:32 +00:00
|
|
|
{
|
|
|
|
int regi;
|
2001-07-05 23:22:04 +00:00
|
|
|
register elf_greg_t *regp = (elf_greg_t *) gregsetp;
|
2000-02-22 01:20:32 +00:00
|
|
|
|
|
|
|
for (regi = 0; regi < 32; regi++)
|
|
|
|
supply_register (regi, (char *) (regp + regi));
|
|
|
|
|
2001-11-30 02:14:08 +00:00
|
|
|
supply_register (PC_REGNUM, (char *) (regp + PT_NIP));
|
2001-12-09 Elena Zannoni <ezannoni@redhat.com>
* config/rs6000/tm-rs6000.h (STAB_REG_TO_REGNUM): Remove
definition, it is now multiarched.
* ppc-tdep.h (struct gdbarch_tdep): Move from rs6000-tdep.c. Add
fields for special register numbers.
* rs6000-tdep.c (rs6000_gdbarch_init): Initialize new tdep special
regnum fields.
(rs6000_saved_pc_after_call): Use gdbarch_tdep registers fields
instead of hardcoded macros.
(branch_dest, rs6000_pop_frame, rs6000_fix_call_dummy,
ppc_push_return_address, rs6000_frame_saved_pc,
frame_get_saved_regs, rs6000_frame_chain,
rs6000_store_return_value): Ditto.
(rs6000_stab_reg_to_regnum): New function.
* ppcnbsd-nat.c (fetch_inferior_registers,
store_inferior_registers, fetch_core_registers): Ditto.
* ppc-linux-tdep.c (ppc_linux_in_sigtramp,
ppc_linux_frame_init_saved_regs): Ditto.
* ppc-linux-nat.c (ppc_register_u_addr, supply_gregset,
fill_gregset): Ditto.
* ppc-bdm.c (bdm_ppc_fetch_registers, bdm_ppc_store_registers):
Ditto.
2001-12-09 21:39:53 +00:00
|
|
|
supply_register (gdbarch_tdep (current_gdbarch)->ppc_lr_regnum,
|
|
|
|
(char *) (regp + PT_LNK));
|
|
|
|
supply_register (gdbarch_tdep (current_gdbarch)->ppc_cr_regnum,
|
|
|
|
(char *) (regp + PT_CCR));
|
|
|
|
supply_register (gdbarch_tdep (current_gdbarch)->ppc_xer_regnum,
|
|
|
|
(char *) (regp + PT_XER));
|
|
|
|
supply_register (gdbarch_tdep (current_gdbarch)->ppc_ctr_regnum,
|
|
|
|
(char *) (regp + PT_CTR));
|
|
|
|
supply_register (gdbarch_tdep (current_gdbarch)->ppc_mq_regnum,
|
|
|
|
(char *) (regp + PT_MQ));
|
|
|
|
supply_register (gdbarch_tdep (current_gdbarch)->ppc_ps_regnum,
|
|
|
|
(char *) (regp + PT_MSR));
|
2000-02-22 01:20:32 +00:00
|
|
|
}
|
|
|
|
|
2000-09-18 01:08:24 +00:00
|
|
|
void
|
2000-09-30 05:41:39 +00:00
|
|
|
fill_gregset (gdb_gregset_t *gregsetp, int regno)
|
2000-09-18 01:08:24 +00:00
|
|
|
{
|
|
|
|
int regi;
|
2001-07-05 23:22:04 +00:00
|
|
|
elf_greg_t *regp = (elf_greg_t *) gregsetp;
|
2000-09-18 01:08:24 +00:00
|
|
|
|
|
|
|
for (regi = 0; regi < 32; regi++)
|
|
|
|
{
|
2001-11-30 02:14:08 +00:00
|
|
|
if ((regno == -1) || regno == regi)
|
|
|
|
regcache_collect (regi, regp + PT_R0 + regi);
|
2000-09-18 01:08:24 +00:00
|
|
|
}
|
|
|
|
|
2001-11-30 02:14:08 +00:00
|
|
|
if ((regno == -1) || regno == PC_REGNUM)
|
|
|
|
regcache_collect (PC_REGNUM, regp + PT_NIP);
|
2001-12-09 Elena Zannoni <ezannoni@redhat.com>
* config/rs6000/tm-rs6000.h (STAB_REG_TO_REGNUM): Remove
definition, it is now multiarched.
* ppc-tdep.h (struct gdbarch_tdep): Move from rs6000-tdep.c. Add
fields for special register numbers.
* rs6000-tdep.c (rs6000_gdbarch_init): Initialize new tdep special
regnum fields.
(rs6000_saved_pc_after_call): Use gdbarch_tdep registers fields
instead of hardcoded macros.
(branch_dest, rs6000_pop_frame, rs6000_fix_call_dummy,
ppc_push_return_address, rs6000_frame_saved_pc,
frame_get_saved_regs, rs6000_frame_chain,
rs6000_store_return_value): Ditto.
(rs6000_stab_reg_to_regnum): New function.
* ppcnbsd-nat.c (fetch_inferior_registers,
store_inferior_registers, fetch_core_registers): Ditto.
* ppc-linux-tdep.c (ppc_linux_in_sigtramp,
ppc_linux_frame_init_saved_regs): Ditto.
* ppc-linux-nat.c (ppc_register_u_addr, supply_gregset,
fill_gregset): Ditto.
* ppc-bdm.c (bdm_ppc_fetch_registers, bdm_ppc_store_registers):
Ditto.
2001-12-09 21:39:53 +00:00
|
|
|
if ((regno == -1)
|
|
|
|
|| regno == gdbarch_tdep (current_gdbarch)->ppc_lr_regnum)
|
|
|
|
regcache_collect (gdbarch_tdep (current_gdbarch)->ppc_lr_regnum,
|
|
|
|
regp + PT_LNK);
|
|
|
|
if ((regno == -1)
|
|
|
|
|| regno == gdbarch_tdep (current_gdbarch)->ppc_cr_regnum)
|
|
|
|
regcache_collect (gdbarch_tdep (current_gdbarch)->ppc_cr_regnum,
|
|
|
|
regp + PT_CCR);
|
|
|
|
if ((regno == -1)
|
|
|
|
|| regno == gdbarch_tdep (current_gdbarch)->ppc_xer_regnum)
|
|
|
|
regcache_collect (gdbarch_tdep (current_gdbarch)->ppc_xer_regnum,
|
|
|
|
regp + PT_XER);
|
|
|
|
if ((regno == -1)
|
|
|
|
|| regno == gdbarch_tdep (current_gdbarch)->ppc_ctr_regnum)
|
|
|
|
regcache_collect (gdbarch_tdep (current_gdbarch)->ppc_ctr_regnum,
|
|
|
|
regp + PT_CTR);
|
|
|
|
if ((regno == -1)
|
|
|
|
|| regno == gdbarch_tdep (current_gdbarch)->ppc_mq_regnum)
|
|
|
|
regcache_collect (gdbarch_tdep (current_gdbarch)->ppc_mq_regnum,
|
|
|
|
regp + PT_MQ);
|
|
|
|
if ((regno == -1)
|
|
|
|
|| regno == gdbarch_tdep (current_gdbarch)->ppc_ps_regnum)
|
|
|
|
regcache_collect (gdbarch_tdep (current_gdbarch)->ppc_ps_regnum,
|
|
|
|
regp + PT_MSR);
|
2000-09-18 01:08:24 +00:00
|
|
|
}
|
|
|
|
|
2000-02-22 18:47:41 +00:00
|
|
|
void
|
2000-09-30 05:41:39 +00:00
|
|
|
supply_fpregset (gdb_fpregset_t * fpregsetp)
|
2000-02-22 01:20:32 +00:00
|
|
|
{
|
|
|
|
int regi;
|
|
|
|
for (regi = 0; regi < 32; regi++)
|
|
|
|
{
|
|
|
|
supply_register (FP0_REGNUM + regi, (char *) (*fpregsetp + regi));
|
|
|
|
}
|
|
|
|
}
|
2000-09-18 01:08:24 +00:00
|
|
|
|
|
|
|
/* 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
|
2000-09-30 05:41:39 +00:00
|
|
|
fill_fpregset (gdb_fpregset_t *fpregsetp, int regno)
|
2000-09-18 01:08:24 +00:00
|
|
|
{
|
|
|
|
int regi;
|
|
|
|
|
|
|
|
for (regi = 0; regi < 32; regi++)
|
|
|
|
{
|
|
|
|
if ((regno == -1) || (regno == FP0_REGNUM + regi))
|
2001-11-20 16:35:24 +00:00
|
|
|
regcache_collect (FP0_REGNUM + regi, (char *) (*fpregsetp + regi));
|
2000-09-18 01:08:24 +00:00
|
|
|
}
|
|
|
|
}
|