summaryrefslogtreecommitdiffstats
path: root/contrib/gdb/gdb/gdbserver/low-hppabsd.c
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/gdb/gdb/gdbserver/low-hppabsd.c')
-rw-r--r--contrib/gdb/gdb/gdbserver/low-hppabsd.c146
1 files changed, 61 insertions, 85 deletions
diff --git a/contrib/gdb/gdb/gdbserver/low-hppabsd.c b/contrib/gdb/gdb/gdbserver/low-hppabsd.c
index c784d0c..3287923 100644
--- a/contrib/gdb/gdb/gdbserver/low-hppabsd.c
+++ b/contrib/gdb/gdb/gdbserver/low-hppabsd.c
@@ -1,23 +1,24 @@
/* Low level interface to ptrace, for the remote server for GDB.
- Copyright (C) 1995 Free Software Foundation, Inc.
+ Copyright 1995, 1996, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
-This file is part of GDB.
+ 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 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.
+ 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. */
+ 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 "server.h"
#include <sys/wait.h>
#include "frame.h"
#include "inferior.h"
@@ -32,33 +33,20 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include <fcntl.h>
/***************Begin MY defs*********************/
-int quit_flag = 0;
-char registers[REGISTER_BYTES];
-
-/* Index within `registers' of the first byte of the space for
- register N. */
-
-
-char buf2[MAX_REGISTER_RAW_SIZE];
+static char my_registers[REGISTER_BYTES];
+char *registers = my_registers;
/***************End MY defs*********************/
#include <sys/ptrace.h>
#include <machine/reg.h>
-extern char **environ;
extern int errno;
-extern int inferior_pid;
-void quit (), perror_with_name ();
-int query ();
/* Start an inferior process and returns its pid.
- ALLARGS is a vector of program-name and args.
- ENV is the environment vector to pass. */
+ ALLARGS is a vector of program-name and args. */
int
-create_inferior (program, allargs)
- char *program;
- char **allargs;
+create_inferior (char *program, char **allargs)
{
int pid;
@@ -84,19 +72,25 @@ create_inferior (program, allargs)
/* Kill the inferior process. Make us have no inferior. */
void
-kill_inferior ()
+kill_inferior (void)
{
if (inferior_pid == 0)
return;
ptrace (8, inferior_pid, 0, 0, 0);
wait (0);
- /*************inferior_died ();****VK**************/
+/*************inferior_died ();****VK**************/
+}
+
+/* Attaching is not supported. */
+int
+myattach (int pid)
+{
+ return -1;
}
/* Return nonzero if the given thread is still alive. */
int
-mythread_alive (pid)
- int pid;
+mythread_alive (int pid)
{
return 1;
}
@@ -104,13 +98,14 @@ mythread_alive (pid)
/* Wait for process, returns status */
unsigned char
-mywait (status)
- char *status;
+mywait (char *status)
{
int pid;
union wait w;
- pid = wait (&w);
+ enable_async_io ();
+ pid = waitpid (inferior_pid, &w, 0);
+ disable_async_io ();
if (pid != inferior_pid)
perror_with_name ("wait");
@@ -138,9 +133,7 @@ mywait (status)
If SIGNAL is nonzero, give it that signal. */
void
-myresume (step, signal)
- int step;
- int signal;
+myresume (int step, int signal)
{
errno = 0;
ptrace (step ? PT_STEP : PT_CONTINUE, inferior_pid, 1, signal, 0);
@@ -162,13 +155,11 @@ myresume (step, signal)
#endif
CORE_ADDR
-register_addr (regno, blockend)
- int regno;
- CORE_ADDR blockend;
+register_addr (int regno, CORE_ADDR blockend)
{
CORE_ADDR addr;
- if (regno < 0 || regno >= ARCH_NUM_REGS)
+ if (regno < 0 || regno >= NUM_REGS)
error ("Invalid register number %d.", regno);
REGISTER_U_ADDR (addr, blockend, regno);
@@ -179,8 +170,7 @@ register_addr (regno, blockend)
/* Fetch one register. */
static void
-fetch_register (regno)
- int regno;
+fetch_register (int regno)
{
register unsigned int regaddr;
char buf[MAX_REGISTER_RAW_SIZE];
@@ -195,8 +185,8 @@ fetch_register (regno)
for (i = 0; i < REGISTER_RAW_SIZE (regno); i += sizeof (int))
{
errno = 0;
- *(int *) &registers[ regno * 4 + i] = ptrace (PT_RUREGS, inferior_pid,
- (PTRACE_ARG3_TYPE) regaddr, 0, 0);
+ *(int *) &registers[regno * 4 + i] = ptrace (PT_RUREGS, inferior_pid,
+ (PTRACE_ARG3_TYPE) regaddr, 0, 0);
regaddr += sizeof (int);
if (errno != 0)
{
@@ -209,14 +199,13 @@ fetch_register (regno)
goto error_exit;
}
}
- error_exit:;
+error_exit:;
}
/* Fetch all registers, or just one, from the child process. */
void
-fetch_inferior_registers (regno)
- int regno;
+fetch_inferior_registers (int regno)
{
if (regno == -1 || regno == 0)
for (regno = 0; regno < NUM_REGS; regno++)
@@ -230,8 +219,7 @@ fetch_inferior_registers (regno)
Otherwise, REGNO specifies which register (so we can save time). */
void
-store_inferior_registers (regno)
- int regno;
+store_inferior_registers (int regno)
{
register unsigned int regaddr;
char buf[80];
@@ -247,20 +235,20 @@ store_inferior_registers (regno)
regaddr = register_addr (regno, offset);
errno = 0;
if (regno == PCOQ_HEAD_REGNUM || regno == PCOQ_TAIL_REGNUM)
- {
- scratch = *(int *) &registers[REGISTER_BYTE (regno)] | 0x3;
- ptrace (PT_WUREGS, inferior_pid, (PTRACE_ARG3_TYPE) regaddr,
- scratch, 0);
- if (errno != 0)
- {
+ {
+ scratch = *(int *) &registers[REGISTER_BYTE (regno)] | 0x3;
+ ptrace (PT_WUREGS, inferior_pid, (PTRACE_ARG3_TYPE) regaddr,
+ scratch, 0);
+ if (errno != 0)
+ {
/* Error, even if attached. Failing to write these two
- registers is pretty serious. */
- sprintf (buf, "writing register number %d", regno);
- perror_with_name (buf);
- }
- }
+ registers is pretty serious. */
+ sprintf (buf, "writing register number %d", regno);
+ perror_with_name (buf);
+ }
+ }
else
- for (i = 0; i < REGISTER_RAW_SIZE (regno); i += sizeof(int))
+ for (i = 0; i < REGISTER_RAW_SIZE (regno); i += sizeof (int))
{
errno = 0;
ptrace (PT_WUREGS, inferior_pid, (PTRACE_ARG3_TYPE) regaddr,
@@ -276,7 +264,7 @@ store_inferior_registers (regno)
error (msg);
return;
}
- regaddr += sizeof(int);
+ regaddr += sizeof (int);
}
}
else
@@ -293,14 +281,12 @@ store_inferior_registers (regno)
/* Copy LEN bytes from inferior's memory starting at MEMADDR
to debugger memory starting at MYADDR. */
-read_inferior_memory (memaddr, myaddr, len)
- CORE_ADDR memaddr;
- char *myaddr;
- int len;
+void
+read_inferior_memory (CORE_ADDR memaddr, char *myaddr, int len)
{
register int i;
/* Round starting address down to longword boundary. */
- register CORE_ADDR addr = memaddr & -sizeof (int);
+ register CORE_ADDR addr = memaddr & -(CORE_ADDR) sizeof (int);
/* Round ending address up; get number of longwords that makes. */
register int count
= (((memaddr + len) - addr) + sizeof (int) - 1) / sizeof (int);
@@ -323,14 +309,11 @@ read_inferior_memory (memaddr, myaddr, len)
returns the value of errno. */
int
-write_inferior_memory (memaddr, myaddr, len)
- CORE_ADDR memaddr;
- char *myaddr;
- int len;
+write_inferior_memory (CORE_ADDR memaddr, char *myaddr, int len)
{
register int i;
/* Round starting address down to longword boundary. */
- register CORE_ADDR addr = memaddr & -sizeof (int);
+ register CORE_ADDR addr = memaddr & -(CORE_ADDR) sizeof (int);
/* Round ending address up; get number of longwords that makes. */
register int count
= (((memaddr + len) - addr) + sizeof (int) - 1) / sizeof (int);
@@ -367,13 +350,6 @@ write_inferior_memory (memaddr, myaddr, len)
}
void
-initialize ()
-{
- inferior_pid = 0;
-}
-
-int
-have_inferior_p ()
+initialize_low (void)
{
- return inferior_pid != 0;
}
OpenPOWER on IntegriCloud