2000-02-10 J.T. Conklin <jtc@redback.com>

* config/i386/nbsd.mt (GDBSERVER_DEPFILES): Add low-nbsd.o
	* configure.tgt (i[3456]86-*-netbsd*): add gdbserver to
 	configdirs.
	* gdbserver/low-nbsd.c: New file.

	* gdbserver/Makefile.in: convert to autoconf.
	* gdbserver/configure.in: likewise.
	* gdbserver/configure: generate.
This commit is contained in:
Jim Kingdon 2000-02-13 01:06:58 +00:00
parent 41c8e0096b
commit d6e9fb0513
7 changed files with 1500 additions and 88 deletions

View File

@ -1,3 +1,14 @@
2000-02-10 J.T. Conklin <jtc@redback.com>
* config/i386/nbsd.mt (GDBSERVER_DEPFILES): Add low-nbsd.o
* configure.tgt (i[3456]86-*-netbsd*): add gdbserver to
configdirs.
* gdbserver/low-nbsd.c: New file.
* gdbserver/Makefile.in: convert to autoconf.
* gdbserver/configure.in: likewise.
* gdbserver/configure: generate.
Sun Feb 13 11:21:00 2000 Andrew Cagney <cagney@b1.cygnus.com>
* CONTRIBUTE: New file. How to contribute to GDB.

View File

@ -1,3 +1,5 @@
# Target: Intel 386 running NetBSD
TDEPFILES= i386-tdep.o i387-tdep.o solib.o
TM_FILE= tm-nbsd.h
GDBSERVER_DEPFILES= low-nbsd.o

View File

@ -86,7 +86,8 @@ i[3456]86-*-elf*) gdb_target=embed ;;
i[3456]86-*-aix*) gdb_target=i386aix ;;
i[3456]86-*-bsd*) gdb_target=i386bsd ;;
i[3456]86-*-freebsd*) gdb_target=fbsd ;;
i[3456]86-*-netbsd*) gdb_target=nbsd ;;
i[3456]86-*-netbsd*) gdb_target=nbsd
configdirs="${configdirs} gdbserver" ;;
i[3456]86-*-os9k) gdb_target=i386os9k ;;
i[3456]86-*-go32*) gdb_target=i386aout ;;
i[3456]86-*-msdosdjgpp*) gdb_target=go32 ;;

View File

