1 #ifndef REPLAY_H 2 #define REPLAY_H 3 4 /* 5 * replay.h 6 * 7 * Copyright (c) 2010-2015 Institute for System Programming 8 * of the Russian Academy of Sciences. 9 * 10 * This work is licensed under the terms of the GNU GPL, version 2 or later. 11 * See the COPYING file in the top-level directory. 12 * 13 */ 14 15 #include <stdbool.h> 16 #include <stdint.h> 17 #include "qapi-types.h" 18 19 /* replay clock kinds */ 20 enum ReplayClockKind { 21 /* host_clock */ 22 REPLAY_CLOCK_HOST, 23 /* virtual_rt_clock */ 24 REPLAY_CLOCK_VIRTUAL_RT, 25 REPLAY_CLOCK_COUNT 26 }; 27 typedef enum ReplayClockKind ReplayClockKind; 28 29 extern ReplayMode replay_mode; 30 31 /* Processing the instructions */ 32 33 /*! Returns number of executed instructions. */ 34 uint64_t replay_get_current_step(void); 35 /*! Returns number of instructions to execute in replay mode. */ 36 int replay_get_instructions(void); 37 /*! Updates instructions counter in replay mode. */ 38 void replay_account_executed_instructions(void); 39 40 /* Interrupts and exceptions */ 41 42 /*! Called by exception handler to write or read 43 exception processing events. */ 44 bool replay_exception(void); 45 /*! Used to determine that exception is pending. 46 Does not proceed to the next event in the log. */ 47 bool replay_has_exception(void); 48 /*! Called by interrupt handlers to write or read 49 interrupt processing events. 50 \return true if interrupt should be processed */ 51 bool replay_interrupt(void); 52 /*! Tries to read interrupt event from the file. 53 Returns true, when interrupt request is pending */ 54 bool replay_has_interrupt(void); 55 56 /* Processing clocks and other time sources */ 57 58 /*! Save the specified clock */ 59 int64_t replay_save_clock(ReplayClockKind kind, int64_t clock); 60 /*! Read the specified clock from the log or return cached data */ 61 int64_t replay_read_clock(ReplayClockKind kind); 62 /*! Saves or reads the clock depending on the current replay mode. */ 63 #define REPLAY_CLOCK(clock, value) \ 64 (replay_mode == REPLAY_MODE_PLAY ? replay_read_clock((clock)) \ 65 : replay_mode == REPLAY_MODE_RECORD \ 66 ? replay_save_clock((clock), (value)) \ 67 : (value)) 68 69 /* Asynchronous events queue */ 70 71 /*! Disables storing events in the queue */ 72 void replay_disable_events(void); 73 /*! Returns true when saving events is enabled */ 74 bool replay_events_enabled(void); 75 76 #endif 77