From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 67447 invoked by alias); 17 Sep 2015 14:10:06 -0000 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 Received: (qmail 67236 invoked by uid 89); 17 Sep 2015 14:10:04 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL,BAYES_00,KAM_LAZY_DOMAIN_SECURITY,T_RP_MATCHES_RCVD autolearn=no version=3.3.2 X-HELO: mga02.intel.com Received: from mga02.intel.com (HELO mga02.intel.com) (134.134.136.20) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 17 Sep 2015 14:09:56 +0000 Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga101.jf.intel.com with ESMTP; 17 Sep 2015 07:09:54 -0700 X-ExtLoop1: 1 Received: from irvmail001.ir.intel.com ([163.33.26.43]) by orsmga001.jf.intel.com with ESMTP; 17 Sep 2015 07:09:53 -0700 Received: from ulvlx001.iul.intel.com (ulvlx001.iul.intel.com [172.28.207.17]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id t8HE9rw8001514; Thu, 17 Sep 2015 15:09:53 +0100 Received: from ulvlx001.iul.intel.com (localhost [127.0.0.1]) by ulvlx001.iul.intel.com with ESMTP id t8HE9qLs001541; Thu, 17 Sep 2015 16:09:52 +0200 Received: (from mmetzger@localhost) by ulvlx001.iul.intel.com with œ id t8HE9qvD001537; Thu, 17 Sep 2015 16:09:52 +0200 From: Markus Metzger To: palves@redhat.com Cc: gdb-patches@sourceware.org Subject: [PATCH v3 06/19] btrace: move breakpoint checking into stepping functions Date: Thu, 17 Sep 2015 14:10:00 -0000 Message-Id: <1442498990-1222-7-git-send-email-markus.t.metzger@intel.com> In-Reply-To: <1442498990-1222-1-git-send-email-markus.t.metzger@intel.com> References: <1442498990-1222-1-git-send-email-markus.t.metzger@intel.com> X-IsSubscribed: yes X-SW-Source: 2015-09/txt/msg00426.txt.bz2 Breakpoints are only checked for BTHR_CONT and BTHR_RCONT stepping requests. A BTHR_STEP and BTHR_RSTEP request will always report stopped without reason. Since breakpoints are reported correctly, I assume infrun is handling this. Move the breakpoint check into the btrace single stepping functions. This will cause us to report breakpoint hits now also for single-step requests. One thing to notice is that - when executing forwards, the breakpoint is checked before 'executing' the instruction, i.e. before moving the PC to the next instruction. - when executing backwards, the breakpoint is checked after 'executing' the instruction, i.e. after moving the PC to the preceding instruction in the recorded execution. There is code in infrun (see, for example proceed and adjust_pc_after_break) that handles this and also depends on this behaviour. 2015-09-17 Markus Metzger gdb/ * record-btrace.c (record_btrace_step_thread): Move breakpoint check to ... (record_btrace_single_step_forward): ... here and (record_btrace_single_step_backward): ... here. --- gdb/record-btrace.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/gdb/record-btrace.c b/gdb/record-btrace.c index fdf7afb..5e8c1d4 100644 --- a/gdb/record-btrace.c +++ b/gdb/record-btrace.c @@ -2038,6 +2038,10 @@ record_btrace_single_step_forward (struct thread_info *tp) if (replay == NULL) return btrace_step_no_history (); + /* Check if we're stepping a breakpoint. */ + if (record_btrace_replay_at_breakpoint (tp)) + return btrace_step_stopped (); + /* Skip gaps during replay. */ do { @@ -2089,6 +2093,18 @@ record_btrace_single_step_backward (struct thread_info *tp) } while (btrace_insn_get (replay) == NULL); + /* Check if we're stepping a breakpoint. + + For reverse-stepping, this check is after the step. There is logic in + infrun.c that handles reverse-stepping separately. See, for example, + proceed and adjust_pc_after_break. + + This code assumes that for reverse-stepping, PC points to the last + de-executed instruction, whereas for forward-stepping PC points to the + next to-be-executed instruction. */ + if (record_btrace_replay_at_breakpoint (tp)) + return btrace_step_stopped (); + return btrace_step_spurious (); } @@ -2154,9 +2170,6 @@ record_btrace_step_thread (struct thread_info *tp) target_pid_to_str (tp->ptid), core_addr_to_string_nz (insn->pc)); } - - if (record_btrace_replay_at_breakpoint (tp)) - return btrace_step_stopped (); } case BTHR_RCONT: @@ -2176,9 +2189,6 @@ record_btrace_step_thread (struct thread_info *tp) DEBUG ("reverse-stepping %d (%s) ... %s", tp->num, target_pid_to_str (tp->ptid), core_addr_to_string_nz (insn->pc)); - - if (record_btrace_replay_at_breakpoint (tp)) - return btrace_step_stopped (); } } } -- 1.8.3.1