Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
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: Wed, 27 Nov 2013 20:35:00 -0000	[thread overview]
Message-ID: <20131127185727.GA18038@host2.jankratochvil.net> (raw)
In-Reply-To: <A78C989F6D9628469189715575E55B230AA127B9@IRSMSX104.ger.corp.intel.com>

[-- Attachment #1: Type: text/plain, Size: 1677 bytes --]

On Thu, 07 Nov 2013 16:41:40 +0100, Metzger, Markus T wrote:
> 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.

In such case it is not finished.  These hacks should not be needed.


> They are required when reverse-stepping the first time or when
> stepping past the end of the execution trace.

I have patched what you describe as the problem.  But as I do not have a box
with reliably working BTS so it is difficult for me to say whether it works or
not.  I can look at other problems if you describe them from a reliable box.


> 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.

It can be cleaned up as I did there, thanks for catching it.


Thanks,
Jan

[-- Attachment #2: 1 --]
[-- Type: text/plain, Size: 2862 bytes --]

diff --git a/gdb/record-btrace.c b/gdb/record-btrace.c
index c50e11b..9fbff15 100644
--- a/gdb/record-btrace.c
+++ b/gdb/record-btrace.c
@@ -1300,16 +1300,6 @@ record_btrace_start_replaying (struct thread_info *tp)
   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 = get_current_frame_nocheck ();
-  insn = btrace_insn_get (replay);
-  sal = find_pc_line (insn->pc, 0);
-  set_step_info (frame, sal);
-
   return replay;
 }
 
@@ -1324,9 +1314,6 @@ record_btrace_stop_replaying (struct thread_info *tp)
 
   xfree (btinfo->replay);
   btinfo->replay = NULL;
-
-  /* Make sure we're not leaving any stale registers.  */
-  registers_changed_ptid (tp->ptid);
 }
 
 /* The to_resume method of target record-btrace.  */
@@ -1619,10 +1606,6 @@ record_btrace_wait (struct target_ops *ops, ptid_t ptid,
   /* Start record histories anew from the current position.  */
   record_btrace_clear_histories (&tp->btrace);
 
-  /* GDB seems to need this.  Without, a stale PC seems to be used resulting in
-     the current location to be displayed incorrectly.  */
-  registers_changed_ptid (tp->ptid);
-
   return tp->ptid;
 }
 
@@ -1662,6 +1645,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 +1671,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 +1692,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.  */

  reply	other threads:[~2013-11-27 18:58 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 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 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: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 03/21] btrace: change branch trace data structure Markus Metzger
2013-10-06 19:46   ` Jan Kratochvil
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 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 08/21] record-btrace: make ranges include begin and end 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 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 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-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 [this message]
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=20131127185727.GA18038@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