Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Yao Qi <yao@codesourcery.com>
To: <gdb-patches@sourceware.org>
Subject: [PATCH 08/14] Uninstall infrun_async_inferior_event token in remote target.
Date: Thu, 03 May 2012 13:13:00 -0000	[thread overview]
Message-ID: <1336050869-29605-9-git-send-email-yao@codesourcery.com> (raw)
In-Reply-To: <1336050869-29605-1-git-send-email-yao@codesourcery.com>

This patch is to fix the problem that GDB is unable to handle ctrl-c
well.

The infrun_async_inferior_event_token is not needed in remote target.
This patch is to uninstall infrun_async_inferior_event_token
in remote target, and restore it when remote target is closed.

Note I don't think I understand the cause of this problem fully, so
explanations on this problem is appreciated.

gdb:

2012-04-12  Yao Qi  <yao@codesourcery.com>

	* inferior.h: Function declaration.
	* infrun.c (do_target_resume): Check NULL of
	infrun_async_inferior_event_token.
	(resume): Likewise.
	(infrun_async_inferior_event_handler_install): New.
	(infrun_async_inferior_event_handler_remove): New.
	* remote.c (remote_close): Call
	infrun_async_inferior_event_handler_install.
	(remote_open_1): Call infrun_async_inferior_event_handler_remove.
---
 gdb/inferior.h |    4 ++++
 gdb/infrun.c   |   25 +++++++++++++++++++------
 gdb/remote.c   |    4 ++++
 3 files changed, 27 insertions(+), 6 deletions(-)

diff --git a/gdb/inferior.h b/gdb/inferior.h
index 63245a2..7932210 100644
--- a/gdb/inferior.h
+++ b/gdb/inferior.h
@@ -269,6 +269,10 @@ extern void notice_new_inferior (ptid_t, int, int);
 extern struct value *get_return_value (struct type *func_type,
                                        struct type *value_type);
 
+extern void infrun_async_inferior_event_handler_install (void);
+
+extern void infrun_async_inferior_event_handler_remove (void);
+
 /* Address at which inferior stopped.  */
 
 extern CORE_ADDR stop_pc;
diff --git a/gdb/infrun.c b/gdb/infrun.c
index b7afa39..0d487eb 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -1851,7 +1851,7 @@ do_target_resume (ptid_t ptid, int step, enum target_signal signo)
 		{
 		  can_wildcard = 0;
 
-		  if (target_can_async_p ())
+		  if (target_can_async_p () && infrun_async_inferior_event_token)
 		    {
 		      target_async (inferior_event_handler, 0);
 
@@ -1931,7 +1931,7 @@ do_target_resume (ptid_t ptid, int step, enum target_signal signo)
       clear_inline_frame_state (ptid);
     }
 
-  if (target_can_async_p ())
+  if (target_can_async_p () && infrun_async_inferior_event_token)
     {
       target_async (inferior_event_handler, 0);
       /* Tell the event loop we have something to process.  */
@@ -1971,7 +1971,7 @@ resume (int step, enum target_signal sig)
       clear_inline_frame_state (inferior_ptid);
       discard_cleanups (old_cleanups);
 
-      if (target_can_async_p ())
+      if (target_can_async_p () && infrun_async_inferior_event_token)
 	{
 	  target_async (inferior_event_handler, 0);
 	  /* Tell the event loop we have something to process.  */
@@ -7857,14 +7857,27 @@ infrun_async_inferior_event_handler (gdb_client_data data)
 }
 
 void
+infrun_async_inferior_event_handler_install (void)
+{
+  /* Register extra event sources in the event loop.  */
+  infrun_async_inferior_event_token
+    = create_async_event_handler (infrun_async_inferior_event_handler, NULL);
+}
+
+void
+infrun_async_inferior_event_handler_remove (void)
+{
+  if (infrun_async_inferior_event_token)
+    delete_async_event_handler (&infrun_async_inferior_event_token);
+}
+
+void
 _initialize_infrun (void)
 {
   int i;
   int numsigs;
 
-  /* Register extra event sources in the event loop.  */
-  infrun_async_inferior_event_token
-    = create_async_event_handler (infrun_async_inferior_event_handler, NULL);
+  infrun_async_inferior_event_handler_install ();
 
   add_info ("signals", signals_info, _("\
 What debugger does when program gets various signals.\n\
diff --git a/gdb/remote.c b/gdb/remote.c
index 6d58aca..0fe2c9e 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -3022,6 +3022,8 @@ remote_close (int quitting)
     delete_async_event_handler (&remote_async_inferior_event_token);
   if (remote_async_get_pending_events_token)
     delete_async_event_handler (&remote_async_get_pending_events_token);
+
+  infrun_async_inferior_event_handler_install ();
 }
 
 /* Query the remote side for the text, data and bss offsets.  */
@@ -4208,6 +4210,8 @@ remote_open_1 (char *name, int from_tty,
     = create_async_event_handler (remote_async_get_pending_events_handler,
 				  NULL);
 
+  infrun_async_inferior_event_handler_remove ();
+
   /* Reset the target state; these things will be queried either by
      remote_query_supported or as they are needed.  */
   init_all_packet_configs ();
-- 
1.7.0.4


  parent reply	other threads:[~2012-05-03 13:13 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-03 13:12 [PATCH v4 0/14] Run all-stop on non-stop target Yao Qi
2012-05-03 13:12 ` [PATCH 03/14] Change parameters of adjust_pc_after_break Yao Qi
2012-05-03 13:12 ` [PATCH 01/14] Fix displaced stepping debug log Yao Qi
2012-05-03 15:01   ` Pedro Alves
2012-05-03 13:13 ` [PATCH 14/14] kfail gdb/13858 Yao Qi
2012-05-03 13:13 ` [PATCH 13/14] ia64-sigill.exp: Don't assume there's no infrun output after the prompt Yao Qi
2012-05-03 13:13 ` [PATCH 02/14] Move displaced_step_fixup bits out to displaced_step_next Yao Qi
2012-05-03 13:13 ` [PATCH 06/14] Flip to set target-async on by default and NEWS Yao Qi
2012-05-03 13:13 ` [PATCH 07/14] Support in remote target Yao Qi
2012-05-03 13:13 ` [PATCH 11/14] Fix fails in gdb.trace/pending.exp Yao Qi
2012-05-03 13:13 ` Yao Qi [this message]
2012-05-03 13:13 ` [PATCH 05/14] Support in linux-nat target Yao Qi
2012-05-03 13:13 ` [PATCH 10/14] watchthreads-reorder.exp: Don't assume there is no infrun output after prompt Yao Qi
2012-05-03 13:13 ` [PATCH 12/14] manythreads.exp: Adjust to handle threads appearing/disappearing after "Program received signal SIGFOO" Yao Qi
2012-05-03 13:13 ` [PATCH 09/14] Set thread's state in infcall Yao Qi
2012-05-03 13:14 ` [PATCH 04/14] Run all-stop on non-stop Yao Qi
2012-05-03 14:23 ` [PATCH v4 0/14] Run all-stop on non-stop target Pedro Alves
2012-05-03 14:38   ` Yao Qi
2012-05-09 17:46     ` Pedro Alves
2012-05-10 12:09       ` Yao Qi
2012-05-10 14:21         ` Pedro Alves
2012-05-26 11:08           ` Yao Qi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1336050869-29605-9-git-send-email-yao@codesourcery.com \
    --to=yao@codesourcery.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox