From patchwork Thu May 21 23:18:58 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Alves X-Patchwork-Id: 6862 Received: (qmail 64104 invoked by alias); 21 May 2015 23:19:21 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 64036 invoked by uid 89); 21 May 2015 23:19:21 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.5 required=5.0 tests=AWL, BAYES_40, KAM_LAZY_DOMAIN_SECURITY, SPF_HELO_PASS, T_RP_MATCHES_RCVD autolearn=no version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Thu, 21 May 2015 23:19:19 +0000 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 4AA5C5D for ; Thu, 21 May 2015 23:19:18 +0000 (UTC) Received: from brno.lan (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t4LNJEJ0027592 for ; Thu, 21 May 2015 19:19:17 -0400 From: Pedro Alves To: gdb-patches@sourceware.org Subject: [PATCH 02/18] Change adjust_pc_after_break's prototype Date: Fri, 22 May 2015 00:18:58 +0100 Message-Id: <1432250354-2721-3-git-send-email-palves@redhat.com> In-Reply-To: <1432250354-2721-1-git-send-email-palves@redhat.com> References: <1432250354-2721-1-git-send-email-palves@redhat.com> Prepare to use it in contexts without an ecs handy. Follow up patches will make use of this. gdb/ChangeLog: 2015-05-21 Pedro Alves * infrun.c (adjust_pc_after_break): Now takes thread_info and waitstatus pointers instead of an ecs. Adjust. (handle_inferior_event): Adjust caller. --- gdb/infrun.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/gdb/infrun.c b/gdb/infrun.c index 537de36..cce021d 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -3432,8 +3432,14 @@ context_switch (ptid_t ptid) switch_to_thread (ptid); } +/* If the target can't tell whether we've hit breakpoints + (target_supports_stopped_by_sw_breakpoint), and we got a SIGTRAP, + check whether that could have been caused by a breakpoint. If so, + adjust the PC, per gdbarch_decr_pc_after_break. */ + static void -adjust_pc_after_break (struct execution_control_state *ecs) +adjust_pc_after_break (struct thread_info *thread, + struct target_waitstatus *ws) { struct regcache *regcache; struct gdbarch *gdbarch; @@ -3461,10 +3467,10 @@ 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) + if (ws->kind != TARGET_WAITKIND_STOPPED) return; - if (ecs->ws.value.sig != GDB_SIGNAL_TRAP) + if (ws->value.sig != GDB_SIGNAL_TRAP) return; /* In reverse execution, when a breakpoint is hit, the instruction @@ -3510,7 +3516,7 @@ adjust_pc_after_break (struct execution_control_state *ecs) /* 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); decr_pc = gdbarch_decr_pc_after_break (gdbarch); @@ -3564,10 +3570,10 @@ adjust_pc_after_break (struct execution_control_state *ecs) software breakpoint. In this case (prev_pc == breakpoint_pc), we also need to back up to the breakpoint address. */ - if (thread_has_single_step_breakpoints_set (ecs->event_thread) - || !currently_stepping (ecs->event_thread) - || (ecs->event_thread->stepped_breakpoint - && ecs->event_thread->prev_pc == breakpoint_pc)) + if (thread_has_single_step_breakpoints_set (thread) + || !currently_stepping (thread) + || (thread->stepped_breakpoint + && thread->prev_pc == breakpoint_pc)) regcache_write_pc (regcache, breakpoint_pc); do_cleanups (old_cleanups); @@ -3748,7 +3754,7 @@ handle_inferior_event_1 (struct execution_control_state *ecs) } /* 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 ();