libipt, block: turn trailing event processing into iteration

To process trailing events, we recursively call pt_blk_process_trailing_events()
from the individual pt_blk_process_trailing_<event>() functions until we either
run out of events or decide to postpone processing of the next event.

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 trailing TSX
events, for example, the block decoder would crash after a sequence of ~80.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: I92683ce0255770ba924074e573fa796de240d181
Signed-off-by: Markus Metzger <markus.t.metzger@intel.com>
1 file changed