aboutsummaryrefslogtreecommitdiff
path: root/gnu/usr.bin/binutils/gdbserver
diff options
context:
space:
mode:
authorDoug Rabson <dfr@FreeBSD.org>1999-05-02 19:50:18 +0000
committerDoug Rabson <dfr@FreeBSD.org>1999-05-02 19:50:18 +0000
commite3af075499082c2b683901b0c4fd188cf19ac057 (patch)
treef93a8f37e61ef3d25270b0fbb4f86b1ba1f84dd0 /gnu/usr.bin/binutils/gdbserver
parent3309076f0be223c66d68671073c06ba1727188cf (diff)
Notes
Diffstat (limited to 'gnu/usr.bin/binutils/gdbserver')
-rw-r--r--gnu/usr.bin/binutils/gdbserver/Makefile12
-rw-r--r--gnu/usr.bin/binutils/gdbserver/low-fbsd.c226
2 files changed, 74 insertions, 164 deletions
diff --git a/gnu/usr.bin/binutils/gdbserver/Makefile b/gnu/usr.bin/binutils/gdbserver/Makefile
index 366f1b7396b8..c20ca0511733 100644
--- a/gnu/usr.bin/binutils/gdbserver/Makefile
+++ b/gnu/usr.bin/binutils/gdbserver/Makefile
@@ -1,16 +1,20 @@
-# $Id: Makefile,v 1.2 1997/04/26 17:34:05 pst Exp $
+# $Id: Makefile,v 1.3 1998/05/01 14:48:06 bde Exp $
+
+.include "../Makefile.inc0"
GDBDIR= ${.CURDIR}/../../../../contrib/gdb
.PATH: ${GDBDIR}/gdb/gdbserver
.PATH: ${GDBDIR}/gdb
-.PATH: ${GDBDIR}/opcodes
PROG= gdbserver
SRCS= remote-utils.c utils.c server.c
SRCS+= low-fbsd.c
-CFLAGS+=-I${.CURDIR}/../gdb -I${.CURDIR}/../bfd
-CFLAGS+=-DNO_MMALLOC
+CFLAGS+= -I${.CURDIR}/../gdb/${MACHINE_ARCH}
+CFLAGS+= -I${GDBDIR}/gdb
+CFLAGS+= -I${GDBDIR}/gdb/config
+CFLAGS+= -I${GDBDIR}/gdb/gdbserver
+CFLAGS+= -DNO_MMALLOC
.include <bsd.prog.mk>
diff --git a/gnu/usr.bin/binutils/gdbserver/low-fbsd.c b/gnu/usr.bin/binutils/gdbserver/low-fbsd.c
index bc85f36791fd..090628e7da00 100644
--- a/gnu/usr.bin/binutils/gdbserver/low-fbsd.c
+++ b/gnu/usr.bin/binutils/gdbserver/low-fbsd.c
@@ -30,6 +30,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include <sys/ioctl.h>
#include <sgtty.h>
#include <fcntl.h>
+#include <string.h>
/***************Begin MY defs*********************/
int quit_flag = 0;
@@ -147,126 +148,101 @@ myresume (step, signal)
perror_with_name ("ptrace");
}
+#if defined(__i386__)
-#if !defined (offsetof)
-#define offsetof(TYPE, MEMBER) ((unsigned long) &((TYPE *)0)->MEMBER)
-#endif
+/* this table must line up with REGISTER_NAMES in tm-i386v.h */
+/* symbols like 'tEAX' come from <machine/reg.h> */
+static int tregmap[] =
+{
+ tEAX, tECX, tEDX, tEBX,
+ tESP, tEBP, tESI, tEDI,
+ tEIP, tEFLAGS, tCS, tSS,
+ tDS, tES, tFS, tGS,
+};
-/* U_REGS_OFFSET is the offset of the registers within the u area. */
-#if !defined (U_REGS_OFFSET)
-#define U_REGS_OFFSET \
- ptrace (PT_READ_U, inferior_pid, \
- (PTRACE_ARG3_TYPE) (offsetof (struct user, u_ar0)), 0) \
- - KERNEL_U_ADDR
-#endif
+static struct save87 pcb_savefpu;
-unsigned int
-register_addr (regno, blockend)
+void
+fetch_inferior_registers (regno)
int regno;
- int blockend;
{
- int addr;
+ struct reg inferior_registers; /* ptrace order, not gcc/gdb order */
+ int r;
- if (regno < 0 || regno >= ARCH_NUM_REGS)
- error ("Invalid register number %d.", regno);
+ ptrace (PT_GETREGS, inferior_pid,
+ (PTRACE_ARG3_TYPE) &inferior_registers, 0);
- REGISTER_U_ADDR (addr, blockend, regno);
-
- return addr;
+ for (r = 0; r < NUM_REGS; r++)
+ memcpy (&registers[REGISTER_BYTE (r)], ((int *)&inferior_registers) + tregmap[r], 4);
}
-/* Fetch one register. */
-
-static void
-fetch_register (regno)
+void
+store_inferior_registers (regno)
int regno;
{
- register unsigned int regaddr;
- char buf[MAX_REGISTER_RAW_SIZE];
- register int i;
+ struct reg inferior_registers; /* ptrace order, not gcc/gdb order */
+ int r;
- /* Offset of registers within the u area. */
- unsigned int offset;
+ ptrace (PT_GETREGS, inferior_pid,
+ (PTRACE_ARG3_TYPE) &inferior_registers, 0);
- offset = U_REGS_OFFSET;
+ for (r = 0; r < NUM_REGS; r++)
+ memcpy (((int *)&inferior_registers) + tregmap[r], &registers[REGISTER_BYTE (r)], 4);
- regaddr = register_addr (regno, offset);
- for (i = 0; i < REGISTER_RAW_SIZE (regno); i += sizeof (int))
- {
- errno = 0;
- *(int *) &registers[ regno * sizeof(int) + i] =
- ptrace (PT_READ_U, inferior_pid, (PTRACE_ARG3_TYPE) regaddr, 0);
- regaddr += sizeof (int);
- if (errno != 0)
- {
- /* Warning, not error, in case we are attached; sometimes the
- kernel doesn't let us at the registers. */
- char *err = strerror (errno);
- char *msg = alloca (strlen (err) + 128);
- sprintf (msg, "reading register %d: %s", regno, err);
- error (msg);
- goto error_exit;
- }
- }
- error_exit:;
+ ptrace (PT_SETREGS, inferior_pid,
+ (PTRACE_ARG3_TYPE) &inferior_registers, 0);
}
-/* Fetch all registers, or just one, from the child process. */
+#elif defined(__alpha__)
void
fetch_inferior_registers (regno)
int regno;
{
- if (regno == -1 || regno == 0)
- for (regno = 0; regno < NUM_REGS; regno++)
- fetch_register (regno);
- else
- fetch_register (regno);
-}
+ struct reg regs; /* ptrace order, not gcc/gdb order */
+ struct fpreg fpregs;
+ int r;
-/* 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). */
+ ptrace (PT_GETREGS, inferior_pid, (PTRACE_ARG3_TYPE) &regs, 0);
+ ptrace (PT_GETFPREGS, inferior_pid, (PTRACE_ARG3_TYPE) &fpregs, 0);
+
+ for (r = 0; r < 31; r++)
+ memcpy (&registers[REGISTER_BYTE (r)],
+ &regs.r_regs[r], sizeof(u_int64_t));
+ for (r = 0; r < 32; r++)
+ memcpy (&registers[REGISTER_BYTE (r + FP0_REGNUM)],
+ &fpregs.fpr_regs[r], sizeof(u_int64_t));
+ memcpy (&registers[REGISTER_BYTE (PC_REGNUM)],
+ &regs.r_regs[31], sizeof(u_int64_t));
+
+ memset (&registers[REGISTER_BYTE (ZERO_REGNUM)], 0, sizeof(u_int64_t));
+ memset (&registers[REGISTER_BYTE (FP_REGNUM)], 0, sizeof(u_int64_t));
+}
void
store_inferior_registers (regno)
int regno;
{
- register unsigned int regaddr;
- char buf[80];
- extern char registers[];
- register int i;
- unsigned int offset = U_REGS_OFFSET;
- int scratch;
+ struct reg regs; /* ptrace order, not gcc/gdb order */
+ struct fpreg fpregs;
+ int r;
- if (regno >= 0)
- {
- regaddr = register_addr (regno, offset);
- errno = 0;
- for (i = 0; i < REGISTER_RAW_SIZE (regno); i += sizeof(int))
- {
- errno = 0;
- ptrace (PT_WRITE_U, inferior_pid, (PTRACE_ARG3_TYPE) regaddr,
- *(int *) &registers[REGISTER_BYTE (regno) + i]);
- if (errno != 0)
- {
- /* Warning, not error, in case we are attached; sometimes the
- kernel doesn't let us at the registers. */
- char *err = strerror (errno);
- char *msg = alloca (strlen (err) + 128);
- sprintf (msg, "writing register %d: %s",
- regno, err);
- error (msg);
- return;
- }
- regaddr += sizeof(int);
- }
- }
- else
- for (regno = 0; regno < NUM_REGS; regno++)
- store_inferior_registers (regno);
+ for (r = 0; r < 31; r++)
+ memcpy (&regs.r_regs[r],
+ &registers[REGISTER_BYTE (r)], sizeof(u_int64_t));
+ for (r = 0; r < 32; r++)
+ memcpy (&fpregs.fpr_regs[r],
+ &registers[REGISTER_BYTE (r + FP0_REGNUM)], sizeof(u_int64_t));
+ memcpy (&regs.r_regs[31],
+ &registers[REGISTER_BYTE (PC_REGNUM)], sizeof(u_int64_t));
+
+ ptrace (PT_SETREGS, inferior_pid, (PTRACE_ARG3_TYPE) &regs, 0);
+ ptrace (PT_SETFPREGS, inferior_pid, (PTRACE_ARG3_TYPE) &fpregs, 0);
}
+#endif
+
+
/* NOTE! I tried using PTRACE_READDATA, etc., to read and write memory
in the NEW_SUN_PTRACE case.
It ought to be straightforward. But it appears that writing did
@@ -361,73 +337,3 @@ have_inferior_p ()
{
return inferior_pid != 0;
}
-
-/* Some systems don't provide all the registers on a trap. Use SS as a
- default if so. */
-
-#ifndef tDS
-#define tDS tSS
-#endif
-#ifndef tES
-#define tES tSS
-#endif
-#ifndef tFS
-#define tFS tSS
-#endif
-#ifndef tGS
-#define tGS tSS
-#endif
-
-/* These tables map between the registers on a trap frame, and the register
- order used by the rest of GDB. */
-/* this table must line up with REGISTER_NAMES in tm-i386.h */
-/* symbols like 'tEAX' come from <machine/reg.h> */
-static int tregmap[] =
-{
- tEAX, tECX, tEDX, tEBX,
- tESP, tEBP, tESI, tEDI,
- tEIP, tEFLAGS, tCS, tSS,
- tDS, tES, tFS, tGS
-};
-
-#ifdef sEAX
-static int sregmap[] =
-{
- sEAX, sECX, sEDX, sEBX,
- sESP, sEBP, sESI, sEDI,
- sEIP, sEFLAGS, sCS, sSS
-};
-#else /* No sEAX */
-
-/* FreeBSD has decided to collapse the s* and t* symbols. So if the s*
- ones aren't around, use the t* ones for sregmap too. */
-
-static int sregmap[] =
-{
- tEAX, tECX, tEDX, tEBX,
- tESP, tEBP, tESI, tEDI,
- tEIP, tEFLAGS, tCS, tSS,
- tDS, tES, tFS, tGS
-};
-#endif /* No sEAX */
-
-/* blockend is the value of u.u_ar0, and points to the
- place where ES is stored. */
-
-int
-i386_register_u_addr (blockend, regnum)
- int blockend;
- int regnum;
-{
- /* The following condition is a kludge to get at the proper register map
- depending upon the state of pcb_flag.
- The proper condition would be
- if (u.u_pcb.pcb_flag & FM_TRAP)
- but that would require a ptrace call here and wouldn't work
- for corefiles. */
-
- if (blockend < 0x1fcc)
- return (blockend + 4 * tregmap[regnum]);
- else
- return (blockend + 4 * sregmap[regnum]);
-}