From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 555 invoked by alias); 3 May 2012 13:13:07 -0000 Received: (qmail 32691 invoked by uid 22791); 3 May 2012 13:13:05 -0000 X-SWARE-Spam-Status: No, hits=-4.1 required=5.0 tests=AWL,BAYES_00,FROM_12LTRDOM,KHOP_RCVD_UNTRUST,KHOP_THREADED,RCVD_IN_HOSTKARMA_W,RCVD_IN_HOSTKARMA_WL X-Spam-Check-By: sourceware.org Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 03 May 2012 13:12:50 +0000 Received: from svr-orw-exc-10.mgc.mentorg.com ([147.34.98.58]) by relay1.mentorg.com with esmtp id 1SPvpw-0005MA-Tv from Yao_Qi@mentor.com for gdb-patches@sourceware.org; Thu, 03 May 2012 06:12:48 -0700 Received: from SVR-ORW-FEM-02.mgc.mentorg.com ([147.34.96.206]) by SVR-ORW-EXC-10.mgc.mentorg.com with Microsoft SMTPSVC(6.0.3790.4675); Thu, 3 May 2012 06:12:42 -0700 Received: from localhost.localdomain (147.34.91.1) by svr-orw-fem-02.mgc.mentorg.com (147.34.96.168) with Microsoft SMTP Server id 14.1.289.1; Thu, 3 May 2012 06:12:39 -0700 From: Yao Qi To: Subject: [PATCH 08/14] Uninstall infrun_async_inferior_event token in remote target. Date: Thu, 03 May 2012 13:13:00 -0000 Message-ID: <1336050869-29605-9-git-send-email-yao@codesourcery.com> In-Reply-To: <1336050869-29605-1-git-send-email-yao@codesourcery.com> References: <1336050869-29605-1-git-send-email-yao@codesourcery.com> MIME-Version: 1.0 Content-Type: text/plain X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2012-05/txt/msg00072.txt.bz2 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 * 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