Description
The uc_emu_start
function may be called with one or more arguments that determine when the emulation should stop: by last instruction address, timeout or instructions count. Unicorn also provides an API to set additional exit points that terminate the emulation once hit.
As of current version, uc_emu_start
returns a value that indicates whether emulation terminated gracefully or not. However, it will be useful for the user to get an indication for the "termination reason" to allow them to handle it properly.
Possible termination reasons (non-exhaustive list):
- Hit end address
- Timeout elapsed
- Exhausted instructions count
- Hit an exit point
- Emulation stopped by
uc_emu_stop
- Hit an unhandled exception (e.g.: performed an invalid write that was not handled by an appropriate hook)
- Hit an internal exception (i.e. reached an invalid internal state)
Further thinking:
Having multiple normal and abnormal termination reasons might require re-thinking the way return values are enumerated. One way to address that is to adopt an approach similar to POSIX errors: negative return values for errors, positive return values for benign situations and zero for success.