@ -1,4 +1,4 @@
#Copyright 1989, 90, 91, 92, 93, 94, 95, 96, 1997
#Copyright 1989, 90, 91, 92, 93, 94, 95, 96, 97, 99, 2000
#Free Software Foundation, Inc.
# This file is part of GDB.
@ -17,16 +17,18 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
prefix = /usr/local
prefix = @prefix@
exec_prefix = @exec_prefix@
program_transform_name =
exec_prefix = $(prefix)
bindir = $(exec_prefix)/bin
libdir = $(exec_prefix)/lib
host_alias = @host_alias@
target_alias = @target_alias@
program_transform_name = @program_transform_name@
bindir = @bindir@
libdir = @libdir@
tooldir = $(libdir)/$(target_alias)
datadir = $(prefix)/share
mandir = $(prefix)/man
datadir = @datadir@
mandir = @mandir@
man1dir = $(mandir)/man1
man2dir = $(mandir)/man2
man3dir = $(mandir)/man3
@ -36,15 +38,15 @@ man6dir = $(mandir)/man6
man7dir = $(mandir)/man7
man8dir = $(mandir)/man8
man9dir = $(mandir)/man9
infodir = $(prefix)/info
infodir = @infodir@
htmldir = $(prefix)/html
includedir = $(prefix)/include
includedir = @includedir@
SHELL = /bin/sh
INSTALL = `cd $(srcdir)/../..;pwd`/install-sh -c
INSTALL_PROGRAM = $(INSTALL)
INSTALL_DATA = $(INSTALL)
INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_DATA = @INSTALL_DATA@
AR = ar
AR_FLAGS = qv
@ -61,7 +63,8 @@ GCC=gcc
# Directory containing source files. Don't clean up the spacing,
# this exact string is matched for by the "configure" script.
srcdir = .
srcdir = @srcdir@
VPATH = @srcdir@
# It is also possible that you will need to add -I/usr/include/sys to the
# CFLAGS section if your system doesn't have fcntl.h in /usr/include (which
@ -117,14 +120,16 @@ LINT=/usr/5bin/lint
LINTFLAGS= $(BFD_CFLAGS)
# Host and target-dependent makefile fragments come in here.
####
@host_makefile_frag@
@target_makefile_frag@
# End of host and target-dependent makefile fragments
# All source files that go into linking GDB remote server.
SFILES = $(srcdir)/low-lynx.c $(srcdir)/low-sparc.c $(srcdir)/low-sun3.c \
$(srcdir)/low-hppabsd.c \
$(srcdir)/utils.c $(srcdir)/server.c $(srcdir)/remote-utils.c
SFILES = $(srcdir)/low-hppabsd.c $(srcdir)/low-linux.c $(srcdir)/low-lynx.c \
$(srcdir)/low-nbsd.c $(srcdir)/low-sim.c $(srcdir)/low-sparc.c \
$(srcdir)/low-sun3.c $(srcdir)/utils.c $(srcdir)/server.c \
$(srcdir)/remote-utils.c
DEPFILES = $(GDBSERVER_DEPFILES)
@ -175,10 +180,6 @@ gdbreplay: gdbreplay.o
${CC-LD} $(GLOBAL_CFLAGS) $(LDFLAGS) -o gdbreplay gdbreplay.o \
$(XM_CLIBS)
config.status:
@echo "You must configure gdbserver. Look at the README file for details."
@false
# Put the proper machine-specific files first, so M-. on a machine
# specific routine gets the one for the correct machine.
# The xyzzy stuff below deals with empty DEPFILES
@ -196,7 +197,7 @@ tags: TAGS
clean:
rm -f *.o ${ADD_FILES} *~
rm -f gdbserver core make.log
rm -f gdbserver gdbreplay core make.log
distclean: clean
rm -f nm.h tm.h xm.h config.status
@ -208,9 +209,12 @@ maintainer-clean realclean: clean
STAGESTUFF=${OBS} ${TSOBS} ${NTSOBS} ${ADD_FILES} init.c init.o version.c gdb
Makefile: $(srcdir)/Makefile.in $(host_makefile_frag) $(target_makefile_frag)
Makefile: Makefile.in config.status @frags@
$(SHELL) ./config.status
config.status: configure
$(SHELL) ./config.status --recheck
force:
version.c: Makefile
@ -236,6 +240,7 @@ server.o : ${srcdir}/server.c ${srcdir}/server.h
remote-utils.o : ${srcdir}/remote-utils.c ${srcdir}/server.h
low-linux.o : ${srcdir}/low-linux.c ${srcdir}/server.h
low-lynx.o : ${srcdir}/low-lynx.c ${srcdir}/server.h
low-nbsd.o : ${srcdir}/low-nbsd.c ${srcdir}/server.h
low-sim.o : ${srcdir}/low-sim.c ${srcdir}/server.h
low-sparc.o : $(srcdir)/low-sparc.c $(srcdir)/server.h
low-sun3.o : $(srcdir)/low-sun3.c $(srcdir)/server.h

1078
gdb/gdbserver/configure vendored Executable file

File diff suppressed because it is too large Load Diff

View File

