/* Handle used to access serial I/O stream. */
static serial_t mips_desc;
+/* Handle low-level error that we can't recover from. Note that just
+ error()ing out from target_wait or some such low-level place will cause
+ all hell to break loose--the rest of GDB will tend to get left in an
+ inconsistent state. */
+
+static void NORETURN
+mips_error (va_alist)
+ va_dcl
+{
+ va_list args;
+ char *string;
+
+ va_start (args);
+ target_terminal_ours ();
+ wrap_here(""); /* Force out any buffered output */
+ gdb_flush (gdb_stdout);
+ if (error_pre_print)
+ fprintf_filtered (gdb_stderr, error_pre_print);
+ string = va_arg (args, char *);
+ vfprintf_filtered (gdb_stderr, string, args);
+ fprintf_filtered (gdb_stderr, "\n");
+ va_end (args);
+
+ /* We probably should print "ending remote debugging" here, but that would
+ appear to be a problem for mips_initialize and its catch_errors. */
+ target_mourn_inferior ();
+
+ return_to_top_level (RETURN_ERROR);
+}
+
/* Read a character from the remote, aborting on error. Returns
SERIAL_TIMEOUT on timeout (since that's what SERIAL_READCHAR
returns). FIXME: If we see the string "<IDT>" from the board, then
ch = SERIAL_READCHAR (mips_desc, timeout);
if (ch == SERIAL_EOF)
- error ("End of file from remote");
+ mips_error ("End of file from remote");
if (ch == SERIAL_ERROR)
- error ("Error reading from remote: %s", safe_strerror (errno));
+ mips_error ("Error reading from remote: %s", safe_strerror (errno));
if (sr_get_debug () > 1)
{
if (ch != SERIAL_TIMEOUT)
state = 0;
- error ("Remote board reset");
+ mips_error ("Remote board reset");
}
if (ch == nextstate[state])
++*pgarbage;
if (*pgarbage > mips_syn_garbage)
- error ("Remote debugging protocol failure");
+ mips_error ("Remote debugging protocol failure");
}
}
len = strlen (s);
if (len > DATA_MAXLEN)
- error ("MIPS protocol data packet too long: %s", s);
+ mips_error ("MIPS protocol data packet too long: %s", s);
packet = (unsigned char *) alloca (HDR_LENGTH + len + TRLR_LENGTH + 1);
if (SERIAL_WRITE (mips_desc, packet,
HDR_LENGTH + len + TRLR_LENGTH) != 0)
- error ("write to target failed: %s", safe_strerror (errno));
+ mips_error ("write to target failed: %s", safe_strerror (errno));
garbage = 0;
ch = 0;
}
}
- error ("Remote did not acknowledge packet");
+ mips_error ("Remote did not acknowledge packet");
}
/* Receive and acknowledge a packet, returning the data in BUFF (which
int err;
if (mips_receive_header (hdr, &garbage, ch, mips_receive_wait) != 0)
- error ("Timed out waiting for remote packet");
+ mips_error ("Timed out waiting for remote packet");
ch = 0;
break;
}
if (rch == SERIAL_TIMEOUT)
- error ("Timed out waiting for remote packet");
+ mips_error ("Timed out waiting for remote packet");
buff[i] = rch;
}
err = mips_receive_trailer (trlr, &garbage, &ch, mips_receive_wait);
if (err == -1)
- error ("Timed out waiting for packet");
+ mips_error ("Timed out waiting for packet");
if (err == -2)
{
if (sr_get_debug () > 0)
}
if (SERIAL_WRITE (mips_desc, ack, HDR_LENGTH + TRLR_LENGTH) != 0)
- error ("write to target failed: %s", safe_strerror (errno));
+ mips_error ("write to target failed: %s", safe_strerror (errno));
}
if (sr_get_debug () > 0)
}
if (SERIAL_WRITE (mips_desc, ack, HDR_LENGTH + TRLR_LENGTH) != 0)
- error ("write to target failed: %s", safe_strerror (errno));
+ mips_error ("write to target failed: %s", safe_strerror (errno));
return len;
}
if (sscanf (buff, "0x%x %c 0x%x 0x%x",
&rpid, &rcmd, &rerrflg, &rresponse) != 4
|| (cmd != '\0' && rcmd != cmd))
- error ("Bad response from remote board");
+ mips_error ("Bad response from remote board");
if (rerrflg != 0)
{
char cc;
if (tries > 0)
- error ("Could not connect to target");
+ mips_error ("Could not connect to target");
++tries;
/* We did not receive the packet we expected; try resetting the
int pid, step, siggnal;
{
if (siggnal)
- error ("Can't send signals to a remote system. Try `handle %d ignore'.",
+ mips_error ("Can't send signals to a remote system. Try `handle %d ignore'.",
siggnal);
mips_request (step ? 's' : 'c',
rstatus = mips_request ('\0', (unsigned int) 0, (unsigned int) 0, &err);
if (err)
- error ("Remote failure: %s", safe_strerror (errno));
+ 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
val = mips_request ('r', (unsigned int) mips_map_regno (regno),
(unsigned int) 0, &err);
if (err)
- error ("Can't read register %d: %s", regno, safe_strerror (errno));
+ mips_error ("Can't read register %d: %s", regno, safe_strerror (errno));
{
char buf[MAX_REGISTER_RAW_SIZE];
(unsigned int) read_register (regno),
&err);
if (err)
- error ("Can't write register %d: %s", regno, safe_strerror (errno));
+ mips_error ("Can't write register %d: %s", regno, safe_strerror (errno));
}
/* Fetch a word from the target board. */
/* Data space failed; try instruction space. */
val = mips_request ('i', (unsigned int) addr, (unsigned int) 0, &err);
if (err)
- error ("Can't read address 0x%x: %s", addr, safe_strerror (errno));
+ mips_error ("Can't read address 0x%x: %s", addr, safe_strerror (errno));
}
return val;
}
/* Data space failed; try instruction space. */
mips_request ('I', (unsigned int) addr, (unsigned int) val, &err);
if (err)
- error ("Can't write address 0x%x: %s", addr, safe_strerror (errno));
+ mips_error ("Can't write address 0x%x: %s", addr, safe_strerror (errno));
}
}
CORE_ADDR entry_pt;
if (args && *args)
- error ("Can't pass arguments to remote MIPS board.");
+ mips_error ("Can't pass arguments to remote MIPS board.");
if (execfile == 0 || exec_bfd == 0)
- error ("No exec file specified");
+ mips_error ("No exec file specified");
entry_pt = (CORE_ADDR) bfd_get_start_address (exec_bfd);