From patchwork Wed May 29 08:47:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Willgerodt, Felix" X-Patchwork-Id: 32889 Received: (qmail 11163 invoked by alias); 29 May 2019 08:48:25 -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 10882 invoked by uid 89); 29 May 2019 08:48:16 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-24.4 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3 autolearn=ham version=3.3.1 spammy=H*r:LOCAL, reaching, history X-HELO: mga18.intel.com Received: from mga18.intel.com (HELO mga18.intel.com) (134.134.136.126) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 29 May 2019 08:48:14 +0000 Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 29 May 2019 01:48:13 -0700 Received: from irvmail001.ir.intel.com ([163.33.26.43]) by orsmga001.jf.intel.com with ESMTP; 29 May 2019 01:48:11 -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 x4T8mBjS007658; Wed, 29 May 2019 09:48:11 +0100 Received: from ulvlx001.iul.intel.com (localhost [127.0.0.1]) by ulvlx001.iul.intel.com with ESMTP id x4T8mB9Q030791; Wed, 29 May 2019 10:48:11 +0200 Received: (from fwillger@localhost) by ulvlx001.iul.intel.com with LOCAL id x4T8mAwU030787; Wed, 29 May 2019 10:48:11 +0200 From: felix.willgerodt@intel.com To: gdb-patches@sourceware.org Cc: markus.t.metzger@intel.com, Felix Willgerodt Subject: [PATCH 04/10] btrace: Handle stepping and goto for auxiliary instructions. Date: Wed, 29 May 2019 10:47:47 +0200 Message-Id: <1559119673-30516-5-git-send-email-felix.willgerodt@intel.com> In-Reply-To: <1559119673-30516-1-git-send-email-felix.willgerodt@intel.com> References: <1559119673-30516-1-git-send-email-felix.willgerodt@intel.com> X-IsSubscribed: yes From: Felix Willgerodt Print the auxiliary data when stepping. Don't allow to goto an auxiliary instruction. This patch is in preparation for the ptwrite feature, which is based on auxiliary instructions. 2019-05-29 Felix Willgerodt gdb/ChangeLog: * record-btrace.c: (record_btrace_single_step_forward): Handle BTRACE_INSN_AUX. (record_btrace_single_step_backward): Likewise. (record_btrace_goto): Likewise. --- gdb/record-btrace.c | 52 ++++++++++++++++++++++++++++++++++++++------- 1 file changed, 44 insertions(+), 8 deletions(-) diff --git a/gdb/record-btrace.c b/gdb/record-btrace.c index 5f70c4838a9..573326924a2 100644 --- a/gdb/record-btrace.c +++ b/gdb/record-btrace.c @@ -2366,6 +2366,8 @@ record_btrace_single_step_forward (struct thread_info *tp) { struct btrace_insn_iterator *replay, end, start; struct btrace_thread_info *btinfo; + const struct btrace_function *bfun; + struct btrace_insn next_insn; btinfo = &tp->btrace; replay = btinfo->replay; @@ -2378,13 +2380,26 @@ record_btrace_single_step_forward (struct thread_info *tp) if (record_btrace_replay_at_breakpoint (tp)) return btrace_step_stopped (); - /* Skip gaps during replay. If we end up at a gap (at the end of the trace), - jump back to the instruction at which we started. */ start = *replay; + + /* Skip gaps during replay. If we end up at a gap (at the end of the trace), + jump back to the instruction at which we started. If we're stepping a + BTRACE_INSN_AUX instruction, print the ptwrite string and skip the + instruction. */ do { unsigned int steps; + /* If we're stepping a BTRACE_INSN_AUX instruction, print the auxiliary + data and skip the instruction. If we are at the end of the trace, jump + back to the instruction at which we started. */ + bfun = &replay->btinfo->functions[replay->call_index]; + next_insn = bfun->insn[replay->insn_index + 1]; + + if (next_insn.iclass == BTRACE_INSN_AUX) + printf_unfiltered ( + "[%s]\n", btinfo->aux_data[next_insn.aux_data_index].c_str ()); + /* We will bail out here if we continue stepping after reaching the end of the execution history. */ steps = btrace_insn_next (replay, 1); @@ -2394,7 +2409,8 @@ record_btrace_single_step_forward (struct thread_info *tp) return btrace_step_no_history (); } } - while (btrace_insn_get (replay) == NULL); + while (btrace_insn_get (replay) == NULL + || next_insn.iclass == BTRACE_INSN_AUX); /* Determine the end of the instruction trace. */ btrace_insn_end (&end, btinfo); @@ -2415,6 +2431,8 @@ record_btrace_single_step_backward (struct thread_info *tp) { struct btrace_insn_iterator *replay, start; struct btrace_thread_info *btinfo; + const struct btrace_function *bfun; + struct btrace_insn prev_insn; btinfo = &tp->btrace; replay = btinfo->replay; @@ -2452,6 +2470,22 @@ record_btrace_single_step_backward (struct thread_info *tp) if (record_btrace_replay_at_breakpoint (tp)) return btrace_step_stopped (); + /* Check if we're stepping a BTRACE_INSN_AUX instruction and skip it. */ + bfun = &replay->btinfo->functions[replay->call_index]; + prev_insn = bfun->insn[replay->insn_index]; + + if (prev_insn.iclass == BTRACE_INSN_AUX) + { + printf_unfiltered ("[%s]\n", + btinfo->aux_data[prev_insn.aux_data_index].c_str ()); + unsigned int steps = btrace_insn_prev (replay, 1); + if (steps == 0) + { + *replay = start; + return btrace_step_no_history (); + } + } + return btrace_step_spurious (); } @@ -2853,25 +2887,27 @@ record_btrace_target::goto_record_end () /* The goto_record method of target record-btrace. */ void -record_btrace_target::goto_record (ULONGEST insn) +record_btrace_target::goto_record (ULONGEST insn_number) { struct thread_info *tp; struct btrace_insn_iterator it; unsigned int number; int found; - number = insn; + number = insn_number; /* Check for wrap-arounds. */ - if (number != insn) + if (number != insn_number) error (_("Instruction number out of range.")); tp = require_btrace_thread (); found = btrace_find_insn_by_number (&it, &tp->btrace, number); + const struct btrace_insn *insn = btrace_insn_get (&it); - /* Check if the instruction could not be found or is a gap. */ - if (found == 0 || btrace_insn_get (&it) == NULL) + /* Check if the instruction could not be found or is a gap or an + auxilliary instruction. */ + if ((found == 0) || (insn == NULL) || (insn->iclass == BTRACE_INSN_AUX)) error (_("No such instruction.")); record_btrace_set_replay (tp, &it);