aboutsummaryrefslogtreecommitdiff
path: root/gdb/ser-base.c
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2017-03-17 16:08:12 +0000
committerPedro Alves <palves@redhat.com>2017-03-17 16:08:12 +0000
commit9bcbdca808b5f9fec6217d20bd4b48a56008c460 (patch)
treed3acc037c9667229df6ad611a5fd45b1ab991ec4 /gdb/ser-base.c
parent7503099f3e29739d34cb1224d54fba96404e6e61 (diff)
downloadgdb-9bcbdca808b5f9fec6217d20bd4b48a56008c460.zip
gdb-9bcbdca808b5f9fec6217d20bd4b48a56008c460.tar.gz
gdb-9bcbdca808b5f9fec6217d20bd4b48a56008c460.tar.bz2
PR remote/21188: Fix remote serial timeout
As Gareth McMullin <gareth@blacksphere.co.nz> reports at <https://sourceware.org/ml/gdb-patches/2017-02/msg00560.html>, the timeout mechanism in ser-unix.c was broken by commit 048094acc ("target remote: Don't rely on immediate_quit (introduce quit handlers)"). Instead of applying a local fix, and since we now finally always use interrupt_select [1], let's get rid of hardwire_readchar entirely, and use ser_base_readchar instead, which has similar timeout handling, except for the bug. Smoke tested with: $ socat -d -d pty,raw,echo=0 pty,raw,echo=0 2017/03/14 14:08:13 socat[4994] N PTY is /dev/pts/14 2017/03/14 14:08:13 socat[4994] N PTY is /dev/pts/15 2017/03/14 14:08:13 socat[4994] N starting data transfer loop with FDs [3,3] and [5,5] $ gdbserver /dev/pts/14 PROG $ gdb PROG -ex "tar rem /dev/pts/15" and then a few continues/ctrl-c's, plus killing gdbserver and socat. [1] - See FIXME comments being removed. gdb/ChangeLog: 2017-03-17 Pedro Alves <palves@redhat.com> PR remote/21188 * ser-base.c (ser_base_wait_for): Add comment. (do_ser_base_readchar): Improve comment based on the ser-unix.c's version. * ser-unix.c (hardwire_raw): Remove reference to scb->current_timeout. (wait_for, do_hardwire_readchar, hardwire_readchar): Delete. (hardwire_ops): Install ser_base_readchar instead of hardwire_readchar. * serial.h (struct serial) <current_timeout, timeout_remaining>: Remove fields.
Diffstat (limited to 'gdb/ser-base.c')
-rw-r--r--gdb/ser-base.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/gdb/ser-base.c b/gdb/ser-base.c
index 3e10033..790cb1b 100644
--- a/gdb/ser-base.c
+++ b/gdb/ser-base.c
@@ -205,6 +205,11 @@ push_event (void *context)
/* Wait for input on scb, with timeout seconds. Returns 0 on success,
otherwise SERIAL_TIMEOUT or SERIAL_ERROR. */
+/* NOTE: Some of the code below is dead. The only possible values of
+ the TIMEOUT parameter are ONE and ZERO. OTOH, we should probably
+ get rid of the deprecated_ui_loop_hook call in do_ser_base_readchar
+ instead and support infinite time outs here. */
+
static int
ser_base_wait_for (struct serial *scb, int timeout)
{
@@ -308,10 +313,11 @@ ser_base_read_error_fd (struct serial *scb, int close_fd)
}
}
-/* Read a character with user-specified timeout. TIMEOUT is number of seconds
- to wait, or -1 to wait forever. Use timeout of 0 to effect a poll. Returns
- char if successful. Returns -2 if timeout expired, EOF if line dropped
- dead, or -3 for any other error (see errno in that case). */
+/* Read a character with user-specified timeout. TIMEOUT is number of
+ seconds to wait, or -1 to wait forever. Use timeout of 0 to effect
+ a poll. Returns char if successful. Returns SERIAL_TIMEOUT if
+ timeout expired, SERIAL_EOF if line dropped dead, or SERIAL_ERROR
+ for any other error (see errno in that case). */
static int
do_ser_base_readchar (struct serial *scb, int timeout)