From: Jan Kratochvil <jan.kratochvil@redhat.com>
To: "Metzger, Markus T" <markus.t.metzger@intel.com>
Cc: "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
Subject: Re: [+rfc] Re: [patch v6 00/21] record-btrace: reverse
Date: Thu, 28 Nov 2013 22:35:00 -0000 [thread overview]
Message-ID: <20131128211623.GA16695@host2.jankratochvil.net> (raw)
In-Reply-To: <A78C989F6D9628469189715575E55B230AA2DBEE@IRSMSX104.ger.corp.intel.com>
[-- Attachment #1: Type: text/plain, Size: 1329 bytes --]
On Thu, 28 Nov 2013 09:42:16 +0100, Metzger, Markus T wrote:
> We store the frame_id of the current frame and do a single-step.
> Then we try to detect stepping into a subroutine by unwinding
> the stack frames and comparing the frame_id's with our stored
> frame_id.
OK, understood now.
In fact the time you change btinfo->replay you also change register contents.
Therefore the registers_changed_ptid() call is there right.
For the frame_id change one could also provide mapping of old frame_id to new
frame_id in frame_id_eq() but that is worse than just re-setting it.
> Do you have a better idea?
I agree in general. Just:
Rather than get_current_frame_nocheck I find safer to just temporarily switch
off the executing flag. There are many other checks which make sense which
were omitted.
Calling set_step_info seems needlessly intrusive to me, there is no need to
re-set tp->current_symtab + tp->current_line. Despite in the moment of
record_btrace_start_replaying() I see step_frame_id should be the current
frame id it does not have to be. Such as when we reverse-continue, it will be
null_frame_id.
The attached patch(es) is on top of yours.
I still believe inferior should resume + wait if it changes its PC.
I am again not sure if the patch passes without FAILs due to my BTS hardware.
Thanks,
Jan
[-- Attachment #2: 1 --]
[-- Type: text/plain, Size: 2747 bytes --]
diff --git a/gdb/record-btrace.c b/gdb/record-btrace.c
index c50e11b..4a57b51 100644
--- a/gdb/record-btrace.c
+++ b/gdb/record-btrace.c
@@ -1281,9 +1281,8 @@ record_btrace_start_replaying (struct thread_info *tp)
{
struct btrace_thread_info *btinfo;
struct btrace_insn_iterator *replay;
- const struct btrace_insn *insn;
- struct symtab_and_line sal;
- struct frame_info *frame;
+ volatile struct gdb_exception except;
+ int executing;
btinfo = &tp->btrace;
@@ -1291,24 +1290,50 @@ record_btrace_start_replaying (struct thread_info *tp)
if (btinfo->begin == NULL)
return NULL;
- /* We start replaying at the end of the branch trace. This corresponds to the
- current instruction. */
- replay = xmalloc (sizeof (*replay));
- btrace_insn_end (replay, btinfo);
+ executing = is_executing (tp->ptid);
+ TRY_CATCH (except, RETURN_MASK_ALL)
+ {
+ int update_step_frame_id, update_step_stack_frame_id;
+ struct frame_id frame_id;
- /* We're not replaying, yet. */
- gdb_assert (btinfo->replay == NULL);
- btinfo->replay = replay;
+ /* We start replaying at the end of the branch trace. This corresponds to the
+ current instruction. */
+ replay = xmalloc (sizeof (*replay));
+ btrace_insn_end (replay, btinfo);
- /* Make sure we're not using any stale registers. */
- registers_changed_ptid (tp->ptid);
+ if (executing)
+ {
+ /* get_current_frame would error out otherwise. */
+ set_executing (tp->ptid, 0);
+ }
+
+ frame_id = get_frame_id (get_current_frame ());
- /* 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);
+ update_step_frame_id = frame_id_eq (frame_id, tp->control.step_frame_id);
+ update_step_stack_frame_id = frame_id_eq (frame_id,
+ tp->control.step_stack_frame_id);
+
+ /* We're not replaying, yet. */
+ gdb_assert (btinfo->replay == NULL);
+ btinfo->replay = replay;
+
+ /* 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_id = get_frame_id (get_current_frame ());
+
+ if (update_step_frame_id)
+ tp->control.step_frame_id = frame_id;
+ if (update_step_stack_frame_id)
+ tp->control.step_stack_frame_id = frame_id;
+ }
+ if (executing)
+ set_executing (tp->ptid, 1);
+ if (except.reason < 0)
+ throw_exception (except);
return replay;
}
[-- Attachment #3: 2 --]
[-- Type: text/plain, Size: 2047 bytes --]
diff --git a/gdb/frame.c b/gdb/frame.c
index 5a6f107..0fd98ff 100644
--- a/gdb/frame.c
+++ b/gdb/frame.c
@@ -1367,29 +1367,6 @@ unwind_to_current_frame (struct ui_out *ui_out, void *args)
return 0;
}
-/* See frame.h. */
-
-struct frame_info *get_current_frame_nocheck (void)
-{
- if (current_frame == NULL)
- {
- struct frame_info *sentinel_frame =
- create_sentinel_frame (current_program_space, get_current_regcache ());
-
- if (catch_exceptions (current_uiout, unwind_to_current_frame,
- sentinel_frame, RETURN_MASK_ERROR) != 0)
- {
- /* Oops! Fake a current frame? Is this useful? It has a PC
- of zero, for instance. */
- current_frame = sentinel_frame;
- }
- }
-
- return current_frame;
-}
-
-/* See frame.h. */
-
struct frame_info *
get_current_frame (void)
{
@@ -1415,7 +1392,19 @@ get_current_frame (void)
error (_("Target is executing."));
}
- return get_current_frame_nocheck ();
+ if (current_frame == NULL)
+ {
+ struct frame_info *sentinel_frame =
+ create_sentinel_frame (current_program_space, get_current_regcache ());
+ if (catch_exceptions (current_uiout, unwind_to_current_frame,
+ sentinel_frame, RETURN_MASK_ERROR) != 0)
+ {
+ /* Oops! Fake a current frame? Is this useful? It has a PC
+ of zero, for instance. */
+ current_frame = sentinel_frame;
+ }
+ }
+ return current_frame;
}
/* The "selected" stack frame is used by default for local and arg
diff --git a/gdb/frame.h b/gdb/frame.h
index cd2033d..f0da19e 100644
--- a/gdb/frame.h
+++ b/gdb/frame.h
@@ -242,10 +242,6 @@ enum frame_type
error. */
extern struct frame_info *get_current_frame (void);
-/* Similar to get_current_frame except that we omit all checks. May
- return NULL if unwinding fails. */
-extern struct frame_info *get_current_frame_nocheck (void);
-
/* Does the current target interface have enough state to be able to
query the current inferior for frame info, and is the inferior in a
state where that is possible? */
[-- Attachment #4: 3 --]
[-- Type: text/plain, Size: 1619 bytes --]
diff --git a/gdb/record-btrace.c b/gdb/record-btrace.c
index c50e11b..4a57b51 100644
--- a/gdb/record-btrace.c
+++ b/gdb/record-btrace.c
@@ -1662,6 +1687,8 @@ record_btrace_goto_target (struct thread_info *tp,
struct btrace_insn_iterator *goto_target;
struct btrace_thread_info *btinfo;
struct target_waitstatus ws;
+ struct btrace_insn_iterator target_it;
+ volatile struct gdb_exception exception;
btinfo = &tp->btrace;
@@ -1686,11 +1713,17 @@ record_btrace_goto_target (struct thread_info *tp,
btinfo->flags |= BTHR_GOTO;
btinfo->goto_target = goto_target;
-#if 0
+ TRY_CATCH (exception, RETURN_MASK_ALL)
+ {
+
+#if 1
if (goto_target != NULL)
+ target_it = *goto_target;
+ else
+ btrace_insn_end (&target_it, btinfo);
tp->control.exception_resume_breakpoint =
set_momentary_breakpoint_at_pc (target_gdbarch (),
- btrace_insn_get (goto_target)->pc,
+ btrace_insn_get (&target_it)->pc,
bp_until);
#endif
#if 0
@@ -1701,8 +1734,18 @@ record_btrace_goto_target (struct thread_info *tp,
proceed ((CORE_ADDR) -1, GDB_SIGNAL_0, 0);
#endif
- if (btinfo->goto_target != NULL || (btinfo->flags & BTHR_GOTO) != 0)
+ // It will need a fix if reverse mode supports target-async mode.
+ if ((btinfo->flags & BTHR_GOTO) != 0)
error (_("Record goto failed."));
+ gdb_assert (btinfo->goto_target == NULL);
+
+ }
+ if (exception.reason < 0)
+ {
+ xfree (btinfo->goto_target);
+ btinfo->goto_target = NULL;
+ btinfo->flags &= ~BTHR_GOTO;
+ }
}
/* The to_goto_record_begin method of target record-btrace. */
next prev parent reply other threads:[~2013-11-28 21:16 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 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:30 ` [patch v6 02/21] gdbarch: add instruction predicate methods 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 16/21] record-btrace: provide target_find_new_threads method Markus Metzger
2013-09-20 11:30 ` [patch v6 06/21] btrace: increase buffer size Markus Metzger
2013-09-20 11:31 ` [patch v6 09/21] btrace: add replay position to btrace thread info 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 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 11/21] record-btrace: supply register target methods Markus Metzger
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 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 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 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 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-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
2013-11-27 20:35 ` Jan Kratochvil
2013-11-28 10:54 ` Metzger, Markus T
2013-11-28 22:35 ` Jan Kratochvil [this message]
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=20131128211623.GA16695@host2.jankratochvil.net \
--to=jan.kratochvil@redhat.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