From: "Willgerodt, Felix" <felix.willgerodt@intel.com>
To: "Metzger, Markus T" <markus.t.metzger@intel.com>,
"gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
Subject: RE: [PATCH 04/10] btrace: Handle stepping and goto for auxiliary instructions.
Date: Mon, 14 Jun 2021 14:53:04 +0000 [thread overview]
Message-ID: <4efa9e8ee809474bb2cb514fb94204ad@intel.com> (raw)
In-Reply-To: <A78C989F6D9628469189715575E55B236B43FCE5@IRSMSX104.ger.corp.intel.com>
I should have fixed all comments.
Thanks,
Felix
On 6/4/19 2:35 PM, Metzger, Markus T wrote:
Hello Felix,
> @@ -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;
Please preserve the order of comment and code.
> +
> + /* 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
Should this say 'print the aux data'?
> + 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];
The below btrace_insn_next () already advances REPLAY to the next instruction. You may use btrace_insn_next (replay) to get that instruction.
> +
> + 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);
Since we now call btrace_insn_get (replay) inside the loop, we should rewrite this.
> @@ -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];
Same here.
> +
> + 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);
You need to check FOUND before dereferencing 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);
> --
> 2.20.1
Thanks,
Markus.
Intel Deutschland GmbH
Registered Address: Am Campeon 10, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de <http://www.intel.de>
Managing Directors: Christin Eisenschmid, Sharon Heck, Tiffany Doon Silva
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928
prev parent reply other threads:[~2021-06-14 14:53 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-29 8:48 [PATCH 00/10] Extensions for PTWRITE felix.willgerodt
2019-05-29 8:48 ` [PATCH 06/10] python: Add clear_trace() to gdb.Record felix.willgerodt
2019-05-29 14:41 ` Eli Zaretskii
2019-06-04 12:36 ` Metzger, Markus T
2021-06-14 14:53 ` Willgerodt, Felix
2019-05-29 8:48 ` [PATCH 07/10] btrace, linux: Enable ptwrite packets felix.willgerodt
2019-06-04 12:36 ` Metzger, Markus T
2021-06-14 14:53 ` Willgerodt, Felix
2019-05-29 8:48 ` [PATCH 08/10] btrace, python: Enable ptwrite listener registration felix.willgerodt
2019-06-04 12:36 ` Metzger, Markus T
2021-06-14 14:53 ` Willgerodt, Felix
2019-05-29 8:48 ` [PATCH 09/10] btrace, python: Enable calling the ptwrite listener felix.willgerodt
2019-06-04 12:37 ` Metzger, Markus T
2021-06-14 14:53 ` Willgerodt, Felix
2019-05-29 8:48 ` [PATCH 03/10] btrace: Enable auxiliary instructions in record function-call-history felix.willgerodt
2019-05-29 14:40 ` Eli Zaretskii
2019-06-04 12:35 ` Metzger, Markus T
2021-06-14 14:53 ` Willgerodt, Felix
2021-06-16 9:13 ` Metzger, Markus T
2021-06-16 10:03 ` Willgerodt, Felix
2021-06-16 10:16 ` Metzger, Markus T
2019-05-29 8:48 ` [PATCH 02/10] btrace: Enable auxiliary instructions in record instruction-history felix.willgerodt
2019-06-04 12:35 ` Metzger, Markus T
2021-06-14 14:53 ` Willgerodt, Felix
2019-05-29 8:48 ` [PATCH 10/10] btrace: Extend event decoding for ptwrite felix.willgerodt
2019-05-29 14:53 ` Eli Zaretskii
2019-06-04 12:37 ` Metzger, Markus T
2021-06-14 14:53 ` Willgerodt, Felix
2019-05-29 8:48 ` [PATCH 05/10] python: Introduce gdb.RecordAuxiliary class felix.willgerodt
2019-05-29 14:42 ` Eli Zaretskii
2019-06-04 12:36 ` Metzger, Markus T
2021-06-14 14:53 ` Willgerodt, Felix
2019-05-29 8:48 ` [PATCH 01/10] btrace: Introduce auxiliary instructions felix.willgerodt
2019-05-29 14:39 ` Eli Zaretskii
2019-06-04 12:35 ` Metzger, Markus T
2019-05-29 8:48 ` [PATCH 04/10] btrace: Handle stepping and goto for " felix.willgerodt
2019-06-04 12:35 ` Metzger, Markus T
2021-06-14 14:53 ` Willgerodt, Felix [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4efa9e8ee809474bb2cb514fb94204ad@intel.com \
--to=felix.willgerodt@intel.com \
--cc=gdb-patches@sourceware.org \
--cc=markus.t.metzger@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).