mirror of
https://github.com/darlinghq/darling-gdb.git
synced 2025-02-01 14:31:54 +00:00
unpush the remote target if serial_write fails.
PR gdb/15275 notes that when debugging with a remote connection over a serial link and the link is disconnected, say by disconnecting USB serial port, the GDB quit command no longer works: (gdb) tar ext /dev/ttyACM0 &"tar ext /dev/ttyACM0\n" ~"Remote debugging using /dev/ttyACM0\n" ^done (gdb) set debug remote 1 &"set debug remote 1\n" ^done (gdb) quit &"quit\n" &"Sending packet: $qTStatus#49..." &"putpkt: write failed: Input/output error.\n" ^error,msg="putpkt: write failed: Input/output error." (gdb) (gdb) quit &"quit\n" &"Sending packet: $qTStatus#49..." &"putpkt: write failed: Input/output error.\n" ^error,msg="putpkt: write failed: Input/output error." This is not reproducible with TCP connections, as with that, sending doesn't error out, but instead the error is detected on the subsequent readchar. When that read fails, we unpush the remote target, and throw TARGET_CLOSE_ERROR. To address PR gdb/15275, instead of catching the error in remote_get_trace_status as presently done (which leaves this same issue latent for another packet to trip on), or of making ser-unix.c fake success too on failed writes, so we'd get to readchar detecting the error on serial ports too, better let the error propagate out of serial_write, and catch it at the remote.c level, throwing away the target if writing fails too, instead of delaying that until the next read. gdb/ 2013-04-02 Pedro Alves <palves@redhat.com> PR gdb/15275 * remote.c (send_interrupt_sequence): Use remote_serial_write. (remote_serial_write): New function. (putpkt_binary, getpkt_or_notif_sane_1): Use remote_serial_write.
This commit is contained in:
parent
ea5f3910af
commit
c33e31fd4a
@ -1,3 +1,11 @@
|
||||
2013-04-02 Pedro Alves <palves@redhat.com>
|
||||
|
||||
PR gdb/15275
|
||||
|
||||
* remote.c (send_interrupt_sequence): Use remote_serial_write.
|
||||
(remote_serial_write): New function.
|
||||
(putpkt_binary, getpkt_or_notif_sane_1): Use remote_serial_write.
|
||||
|
||||
2013-04-01 Jiong Wang <jiwang@tilera.com>
|
||||
|
||||
* NEWS: Mention TILE-Gx in "New native configurations" and
|
||||
|
32
gdb/remote.c
32
gdb/remote.c
@ -122,6 +122,8 @@ static void remote_send (char **buf, long *sizeof_buf_p);
|
||||
|
||||
static int readchar (int timeout);
|
||||
|
||||
static void remote_serial_write (const char *str, int len);
|
||||
|
||||
static void remote_kill (struct target_ops *ops);
|
||||
|
||||
static int tohex (int nib);
|
||||
@ -3210,13 +3212,13 @@ static void
|
||||
send_interrupt_sequence (void)
|
||||
{
|
||||
if (interrupt_sequence_mode == interrupt_sequence_control_c)
|
||||
serial_write (remote_desc, "\x03", 1);
|
||||
remote_serial_write ("\x03", 1);
|
||||
else if (interrupt_sequence_mode == interrupt_sequence_break)
|
||||
serial_send_break (remote_desc);
|
||||
else if (interrupt_sequence_mode == interrupt_sequence_break_g)
|
||||
{
|
||||
serial_send_break (remote_desc);
|
||||
serial_write (remote_desc, "g", 1);
|
||||
remote_serial_write ("g", 1);
|
||||
}
|
||||
else
|
||||
internal_error (__FILE__, __LINE__,
|
||||
@ -7061,6 +7063,21 @@ readchar (int timeout)
|
||||
return ch;
|
||||
}
|
||||
|
||||
/* Wrapper for serial_write that closes the target and throws if
|
||||
writing fails. */
|
||||
|
||||
static void
|
||||
remote_serial_write (const char *str, int len)
|
||||
{
|
||||
if (serial_write (remote_desc, str, len))
|
||||
{
|
||||
remote_unpush_target ();
|
||||
throw_perror_with_name (TARGET_CLOSE_ERROR,
|
||||
_("Remote communication error. "
|
||||
"Target disconnected."));
|
||||
}
|
||||
}
|
||||
|
||||
/* Send the command in *BUF to the remote machine, and read the reply
|
||||
into *BUF. Report an error if we get an error reply. Resize
|
||||
*BUF using xrealloc if necessary to hold the result, and update
|
||||
@ -7181,8 +7198,7 @@ putpkt_binary (char *buf, int cnt)
|
||||
gdb_flush (gdb_stdlog);
|
||||
do_cleanups (old_chain);
|
||||
}
|
||||
if (serial_write (remote_desc, buf2, p - buf2))
|
||||
perror_with_name (_("putpkt: write failed"));
|
||||
remote_serial_write (buf2, p - buf2);
|
||||
|
||||
/* If this is a no acks version of the remote protocol, send the
|
||||
packet and move on. */
|
||||
@ -7237,7 +7253,7 @@ putpkt_binary (char *buf, int cnt)
|
||||
doesn't get retransmitted when we resend this
|
||||
packet. */
|
||||
skip_frame ();
|
||||
serial_write (remote_desc, "+", 1);
|
||||
remote_serial_write ("+", 1);
|
||||
continue; /* Now, go look for +. */
|
||||
}
|
||||
|
||||
@ -7592,7 +7608,7 @@ getpkt_or_notif_sane_1 (char **buf, long *sizeof_buf, int forever,
|
||||
break;
|
||||
}
|
||||
|
||||
serial_write (remote_desc, "-", 1);
|
||||
remote_serial_write ("-", 1);
|
||||
}
|
||||
|
||||
if (tries > MAX_TRIES)
|
||||
@ -7603,7 +7619,7 @@ getpkt_or_notif_sane_1 (char **buf, long *sizeof_buf, int forever,
|
||||
|
||||
/* Skip the ack char if we're in no-ack mode. */
|
||||
if (!rs->noack_mode)
|
||||
serial_write (remote_desc, "+", 1);
|
||||
remote_serial_write ("+", 1);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -7623,7 +7639,7 @@ getpkt_or_notif_sane_1 (char **buf, long *sizeof_buf, int forever,
|
||||
|
||||
/* Skip the ack char if we're in no-ack mode. */
|
||||
if (!rs->noack_mode)
|
||||
serial_write (remote_desc, "+", 1);
|
||||
remote_serial_write ("+", 1);
|
||||
if (is_notif != NULL)
|
||||
*is_notif = 0;
|
||||
return val;
|
||||
|
Loading…
x
Reference in New Issue
Block a user