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.