/* Remote debugging interface for MIPS remote debugging protocol.
- Copyright 1993 Free Software Foundation, Inc.
+ Copyright 1993, 1994 Free Software Foundation, Inc.
Contributed by Cygnus Support. Written by Ian Lance Taylor
<ian@cygnus.com>.
static int
mips_request PARAMS ((char cmd, unsigned int addr, unsigned int data,
- int *perr, timeout));
+ int *perr, int timeout));
static void
mips_initialize PARAMS ((void));
static void
mips_detach PARAMS ((char *args, int from_tty));
-static void
-mips_resume PARAMS ((int pid, int step, int siggnal));
+static void mips_resume PARAMS ((int pid, int step,
+ enum target_signal siggnal));
static int
-mips_wait PARAMS ((int pid, WAITTYPE *status));
+mips_wait PARAMS ((int pid, struct target_waitstatus *status));
static int
mips_map_regno PARAMS ((int regno));
return rresponse;
}
+static void
+mips_initialize_cleanups (arg)
+ PTR arg;
+{
+ mips_initializing = 0;
+}
+
/* Initialize a new connection to the MIPS board, and make sure we are
really connected. */
char cr;
char buff[DATA_MAXLEN + 1];
int err;
+ struct cleanup *old_cleanups = make_cleanup (mips_initialize_cleanups, NULL);
+ /* What is this code doing here? I don't see any way it can happen, and
+ it might mean mips_initializing didn't get cleared properly.
+ So I'll make it a warning. */
if (mips_initializing)
- return;
+ {
+ warning ("internal error: mips_initialize called twice");
+ return;
+ }
mips_initializing = 1;
}
mips_receive_packet (buff, 1, 3);
- mips_initializing = 0;
+ do_cleanups (old_cleanups);
/* If this doesn't call error, we have connected; we don't care if
the request itself succeeds or fails. */
static void
mips_resume (pid, step, siggnal)
- int pid, step, siggnal;
+ int pid, step;
+ enum target_signal siggnal;
{
- if (siggnal)
- mips_error ("Can't send signals to a remote system. Try `handle %d ignore'.",
- siggnal);
+ if (siggnal != TARGET_SIGNAL_0)
+ warning
+ ("Can't send signals to a remote system. Try `handle %s ignore'.",
+ target_signal_to_name (siggnal));
mips_request (step ? 's' : 'c',
(unsigned int) 1,
mips_receive_wait);
}
+/* Return the signal corresponding to SIG, where SIG is the number which
+ the MIPS protocol uses for the signal. */
+enum target_signal
+mips_signal_from_protocol (sig)
+ int sig;
+{
+ /* We allow a few more signals than the IDT board actually returns, on
+ the theory that there is at least *some* hope that perhaps the numbering
+ for these signals is widely agreed upon. */
+ if (sig <= 0
+ || sig > 31)
+ return TARGET_SIGNAL_UNKNOWN;
+
+ /* Don't want to use target_signal_from_host because we are converting
+ from MIPS signal numbers, not host ones. Our internal numbers
+ match the MIPS numbers for the signals the board can return, which
+ are: SIGINT, SIGSEGV, SIGBUS, SIGILL, SIGFPE, SIGTRAP. */
+ return (enum target_signal) sig;
+}
+
/* Wait until the remote stops, and return a wait status. */
static int
mips_wait (pid, status)
int pid;
- WAITTYPE *status;
+ struct target_waitstatus *status;
{
int rstatus;
int err;
indicating that it is stopped. */
if (! mips_need_reply)
{
- WSETSTOP (*status, SIGTRAP);
+ status->kind = TARGET_WAITKIND_STOPPED;
+ status->value.sig = TARGET_SIGNAL_TRAP;
return 0;
}
if (err)
mips_error ("Remote failure: %s", safe_strerror (errno));
- /* FIXME: The target board uses numeric signal values which are
- those used on MIPS systems. If the host uses different signal
- values, we need to translate here. I believe all Unix systems
- use the same values for the signals the board can return, which
- are: SIGINT, SIGSEGV, SIGBUS, SIGILL, SIGFPE, SIGTRAP. */
-
- /* FIXME: The target board uses a standard Unix wait status int. If
- the host system does not, we must translate here. */
-
- *status = rstatus;
+ /* Translate a MIPS waitstatus. We use constants here rather than WTERMSIG
+ and so on, because the constants we want here are determined by the
+ MIPS protocol and have nothing to do with what host we are running on. */
+ if ((rstatus & 0377) == 0)
+ {
+ status->kind = TARGET_WAITKIND_EXITED;
+ status->value.integer = (((rstatus) >> 8) & 0377);
+ }
+ else if ((rstatus & 0377) == 0177)
+ {
+ status->kind = TARGET_WAITKIND_STOPPED;
+ status->value.sig = mips_signal_from_protocol (((rstatus) >> 8) & 0377);
+ }
+ else
+ {
+ status->kind = TARGET_WAITKIND_SIGNALLED;
+ status->value.sig = mips_signal_from_protocol (rstatus & 0177);
+ }
return 0;
}
/* FIXME: Should we set inferior_pid here? */
- proceed (entry_pt, -1, 0);
+ proceed (entry_pt, TARGET_SIGNAL_DEFAULT, 0);
}
/* Clean up after a process. Actually nothing to do. */
{
"mips", /* to_shortname */
"Remote MIPS debugging over serial line", /* to_longname */
- "Debug a board using the MIPS remote debugging protocol over a serial line.\n\
-Specify the serial device it is connected to (e.g., /dev/ttya).", /* to_doc */
+ "\
+Debug a board using the MIPS remote debugging protocol over a serial line.\n\
+The argument is the device it is connected to or, if it contains a colon,\n\
+HOST:PORT to access a board over a network", /* to_doc */
mips_open, /* to_open */
mips_close, /* to_close */
NULL, /* to_attach */