aboutsummaryrefslogtreecommitdiff
path: root/gdb/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/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/btrace.c')
-rw-r--r--gdb/btrace.c50
1 files changed, 25 insertions, 25 deletions
diff --git a/gdb/btrace.c b/gdb/btrace.c
index 3b4e60d..648d495 100644
--- a/gdb/btrace.c
+++ b/gdb/btrace.c
@@ -626,17 +626,17 @@ btrace_compute_ftrace_bts (struct thread_info *tp,
/* We should hit the end of the block. Warn if we went too far. */
if (block->end < pc)
{
- /* Indicate the gap in the trace - unless we're at the
- beginning. */
- if (begin != NULL)
- {
- end = ftrace_new_gap (end, BDE_BTS_OVERFLOW);
- ngaps += 1;
+ /* Indicate the gap in the trace. */
+ end = ftrace_new_gap (end, BDE_BTS_OVERFLOW);
+ if (begin == NULL)
+ begin = end;
+
+ ngaps += 1;
+
+ warning (_("Recorded trace may be corrupted at instruction "
+ "%u (pc = %s)."), end->insn_offset - 1,
+ core_addr_to_string_nz (pc));
- warning (_("Recorded trace may be corrupted at instruction "
- "%u (pc = %s)."), end->insn_offset - 1,
- core_addr_to_string_nz (pc));
- }
break;
}
@@ -796,19 +796,22 @@ ftrace_add_pt (struct pt_insn_decoder *decoder,
"= 0x%" PRIx64 ", pc = 0x%" PRIx64 ")."),
end->insn_offset - 1, offset, insn.ip);
}
+ }
- /* Indicate trace overflows. */
- if (insn.resynced)
- {
- *pend = end = ftrace_new_gap (end, BDE_PT_OVERFLOW);
- *ngaps += 1;
+ /* Indicate trace overflows. */
+ if (insn.resynced)
+ {
+ *pend = end = ftrace_new_gap (end, BDE_PT_OVERFLOW);
+ if (begin == NULL)
+ *pbegin = begin = end;
- pt_insn_get_offset (decoder, &offset);
+ *ngaps += 1;
- warning (_("Overflow at instruction %u (offset = 0x%" PRIx64
- ", pc = 0x%" PRIx64 ")."), end->insn_offset - 1,
- offset, insn.ip);
- }
+ pt_insn_get_offset (decoder, &offset);
+
+ warning (_("Overflow at instruction %u (offset = 0x%" PRIx64
+ ", pc = 0x%" PRIx64 ")."), end->insn_offset - 1,
+ offset, insn.ip);
}
upd = ftrace_update_function (end, insn.ip);
@@ -834,13 +837,10 @@ ftrace_add_pt (struct pt_insn_decoder *decoder,
if (errcode == -pte_eos)
break;
- /* If the gap is at the very beginning, we ignore it - we will have
- less trace, but we won't have any holes in the trace. */
- if (begin == NULL)
- continue;
-
/* Indicate the gap in the trace. */
*pend = end = ftrace_new_gap (end, errcode);
+ if (begin == NULL)
+ *pbegin = begin = end;
*ngaps += 1;
pt_insn_get_offset (decoder, &offset);