Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PUSHED] PR gdb/17096: async support breaks remote debugging on Windows
@ 2014-07-07 18:13 Pedro Alves
  2014-07-07 20:30 ` Joel Brobecker
  0 siblings, 1 reply; 3+ messages in thread
From: Pedro Alves @ 2014-07-07 18:13 UTC (permalink / raw)
  To: gdb-patches

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>

	gdb/17096
	* 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 | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 513a919..cb7185e 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -6,6 +6,14 @@
 	gdb_call_async_signal_handler instead of
 	mark_async_signal_handler.
 
+2014-07-07  Pedro Alves  <palves@redhat.com>
+
+	PR gdb/17096
+	* 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.
-- 
1.9.3


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

* Re: [PUSHED] PR gdb/17096: async support breaks remote debugging on Windows
  2014-07-07 18:13 [PUSHED] PR gdb/17096: async support breaks remote debugging on Windows Pedro Alves
@ 2014-07-07 20:30 ` Joel Brobecker
  2014-07-08 15:27   ` Pedro Alves
  0 siblings, 1 reply; 3+ messages in thread
From: Joel Brobecker @ 2014-07-07 20:30 UTC (permalink / raw)
  To: Pedro Alves; +Cc: gdb-patches

> gdb/
> 2014-07-07  Pedro Alves  <palves@redhat.com>
> 
> 	gdb/17096
> 	* remote.c (async_handle_remote_sigint)
> 	(async_handle_remote_sigint_twice): Call
> 	gdb_call_async_signal_handler instead of
> 	mark_async_signal_handler.

It looks like the remote.c patch was missing, and since I looked it
up to take a look, I thought I might as well provide it here as well!
Thanks for working on this one, Pedro.

-- 
Joel

diff --git a/gdb/remote.c b/gdb/remote.c
index b6f3ddb..3aa030c 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -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


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

* Re: [PUSHED] PR gdb/17096: async support breaks remote debugging on Windows
  2014-07-07 20:30 ` Joel Brobecker
@ 2014-07-08 15:27   ` Pedro Alves
  0 siblings, 0 replies; 3+ messages in thread
From: Pedro Alves @ 2014-07-08 15:27 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: gdb-patches

On 07/07/2014 09:30 PM, Joel Brobecker wrote:
>> gdb/
>> 2014-07-07  Pedro Alves  <palves@redhat.com>
>>
>> 	gdb/17096
>> 	* remote.c (async_handle_remote_sigint)
>> 	(async_handle_remote_sigint_twice): Call
>> 	gdb_call_async_signal_handler instead of
>> 	mark_async_signal_handler.
> 
> It looks like the remote.c patch was missing, and since I looked it
> up to take a look, I thought I might as well provide it here as well!
> Thanks for working on this one, Pedro.

Thanks Joel!

-- 
Pedro Alves


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

end of thread, other threads:[~2014-07-08 15:27 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-07 18:13 [PUSHED] PR gdb/17096: async support breaks remote debugging on Windows Pedro Alves
2014-07-07 20:30 ` Joel Brobecker
2014-07-08 15:27   ` Pedro Alves

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox