From: "Metzger, Markus T" <markus.t.metzger@intel.com>
To: Jan Kratochvil <jan.kratochvil@redhat.com>
Cc: "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
Subject: RE: [+rfc] Re: [patch v6 00/21] record-btrace: reverse
Date: Thu, 07 Nov 2013 15:44:00 -0000 [thread overview]
Message-ID: <A78C989F6D9628469189715575E55B230AA127B9@IRSMSX104.ger.corp.intel.com> (raw)
In-Reply-To: <20131006195913.GA2518@host2.jankratochvil.net>
> -----Original Message-----
> From: Jan Kratochvil [mailto:jan.kratochvil@redhat.com]
> Sent: Sunday, October 06, 2013 9:59 PM
Hello Jan,
> Besides some nitpicks there remains the larger request
> Re: [patch v4 23/24] record-btrace: add (reverse-)stepping support
> https://sourceware.org/ml/gdb-patches/2013-09/msg01004.html
> Message-ID: <20130930102533.GA29665@host2.jankratochvil.net>
>
>
> to always use to_resume + to_wait for any change of history position. This
> also means the "hacks" like
> +record_btrace_goto_end (void)
> + print_stack_frame (get_selected_frame (NULL), 1, SRC_AND_LOC,
> 1);
> can be removed as normal GDB inferior stop will print the frame.
>
> Other comments are welcome if it is not a too strict requirement from me
> but
> I think we could face some forgotten resetting of future caches avoiding the
> normal resume+wait path this way. Or ... we would not face them but it
> would
> violate localized of cache resets in to_resume+to_wait code path.
I hacked a first prototype of this (see below). It passes most tests but
results in three fails in the record_goto suite.
One thing that it shows, though, is that it only removes the 'mostly harmless'
hack in the various goto functions shown above.
The more serious hacks in record_btrace_start_replaying
/* Make sure we're not using any stale registers. */
registers_changed_ptid (tp->ptid);
/* We just started replaying. The frame id cached for stepping is based
on unwinding, not on branch tracing. Recompute it. */
frame = get_current_frame_nocheck ();
insn = btrace_insn_get (replay);
sal = find_pc_line (insn->pc, 0);
set_step_info (frame, sal);
and record_btrace_stop_replaying
/* Make sure we're not leaving any stale registers. */
registers_changed_ptid (tp->ptid);
however, are not removed by this.
They are required when reverse-stepping the first time or when
stepping past the end of the execution trace.
I don't think that there's a big benefit in pursuing this. Plus the patch has the
potential of messing things up pretty badly if somehow (maybe due to some
unexpected error () somewhere in proceed ()) the record goto command does
not complete and BTHR_GOTO remains set.
Regards,
Markus.
diff --git a/gdb/btrace.h b/gdb/btrace.h
index 5b52ec6..c1a5d14 100644
--- a/gdb/btrace.h
+++ b/gdb/btrace.h
@@ -169,7 +169,10 @@ enum btrace_thread_flag
BTHR_RCONT = (1 << 3),
/* The thread is to be moved. */
- BTHR_MOVE = (BTHR_STEP | BTHR_RSTEP | BTHR_CONT | BTHR_RCONT)
+ BTHR_MOVE = (BTHR_STEP | BTHR_RSTEP | BTHR_CONT | BTHR_RCONT),
+
+ /* The thread is to go to GOTO_TARGET in its BTINFO. */
+ BTHR_GOTO = (1 << 4)
};
/* Branch trace information per thread.
@@ -212,6 +215,9 @@ struct btrace_thread_info
/* The current replay position. NULL if not replaying. */
struct btrace_insn_iterator *replay;
+
+ /* The goto target replay position. NULL if not active. */
+ struct btrace_insn_iterator *goto_target;
};
/* Enable branch tracing for a thread. */
diff --git a/gdb/record-btrace.c b/gdb/record-btrace.c
index f32f1fd..c559327 100644
--- a/gdb/record-btrace.c
+++ b/gdb/record-btrace.c
@@ -1459,6 +1459,17 @@ record_btrace_step_thread (struct thread_info *tp)
DEBUG ("stepping %d (%s): %u", tp->num, target_pid_to_str (tp->ptid), flags);
+ if ((btinfo->flags & BTHR_GOTO) != 0)
+ {
+ btinfo->replay = btinfo->goto_target;
+ btinfo->goto_target = NULL;
+ btinfo->flags &= ~BTHR_GOTO;
+
+ xfree (replay);
+
+ return btrace_step_stopped ();
+ }
+
switch (flags)
{
default:
@@ -1635,32 +1646,57 @@ record_btrace_find_new_threads (struct target_ops *ops)
}
}
-/* Set the replay branch trace instruction iterator. If IT is NULL, replay
+/* Move to the IT in the branch trace of TP. If IT is NULL, replay
is stopped. */
static void
-record_btrace_set_replay (struct thread_info *tp,
- const struct btrace_insn_iterator *it)
+record_btrace_goto_target (struct thread_info *tp,
+ const struct btrace_insn_iterator *it)
{
+ struct btrace_insn_iterator *goto_target;
struct btrace_thread_info *btinfo;
+ struct target_waitstatus ws;
btinfo = &tp->btrace;
- if (it == NULL || it->function == NULL)
- record_btrace_stop_replaying (tp);
+ if (btinfo->goto_target != NULL || (btinfo->flags & BTHR_GOTO) != 0)
+ error (_("Record goto already in progress."));
+
+ if ((btinfo->flags & BTHR_MOVE) != 0)
+ error (_("Thread is already moving."));
+
+ /* If we're not replaying, to_resume might misinterpret our request. */
+ if (btinfo->replay == NULL)
+ record_btrace_start_replaying (tp);
+
+ if (it == NULL)
+ goto_target = NULL;
else
{
- if (btinfo->replay == NULL)
- record_btrace_start_replaying (tp);
- else if (btrace_insn_cmp (btinfo->replay, it) == 0)
- return;
-
- *btinfo->replay = *it;
- registers_changed_ptid (tp->ptid);
+ goto_target = xmalloc (sizeof(*goto_target));
+ *goto_target = *it;
}
- /* Start anew from the new replay position. */
- record_btrace_clear_histories (btinfo);
+ btinfo->flags |= BTHR_GOTO;
+ btinfo->goto_target = goto_target;
+
+#if 0
+ if (goto_target != NULL)
+ tp->control.exception_resume_breakpoint =
+ set_momentary_breakpoint_at_pc (target_gdbarch (),
+ btrace_insn_get (goto_target)->pc,
+ bp_until);
+#endif
+#if 0
+ target_resume (tp->ptid, 0, GDB_SIGNAL_0);
+ target_wait (tp->ptid, &ws, 0);
+#else
+ clear_proceed_status ();
+ proceed ((CORE_ADDR) -1, GDB_SIGNAL_0, 0);
+#endif
+
+ if (btinfo->goto_target != NULL || (btinfo->flags & BTHR_GOTO) != 0)
+ error (_("Record goto failed."));
}
/* The to_goto_record_begin method of target record-btrace. */
@@ -1674,9 +1710,8 @@ record_btrace_goto_begin (void)
tp = require_btrace_thread ();
btrace_insn_begin (&begin, &tp->btrace);
- record_btrace_set_replay (tp, &begin);
- print_stack_frame (get_selected_frame (NULL), 1, SRC_AND_LOC, 1);
+ record_btrace_goto_target (tp, &begin);
}
/* The to_goto_record_end method of target record-btrace. */
@@ -1688,9 +1723,7 @@ record_btrace_goto_end (void)
tp = require_btrace_thread ();
- record_btrace_set_replay (tp, NULL);
-
- print_stack_frame (get_selected_frame (NULL), 1, SRC_AND_LOC, 1);
+ record_btrace_goto_target (tp, NULL);
}
/* The to_goto_record method of target record-btrace. */
@@ -1715,9 +1748,7 @@ record_btrace_goto (ULONGEST insn)
if (found == 0)
error (_("No such instruction."));
- record_btrace_set_replay (tp, &it);
-
- print_stack_frame (get_selected_frame (NULL), 1, SRC_AND_LOC, 1);
+ record_btrace_goto_target (tp, &it);
}
/* Initialize the record-btrace target ops. */
Intel GmbH
Dornacher Strasse 1
85622 Feldkirchen/Muenchen, Deutschland
Sitz der Gesellschaft: Feldkirchen bei Muenchen
Geschaeftsfuehrer: Christian Lamprechter, Hannes Schwaderer, Douglas Lusk
Registergericht: Muenchen HRB 47456
Ust.-IdNr./VAT Registration No.: DE129385895
Citibank Frankfurt a.M. (BLZ 502 109 00) 600119052
next prev parent reply other threads:[~2013-11-07 15:41 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-09-20 11:30 Markus Metzger
2013-09-20 11:30 ` [patch v6 06/21] btrace: increase buffer size Markus Metzger
2013-09-20 11:30 ` [patch v6 16/21] record-btrace: provide target_find_new_threads method Markus Metzger
2013-09-20 11:30 ` [patch v6 12/21] frame, backtrace: allow targets to supply a frame unwinder Markus Metzger
2013-09-20 11:30 ` [patch v6 10/21] target: add ops parameter to to_prepare_to_store method Markus Metzger
2013-09-20 11:30 ` [patch v6 02/21] gdbarch: add instruction predicate methods Markus Metzger
2013-09-20 11:30 ` [patch v6 15/21] record-btrace: add to_wait and to_resume target methods Markus Metzger
2013-09-20 11:30 ` [patch v6 14/21] record-btrace: provide xfer_partial target method Markus Metzger
2013-09-20 11:31 ` [patch v6 18/21] record-btrace: extend unwinder Markus Metzger
2013-10-06 19:49 ` Jan Kratochvil
2013-11-06 13:45 ` Metzger, Markus T
2013-11-25 21:11 ` Jan Kratochvil
2013-09-20 11:31 ` [patch v6 03/21] btrace: change branch trace data structure Markus Metzger
2013-10-06 19:46 ` Jan Kratochvil
2013-09-20 11:31 ` [patch v6 07/21] record-btrace: optionally indent function call history Markus Metzger
2013-10-06 19:47 ` Jan Kratochvil
2013-09-20 11:31 ` [patch v6 01/21] btrace, linux: fix memory leak when reading branch trace Markus Metzger
2013-09-20 11:31 ` [patch v6 04/21] record-btrace: fix insn range in function call history Markus Metzger
2013-09-20 11:31 ` [patch v6 08/21] record-btrace: make ranges include begin and end Markus Metzger
2013-09-20 11:31 ` [patch v6 05/21] record-btrace: start counting at one Markus Metzger
2013-09-20 11:31 ` [patch v6 19/21] btrace, gdbserver: read branch trace incrementally Markus Metzger
2013-10-06 19:51 ` Jan Kratochvil
2013-09-20 11:31 ` [patch v6 13/21] record-btrace, frame: supply target-specific unwinder Markus Metzger
2013-09-20 11:31 ` [patch v6 11/21] record-btrace: supply register target methods Markus Metzger
2013-09-20 11:31 ` [patch v6 21/21] record-btrace: add (reverse-)stepping support Markus Metzger
2013-10-06 19:52 ` Jan Kratochvil
2013-11-06 15:06 ` Metzger, Markus T
2013-11-26 13:48 ` Jan Kratochvil
2013-09-20 11:31 ` [patch v6 20/21] record-btrace: show trace from enable location Markus Metzger
2013-09-20 11:31 ` [patch v6 17/21] record-btrace: add record goto target methods Markus Metzger
2013-10-06 19:48 ` Jan Kratochvil
2013-09-20 11:31 ` [patch v6 09/21] btrace: add replay position to btrace thread info Markus Metzger
2013-09-26 19:16 ` v6 crash bugreport [Re: [patch v6 00/21] record-btrace: reverse] Jan Kratochvil
2013-09-27 6:37 ` Metzger, Markus T
2013-10-06 19:59 ` [+rfc] Re: [patch v6 00/21] record-btrace: reverse Jan Kratochvil
2013-11-07 15:44 ` Metzger, Markus T [this message]
2013-11-27 20:35 ` Jan Kratochvil
2013-11-28 10:54 ` Metzger, Markus T
2013-11-28 22:35 ` Jan Kratochvil
2013-11-29 14:27 ` Metzger, Markus T
2013-12-11 19:57 ` Jan Kratochvil
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=A78C989F6D9628469189715575E55B230AA127B9@IRSMSX104.ger.corp.intel.com \
--to=markus.t.metzger@intel.com \
--cc=gdb-patches@sourceware.org \
--cc=jan.kratochvil@redhat.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