/* Machine-dependent code which would otherwise be in infptrace.c,
for GDB, the GNU debugger. This code is for the HP PA-RISC cpu.
- Copyright (C) 1986, 1987, 1989, 1990, 1991 Free Software Foundation, Inc.
+ Copyright 1986, 1987, 1989, 1990, 1991, 1992 Free Software Foundation, Inc.
Contributed by the Center for Software Science at the
University of Utah (pa-gdb-bugs@cs.utah.edu).
-/* Low level Unix child interface to ptrace, for GDB when running under Unix.
- Copyright (C) 1988, 1989, 1990, 1991 Free Software Foundation, Inc.
-
This file is part of GDB.
This program is free software; you can redistribute it and/or modify
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
-#include <stdio.h>
#include "defs.h"
#include "frame.h"
#include "inferior.h"
machine-dependent file. */
int
call_ptrace (request, pid, addr, data)
- int request, pid, *addr, data;
+ int request, pid;
+ PTRACE_ARG3_TYPE addr;
+ int data;
{
return ptrace (request, pid, addr, data, 0);
}
{
if (inferior_pid == 0)
return;
- ptrace (PT_EXIT, inferior_pid, 0, 0, 0); /* PT_EXIT = PT_KILL ? */
+ ptrace (PT_EXIT, inferior_pid, (PTRACE_ARG3_TYPE) 0, 0, 0); /* PT_EXIT = PT_KILL ? */
wait ((int *)0);
}
{
errno = 0;
- /* An address of (int *)1 tells ptrace to continue from where it was.
- (If GDB wanted it to start some other way, we have already written
- a new PC value to the child.) */
+ /* An address of (PTRACE_ARG3_TYPE) 1 tells ptrace to continue from where
+ it was. (If GDB wanted it to start some other way, we have already
+ written a new PC value to the child.) */
if (step)
- ptrace (PT_SINGLE, inferior_pid, (int *)1, signal, 0);
+ ptrace (PT_SINGLE, inferior_pid, (PTRACE_ARG3_TYPE) 1, signal, 0);
else
- ptrace (PT_CONTIN, inferior_pid, (int *)1, signal, 0);
+ ptrace (PT_CONTIN, inferior_pid, (PTRACE_ARG3_TYPE) 1, signal, 0);
if (errno)
perror_with_name ("ptrace");
int pid;
{
errno = 0;
- ptrace (PT_ATTACH, pid, 0, 0, 0);
+ ptrace (PT_ATTACH, pid, (PTRACE_ARG3_TYPE) 0, 0, 0);
if (errno)
perror_with_name ("ptrace");
attach_flag = 1;
int signal;
{
errno = 0;
- ptrace (PT_DETACH, inferior_pid, 1, signal, 0);
+ ptrace (PT_DETACH, inferior_pid, (PTRACE_ARG3_TYPE) 1, signal, 0);
if (errno)
perror_with_name ("ptrace");
attach_flag = 0;
#if !defined (U_REGS_OFFSET)
#define U_REGS_OFFSET \
ptrace (PT_READ_U, inferior_pid, \
- (int *)(offsetof (struct user, u_ar0)), 0, 0) - KERNEL_U_ADDR
+ (PTRACE_ARG3_TYPE) (offsetof (struct user, u_ar0)), 0, 0) \
+ - KERNEL_U_ADDR
#endif
/* Registers we shouldn't try to fetch. */
for (i = 0; i < REGISTER_RAW_SIZE (regno); i += sizeof (int))
{
errno = 0;
- *(int *) &buf[i] = ptrace (PT_RUREGS, inferior_pid, (int *)regaddr, 0, 0);
+ *(int *) &buf[i] = ptrace (PT_RUREGS, inferior_pid,
+ (PTRACE_ARG3_TYPE) regaddr, 0, 0);
regaddr += sizeof (int);
if (errno != 0)
{
for (i = 0; i < REGISTER_RAW_SIZE (regno); i += sizeof(int))
{
errno = 0;
- ptrace (PT_WUAREA, inferior_pid, (int *)regaddr,
+ ptrace (PT_WUAREA, inferior_pid, (PTRACE_ARG3_TYPE) regaddr,
*(int *) ®isters[REGISTER_BYTE (regno) + i], 0);
if (errno != 0)
{
for (i = 0; i < REGISTER_RAW_SIZE (regno); i += sizeof(int))
{
errno = 0;
- ptrace (PT_WUAREA, inferior_pid, (int *)regaddr,
+ ptrace (PT_WUAREA, inferior_pid, (PTRACE_ARG3_TYPE) regaddr,
*(int *) ®isters[REGISTER_BYTE (regno) + i], 0);
if (errno != 0)
{
if (addr != memaddr || len < (int)sizeof (int)) {
/* Need part of initial word -- fetch it. */
- buffer[0] = ptrace (PT_RIUSER, inferior_pid, (int *)addr, 0, 0);
+ buffer[0] = ptrace (PT_RIUSER, inferior_pid,
+ (PTRACE_ARG3_TYPE) addr, 0, 0);
}
if (count > 1) /* FIXME, avoid if even boundary */
{
buffer[count - 1]
= ptrace (PT_RIUSER, inferior_pid,
- (int *)(addr + (count - 1) * sizeof (int)), 0, 0);
+ (PTRACE_ARG3_TYPE) (addr + (count - 1) * sizeof (int)),
+ 0, 0);
}
/* Copy data to be written over corresponding part of buffer */
for (i = 0; i < count; i++, addr += sizeof (int))
{
+#if 0
+/* The HP-UX kernel crashes if you use PT_WDUSER to write into the text
+ segment. FIXME -- does it work to write into the data segment using
+ WIUSER, or do these idiots really expect us to figure out which segment
+ the address is in, so we can use a separate system call for it??! */
errno = 0;
- ptrace (PT_WDUSER, inferior_pid, (int *)addr, buffer[i], 0);
+ ptrace (PT_WDUSER, inferior_pid, (PTRACE_ARG3_TYPE) addr,
+ buffer[i], 0);
if (errno)
+#endif
{
/* Using the appropriate one (I or D) is necessary for
Gould NP1, at least. */
errno = 0;
- ptrace (PT_WIUSER, inferior_pid, (int *)addr, buffer[i], 0);
+ ptrace (PT_WIUSER, inferior_pid, (PTRACE_ARG3_TYPE) addr,
+ buffer[i], 0);
}
if (errno)
return 0;
for (i = 0; i < count; i++, addr += sizeof (int))
{
errno = 0;
- buffer[i] = ptrace (PT_RIUSER, inferior_pid, (int *)addr, 0, 0);
+ buffer[i] = ptrace (PT_RIUSER, inferior_pid,
+ (PTRACE_ARG3_TYPE) addr, 0, 0);
if (errno)
return 0;
QUIT;