/* Machine-dependent hooks for the unix child process stratum. This
code is for the HP PA-RISC cpu.
- Copyright 1986, 1987, 1989, 1990, 1991, 1992 Free Software Foundation, Inc.
+ Copyright 1986, 1987, 1989, 1990, 1991, 1992, 1993 Free Software Foundation, Inc.
Contributed by the Center for Software Science at the
University of Utah (pa-gdb-bugs@cs.utah.edu).
#include "defs.h"
#include "inferior.h"
+#include "target.h"
+#include <sys/ptrace.h>
+
+#ifdef FIVE_ARG_PTRACE
+
+/* Deal with HPUX 8.0 braindamage. */
+#define ptrace(a,b,c,d) ptrace(a,b,c,d,0)
+
+#endif
#ifndef PT_ATTACH
#define PT_ATTACH PTRACE_ATTACH
#endif
+
#ifndef PT_DETACH
#define PT_DETACH PTRACE_DETACH
#endif
/* This function simply calls ptrace with the given arguments.
It exists so that all calls to ptrace are isolated in this
machine-dependent file. */
-#ifdef WANT_NATIVE_TARGET
+
int
call_ptrace (request, pid, addr, data)
int request, pid;
{
return ptrace (request, pid, addr, data);
}
-#endif /* WANT_NATIVE_TARGET */
#ifdef DEBUG_PTRACE
/* For the rest of the file, use an extra level of indirection */
\f
-#if !defined (FETCH_INFERIOR_REGISTERS)
-
/* KERNEL_U_ADDR is the amount to subtract from u.u_ar0
to get the offset in the core file of the register values. */
#if defined (KERNEL_U_ADDR_BSD)
- KERNEL_U_ADDR
#endif
-/* Registers we shouldn't try to fetch. */
-#if !defined (CANNOT_FETCH_REGISTER)
-#define CANNOT_FETCH_REGISTER(regno) 0
-#endif
-
/* Fetch one register. */
static void
{
register unsigned int regaddr;
char buf[MAX_REGISTER_RAW_SIZE];
- char mess[128]; /* For messages */
register int i;
/* Offset of registers within the u area. */
unsigned int offset;
- if (CANNOT_FETCH_REGISTER (regno))
- {
- bzero (buf, REGISTER_RAW_SIZE (regno)); /* Supply zeroes */
- supply_register (regno, buf);
- return;
- }
-
offset = U_REGS_OFFSET;
regaddr = register_addr (regno, offset);
regaddr += sizeof (int);
if (errno != 0)
{
- sprintf (mess, "reading register %s (#%d)", reg_names[regno], regno);
- perror_with_name (mess);
+ /* Warning, not error, in case we are attached; sometimes the
+ kernel doesn't let us at the registers. */
+ char *err = safe_strerror (errno);
+ char *msg = alloca (strlen (err) + 128);
+ sprintf (msg, "reading register %s: %s", reg_names[regno], err);
+ warning (msg);
+ goto error_exit;
}
}
supply_register (regno, buf);
+ error_exit:;
}
-#endif /* !defined (FETCH_INFERIOR_REGISTERS). */
/* Fetch all registers, or just one, from the child process. */
-#ifndef FETCH_INFERIOR_REGISTERS
void
fetch_inferior_registers (regno)
int regno;
fetch_register (regno);
}
-/* Registers we shouldn't try to store. */
-#if !defined (CANNOT_STORE_REGISTER)
-#define CANNOT_STORE_REGISTER(regno) 0
-#endif
-
/* 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). */
int regno;
{
register unsigned int regaddr;
- char buf[80];
extern char registers[];
register int i;
for (i = 0; i < REGISTER_RAW_SIZE (regno); i += sizeof(int))
{
errno = 0;
- ptrace (PT_WRITE_U, inferior_pid, (PTRACE_ARG3_TYPE) regaddr,
+ ptrace (PT_WUREGS, inferior_pid, (PTRACE_ARG3_TYPE) regaddr,
*(int *) ®isters[REGISTER_BYTE (regno) + i]);
if (errno != 0)
{
- sprintf (buf, "writing register number %d(%d)", regno, i);
- perror_with_name (buf);
+ char *err = safe_strerror (errno);
+ char *msg = alloca (strlen (err) + 128);
+ sprintf (msg, "writing register %s: %s", reg_names[regno], err);
+ warning (msg);
}
regaddr += sizeof(int);
}
{
if (CANNOT_STORE_REGISTER (regno))
continue;
- regaddr = register_addr (regno, offset);
- for (i = 0; i < REGISTER_RAW_SIZE (regno); i += sizeof(int))
- {
- errno = 0;
- ptrace (PT_WRITE_U, inferior_pid, (PTRACE_ARG3_TYPE) regaddr,
- *(int *) ®isters[REGISTER_BYTE (regno) + i]);
- if (errno != 0)
- {
- sprintf (buf, "writing register number %d(%d)", regno, i);
- perror_with_name (buf);
- }
- regaddr += sizeof(int);
- }
+ store_inferior_registers (regno);
}
}
return;
}
-#endif /* !defined(FETCH_INFERIOR_REGISTERS) */
-/* Resume execution of the inferior process.
+/* Resume execution of process PID.
If STEP is nonzero, single-step it.
If SIGNAL is nonzero, give it that signal. */
void
-child_resume (step, signal)
+child_resume (pid, step, signal)
+ int pid;
int step;
int signal;
{
written a new PC value to the child.) */
if (step)
- ptrace (PT_STEP, inferior_pid, (PTRACE_ARG3_TYPE) 1, signal);
+ ptrace (PT_STEP, pid, (PTRACE_ARG3_TYPE) 1, signal);
else
- ptrace (PT_CONTINUE, inferior_pid, (PTRACE_ARG3_TYPE) 1, signal);
+ ptrace (PT_CONTINUE, pid, (PTRACE_ARG3_TYPE) 1, signal);
if (errno)
perror_with_name ("ptrace");