From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30643 invoked by alias); 3 May 2012 13:12:52 -0000 Received: (qmail 30369 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,TW_EG 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:34 +0000 Received: from svr-orw-fem-01.mgc.mentorg.com ([147.34.98.93]) by relay1.mentorg.com with esmtp id 1SPvph-0005Kh-RA from Yao_Qi@mentor.com for gdb-patches@sourceware.org; Thu, 03 May 2012 06:12:33 -0700 Received: from SVR-ORW-FEM-02.mgc.mentorg.com ([147.34.96.206]) by svr-orw-fem-01.mgc.mentorg.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.4675); Thu, 3 May 2012 06:12:33 -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:24 -0700 From: Yao Qi To: Subject: [PATCH 03/14] Change parameters of adjust_pc_after_break. Date: Thu, 03 May 2012 13:12:00 -0000 Message-ID: <1336050869-29605-4-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/msg00065.txt.bz2 A refactor change patch. gdb: 2012-04-12 Pedro Alves * infrun.c (adjust_pc_after_break): Remove parameter `ecs'. Add parameter `thread' and 'ws'. Change to return int. (handle_inferior_event): Caller update. --- gdb/infrun.c | 38 ++++++++++++++++++++++++-------------- 1 files changed, 24 insertions(+), 14 deletions(-) diff --git a/gdb/infrun.c b/gdb/infrun.c index c58688c..9de9674 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -2937,13 +2937,18 @@ context_switch (ptid_t ptid) switch_to_thread (ptid); } -static void -adjust_pc_after_break (struct execution_control_state *ecs) +/* Adjust PC value after thread THREAD hits breakpoint. Return 1 if PC value + is adjusted, otherwise, return 0. */ + +static int +adjust_pc_after_break (struct thread_info *thread, + struct target_waitstatus *ws) { struct regcache *regcache; struct gdbarch *gdbarch; struct address_space *aspace; CORE_ADDR breakpoint_pc; + int ret = 0; /* If we've hit a breakpoint, we'll normally be stopped with SIGTRAP. If we aren't, just return. @@ -2966,11 +2971,11 @@ adjust_pc_after_break (struct execution_control_state *ecs) target with both of these set in GDB history, and it seems unlikely to be correct, so gdbarch_have_nonsteppable_watchpoint is not checked here. */ - if (ecs->ws.kind != TARGET_WAITKIND_STOPPED) - return; + if (ws->kind != TARGET_WAITKIND_STOPPED) + return 0; - if (ecs->ws.value.sig != TARGET_SIGNAL_TRAP) - return; + if (ws->value.sig != TARGET_SIGNAL_TRAP) + return 0; /* In reverse execution, when a breakpoint is hit, the instruction under it has already been de-executed. The reported PC always @@ -2999,14 +3004,14 @@ adjust_pc_after_break (struct execution_control_state *ecs) INSN1 hadn't been de-executed yet. Doing nothing is the correct behaviour. */ if (execution_direction == EXEC_REVERSE) - return; + return 0; /* If this target does not decrement the PC after breakpoints, then we have nothing to do. */ - regcache = get_thread_regcache (ecs->ptid); + regcache = get_thread_regcache (thread->ptid); gdbarch = get_regcache_arch (regcache); if (gdbarch_decr_pc_after_break (gdbarch) == 0) - return; + return 0; aspace = get_regcache_aspace (regcache); @@ -3050,14 +3055,19 @@ adjust_pc_after_break (struct execution_control_state *ecs) we also need to back up to the breakpoint address. */ if (singlestep_breakpoints_inserted_p - || !ptid_equal (ecs->ptid, inferior_ptid) - || !currently_stepping (ecs->event_thread) - || ecs->event_thread->prev_pc == breakpoint_pc) - regcache_write_pc (regcache, breakpoint_pc); + || !ptid_equal (thread->ptid, inferior_ptid) + || !currently_stepping (thread) + || thread->prev_pc == breakpoint_pc) + { + regcache_write_pc (regcache, breakpoint_pc); + ret = 1; + } if (RECORD_IS_USED) do_cleanups (old_cleanups); } + + return ret; } void @@ -3264,7 +3274,7 @@ handle_inferior_event (struct execution_control_state *ecs) ecs->event_thread = find_thread_ptid (ecs->ptid); /* Dependent on valid ECS->EVENT_THREAD. */ - adjust_pc_after_break (ecs); + adjust_pc_after_break (ecs->event_thread, &ecs->ws); /* Dependent on the current PC value modified by adjust_pc_after_break. */ reinit_frame_cache (); -- 1.7.0.4