/* Remote target communications for serial-line targets using SDS' protocol.
- Copyright 1997 Free Software Foundation, Inc.
+ Copyright 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
This file is part of GDB.
#include "bfd.h"
#include "symfile.h"
#include "target.h"
-#include "gdb_wait.h"
#include "gdbcmd.h"
#include "objfiles.h"
#include "gdb-stabs.h"
#include "gdbthread.h"
#include "gdbcore.h"
-#include "dcache.h"
+#include "regcache.h"
#ifdef USG
#include <sys/types.h>
static void sds_files_info (struct target_ops *ignore);
-static int sds_xfer_memory (CORE_ADDR, char *, int, int, struct target_ops *);
+static int sds_xfer_memory (CORE_ADDR, char *, int, int,
+ struct mem_attrib *, struct target_ops *);
static void sds_prepare_to_store (void);
static void sds_fetch_registers (int);
-static void sds_resume (int, int, enum target_signal);
+static void sds_resume (ptid_t, int, enum target_signal);
static int sds_start_remote (PTR);
static int readchar (int);
-static int sds_wait (int, struct target_waitstatus *);
+static ptid_t sds_wait (ptid_t, struct target_waitstatus *);
static void sds_kill (void);
/* ARGSUSED */
static void
-sds_close (quitting)
- int quitting;
+sds_close (int quitting)
{
if (sds_desc)
SERIAL_CLOSE (sds_desc);
/* Stub for catch_errors. */
static int
-sds_start_remote (dummy)
- PTR dummy;
+sds_start_remote (PTR dummy)
{
- char c;
+ int c;
unsigned char buf[200];
- immediate_quit = 1; /* Allow user to interrupt it */
+ immediate_quit++; /* Allow user to interrupt it */
/* Ack any packet which the remote side has already sent. */
SERIAL_WRITE (sds_desc, "{#*\r\n", 5);
buf[0] = 0;
sds_send (buf, 1);
- immediate_quit = 0;
+ immediate_quit--;
start_remote (); /* Initialize gdb process mechanisms */
return 1;
/* Open a connection to a remote debugger.
NAME is the filename used for communication. */
-static DCACHE *sds_dcache;
-
static void
-sds_open (name, from_tty)
- char *name;
- int from_tty;
+sds_open (char *name, int from_tty)
{
if (name == 0)
error ("To open a remote debug connection, you need to specify what serial\n\
unpush_target (&sds_ops);
- sds_dcache = dcache_init (sds_read_bytes, sds_write_bytes);
-
sds_desc = SERIAL_OPEN (name);
if (!sds_desc)
perror_with_name (name);
die when it hits one. */
static void
-sds_detach (args, from_tty)
- char *args;
- int from_tty;
+sds_detach (char *args, int from_tty)
{
char buf[PBUFSIZ];
/* Convert hex digit A to a number. */
static int
-fromhex (a)
- int a;
+fromhex (int a)
{
if (a >= '0' && a <= '9')
return a - '0';
/* Convert number NIB to a hex digit. */
static int
-tohex (nib)
- int nib;
+tohex (int nib)
{
if (nib < 10)
return '0' + nib;
}
static int
-tob64 (inbuf, outbuf, len)
- unsigned char *inbuf;
- char *outbuf;
- int len;
+tob64 (unsigned char *inbuf, char *outbuf, int len)
{
int i, sum;
char *p;
}
static int
-fromb64 (inbuf, outbuf, len)
- char *inbuf, *outbuf;
- int len;
+fromb64 (char *inbuf, char *outbuf, int len)
{
int i, sum;
int last_sent_step;
static void
-sds_resume (pid, step, siggnal)
- int pid, step;
- enum target_signal siggnal;
+sds_resume (ptid_t ptid, int step, enum target_signal siggnal)
{
unsigned char buf[PBUFSIZ];
- dcache_flush (sds_dcache);
-
last_sent_signal = siggnal;
last_sent_step = step;
us a message pending notice. */
static void
-sds_interrupt (signo)
- int signo;
+sds_interrupt (int signo)
{
unsigned char buf[PBUFSIZ];
/* The user typed ^C twice. */
static void
-sds_interrupt_twice (signo)
- int signo;
+sds_interrupt_twice (int signo)
{
signal (signo, ofunc);
/* Ask the user what to do when an interrupt is received. */
static void
-interrupt_query ()
+interrupt_query (void)
{
target_terminal_ours ();
STATUS just as `wait' would. Returns "pid" (though it's not clear
what, if anything, that means in the case of this target). */
-static int
-sds_wait (pid, status)
- int pid;
- struct target_waitstatus *status;
+static ptid_t
+sds_wait (ptid_t ptid, struct target_waitstatus *status)
{
unsigned char buf[PBUFSIZ];
int retlen;
{
just_started = 0;
status->kind = TARGET_WAITKIND_STOPPED;
- return inferior_pid;
+ return inferior_ptid;
}
while (1)
}
}
got_status:
- return inferior_pid;
+ return inferior_ptid;
}
static unsigned char sprs[16];
/* ARGSUSED */
static void
-sds_fetch_registers (regno)
- int regno;
+sds_fetch_registers (int regno)
{
unsigned char buf[PBUFSIZ];
int i, retlen;
read out the ones we don't want to change first. */
static void
-sds_prepare_to_store ()
+sds_prepare_to_store (void)
{
/* Make sure the entire registers array is valid. */
read_register_bytes (0, (char *) NULL, REGISTER_BYTES);
of REGISTERS. FIXME: ignores errors. */
static void
-sds_store_registers (regno)
- int regno;
+sds_store_registers (int regno)
{
unsigned char *p, buf[PBUFSIZ];
int i;
Returns number of bytes transferred, or 0 for error. */
static int
-sds_write_bytes (memaddr, myaddr, len)
- CORE_ADDR memaddr;
- char *myaddr;
- int len;
+sds_write_bytes (CORE_ADDR memaddr, char *myaddr, int len)
{
int max_buf_size; /* Max size of packet output buffer */
int origlen;
Returns number of bytes transferred, or 0 for error. */
static int
-sds_read_bytes (memaddr, myaddr, len)
- CORE_ADDR memaddr;
- char *myaddr;
- int len;
+sds_read_bytes (CORE_ADDR memaddr, char *myaddr, int len)
{
int max_buf_size; /* Max size of packet output buffer */
int origlen, retlen;
/* Read or write LEN bytes from inferior memory at MEMADDR,
transferring to or from debugger address MYADDR. Write to inferior
if SHOULD_WRITE is nonzero. Returns length of data written or
- read; 0 for error. */
+ read; 0 for error. TARGET is unused. */
/* ARGSUSED */
static int
-sds_xfer_memory (memaddr, myaddr, len, should_write, target)
- CORE_ADDR memaddr;
- char *myaddr;
- int len;
- int should_write;
- struct target_ops *target; /* ignored */
+sds_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int should_write,
+ struct mem_attrib *attrib ATTRIBUTE_UNUSED,
+ struct target_ops *target ATTRIBUTE_UNUSED)
{
- return dcache_xfer_memory (sds_dcache, memaddr, myaddr, len, should_write);
+ int res;
+
+ if (should_write)
+ res = sds_write_bytes (memaddr, myaddr, len);
+ else
+ res = sds_read_bytes (memaddr, myaddr, len);
+
+ return res;
}
\f
static void
-sds_files_info (ignore)
- struct target_ops *ignore;
+sds_files_info (struct target_ops *ignore)
{
puts_filtered ("Debugging over a serial connection, using SDS protocol.\n");
}
/* Read a single character from the remote end, masking it down to 7 bits. */
static int
-readchar (timeout)
- int timeout;
+readchar (int timeout)
{
int ch;
because 253, 254, and 255 are special flags in the protocol.) */
static int
-compute_checksum (csum, buf, len)
- int csum, len;
- char *buf;
+compute_checksum (int csum, char *buf, int len)
{
int i;
into BUF also. */
static int
-sds_send (buf, len)
- unsigned char *buf;
- int len;
+sds_send (unsigned char *buf, int len)
{
putmessage (buf, len);
/* Send a message to the remote machine. */
static int
-putmessage (buf, len)
- unsigned char *buf;
- int len;
+putmessage (unsigned char *buf, int len)
{
int i, enclen;
unsigned char csum = 0;
and giving it a checksum. */
if (len > 170) /* Prosanity check */
- abort ();
+ internal_error (__FILE__, __LINE__, "failed internal consistency check");
if (remote_debug)
{
into BUF. Returns 0 on any error, 1 on success. */
static int
-read_frame (buf)
- char *buf;
+read_frame (char *buf)
{
char *bp;
int c;
while the target is executing user code. */
static int
-getmessage (buf, forever)
- unsigned char *buf;
- int forever;
+getmessage (unsigned char *buf, int forever)
{
int c, c2, c3;
int tries;
}
\f
static void
-sds_kill ()
+sds_kill (void)
{
/* Don't try to do anything to the target. */
}
static void
-sds_mourn ()
+sds_mourn (void)
{
unpush_target (&sds_ops);
generic_mourn_inferior ();
}
static void
-sds_create_inferior (exec_file, args, env)
- char *exec_file;
- char *args;
- char **env;
+sds_create_inferior (char *exec_file, char *args, char **env)
{
- inferior_pid = 42000;
+ inferior_ptid = pid_to_ptid (42000);
/* Clean up from the last time we were running. */
clear_proceed_status ();
}
static void
-sds_load (filename, from_tty)
- char *filename;
- int from_tty;
+sds_load (char *filename, int from_tty)
{
generic_load (filename, from_tty);
- inferior_pid = 0;
+ inferior_ptid = null_ptid;
}
\f
/* The SDS monitor has commands for breakpoint insertion, although it
replaced instruction back to the debugger. */
static int
-sds_insert_breakpoint (addr, contents_cache)
- CORE_ADDR addr;
- char *contents_cache;
+sds_insert_breakpoint (CORE_ADDR addr, char *contents_cache)
{
int i, retlen;
unsigned char *p, buf[PBUFSIZ];
}
static int
-sds_remove_breakpoint (addr, contents_cache)
- CORE_ADDR addr;
- char *contents_cache;
+sds_remove_breakpoint (CORE_ADDR addr, char *contents_cache)
{
int i, retlen;
unsigned char *p, buf[PBUFSIZ];
}
\f
static void
-init_sds_ops ()
+init_sds_ops (void)
{
sds_ops.to_shortname = "sds";
sds_ops.to_longname = "Remote serial target with SDS protocol";
reply message. */
static void
-sds_command (args, from_tty)
- char *args;
- int from_tty;
+sds_command (char *args, int from_tty)
{
char *p;
int i, len, retlen;
}
void
-_initialize_remote_sds ()
+_initialize_remote_sds (void)
{
init_sds_ops ();
add_target (&sds_ops);