From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 49719 invoked by alias); 11 Sep 2015 06:51:56 -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 49694 invoked by uid 89); 11 Sep 2015 06:51:55 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.7 required=5.0 tests=AWL,BAYES_50,KAM_LAZY_DOMAIN_SECURITY,T_RP_MATCHES_RCVD autolearn=no version=3.3.2 X-HELO: mga03.intel.com Received: from mga03.intel.com (HELO mga03.intel.com) (134.134.136.65) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 11 Sep 2015 06:51:52 +0000 Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga103.jf.intel.com with ESMTP; 10 Sep 2015 23:51:48 -0700 X-ExtLoop1: 1 Received: from irvmail001.ir.intel.com ([163.33.26.43]) by orsmga001.jf.intel.com with ESMTP; 10 Sep 2015 23:51:42 -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 t8B6pedT021799; Fri, 11 Sep 2015 07:51:40 +0100 Received: from ulvlx001.iul.intel.com (localhost [127.0.0.1]) by ulvlx001.iul.intel.com with ESMTP id t8B6pdbQ025597; Fri, 11 Sep 2015 08:51:39 +0200 Received: (from mmetzger@localhost) by ulvlx001.iul.intel.com with œ id t8B6pdGg025593; Fri, 11 Sep 2015 08:51:39 +0200 From: Markus Metzger To: palves@redhat.com Cc: gdb-patches@sourceware.org Subject: [PATCH v2 04/17] btrace: extract the breakpoint check from record_btrace_step_thread Date: Fri, 11 Sep 2015 06:51:00 -0000 Message-Id: <1441954298-25298-5-git-send-email-markus.t.metzger@intel.com> In-Reply-To: <1441954298-25298-1-git-send-email-markus.t.metzger@intel.com> References: <1441954298-25298-1-git-send-email-markus.t.metzger@intel.com> X-IsSubscribed: yes X-SW-Source: 2015-09/txt/msg00191.txt.bz2 There are two places where record_btrace_step_thread checks for a breakpoint at the current replay position. Move this code into its own function. 2015-09-11 Markus Metzger gdb/ * record-btrace.c (record_btrace_replay_at_breakpoint): New. (record_btrace_step_thread): Call record_btrace_replay_at_breakpoint. --- gdb/record-btrace.c | 42 ++++++++++++++++++++++++++++++------------ 1 file changed, 30 insertions(+), 12 deletions(-) diff --git a/gdb/record-btrace.c b/gdb/record-btrace.c index 7ee681c..77494ba 100644 --- a/gdb/record-btrace.c +++ b/gdb/record-btrace.c @@ -1983,6 +1983,34 @@ record_btrace_clear_histories (struct btrace_thread_info *btinfo) btinfo->call_history = NULL; } +/* Check whether TP's current replay position is at a breakpoint. */ + +static int +record_btrace_replay_at_breakpoint (struct thread_info *tp) +{ + struct btrace_insn_iterator *replay; + struct btrace_thread_info *btinfo; + const struct btrace_insn *insn; + struct inferior *inf; + + btinfo = &tp->btrace; + replay = btinfo->replay; + + if (replay == NULL) + return 0; + + insn = btrace_insn_get (replay); + if (insn == NULL) + return 0; + + inf = find_inferior_ptid (tp->ptid); + if (inf == NULL) + return 0; + + return record_check_stopped_by_breakpoint (inf->aspace, insn->pc, + &btinfo->stop_reason); +} + /* Step a single thread. */ static struct target_waitstatus @@ -1990,8 +2018,6 @@ record_btrace_step_thread (struct thread_info *tp) { struct btrace_insn_iterator *replay, end; struct btrace_thread_info *btinfo; - struct address_space *aspace; - struct inferior *inf; enum btrace_thread_flag flags; unsigned int steps; @@ -2067,9 +2093,6 @@ record_btrace_step_thread (struct thread_info *tp) if (replay == NULL) return btrace_step_no_history (); - inf = find_inferior_ptid (tp->ptid); - aspace = inf->aspace; - /* Determine the end of the instruction trace. */ btrace_insn_end (&end, btinfo); @@ -2102,8 +2125,7 @@ record_btrace_step_thread (struct thread_info *tp) target_pid_to_str (tp->ptid), core_addr_to_string_nz (insn->pc)); - if (record_check_stopped_by_breakpoint (aspace, insn->pc, - &btinfo->stop_reason)) + if (record_btrace_replay_at_breakpoint (tp)) return btrace_step_stopped (); } @@ -2112,9 +2134,6 @@ record_btrace_step_thread (struct thread_info *tp) if (replay == NULL) replay = record_btrace_start_replaying (tp); - inf = find_inferior_ptid (tp->ptid); - aspace = inf->aspace; - for (;;) { const struct btrace_insn *insn; @@ -2135,8 +2154,7 @@ record_btrace_step_thread (struct thread_info *tp) target_pid_to_str (tp->ptid), core_addr_to_string_nz (insn->pc)); - if (record_check_stopped_by_breakpoint (aspace, insn->pc, - &btinfo->stop_reason)) + if (record_btrace_replay_at_breakpoint (tp)) return btrace_step_stopped (); } } -- 1.8.3.1