> On 8/8/23 06:44, Mikhail Tyutin wrote: > > Initially, we can only call the callback BEFORE instructions. This commit > > adds the ability to insert the callback AFTER instructions. > > > > No callback call for control-flow instructions. > > You're going to miss whole categories of instructions, not just control-flow. > You're > going to miss anything that raises an exception. The list goes on and on. > This is why we > didn't implement this "after" hook in the first place. >
To be fair it works quite well for code translations in user-mode and baremetal applications. At least we can intercept a set of instructions that have registers as operands and even syscall-like instructions. Logically it had to work identically to memory 'store' callbacks, but we had to add a shortcut to fix problem when some of code translators inserts exit_tb operation explicitly. Maybe there is better way to do it. We use such AFTER callback in plugins to capture CPU state changes in generic way (using registers API patch I posted earlier). Without it, BEFORE callback has to be added to 'current' and 'following' instructions to achieve the same effect. Having callbacks on different instructions adds complexity to the callbacks itself to performs state dumps at appropriate conditions (e.g. was 'previous' instruction the one we instrumented or it was some jump).