PR gdb/17096: async support breaks remote debugging on Windows
authorPedro Alves <palves@redhat.com>
Mon, 7 Jul 2014 16:51:04 +0000 (17:51 +0100)
committerPedro Alves <palves@redhat.com>
Mon, 7 Jul 2014 16:51:04 +0000 (17:51 +0100)
On Windows, with "maint set target-async on" (the default since
a09dd441), Ctrl-C fails to stop a remote target.

With maint target-async on, the SIGINT signal handler doesn't send the
remote interrupt request immediately.  Instead, it marks an async
handler as ready, and then the main event loop wakes up and notices
that the SIGINT async signal handler token was set, and calls the
corresponding event handler, which sends the remote interrupt request.

On POSIX-like systems, the SIGINT signal makes the select/poll in the
main event loop wake up / return with EINTR.  However, on Windows,
signal handlers run on a separate thread, and Windows doesn't really
have a concept of EINTR.  So, just marking the async handler
(effectively just setting a flag) does not wake up gdb_select.
Instead, we need to call gdb_call_async_signal_handler from the signal
handler.  The Windows version (in mingw-hdep.c) sets a Windows event
that gdb_select's WaitForMultipleObjects is waiting for.

Confirmed that with this, Ctrl-C interrupts the remote target on
Windows.  Also regression tested on x86_64 Fedora 20 against
GDBserver.

gdb/
2014-07-07  Pedro Alves  <palves@redhat.com>

* remote.c (async_handle_remote_sigint)
(async_handle_remote_sigint_twice): Call
gdb_call_async_signal_handler instead of
mark_async_signal_handler.

gdb/ChangeLog
gdb/remote.c

index f41451a16f3732b5fa3abf6999958824dc807840..f2e64505c7d44348a22147da036e2cecb60a5426 100644 (file)
@@ -1,3 +1,10 @@
+2014-07-07  Pedro Alves  <palves@redhat.com>
+
+       * remote.c (async_handle_remote_sigint)
+       (async_handle_remote_sigint_twice): Call
+       gdb_call_async_signal_handler instead of
+       mark_async_signal_handler.
+
 2014-07-07  Tom Tromey  <tromey@redhat.com>
 
        * target-delegates.c: Rebuild.
index b6f3ddb54dd9357525bb1e0c3cc031967df9e73a..3aa030cf39050b2c1944e87941db8352c5466a2f 100644 (file)
@@ -4818,7 +4818,9 @@ static void
 async_handle_remote_sigint (int sig)
 {
   signal (sig, async_handle_remote_sigint_twice);
-  mark_async_signal_handler (async_sigint_remote_token);
+  /* Note we need to go through gdb_call_async_signal_handler in order
+     to wake up the event loop on Windows.  */
+  gdb_call_async_signal_handler (async_sigint_remote_token, 0);
 }
 
 /* Signal handler for SIGINT, installed after SIGINT has already been
@@ -4828,7 +4830,8 @@ static void
 async_handle_remote_sigint_twice (int sig)
 {
   signal (sig, async_handle_remote_sigint);
-  mark_async_signal_handler (async_sigint_remote_twice_token);
+  /* See note in async_handle_remote_sigint.  */
+  gdb_call_async_signal_handler (async_sigint_remote_twice_token, 0);
 }
 
 /* Perform the real interruption of the target execution, in response
This page took 0.034776 seconds and 4 git commands to generate.