Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/gnu/usr.bin/gdb Add IPKDB support to GDB.
details: https://anonhg.NetBSD.org/src/rev/88206570cb18
branches: trunk
changeset: 484044:88206570cb18
user: ws <ws%NetBSD.org@localhost>
date: Thu Mar 23 20:44:40 2000 +0000
description:
Add IPKDB support to GDB.
diffstat:
gnu/usr.bin/gdb/Makefile | 4 +-
gnu/usr.bin/gdb/remote-ipkdb.c | 753 +++++++++++++++++++++++++++++++++++++++++
2 files changed, 755 insertions(+), 2 deletions(-)
diffs (truncated from 775 to 300 lines):
diff -r a5ff5f02544e -r 88206570cb18 gnu/usr.bin/gdb/Makefile
--- a/gnu/usr.bin/gdb/Makefile Thu Mar 23 20:39:58 2000 +0000
+++ b/gnu/usr.bin/gdb/Makefile Thu Mar 23 20:44:40 2000 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.35 1999/11/26 14:39:47 msaitoh Exp $
+# $NetBSD: Makefile,v 1.36 2000/03/23 20:44:40 ws Exp $
# for OBJECT_FMT
.include <bsd.own.mk>
@@ -44,7 +44,7 @@
c-valprint.c cp-valprint.c ch-valprint.c f-valprint.c m2-valprint.c \
nlmread.c serial.c mdebugread.c os9kread.c top.c utils.c
YYSRCS= c-exp.y f-exp.y jv-exp.y m2-exp.y
-REMOTE_SRCS= remote.c dcache.c remote-utils.c tracepoint.c
+REMOTE_SRCS= remote.c dcache.c remote-utils.c tracepoint.c remote-ipkdb.c
DEPFILES= ${TDEPFILES.${MACHINE_ARCH}} ${XDEPFILES} ${SER_HARDWIRE} \
${NATDEPFILES} ${REMOTE_SRCS} ${SIM_SRCS}
diff -r a5ff5f02544e -r 88206570cb18 gnu/usr.bin/gdb/remote-ipkdb.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gnu/usr.bin/gdb/remote-ipkdb.c Thu Mar 23 20:44:40 2000 +0000
@@ -0,0 +1,753 @@
+/* Remote target communications for NetBSD targets via UDP (aka IPKDB).
+ Copyright (C) 1988-1991 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 Foudation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that is 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., 675 Mass Ave, Cambridge, MA 02139, USA. */
+
+/* Remote communication protocol.
+
+ Data is sent in binary.
+ The first byte is the command code.
+
+ Packets have a sequence number and the data length prepended
+ and a signature appended. The signature is computed according
+ to the HMAC algorithm (see draft-ietf-ipsec-hmac-md5-00.txt).
+ The answer has the same sequence number. On a timeout, packets
+ are rerequested by resending the request.
+
+ Request Packet
+
+ read registers R
+ reply pXX...X Register data is sent in target format.
+ emessage for an error.
+
+ write regs WXX...X Same as above.
+ reply ok for success.
+ emessage for an error.
+
+ read mem MAA...ALL...L AA...A is address, LL...L is length
+ (both as CORE_ADDR).
+ reply pXX...X XX...X is mem contents.
+ emessage for an error.
+
+ write mem NAA...ALL...LXX...X
+ AA...A is address, LL...L is length,
+ XX...X is data.
+ reply ok for success.
+ emessage for an error.
+
+ cont C
+
+ step S
+
+ open debug OII...IWW...W II...I is an arbitrary id of the session,
+ WW...W is the user and machine running gdb.
+
+ There is no immediate reply to step, cont or open.
+ The reply comes when the machines stops (again).
+ It is s
+
+ detach X
+ reply ok
+*/
+
+#include "defs.h"
+#include "command.h"
+#include "gdbcmd.h"
+#include "inferior.h"
+#include "target.h"
+#include "valprint.h"
+#include "wait.h"
+
+#include <string.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/time.h>
+
+#include <netinet/in.h>
+#include <netdb.h>
+
+#include <md5.h>
+
+static struct target_ops ipkdb_ops;
+
+static int ipkdb_desc = -1;
+static char host[512];
+
+#define DBGPORT 1138
+
+#define PBUFSIZ 400
+
+static void remote_send();
+static void putpkt();
+static void getpkt();
+static int startprot();
+static void netread();
+static void netwrite();
+static void trykey();
+
+/* Clean up connection to remote debugger. */
+static void
+ipkdb_close(quitting)
+ int quitting;
+{
+ if (ipkdb_desc >= 0)
+ close(ipkdb_desc);
+ ipkdb_desc = -1;
+}
+
+/* Open a connection to a remote debugger.
+ The argument NAME, being the hostname of the target,
+ may optionally have the HMAC key for this appended. */
+static void
+ipkdb_open(name, from_tty)
+ char *name;
+ int from_tty;
+{
+ struct hostent *he;
+ struct sockaddr_in sin;
+
+ if (name == 0)
+ error(
+"To open a remote debug connection, you need to specify\n\
+the name of the target machine.");
+
+ trykey(name, from_tty);
+ strcpy(host, name);
+
+ ipkdb_close(0);
+
+ if (!(he = gethostbyname(host))
+ || he->h_addrtype != AF_INET)
+ error("host '%s' unknown\n", host);
+
+ target_preopen(from_tty);
+ push_target(&ipkdb_ops);
+
+ if ((ipkdb_desc = socket(AF_INET, SOCK_DGRAM, 0)) < 0)
+ perror_with_name(host);
+
+ sin.sin_len = sizeof sin;
+ sin.sin_family = AF_INET;
+ sin.sin_port = htons(DBGPORT);
+ sin.sin_addr = *(struct in_addr *)he->h_addr;
+
+ if (connect(ipkdb_desc, (struct sockaddr *)&sin, sizeof sin) < 0)
+ perror_with_name(host);
+
+ if (!catch_errors(startprot, NULL,
+ "Couldn't establish connection to remote target\n",
+ RETURN_MASK_ALL))
+ pop_target();
+ else if (from_tty)
+ printf_filtered("Remote debugging on %s\n", name);
+}
+
+/* Close the open connection to the remote debugger.
+ Use this when you want to detach and do something else
+ with your gdb. */
+static void
+ipkdb_detach(args, from_tty)
+ char *args;
+ int from_tty;
+{
+ char buf[PBUFSIZ];
+ int l;
+
+ *buf = 'X';
+ l = 1;
+ remote_send(buf, &l);
+ pop_target();
+ if (from_tty)
+ puts_filtered("Ending remote debugging IPKDB.\n");
+}
+
+/* Tell the remote machine to resume. */
+static void
+ipkdb_resume(pid, step, ssignal)
+ int pid, step;
+ enum target_signal ssignal;
+{
+ if (ssignal != TARGET_SIGNAL_0)
+ error("Can't send signals to a remote IPKDB system.");
+
+ putpkt(step ? "S" : "C", 1);
+}
+
+/* Wait until the remote machine stops, then return. */
+static int
+ipkdb_wait(pid, status)
+ int pid;
+ struct target_waitstatus *status;
+{
+ unsigned char buf[PBUFSIZ];
+ int l;
+
+ getpkt(buf, &l);
+ if (l > 0 && buf[0] == 'e') {
+ buf[l] = 0;
+ error("Remote failure reply: '%s'", buf + 1);
+ }
+ if (buf[0] != 's')
+ error("Invalid remote reply: '%s'", buf);
+ status->kind = TARGET_WAITKIND_STOPPED;
+ status->value.sig = TARGET_SIGNAL_TRAP;
+
+ return 0;
+}
+
+/* Read the remote registers. */
+static void
+ipkdb_fetch_register(regno)
+ int regno;
+{
+ char buf[PBUFSIZ];
+ int l;
+
+ *buf = 'R';
+ l = 1;
+ remote_send(buf, &l);
+
+ /* Reply describes registers byte by byte.
+ Suck them all up, and supply them to the
+ register cacheing/storage mechanism. */
+ for (l = 0; l < NUM_REGS; l++)
+ supply_register(l, &buf[1 + REGISTER_BYTE(l)]);
+}
+
+/* Prepare to store registers. Since we send them all, we have to
+ read out the ones we don't want to change first. */
+static void
+ipkdb_prepare_to_store()
+{
+ ipkdb_fetch_register(-1);
+}
+
+/* Store the remote registers. */
+static void
+ipkdb_store_register(regno)
+ int regno;
+{
+ char buf[PBUFSIZ];
+ int l;
+
+ buf[0] = 'W';
+
+ memcpy(buf + 1, registers, REGISTER_BYTES);
+ l = 1 + REGISTER_BYTES;
+
+ remote_send(buf, &l);
+}
+
+/* Put addr into buf */
+static void
+addrput(addr, buf)
+ CORE_ADDR addr;
+ char *buf;
+{
+ int i;
+
+ buf += sizeof addr;
+ for (i = sizeof addr; --i >= 0; addr >>= 8)
+ *--buf = addr;
+}
+
+/* Write memory data directly to the remote machine. */
+static void
+ipkdb_write_bytes(memaddr, myaddr, len)
+ CORE_ADDR memaddr;
+ char *myaddr;
+ int len;
+{
+ char buf[PBUFSIZ];
+
+ *buf = 'N';
Home |
Main Index |
Thread Index |
Old Index