Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Markus Metzger <markus.t.metzger@intel.com>
To: palves@redhat.com, dje@google.com
Cc: gdb-patches@sourceware.org
Subject: [PATCH 6/6] btrace: use gdb_disassembly_vec and new source interleaving method
Date: Mon, 21 Sep 2015 14:54:00 -0000	[thread overview]
Message-ID: <1442847283-10200-7-git-send-email-markus.t.metzger@intel.com> (raw)
In-Reply-To: <1442847283-10200-1-git-send-email-markus.t.metzger@intel.com>

Use the new gdb_disassembly_vec interface for the "record instruction-
history" command.

Use the new source interleaving method.  We stick to the /m modifier.
The old version is broken and there's no point in keeping it as alternative
to this new version.

2015-09-21  Markus Metzger <markus.t.metzger@intel.com>

gdb/
	* record-btrace.c (btrace_insn_history): Call gdb_disassembly_vec
	instead of gdb_disassembly.  Set DISASSEMBLY_SPECULATIVE.
	* record.c (get_insn_history_modifiers): Set DISASSEMBLY_SOURCE
	instead of DISASSEMBLY_SOURCE_DEPRECATED.
---
 gdb/record-btrace.c | 54 ++++++++++++++++++++++++++---------------------------
 gdb/record.c        |  2 +-
 2 files changed, 27 insertions(+), 29 deletions(-)

diff --git a/gdb/record-btrace.c b/gdb/record-btrace.c
index d14e6cf..ecb8085 100644
--- a/gdb/record-btrace.c
+++ b/gdb/record-btrace.c
@@ -538,11 +538,17 @@ btrace_insn_history (struct ui_out *uiout,
 {
   struct gdbarch *gdbarch;
   struct btrace_insn_iterator it;
+  VEC (disas_insn_t) *insns;
+  struct cleanup *cleanups;
 
   DEBUG ("itrace (0x%x): [%u; %u)", flags, btrace_insn_number (begin),
 	 btrace_insn_number (end));
 
+  flags |= DISASSEMBLY_SPECULATIVE;
+
   gdbarch = target_gdbarch ();
+  insns = NULL;
+  cleanups = make_cleanup (VEC_cleanup (disas_insn_t), &insns);
 
   for (it = *begin; btrace_insn_cmp (&it, end) != 0; btrace_insn_next (&it, 1))
     {
@@ -560,42 +566,34 @@ btrace_insn_history (struct ui_out *uiout,
 	  /* We have trace so we must have a configuration.  */
 	  gdb_assert (conf != NULL);
 
+	  /* Print the instructions we collected, so far, then the error.
+
+	     This will result in two disjoint "asm_insns" lists with a
+	     stand-alone error in-between.  It's better than what we had
+	     before but still not OK for MI users.  */
+	  gdb_disassembly_vec (gdbarch, uiout, flags, insns);
+
 	  btrace_ui_out_decode_error (uiout, it.function->errcode,
 				      conf->format);
+
+	  /* Start over.  */
+	  VEC_free (disas_insn_t, insns);
 	}
       else
 	{
-	  char prefix[4];
-
-	  /* We may add a speculation prefix later.  We use the same space
-	     that is used for the pc prefix.  */
-	  if ((flags & DISASSEMBLY_OMIT_PC) == 0)
-	    strncpy (prefix, pc_prefix (insn->pc), 3);
-	  else
-	    {
-	      prefix[0] = ' ';
-	      prefix[1] = ' ';
-	      prefix[2] = ' ';
-	    }
-	  prefix[3] = 0;
+	  struct disas_insn *dinsn;
 
-	  /* Print the instruction index.  */
-	  ui_out_field_uint (uiout, "index", btrace_insn_number (&it));
-	  ui_out_text (uiout, "\t");
-
-	  /* Indicate speculative execution by a leading '?'.  */
-	  if ((insn->flags & BTRACE_INSN_FLAG_SPECULATIVE) != 0)
-	    prefix[0] = '?';
-
-	  /* Print the prefix; we tell gdb_disassembly below to omit it.  */
-	  ui_out_field_fmt (uiout, "prefix", "%s", prefix);
-
-	  /* Disassembly with '/m' flag may not produce the expected result.
-	     See PR gdb/11833.  */
-	  gdb_disassembly (gdbarch, uiout, NULL, flags | DISASSEMBLY_OMIT_PC,
-			   1, insn->pc, insn->pc + 1);
+	  dinsn = VEC_safe_push (disas_insn_t, insns, NULL);
+	  dinsn->addr = insn->pc;
+	  dinsn->number = btrace_insn_number (&it);
+	  dinsn->is_speculative = (insn->flags & BTRACE_INSN_FLAG_SPECULATIVE) != 0;
 	}
     }
+
+  /* Print the instructions we collected.  */
+  gdb_disassembly_vec (gdbarch, uiout, flags, insns);
+
+  do_cleanups (cleanups);
 }
 
 /* The to_insn_history method of target record-btrace.  */
diff --git a/gdb/record.c b/gdb/record.c
index 71ef973..c17b199 100644
--- a/gdb/record.c
+++ b/gdb/record.c
@@ -458,7 +458,7 @@ get_insn_history_modifiers (char **arg)
 	  switch (*args)
 	    {
 	    case 'm':
-	      modifiers |= DISASSEMBLY_SOURCE_DEPRECATED;
+	      modifiers |= DISASSEMBLY_SOURCE;
 	      modifiers |= DISASSEMBLY_FILENAME;
 	      break;
 	    case 'r':
-- 
1.8.3.1


  reply	other threads:[~2015-09-21 14:54 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-21 14:55 [PATCH 0/6] disasm, record: fix "record instruction-history /m" Markus Metzger
2015-09-21 14:54 ` Markus Metzger [this message]
2015-09-21 21:48   ` [PATCH 6/6] btrace: use gdb_disassembly_vec and new source interleaving method Andrew Burgess
2015-09-22  6:18     ` Metzger, Markus T
2015-09-21 14:54 ` [PATCH 1/6] disasm: change dump_insns to print a single instruction Markus Metzger
2015-09-21 14:54 ` [PATCH 2/6] disasm: add struct disas_insn to describe to-be-disassembled instruction Markus Metzger
2015-10-09 12:51   ` Pedro Alves
2015-10-12  8:44     ` Metzger, Markus T
2015-10-20 11:29       ` Pedro Alves
2015-09-21 14:55 ` [PATCH 4/6] disasm: use entire line table in line_has_code_p Markus Metzger
2015-09-21 14:55 ` [PATCH 3/6] disas: add gdb_disassembly_vec Markus Metzger
2015-10-09 12:49   ` Pedro Alves
2015-10-09 13:17     ` Metzger, Markus T
2015-10-12  8:59       ` Andrew Burgess
2015-10-18 20:39       ` Doug Evans
2015-09-21 14:55 ` [PATCH 5/6] disasm: determine preceding lines independent of last_line Markus Metzger
2015-10-12 14:19 ` [PATCH 0/6] disasm, record: fix "record instruction-history /m" Metzger, Markus T
2015-10-18 21:17   ` Doug Evans
2015-10-19  9:35     ` Metzger, Markus T

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=1442847283-10200-7-git-send-email-markus.t.metzger@intel.com \
    --to=markus.t.metzger@intel.com \
    --cc=dje@google.com \
    --cc=gdb-patches@sourceware.org \
    --cc=palves@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