From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30463 invoked by alias); 3 May 2012 13:12:51 -0000 Received: (qmail 30360 invoked by uid 22791); 3 May 2012 13:12:49 -0000 X-SWARE-Spam-Status: No, hits=-4.0 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:31 +0000 Received: from svr-orw-exc-10.mgc.mentorg.com ([147.34.98.58]) by relay1.mentorg.com with esmtp id 1SPvpf-0005KK-3k from Yao_Qi@mentor.com for gdb-patches@sourceware.org; Thu, 03 May 2012 06:12:31 -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:24 -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:21 -0700 From: Yao Qi To: Subject: [PATCH 02/14] Move displaced_step_fixup bits out to displaced_step_next. Date: Thu, 03 May 2012 13:13:00 -0000 Message-ID: <1336050869-29605-3-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/msg00067.txt.bz2 It is a refactor patch. No functionality is changed. gdb: 2012-04-12 Pedro Alves * infrun.c (displaced_step_fixup): Change return type to int. Factor out bits into ... (displaced_step_next): ... this. (handle_inferior_event): Call displaced_step_next if displaced_step_fixup returns non-zero. --- gdb/infrun.c | 35 +++++++++++++++++++++++++++++------ 1 files changed, 29 insertions(+), 6 deletions(-) diff --git a/gdb/infrun.c b/gdb/infrun.c index c3074d5..c58688c 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -1432,21 +1432,26 @@ displaced_step_restore (struct displaced_step_inferior_state *displaced, displaced->step_copy)); } -static void +/* Fix up the resulting state after displaced stepping. Return 0 if + no event to process. Return 1 if instruction completes, otherwise + return -1. */ + +static int displaced_step_fixup (ptid_t event_ptid, enum target_signal signal) { struct cleanup *old_cleanups; struct displaced_step_inferior_state *displaced = get_displaced_stepping_state (ptid_get_pid (event_ptid)); + int ret; /* Was any thread of this process doing a displaced step? */ if (displaced == NULL) - return; + return 0; /* Was this event for the pid we displaced? */ if (ptid_equal (displaced->step_ptid, null_ptid) || ! ptid_equal (displaced->step_ptid, event_ptid)) - return; + return 0; old_cleanups = make_cleanup (displaced_step_clear_cleanup, displaced); @@ -1461,6 +1466,7 @@ displaced_step_fixup (ptid_t event_ptid, enum target_signal signal) displaced->step_original, displaced->step_copy, get_thread_regcache (displaced->step_ptid)); + ret = 1; } else { @@ -1471,12 +1477,27 @@ displaced_step_fixup (ptid_t event_ptid, enum target_signal signal) pc = displaced->step_original + (pc - displaced->step_copy); regcache_write_pc (regcache, pc); + ret = -1; } do_cleanups (old_cleanups); displaced->step_ptid = null_ptid; + return ret; +} + +/* Process pending displaced stepping requests. */ + +static void +displaced_step_next (ptid_t event_ptid) +{ + struct displaced_step_inferior_state *displaced + = get_displaced_stepping_state (ptid_get_pid (event_ptid)); + + if (displaced == NULL) + return; + /* Are there any pending displaced stepping requests? If so, run one now. Leave the state object around, since we're likely to need it again soon. */ @@ -3481,7 +3502,8 @@ handle_inferior_event (struct execution_control_state *ecs) has been done. Perform cleanup for parent process here. Note that this operation also cleans up the child process for vfork, because their pages are shared. */ - displaced_step_fixup (ecs->ptid, TARGET_SIGNAL_TRAP); + if (displaced_step_fixup (ecs->ptid, TARGET_SIGNAL_TRAP)) + displaced_step_next (ecs->ptid); if (ecs->ws.kind == TARGET_WAITKIND_FORKED) { @@ -3743,8 +3765,9 @@ handle_inferior_event (struct execution_control_state *ecs) /* Do we need to clean up the state of a thread that has completed a displaced single-step? (Doing so usually affects the PC, so do it here, before we set stop_pc.) */ - displaced_step_fixup (ecs->ptid, - ecs->event_thread->suspend.stop_signal); + if (displaced_step_fixup (ecs->ptid, + ecs->event_thread->suspend.stop_signal)) + displaced_step_next (ecs->ptid); /* If we either finished a single-step or hit a breakpoint, but the user wanted this thread to be stopped, pretend we got a -- 1.7.0.4