This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH 08/14] Uninstall infrun_async_inferior_event token in remote target.


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]