1999-04-16 01:35:26 +00:00
|
|
|
/* HP/UX native interface for HP 300's, for GDB when running under Unix.
|
2001-03-06 08:22:02 +00:00
|
|
|
Copyright 1986, 1987, 1989, 1991, 1992, 1993, 1994, 1996, 1999, 2000,
|
|
|
|
2001 Free Software Foundation, Inc.
|
1999-04-16 01:35:26 +00:00
|
|
|
|
1999-07-07 20:19:36 +00:00
|
|
|
This file is part of GDB.
|
1999-04-16 01:35:26 +00:00
|
|
|
|
1999-07-07 20:19:36 +00:00
|
|
|
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.
|
1999-04-16 01:35:26 +00:00
|
|
|
|
1999-07-07 20:19:36 +00:00
|
|
|
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. */
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
|
|
#include "defs.h"
|
|
|
|
#include "frame.h"
|
|
|
|
#include "inferior.h"
|
2001-03-01 01:39:22 +00:00
|
|
|
#include "regcache.h"
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
|
|
/* Defining this means some system include files define some extra stuff. */
|
|
|
|
#define WOPR
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <signal.h>
|
|
|
|
#include <sys/user.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
|
|
|
|
#include <sys/ptrace.h>
|
|
|
|
#include <sys/reg.h>
|
|
|
|
#include <sys/trap.h>
|
|
|
|
|
|
|
|
#include <sys/file.h>
|
|
|
|
|
2000-05-28 01:12:42 +00:00
|
|
|
static void fetch_inferior_register (int, unsigned int);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
2000-05-28 01:12:42 +00:00
|
|
|
static void store_inferior_register_1 (int, unsigned int, int);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
2000-05-28 01:12:42 +00:00
|
|
|
static void store_inferior_register (int, unsigned int);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
|
|
/* Get kernel_u_addr using HPUX-style nlist(). */
|
|
|
|
CORE_ADDR kernel_u_addr;
|
|
|
|
|
1999-07-07 20:19:36 +00:00
|
|
|
struct hpnlist
|
|
|
|
{
|
|
|
|
char *n_name;
|
|
|
|
long n_value;
|
|
|
|
unsigned char n_type;
|
|
|
|
unsigned char n_length;
|
|
|
|
short n_almod;
|
|
|
|
short n_unused;
|
|
|
|
};
|
|
|
|
static struct hpnlist nl[] =
|
|
|
|
{
|
|
|
|
{"_u", -1,},
|
|
|
|
{(char *) 0,}};
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
|
|
/* read the value of the u area from the hp-ux kernel */
|
|
|
|
void
|
2000-07-30 01:48:28 +00:00
|
|
|
_initialize_hp300ux_nat (void)
|
1999-04-16 01:35:26 +00:00
|
|
|
{
|
|
|
|
#ifndef HPUX_VERSION_5
|
1999-07-07 20:19:36 +00:00
|
|
|
nlist ("/hp-ux", nl);
|
|
|
|
kernel_u_addr = nl[0].n_value;
|
1999-04-16 01:35:26 +00:00
|
|
|
#else /* HPUX version 5. */
|
1999-07-07 20:19:36 +00:00
|
|
|
kernel_u_addr = (CORE_ADDR) 0x0097900;
|
1999-04-16 01:35:26 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
#define INFERIOR_AR0(u) \
|
|
|
|
((ptrace \
|
2001-05-04 04:15:33 +00:00
|
|
|
(PT_RUAREA, PIDGET (inferior_ptid), \
|
|
|
|
(PTRACE_ARG3_TYPE) ((char *) &u.u_ar0 - (char *) &u), 0, 0)) \
|
1999-04-16 01:35:26 +00:00
|
|
|
- kernel_u_addr)
|
|
|
|
|
|
|
|
static void
|
2000-07-30 01:48:28 +00:00
|
|
|
fetch_inferior_register (register int regno, register unsigned int regaddr)
|
1999-04-16 01:35:26 +00:00
|
|
|
{
|
|
|
|
#ifndef HPUX_VERSION_5
|
|
|
|
if (regno == PS_REGNUM)
|
|
|
|
{
|
1999-07-07 20:19:36 +00:00
|
|
|
union
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
short s[2];
|
|
|
|
}
|
|
|
|
ps_val;
|
1999-04-16 01:35:26 +00:00
|
|
|
int regval;
|
1999-07-07 20:19:36 +00:00
|
|
|
|
2001-05-04 04:15:33 +00:00
|
|
|
ps_val.i = (ptrace (PT_RUAREA, PIDGET (inferior_ptid),
|
|
|
|
(PTRACE_ARG3_TYPE) regaddr, 0, 0));
|
1999-04-16 01:35:26 +00:00
|
|
|
regval = ps_val.s[0];
|
1999-07-07 20:19:36 +00:00
|
|
|
supply_register (regno, (char *) ®val);
|
1999-04-16 01:35:26 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
#endif /* not HPUX_VERSION_5 */
|
|
|
|
{
|
|
|
|
char buf[MAX_REGISTER_RAW_SIZE];
|
|
|
|
register int i;
|
1999-07-07 20:19:36 +00:00
|
|
|
|
1999-04-16 01:35:26 +00:00
|
|
|
for (i = 0; i < REGISTER_RAW_SIZE (regno); i += sizeof (int))
|
|
|
|
{
|
2001-05-04 04:15:33 +00:00
|
|
|
*(int *) &buf[i] = ptrace (PT_RUAREA, PIDGET (inferior_ptid),
|
1999-04-16 01:35:26 +00:00
|
|
|
(PTRACE_ARG3_TYPE) regaddr, 0, 0);
|
|
|
|
regaddr += sizeof (int);
|
|
|
|
}
|
|
|
|
supply_register (regno, buf);
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2000-07-30 01:48:28 +00:00
|
|
|
store_inferior_register_1 (int regno, unsigned int regaddr, int val)
|
1999-04-16 01:35:26 +00:00
|
|
|
{
|
|
|
|
errno = 0;
|
2001-05-04 04:15:33 +00:00
|
|
|
ptrace (PT_WUAREA, PIDGET (inferior_ptid), (PTRACE_ARG3_TYPE) regaddr,
|
|
|
|
val, 0);
|
1999-04-16 01:35:26 +00:00
|
|
|
#if 0
|
|
|
|
/* HP-UX randomly sets errno to non-zero for regno == 25.
|
|
|
|
However, the value is correctly written, so ignore errno. */
|
|
|
|
if (errno != 0)
|
|
|
|
{
|
|
|
|
char string_buf[64];
|
1999-07-07 20:19:36 +00:00
|
|
|
|
1999-04-16 01:35:26 +00:00
|
|
|
sprintf (string_buf, "writing register number %d", regno);
|
|
|
|
perror_with_name (string_buf);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2000-07-30 01:48:28 +00:00
|
|
|
store_inferior_register (register int regno, register unsigned int regaddr)
|
1999-04-16 01:35:26 +00:00
|
|
|
{
|
|
|
|
#ifndef HPUX_VERSION_5
|
|
|
|
if (regno == PS_REGNUM)
|
|
|
|
{
|
1999-07-07 20:19:36 +00:00
|
|
|
union
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
short s[2];
|
|
|
|
}
|
|
|
|
ps_val;
|
|
|
|
|
2001-05-04 04:15:33 +00:00
|
|
|
ps_val.i = (ptrace (PT_RUAREA, PIDGET (inferior_ptid),
|
|
|
|
(PTRACE_ARG3_TYPE) regaddr, 0, 0));
|
1999-04-16 01:35:26 +00:00
|
|
|
ps_val.s[0] = (read_register (regno));
|
|
|
|
store_inferior_register_1 (regno, regaddr, ps_val.i);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
#endif /* not HPUX_VERSION_5 */
|
|
|
|
{
|
|
|
|
register int i;
|
1999-07-07 20:19:36 +00:00
|
|
|
|
1999-04-16 01:35:26 +00:00
|
|
|
for (i = 0; i < REGISTER_RAW_SIZE (regno); i += sizeof (int))
|
|
|
|
{
|
|
|
|
store_inferior_register_1
|
|
|
|
(regno, regaddr,
|
2002-11-14 Andrew Cagney <ac131313@redhat.com>
* regcache.h (deprecated_registers): Rename registers.
* a68v-nat.c, alpha-nat.c, arch-utils.c, core-sol2.c: Update.
* hp300ux-nat.c, hppab-nat.c, hppah-nat.c: Update.
* hppam3-nat.c, hpux-thread.c, i386gnu-nat.c: Update.
* ia64-aix-nat.c, ia64-linux-nat.c, ia64-tdep.c: Update.
* irix4-nat.c, irix5-nat.c, lynx-nat.c, m68k-tdep.c: Update.
* m68knbsd-nat.c, mips-linux-tdep.c, mipsm3-nat.c: Update.
* mipsv4-nat.c, ns32knbsd-nat.c, ppc-bdm.c: Update.
* ppc-sysv-tdep.c, ptx4-nat.c, regcache.c, remote-es.c: Update.
* remote-sds.c, remote-vx68.c, remote-vxmips.c: Update.
* remote-vxsparc.c, rs6000-tdep.c, sol-thread.c: Update.
* sparc-nat.c, sparc-tdep.c, sun3-nat.c, symm-nat.c: Update.
* v850ice.c: Update.
2002-11-14 20:37:29 +00:00
|
|
|
(*(int *) &deprecated_registers[(REGISTER_BYTE (regno)) + i]));
|
1999-04-16 01:35:26 +00:00
|
|
|
regaddr += sizeof (int);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2000-07-30 01:48:28 +00:00
|
|
|
fetch_inferior_registers (int regno)
|
1999-04-16 01:35:26 +00:00
|
|
|
{
|
|
|
|
struct user u;
|
|
|
|
register unsigned int ar0_offset;
|
1999-07-07 20:19:36 +00:00
|
|
|
|
1999-04-16 01:35:26 +00:00
|
|
|
ar0_offset = (INFERIOR_AR0 (u));
|
|
|
|
if (regno == -1)
|
|
|
|
{
|
|
|
|
for (regno = 0; (regno < FP0_REGNUM); regno++)
|
|
|
|
fetch_inferior_register (regno, (REGISTER_ADDR (ar0_offset, regno)));
|
|
|
|
for (; (regno < NUM_REGS); regno++)
|
|
|
|
fetch_inferior_register (regno, (FP_REGISTER_ADDR (u, regno)));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
fetch_inferior_register (regno,
|
|
|
|
(regno < FP0_REGNUM
|
|
|
|
? REGISTER_ADDR (ar0_offset, regno)
|
|
|
|
: FP_REGISTER_ADDR (u, regno)));
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Store our register values back into the inferior.
|
|
|
|
If REGNO is -1, do this for all registers.
|
|
|
|
Otherwise, REGNO specifies which register (so we can save time). */
|
|
|
|
|
|
|
|
void
|
2000-07-30 01:48:28 +00:00
|
|
|
store_inferior_registers (register int regno)
|
1999-04-16 01:35:26 +00:00
|
|
|
{
|
|
|
|
struct user u;
|
|
|
|
register unsigned int ar0_offset;
|
|
|
|
|
|
|
|
if (regno >= FP0_REGNUM)
|
|
|
|
{
|
|
|
|
store_inferior_register (regno, (FP_REGISTER_ADDR (u, regno)));
|
|
|
|
return;
|
|
|
|
}
|
1999-07-07 20:19:36 +00:00
|
|
|
|
1999-04-16 01:35:26 +00:00
|
|
|
ar0_offset = (INFERIOR_AR0 (u));
|
|
|
|
if (regno >= 0)
|
|
|
|
{
|
|
|
|
store_inferior_register (regno, (REGISTER_ADDR (ar0_offset, regno)));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (regno = 0; (regno < FP0_REGNUM); regno++)
|
|
|
|
store_inferior_register (regno, (REGISTER_ADDR (ar0_offset, regno)));
|
|
|
|
for (; (regno < NUM_REGS); regno++)
|
|
|
|
store_inferior_register (regno, (FP_REGISTER_ADDR (u, regno)));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2000-07-30 01:48:28 +00:00
|
|
|
getpagesize (void)
|
1999-04-16 01:35:26 +00:00
|
|
|
{
|
|
|
|
return 4096;
|
|
|
|
}
|