@ -1,46 +1,65 @@
srcname="Remote GDB server"
srctrigger=server.c
gdb_serial_driver=../ser-unix.c
dnl Autoconf configure script for GDB server.
dnl Copyright 2000 Free Software Foundation, Inc.
dnl
dnl This file is part of GDB.
dnl
dnl This program is free software; you can redistribute it and/or modify
dnl it under the terms of the GNU General Public License as published by
dnl the Free Software Foundation; either version 2 of the License, or
dnl (at your option) any later version.
dnl
dnl This program is distributed in the hope that it will be useful,
dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
dnl GNU General Public License for more details.
dnl
dnl You should have received a copy of the GNU General Public License
dnl along with this program; if not, write to the Free Software
dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# per-host:
dnl Process this file with autoconf to produce a configure script.
AC_INIT(server.c)
AC_CANONICAL_SYSTEM
AC_PROG_INSTALL
. ${srcdir}/../configure.host
echo "gdbserver/configure.in: host is $host, target is $target"
if [ ! -f ${srcdir}/../config/${gdb_host_cpu}/${gdb_host}.mh ]; then
echo '***' "GDB remote does not support host ${host}" 1>&2
exit 1
fi
# We really shouldn't depend on there being a space after XM_FILE= ...
hostfile=`awk '$1 == "XM_FILE=" { print $2 }' <${srcdir}/../config/${gdb_host_cpu}/${gdb_host}.mh`
# per-target:
. ${srcdir}/../configure.tgt
echo "gdbserver/configure.in: host_cpu is $host_cpu, target_cpu is $target_cpu"
if [ ! -f ${srcdir}/../config/${gdb_target_cpu}/${gdb_target}.mt ]; then
echo '***' "GDB remote does not support target ${target}" 1>&2
exit 1
frags=
host_makefile_frag=${srcdir}/../config/${gdb_host_cpu}/${gdb_host}.mh
if test ! -f ${host_makefile_frag}; then
AC_MSG_ERROR("*** GDB remote does not support host ${host}")
fi
frags="$frags $host_makefile_frag"
if [ -z "${removing}" ] ; then
cat ${srcdir}/../config/${gdb_host_cpu}/${gdb_host}.mh ${srcdir}/../config/${gdb_target_cpu}/${gdb_target}.mt | awk '$1 == "#msg" {
print substr($0,6)}'
target_makefile_frag=${srcdir}/../config/${gdb_target_cpu}/${gdb_target}.mt
if test ! -f ${target_makefile_frag}; then
AC_MSG_ERROR("*** GDB remote does not support target ${target}")
fi
frags="$frags $target_makefile_frag"
# We really shouldn't depend on there being a space after TM_FILE= ...
targetfile=`awk '$1 == "TM_FILE=" { print $2 }' <${srcdir}/../config/${gdb_target_cpu}/${gdb_target}.mt`
AC_SUBST_FILE(host_makefile_frag)
AC_SUBST_FILE(target_makefile_frag)
AC_SUBST(frags)
if [ "${target}" = "${host}" ] ; then
nativefile=`awk '$1 == "NAT_FILE=" { print $2 }' <${srcdir}/../config/${gdb_host_cpu}/${gdb_host}.mh`
changequote(,)dnl
hostfile=`sed -n '
s/XM_FILE[ ]*=[ ]*\([^ ]*\)/\1/p
' ${host_makefile_frag}`
targetfile=`sed -n '
s/TM_FILE[ ]*=[ ]*\([^ ]*\)/\1/p
' ${target_makefile_frag}`
if test "${target}" = "${host}"; then
nativefile=`sed -n '
s/NAT_FILE[ ]*=[ ]*\([^ ]*\)/\1/p
' ${host_makefile_frag}`
fi
host_makefile_frag=../config/${gdb_host_cpu}/${gdb_host}.mh
target_makefile_frag=../config/${gdb_target_cpu}/${gdb_target}.mt
changequote([,])dnl
# If hostfile (XM_FILE) and/or targetfile (TM_FILE) and/or nativefile
# (NAT_FILE) is not set in the ?config/* file, we don't make the
@ -52,33 +71,18 @@ files=
links=
rm -f xm.h
rm -f ser-hardwire.c
if [ "${hostfile}" != "" ]; then
if [ -f ${srcdir}/../config/${hostfile} ]; then
files="${files} ../config/${hostfile}"
else
files="${files} ../config/${gdb_host_cpu}/${hostfile}"
fi
if test "${hostfile}" != ""; then
files="${files} ../config/${gdb_host_cpu}/${hostfile}"
links="${links} xm.h"
# files="${files} ${gdb_serial_driver}"
# links="${links} ser-hardwire.c"
fi
rm -f tm.h
if [ "${targetfile}" != "" ]; then
if [ -f ${srcdir}/../config/${targetfile} ]; then
files="${files} ../config/${targetfile}"
else
files="${files} ../config/${gdb_target_cpu}/${targetfile}"
fi
if test "${targetfile}" != ""; then
files="${files} ../config/${gdb_target_cpu}/${targetfile}"
links="${links} tm.h"
fi
rm -f nm.h
if [ "${nativefile}" != "" ]; then
if [ -f ${srcdir}/../config/${nativefile} ]; then
files="${files} ../config/${nativefile}"
else
files="${files} ../config/${gdb_host_cpu}/${nativefile}"
fi
if test "${nativefile}" != ""; then
files="${files} ../config/${gdb_host_cpu}/${nativefile}"
links="${links} nm.h"
# temporary scaffolding until all hosts have the host/target/native
# split in place.
@ -86,15 +90,6 @@ else
files="${files} ../config/nm-empty.h"
links="${links} nm.h"
fi
AC_LINK_FILES($files, $links)
if [ ${target_cpu} = "sparclite" ]; then
configdirs="${configdirs} sparclite"
fi
# post-target:
if [ "${nativefile}" = "" ] ; then
sed -e '/^NATDEPFILES= /s//# NATDEPFILES= /' \
< Makefile > Makefile.tem
mv -f Makefile.tem Makefile
fi
AC_OUTPUT(Makefile)

