aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@polymtl.ca>2021-01-21 14:04:52 -0500
committerSimon Marchi <simon.marchi@polymtl.ca>2021-01-21 14:04:52 -0500
commit439706e6a907b54658714a358b220febc63a0182 (patch)
tree885bc354b9501dfff4ff3c729410bb1fcd184ffa
parent730af66356b3181784c72b3ddd5cb23dd09a2ef3 (diff)
downloadfsf-binutils-gdb-439706e6a907b54658714a358b220febc63a0182.zip
fsf-binutils-gdb-439706e6a907b54658714a358b220febc63a0182.tar.gz
fsf-binutils-gdb-439706e6a907b54658714a358b220febc63a0182.tar.bz2
gdb: use interruptible_select when connecting to a remote
When GDB is waiting trying to connect to a remote target and it receives a SIGWINCH (terminal gets resized), the blocking system call gets interrupted and we abort. For example, I connect to some port (on which nothing listens): (gdb) tar rem :1234 ... GDB blocks here, resize the terminal ... :1234: Interrupted system call. The backtrace where GDB is blocked while waiting for the connection to establish is: #0 0x00007fe9db805b7b in select () from /usr/lib/libc.so.6 #1 0x000055f2472e9c42 in gdb_select (n=0, readfds=0x0, writefds=0x0, exceptfds=0x0, timeout=0x7ffe8fafe050) at /home/simark/src/binutils-gdb/gdb/posix-hdep.c:31 #2 0x000055f24759c212 in wait_for_connect (sock=-1, polls=0x7ffe8fafe300) at /home/simark/src/binutils-gdb/gdb/ser-tcp.c:147 #3 0x000055f24759d0e8 in net_open (scb=0x62500015b900, name=0x6020000601d8 ":1234") at /home/simark/src/binutils-gdb/gdb/ser-tcp.c:356 #4 0x000055f2475a0395 in serial_open_ops_1 (ops=0x55f24892ca60 <tcp_ops>, open_name=0x6020000601d8 ":1234") at /home/simark/src/binutils-gdb/gdb/serial.c:244 #5 0x000055f2475a01d6 in serial_open (name=0x6020000601d8 ":1234") at /home/simark/src/binutils-gdb/gdb/serial.c:231 #6 0x000055f2474d5274 in remote_serial_open (name=0x6020000601d8 ":1234") at /home/simark/src/binutils-gdb/gdb/remote.c:5019 #7 0x000055f2474d7025 in remote_target::open_1 (name=0x6020000601d8 ":1234", from_tty=1, extended_p=0) at /home/simark/src/binutils-gdb/gdb/remote.c:5571 #8 0x000055f2474d47d5 in remote_target::open (name=0x6020000601d8 ":1234", from_tty=1) at /home/simark/src/binutils-gdb/gdb/remote.c:4898 #9 0x000055f24776379f in open_target (args=0x6020000601d8 ":1234", from_tty=1, command=0x611000042bc0) at /home/simark/src/binutils-gdb/gdb/target.c:242 Fix that by using interruptible_select in wait_for_connect, instead of gdb_select. Resizing the terminal now no longer aborts the connection. It is still possible to interrupt the connection using ctrl-c. gdb/ChangeLog: * ser-tcp.c (wait_for_connect): Use interruptible_select instead of gdb_select. Change-Id: Ie25577bd1e5699e4847b6b53fdfa10b8c0dc5c89
-rw-r--r--gdb/ChangeLog5
-rw-r--r--gdb/ser-tcp.c2
2 files changed, 6 insertions, 1 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 468447d..a0fb3cf 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,8 @@
+2021-01-21 Simon Marchi <simon.marchi@polymtl.ca>
+
+ * ser-tcp.c (wait_for_connect): Use interruptible_select instead
+ of gdb_select.
+
2021-01-21 Hannes Domani <ssbssa@yahoo.de>
PR python/19151
diff --git a/gdb/ser-tcp.c b/gdb/ser-tcp.c
index 019aa4e5..e79c9e6 100644
--- a/gdb/ser-tcp.c
+++ b/gdb/ser-tcp.c
@@ -144,7 +144,7 @@ wait_for_connect (int sock, unsigned int *polls)
else
/* Use gdb_select here, since we have no file descriptors, and on
Windows, plain select doesn't work in that case. */
- n = gdb_select (0, NULL, NULL, NULL, &t);
+ n = interruptible_select (0, NULL, NULL, NULL, &t);
/* If we didn't time out, only count it as one poll. */
if (n > 0 || *polls < POLL_INTERVAL)