libipt, block: turn event processing into iteration

To process events, we recursively call pt_blk_proceed_event() from the
individual pt_blk_proceed_<event>() functions via pt_blk_proceed() until we run
out of events and proceed with pt_blk_proceed_no_event() (or until the event
ends the block).

The idea was to allow the compiler to turn those recursive calls into tail calls
and thus the entire event processing into a series of jumps.

If that tail call optimization does not happen, for exmple in debug mode, we
might overflow the call stack on some trace inputs.  In the case of leading TSX
events, for example, the block decoder would crash after a sequence of ~40.000
MODE.TSX packets given an 8KB stack.  I'm omitting the test as it is quite big.

Turn the recursion into iteration to avoid a stack overflow.

Change-Id: I44cbffc3636f81d74ee0268b4a5ed54f62909fce
Signed-off-by: Markus Metzger <markus.t.metzger@intel.com>
1 file changed