summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarkus Metzger <markus.t.metzger@intel.com>2015-09-11 10:09:54 +0200
committerMarkus Metzger <markus.t.metzger@intel.com>2015-09-22 08:42:30 +0200
commitf822206ba951b23cbcde811df1c165b7331e9cac (patch)
treeacf531e1e42d0c1a94e863cd27bd146041f14ff9
parent5fb809b9ffac08ded7ffa8cfb76283fc4f9c2fc5 (diff)
downloadbinutils-gdb-users/mmetzger/disasm-vec.tar.gz
btrace: use gdb_disassembly_vec and new source interleaving methodusers/mmetzger/disasm-vec
Use the new gdb_disassembly_vec interface for the "record instruction- history" command. Use the new source interleaving method. We accept the /m and /s modifiers. The old version is broken and there's no point in keeping it as alternative to this new version. The "record instruction-history" modifiers were not documented. Document all of them. CC: Eli Zaretskii <eliz@gnu.org> Signed-off-by: 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. Also accept /s. (_initialize_record): Document the /s modifier. * NEWS: Announce record instruction-history new /s modifier. doc/ * gdb.texinfo (Process Record and Replay): Document "record instruction-history" modifiers.
-rw-r--r--gdb/NEWS3
-rw-r--r--gdb/doc/gdb.texinfo14
-rw-r--r--gdb/record-btrace.c54
-rw-r--r--gdb/record.c5
4 files changed, 46 insertions, 30 deletions
diff --git a/gdb/NEWS b/gdb/NEWS
index 2e38d9a6c8d..7706e5c0e36 100644
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -49,6 +49,9 @@ show remote multiprocess-extensions-packet
The "/m" option is now considered deprecated: its "source-centric"
output hasn't proved useful in practice.
+* The "record instruction-history" command accepts a new modifier: /s.
+ It behaves exactly like /m and prints mixed source+disassembly.
+
* The "set scheduler-locking" command supports a new mode "replay".
It behaves like "off" in record mode and like "on" in replay mode.
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index 06870396301..36c9638137b 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -6741,6 +6741,20 @@ default, ten instructions are disassembled. This can be changed using
the @code{set record instruction-history-size} command. Instructions
are printed in execution order.
+It can also print mixed source+disassembly by specifying the @code{/m}
+or @code{/s} modifier and print the raw instructions in hex as well as
+in symbolic form by specifying the @code{/r} modifier.
+
+The current position marker is printed for the instruction at the
+current program counter value. This instruction can appear multiple
+times in the trace and the current position marker will be printed
+every time. To omit the current position marker, specify the
+@code{/p} modifier.
+
+To better align the printed instructions when the trace contains
+instructions from more than one function, the function name may be
+omitted by specifying the @code{/f} modifier.
+
Speculatively executed instructions are prefixed with @samp{?}. This
feature is not available for all recording formats.
diff --git a/gdb/record-btrace.c b/gdb/record-btrace.c
index d14e6cf09cf..ecb8085a6b7 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 71ef97337bb..b06bec79dec 100644
--- a/gdb/record.c
+++ b/gdb/record.c
@@ -458,7 +458,8 @@ get_insn_history_modifiers (char **arg)
switch (*args)
{
case 'm':
- modifiers |= DISASSEMBLY_SOURCE_DEPRECATED;
+ case 's':
+ modifiers |= DISASSEMBLY_SOURCE;
modifiers |= DISASSEMBLY_FILENAME;
break;
case 'r':
@@ -817,7 +818,7 @@ Argument is instruction number, as shown by 'info record'."),
add_cmd ("instruction-history", class_obscure, cmd_record_insn_history, _("\
Print disassembled instructions stored in the execution log.\n\
-With a /m modifier, source lines are included (if available).\n\
+With a /m or /s modifier, source lines are included (if available).\n\
With a /r modifier, raw instructions in hex are included.\n\
With a /f modifier, function names are omitted.\n\
With a /p modifier, current position markers are omitted.\n\