public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Wake up interruptible_select in remote_fileio ctrl-c handler
@ 2016-05-19 14:38 Yao Qi
  2016-06-01  8:35 ` Yao Qi
  0 siblings, 1 reply; 6+ messages in thread
From: Yao Qi @ 2016-05-19 14:38 UTC (permalink / raw)
  To: gdb-patches

As reported in PR 19998, after type ctrl-c, GDB hang there and does
not send interrupt.  It causes a fail in gdb.base/interrupt.exp.
All targets support remote fileio should be affected.

When we type ctrc-c, SIGINT is handled by remote_fileio_sig_set,
as shown below,

 #0  remote_fileio_sig_set (sigint_func=0x4495d0 <remote_fileio_ctrl_c_signal_handler(int)>) at /home/yao/SourceCode/gnu/gdb/git/gdb/remote-fileio.c:325
 #1  0x00000000004495de in remote_fileio_ctrl_c_signal_handler (signo=<optimised out>) at /home/yao/SourceCode/gnu/gdb/git/gdb/remote-fileio.c:349
 #2  <signal handler called>
 #3  0x00007ffff647ed83 in __select_nocancel () at ../sysdeps/unix/syscall-template.S:81
 #4  0x00000000005530ce in interruptible_select (n=10, readfds=readfds@entry=0x7fffffffd730, writefds=writefds@entry=0x0, exceptfds=exceptfds@entry=0x0,
    timeout=timeout@entry=0x0) at /home/yao/SourceCode/gnu/gdb/git/gdb/event-top.c:1017
 #5  0x000000000061ab20 in stdio_file_read (file=<optimised out>, buf=0x12d02e0 "\n\022-\001", length_buf=16383)
    at /home/yao/SourceCode/gnu/gdb/git/gdb/ui-file.c:577
 #6  0x000000000044a4dc in remote_fileio_func_read (buf=0x12c0360 "") at /home/yao/SourceCode/gnu/gdb/git/gdb/remote-fileio.c:583
 #7  0x0000000000449598 in do_remote_fileio_request (uiout=<optimised out>, buf_arg=buf_arg@entry=0x12c0340)
    at /home/yao/SourceCode/gnu/gdb/git/gdb/remote-fileio.c:1179

we don't set quit_serial_event,

  do
    {
      res = gdb_select (n, readfds, writefds, exceptfds, timeout);
    }
  while (res == -1 && errno == EINTR);

  if (res == 1 && FD_ISSET (fd, readfds))
    {
      errno = EINTR;
      return -1;
    }
  return res;

we can't go out of the loop above, and that is why GDB can't send
interrupt.

Recently, we stop throwing exception from SIGINT handler
(remote_fileio_ctrl_c_signal_handler)
https://sourceware.org/ml/gdb-patches/2016-03/msg00372.html, which
is correct, because gdb_select is interruptible.  However, in the
same patch series, we add interruptible_select later as a wrapper
to gdb_select, https://sourceware.org/ml/gdb-patches/2016-03/msg00375.html
and it is not interruptible (because of the loop in it) unless
select/poll-able file descriptors are marked.

This fix in this patch is to call quit_serial_event_set, so that we can
go out of the loop above, return -1 and set errno to EINTR.

I don't have the test env to run testsuite against targets support
remote fileio.

2016-05-19  Yao Qi  <yao.qi@linaro.org>

	PR remote/19998
	* remote-fileio.c (remote_fileio_ctrl_c_signal_handler): Call
	quit_serial_event_set.
---
 gdb/remote-fileio.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/gdb/remote-fileio.c b/gdb/remote-fileio.c
index 44817df..29c5ca3 100644
--- a/gdb/remote-fileio.c
+++ b/gdb/remote-fileio.c
@@ -348,6 +348,8 @@ remote_fileio_ctrl_c_signal_handler (int signo)
 {
   remote_fileio_sig_set (remote_fileio_ctrl_c_signal_handler);
   remote_fio_ctrl_c_flag = 1;
+  /* Wake up interruptible_select.  */
+  quit_serial_event_set ();
 }
 
 static void
-- 
1.9.1

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2016-06-01 15:38 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-19 14:38 [PATCH] Wake up interruptible_select in remote_fileio ctrl-c handler Yao Qi
2016-06-01  8:35 ` Yao Qi
2016-06-01 11:52   ` Pedro Alves
2016-06-01 13:42     ` Yao Qi
2016-06-01 14:15       ` Pedro Alves
     [not found]         ` <CAH=s-PMDdhETFmMxMdbanHfRM-r13cyxiERdmaDRD5iQgZmzjA@mail.gmail.com>
2016-06-01 15:38           ` Pedro Alves

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).