diff --git a/libipt/src/pt_block_decoder.c b/libipt/src/pt_block_decoder.c index 2d8cbf58..6709863a 100644 --- a/libipt/src/pt_block_decoder.c +++ b/libipt/src/pt_block_decoder.c @@ -45,6 +45,10 @@ static int pt_blk_proceed_trailing_event(struct pt_block_decoder *, struct pt_block *); +static int pt_blk_proceed_no_event_cached(struct pt_block_decoder *decoder, + struct pt_block *block, + struct pt_block_cache *bcache, + const struct pt_mapped_section *msec); static int pt_blk_set_trig_anchor(struct pt_block_decoder *decoder) { if (!decoder) @@ -2431,12 +2435,14 @@ pt_blk_proceed_no_event_fill_cache(struct pt_block_decoder *decoder, if (status < 0) return status; + + int valid_cache = pt_bce_is_valid(bce); /* If we don't have a valid cache entry, yet, fill the cache some more. * * On our way back, we add a cache entry for this instruction based on * the cache entry of the succeeding instruction. */ - if (!pt_bce_is_valid(bce)) { + if (!valid_cache) { /* If we exceeded the maximum number of allowed steps, we insert * a trampoline to the next instruction. * @@ -2515,7 +2521,14 @@ pt_blk_proceed_no_event_fill_cache(struct pt_block_decoder *decoder, * Cache updates are atomic so even if the two versions were not * identical, we wouldn't care because they are both correct. */ - return pt_bcache_add(bcache, ioff, bce); + status = pt_bcache_add(bcache, ioff, bce); + if (status < 0) + return status; + + if (valid_cache) + return pt_blk_proceed_no_event_cached(decoder, block, + bcache, msec); + return status; } /* Proceed at a potentially truncated instruction.