320
gdb/gdbserver/low-nbsd.c Normal file
View File

@ -0,0 +1,320 @@
/* Low level interface to ptrace, for the remote server for GDB.
Copyright (C) 1986, 1987, 1993, 2000 Free Software Foundation, Inc.
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 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. */
#include "defs.h"
#include <sys/types.h>
#include <sys/wait.h>
#include "frame.h"
#include "inferior.h"
#include <stdio.h>
#include <errno.h>
/***************Begin MY defs*********************/
int quit_flag = 0;
static char my_registers[REGISTER_BYTES];
char *registers = my_registers;
/* Index within `registers' of the first byte of the space for
register N. */
char buf2[MAX_REGISTER_RAW_SIZE];
/***************End MY defs*********************/
#include <sys/ptrace.h>
#include <machine/reg.h>
extern int sys_nerr;
// extern char **sys_errlist;
extern char **environ;
extern int inferior_pid;
void quit (), perror_with_name ();
#ifdef TM_I386_H
/* i386_register_raw_size[i] is the number of bytes of storage in the
actual machine representation for register i. */
int i386_register_raw_size[MAX_NUM_REGS] = {
4, 4, 4, 4,
4, 4, 4, 4,
4, 4, 4, 4,
4, 4, 4, 4,
10, 10, 10, 10,
10, 10, 10, 10,
4, 4, 4, 4,
4, 4, 4, 4,
16, 16, 16, 16,
16, 16, 16, 16,
4
};
int i386_register_byte[MAX_NUM_REGS];
static void
initialize_arch()
{
/* Initialize the table saying where each register starts in the
register file. */
{
int i, offset;
offset = 0;
for (i = 0; i < MAX_NUM_REGS; i++)
{
i386_register_byte[i] = offset;
offset += i386_register_raw_size[i];
}
}
}
#endif
/* Start an inferior process and returns its pid.
ALLARGS is a vector of program-name and args.
ENV is the environment vector to pass. */
int
create_inferior (program, allargs)
char *program;
char **allargs;
{
int pid;
pid = fork ();
if (pid < 0)
perror_with_name ("fork");
if (pid == 0)
{
ptrace (PT_TRACE_ME, 0, 0, 0);
execv (program, allargs);
fprintf (stderr, "Cannot exec %s: %s.\n", program,
errno < sys_nerr ? sys_errlist[errno] : "unknown error");
fflush (stderr);
_exit (0177);
}
return pid;
}
/* Kill the inferior process. Make us have no inferior. */
void
kill_inferior ()
{
if (inferior_pid == 0)
return;
ptrace (PT_KILL, inferior_pid, 0, 0);
wait (0);
/*************inferior_died ();****VK**************/
}
/* Return nonzero if the given thread is still alive. */
int
mythread_alive (pid)
int pid;
{
return 1;
}
/* Wait for process, returns status */
unsigned char
mywait (status)
char *status;
{
int pid;
int w;
pid = wait (&w);
if (pid != inferior_pid)
perror_with_name ("wait");
if (WIFEXITED (w))
{
fprintf (stderr, "\nChild exited with retcode = %x \n", WEXITSTATUS (w));
*status = 'W';
return ((unsigned char) WEXITSTATUS (w));
}
else if (!WIFSTOPPED (w))
{
fprintf (stderr, "\nChild terminated with signal = %x \n", WTERMSIG (w));
*status = 'X';
return ((unsigned char) WTERMSIG (w));
}
fetch_inferior_registers (0);
*status = 'T';
return ((unsigned char) WSTOPSIG (w));
}
/* Resume execution of the inferior process.
If STEP is nonzero, single-step it.
If SIGNAL is nonzero, give it that signal. */
void
myresume (step, signal)
int step;
int signal;
{
errno = 0;
ptrace (step ? PT_STEP : PT_CONTINUE, inferior_pid,
(PTRACE_ARG3_TYPE) 1, signal);
if (errno)
perror_with_name ("ptrace");
}
/* Fetch one or more registers from the inferior. REGNO == -1 to get
them all. We actually fetch more than requested, when convenient,
marking them as valid so we won't fetch them again. */
void
fetch_inferior_registers (ignored)
int ignored;
{
struct reg inferior_registers;
struct fpreg inferior_fp_registers;
ptrace (PT_GETREGS, inferior_pid,
(PTRACE_ARG3_TYPE) &inferior_registers, 0);
memcpy (&registers[REGISTER_BYTE(0)], &inferior_registers,
sizeof(inferior_registers));
#if 0 /* def FP0_REGNUM */
ptrace (PT_GETFPREGS, inferior_pid,
(PTRACE_ARG3_TYPE) &inferior_fp_registers, 0);
memcpy (&registers[REGISTER_BYTE(FP0_REGNUM)], &inferior_fp_registers,
sizeof(inferior_fp_registers));
#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). */
void
store_inferior_registers (ignored)
int ignored;
{
struct reg inferior_registers;
struct fpreg inferior_fp_registers;
memcpy (&inferior_registers, &registers[REGISTER_BYTE(0)],
sizeof(inferior_registers));
ptrace (PT_SETREGS, inferior_pid,
(PTRACE_ARG3_TYPE) &inferior_registers, 0);
#if 0 /* def FP0_REGNUM */
memcpy (&inferior_fp_registers, &registers[REGISTER_BYTE (FP0_REGNUM)],
sizeof (inferior_fp_registers));
ptrace (PT_SETFPREGS, inferior_pid,
(PTRACE_ARG3_TYPE) &inferior_fp_registers, 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
not write the data that I specified. I cannot understand where
it got the data that it actually did write. */
/* 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;
{
register int i;
/* Round starting address down to longword boundary. */
register CORE_ADDR addr = memaddr & -sizeof (int);
/* Round ending address up; get number of longwords that makes. */
register int count
= (((memaddr + len) - addr) + sizeof (int) - 1) / sizeof (int);
/* Allocate buffer of that many longwords. */
register int *buffer = (int *) alloca (count * sizeof (int));
/* Read all the longwords */
for (i = 0; i < count; i++, addr += sizeof (int))
{
buffer[i] = ptrace (PT_READ_D, inferior_pid, (PTRACE_ARG3_TYPE) addr, 0);
}
/* Copy appropriate bytes out of the buffer. */
memcpy (myaddr, (char *) buffer + (memaddr & (sizeof (int) - 1)), len);
}
/* Copy LEN bytes of data from debugger memory at MYADDR
to inferior's memory at MEMADDR.
On failure (cannot write the inferior)
returns the value of errno. */
int
write_inferior_memory (memaddr, myaddr, len)
CORE_ADDR memaddr;
char *myaddr;
int len;
{
register int i;
/* Round starting address down to longword boundary. */
register CORE_ADDR addr = memaddr & -sizeof (int);
/* Round ending address up; get number of longwords that makes. */
register int count
= (((memaddr + len) - addr) + sizeof (int) - 1) / sizeof (int);
/* Allocate buffer of that many longwords. */
register int *buffer = (int *) alloca (count * sizeof (int));
extern int errno;
/* Fill start and end extra bytes of buffer with existing memory data. */
buffer[0] = ptrace (PT_READ_D, inferior_pid, (PTRACE_ARG3_TYPE) addr, 0);
if (count > 1)
{
buffer[count - 1]
= ptrace (PT_READ_D, inferior_pid,
(PTRACE_ARG3_TYPE) addr + (count - 1) * sizeof (int), 0);
}
/* Copy data to be written over corresponding part of buffer */
memcpy ((char *) buffer + (memaddr & (sizeof (int) - 1)), myaddr, len);
/* Write the entire buffer. */
for (i = 0; i < count; i++, addr += sizeof (int))
{
errno = 0;
ptrace (PT_WRITE_D, inferior_pid, (PTRACE_ARG3_TYPE) addr, buffer[i]);
if (errno)
return errno;
}
return 0;
}
void
initialize_low ()
{
initialize_arch ();
}