bool replay_checkpoint(ReplayCheckpoint checkpoint)
{
bool res = false;
+ static bool in_checkpoint;
assert(EVENT_CHECKPOINT + checkpoint <= EVENT_CHECKPOINT_LAST);
- replay_save_instructions();
if (!replay_file) {
return true;
}
+ if (in_checkpoint) {
+ /* If we are already in checkpoint, then there is no need
+ for additional synchronization.
+ Recursion occurs when HW event modifies timers.
+ Timer modification may invoke the checkpoint and
+ proceed to recursion. */
+ return true;
+ }
+ in_checkpoint = true;
+
+ replay_save_instructions();
if (replay_mode == REPLAY_MODE_PLAY) {
g_assert(replay_mutex_locked());
} else if (replay_mode == REPLAY_MODE_RECORD) {
g_assert(replay_mutex_locked());
replay_put_event(EVENT_CHECKPOINT + checkpoint);
- replay_save_events(checkpoint);
+ /* This checkpoint belongs to several threads.
+ Processing events from different threads is
+ non-deterministic */
+ if (checkpoint != CHECKPOINT_CLOCK_WARP_START
+ /* FIXME: this is temporary fix, other checkpoints
+ may also be invoked from the different threads someday.
+ Asynchronous event processing should be refactored
+ to create additional replay event kind which is
+ nailed to the one of the threads and which processes
+ the event queue. */
+ && checkpoint != CHECKPOINT_CLOCK_VIRTUAL) {
+ replay_save_events(checkpoint);
+ }
res = true;
}
out:
+ in_checkpoint = false;
+ return res;
+}
+
+bool replay_has_checkpoint(void)
+{
+ bool res = false;
+ if (replay_mode == REPLAY_MODE_PLAY) {
+ g_assert(replay_mutex_locked());
+ replay_account_executed_instructions();
+ res = EVENT_CHECKPOINT <= replay_state.data_kind
+ && replay_state.data_kind <= EVENT_CHECKPOINT_LAST;
+ }
return res;
}