libipt: sync from the current position

When synchronizing forward, we start from the current position.  When
synchronizing backward, we start from the last synchronization point.

This guarantees that repeated sync-backwards can be used to split the trace for
parallel decode even when the trace contains empty trace segments, which would
be skipped when reading ahead.

On the other hand, this does not allow forward and backward synchronization to
be combined in a meaningful way.  And it does not support backtracking to the
beginning of the current trace segment in case of errors.

Change the behaviour of backward synchronization to start from the current
position and skip empty trace segments.  In order to reach the initial
synchronization point, multiple calls to pt_*_sync_backward() may be required.

We leave pt_*_get_sync_offset() to provide the offset of the last successful or
attempted synchronization.  It is not updated when reading over synchronization
points (i.e. PSB packets).  It is updated during synchronization before reading
the PSB+ header.

This fixes #19.

Change-Id: I6f939321b6621c6725a3a794cfdc5d5038dff90f
Signed-off-by: Markus Metzger <markus.t.metzger@intel.com>
3 files changed