aboutsummaryrefslogtreecommitdiff
path: root/gdb/record-btrace.c
diff options
context:
space:
mode:
authorMarkus Metzger <markus.t.metzger@intel.com>2016-01-18 16:59:21 +0100
committerMarkus Metzger <markus.t.metzger@intel.com>2016-10-28 10:53:45 +0200
commitb61ce85cc54bf4acc86714cacd10d6f9f7e89d1b (patch)
tree95a47a40d106d14b3e071c446bad351cd6f1d7be /gdb/record-btrace.c
parent63ab433e29b2715f429551cdbec72dab0d752c20 (diff)
downloadgdb-b61ce85cc54bf4acc86714cacd10d6f9f7e89d1b.zip
gdb-b61ce85cc54bf4acc86714cacd10d6f9f7e89d1b.tar.gz
gdb-b61ce85cc54bf4acc86714cacd10d6f9f7e89d1b.tar.bz2
btrace: allow leading trace gaps
GDB ignores trace gaps from decode errors or overflows at the beginning of the trace. There isn't really a gap in the trace; the trace just starts a bit later than expected. In cases where there is no trace at all or where the trace is smaller than expected, this may hide the reason for the missing trace. Allow leading trace gaps. They will be shown as decode warnings and by the record function-call-history command. (gdb) info record Active record target: record-btrace Recording format: Intel Processor Trace. Buffer size: 16kB. warning: Decode error (-6) at instruction 0 (offset = 0x58, pc = 0x0): unexpected packet context. warning: Decode error (-6) at instruction 0 (offset = 0xb0, pc = 0x0): unexpected packet context. warning: Decode error (-6) at instruction 0 (offset = 0x168, pc = 0x0): unexpected packet context. warning: Decode error (-6) at instruction 54205 (offset = 0xe08, pc = 0x0): unexpected packet context. warning: Decode error (-6) at instruction 54205 (offset = 0xe60, pc = 0x0): unexpected packet context. warning: Decode error (-6) at instruction 54205 (offset = 0xed8, pc = 0x0): unexpected packet context. Recorded 91582 instructions in 1111 functions (6 gaps) for thread 1 (process 15710). (gdb) record function-call-history /c 1 1 [decode error (-6): unexpected packet context] 2 [decode error (-6): unexpected packet context] 3 [decode error (-6): unexpected packet context] 4 _dl_addr 5 ?? 6 _dl_addr 7 ?? 8 ?? 9 ?? 10 ?? Leading trace gaps will not be shown by the record instruction-history command without further changes. gdb/ * btrace.c (btrace_compute_ftrace_bts, ftrace_add_pt): Allow leading gaps. * record-btrace.c (record_btrace_single_step_forward) (record_btrace_single_step_backward): Jump back to last instruction if step ends at a gap. (record_btrace_goto_begin): Skip gaps.
Diffstat (limited to 'gdb/record-btrace.c')
-rw-r--r--gdb/record-btrace.c33
1 files changed, 27 insertions, 6 deletions
diff --git a/gdb/record-btrace.c b/gdb/record-btrace.c
index 4808129..7c0e39f 100644
--- a/gdb/record-btrace.c
+++ b/gdb/record-btrace.c
@@ -2300,7 +2300,7 @@ record_btrace_replay_at_breakpoint (struct thread_info *tp)
static struct target_waitstatus
record_btrace_single_step_forward (struct thread_info *tp)
{
- struct btrace_insn_iterator *replay, end;
+ struct btrace_insn_iterator *replay, end, start;
struct btrace_thread_info *btinfo;
btinfo = &tp->btrace;
@@ -2314,7 +2314,9 @@ record_btrace_single_step_forward (struct thread_info *tp)
if (record_btrace_replay_at_breakpoint (tp))
return btrace_step_stopped ();
- /* Skip gaps during replay. */
+ /* Skip gaps during replay. If we end up at a gap (at the end of the trace),
+ jump back to the instruction at which we started. */
+ start = *replay;
do
{
unsigned int steps;
@@ -2323,7 +2325,10 @@ record_btrace_single_step_forward (struct thread_info *tp)
of the execution history. */
steps = btrace_insn_next (replay, 1);
if (steps == 0)
- return btrace_step_no_history ();
+ {
+ *replay = start;
+ return btrace_step_no_history ();
+ }
}
while (btrace_insn_get (replay) == NULL);
@@ -2344,7 +2349,7 @@ record_btrace_single_step_forward (struct thread_info *tp)
static struct target_waitstatus
record_btrace_single_step_backward (struct thread_info *tp)
{
- struct btrace_insn_iterator *replay;
+ struct btrace_insn_iterator *replay, start;
struct btrace_thread_info *btinfo;
btinfo = &tp->btrace;
@@ -2355,14 +2360,19 @@ record_btrace_single_step_backward (struct thread_info *tp)
replay = record_btrace_start_replaying (tp);
/* If we can't step any further, we reached the end of the history.
- Skip gaps during replay. */
+ Skip gaps during replay. If we end up at a gap (at the beginning of
+ the trace), jump back to the instruction at which we started. */
+ start = *replay;
do
{
unsigned int steps;
steps = btrace_insn_prev (replay, 1);
if (steps == 0)
- return btrace_step_no_history ();
+ {
+ *replay = start;
+ return btrace_step_no_history ();
+ }
}
while (btrace_insn_get (replay) == NULL);
@@ -2772,6 +2782,17 @@ record_btrace_goto_begin (struct target_ops *self)
tp = require_btrace_thread ();
btrace_insn_begin (&begin, &tp->btrace);
+
+ /* Skip gaps at the beginning of the trace. */
+ while (btrace_insn_get (&begin) == NULL)
+ {
+ unsigned int steps;
+
+ steps = btrace_insn_next (&begin, 1);
+ if (steps == 0)
+ error (_("No trace."));
+ }
+
record_btrace_set_replay (tp, &begin);
}