2015-09-17 19:23:37 +03:00
|
|
|
#ifndef REPLAY_H
|
|
|
|
#define REPLAY_H
|
|
|
|
|
|
|
|
/*
|
|
|
|
* replay.h
|
|
|
|
*
|
|
|
|
* Copyright (c) 2010-2015 Institute for System Programming
|
|
|
|
* of the Russian Academy of Sciences.
|
|
|
|
*
|
|
|
|
* This work is licensed under the terms of the GNU GPL, version 2 or later.
|
|
|
|
* See the COPYING file in the top-level directory.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "qapi-types.h"
|
|
|
|
|
2015-09-17 19:24:28 +03:00
|
|
|
/* replay clock kinds */
|
|
|
|
enum ReplayClockKind {
|
|
|
|
/* host_clock */
|
|
|
|
REPLAY_CLOCK_HOST,
|
|
|
|
/* virtual_rt_clock */
|
|
|
|
REPLAY_CLOCK_VIRTUAL_RT,
|
|
|
|
REPLAY_CLOCK_COUNT
|
|
|
|
};
|
|
|
|
typedef enum ReplayClockKind ReplayClockKind;
|
|
|
|
|
2015-09-17 19:24:44 +03:00
|
|
|
/* IDs of the checkpoints */
|
|
|
|
enum ReplayCheckpoint {
|
2016-03-10 14:56:09 +03:00
|
|
|
CHECKPOINT_CLOCK_WARP_START,
|
|
|
|
CHECKPOINT_CLOCK_WARP_ACCOUNT,
|
2015-09-17 19:24:44 +03:00
|
|
|
CHECKPOINT_RESET_REQUESTED,
|
|
|
|
CHECKPOINT_SUSPEND_REQUESTED,
|
|
|
|
CHECKPOINT_CLOCK_VIRTUAL,
|
|
|
|
CHECKPOINT_CLOCK_HOST,
|
|
|
|
CHECKPOINT_CLOCK_VIRTUAL_RT,
|
|
|
|
CHECKPOINT_INIT,
|
|
|
|
CHECKPOINT_RESET,
|
|
|
|
CHECKPOINT_COUNT
|
|
|
|
};
|
|
|
|
typedef enum ReplayCheckpoint ReplayCheckpoint;
|
|
|
|
|
2015-09-17 19:23:37 +03:00
|
|
|
extern ReplayMode replay_mode;
|
|
|
|
|
2015-09-17 19:25:07 +03:00
|
|
|
/* Replay process control functions */
|
|
|
|
|
|
|
|
/*! Enables recording or saving event log with specified parameters */
|
|
|
|
void replay_configure(struct QemuOpts *opts);
|
|
|
|
/*! Initializes timers used for snapshotting and enables events recording */
|
|
|
|
void replay_start(void);
|
|
|
|
/*! Closes replay log file and frees other resources. */
|
|
|
|
void replay_finish(void);
|
2015-09-17 19:25:13 +03:00
|
|
|
/*! Adds replay blocker with the specified error description */
|
|
|
|
void replay_add_blocker(Error *reason);
|
2015-09-17 19:25:07 +03:00
|
|
|
|
2015-09-17 19:23:54 +03:00
|
|
|
/* Processing the instructions */
|
|
|
|
|
|
|
|
/*! Returns number of executed instructions. */
|
|
|
|
uint64_t replay_get_current_step(void);
|
2015-09-17 19:24:05 +03:00
|
|
|
/*! Returns number of instructions to execute in replay mode. */
|
|
|
|
int replay_get_instructions(void);
|
|
|
|
/*! Updates instructions counter in replay mode. */
|
|
|
|
void replay_account_executed_instructions(void);
|
2015-09-17 19:23:54 +03:00
|
|
|
|
2015-09-17 19:24:16 +03:00
|
|
|
/* Interrupts and exceptions */
|
|
|
|
|
|
|
|
/*! Called by exception handler to write or read
|
|
|
|
exception processing events. */
|
|
|
|
bool replay_exception(void);
|
|
|
|
/*! Used to determine that exception is pending.
|
|
|
|
Does not proceed to the next event in the log. */
|
|
|
|
bool replay_has_exception(void);
|
|
|
|
/*! Called by interrupt handlers to write or read
|
|
|
|
interrupt processing events.
|
|
|
|
\return true if interrupt should be processed */
|
|
|
|
bool replay_interrupt(void);
|
|
|
|
/*! Tries to read interrupt event from the file.
|
|
|
|
Returns true, when interrupt request is pending */
|
|
|
|
bool replay_has_interrupt(void);
|
|
|
|
|
2015-09-17 19:24:28 +03:00
|
|
|
/* Processing clocks and other time sources */
|
|
|
|
|
|
|
|
/*! Save the specified clock */
|
|
|
|
int64_t replay_save_clock(ReplayClockKind kind, int64_t clock);
|
|
|
|
/*! Read the specified clock from the log or return cached data */
|
|
|
|
int64_t replay_read_clock(ReplayClockKind kind);
|
|
|
|
/*! Saves or reads the clock depending on the current replay mode. */
|
|
|
|
#define REPLAY_CLOCK(clock, value) \
|
|
|
|
(replay_mode == REPLAY_MODE_PLAY ? replay_read_clock((clock)) \
|
|
|
|
: replay_mode == REPLAY_MODE_RECORD \
|
|
|
|
? replay_save_clock((clock), (value)) \
|
|
|
|
: (value))
|
|
|
|
|
2015-09-17 19:24:33 +03:00
|
|
|
/* Events */
|
|
|
|
|
|
|
|
/*! Called when qemu shutdown is requested. */
|
|
|
|
void replay_shutdown_request(void);
|
2015-09-17 19:24:44 +03:00
|
|
|
/*! Should be called at check points in the execution.
|
|
|
|
These check points are skipped, if they were not met.
|
|
|
|
Saves checkpoint in the SAVE mode and validates in the PLAY mode.
|
|
|
|
Returns 0 in PLAY mode if checkpoint was not found.
|
|
|
|
Returns 1 in all other cases. */
|
|
|
|
bool replay_checkpoint(ReplayCheckpoint checkpoint);
|
2015-09-17 19:24:33 +03:00
|
|
|
|
2015-09-17 19:24:22 +03:00
|
|
|
/* Asynchronous events queue */
|
|
|
|
|
|
|
|
/*! Disables storing events in the queue */
|
|
|
|
void replay_disable_events(void);
|
|
|
|
/*! Returns true when saving events is enabled */
|
|
|
|
bool replay_events_enabled(void);
|
2015-09-17 19:24:56 +03:00
|
|
|
/*! Adds bottom half event to the queue */
|
|
|
|
void replay_bh_schedule_event(QEMUBH *bh);
|
2015-09-17 19:25:24 +03:00
|
|
|
/*! Adds input event to the queue */
|
|
|
|
void replay_input_event(QemuConsole *src, InputEvent *evt);
|
|
|
|
/*! Adds input sync event to the queue */
|
|
|
|
void replay_input_sync_event(void);
|
2016-03-14 10:45:10 +03:00
|
|
|
/*! Adds block layer event to the queue */
|
|
|
|
void replay_block_event(QEMUBH *bh, uint64_t id);
|
2015-09-17 19:24:16 +03:00
|
|
|
|
2016-03-14 10:44:36 +03:00
|
|
|
/* Character device */
|
|
|
|
|
|
|
|
/*! Registers char driver to save it's events */
|
|
|
|
void replay_register_char_driver(struct CharDriverState *chr);
|
|
|
|
/*! Saves write to char device event to the log */
|
|
|
|
void replay_chr_be_write(struct CharDriverState *s, uint8_t *buf, int len);
|
|
|
|
/*! Writes char write return value to the replay log. */
|
|
|
|
void replay_char_write_event_save(int res, int offset);
|
|
|
|
/*! Reads char write return value from the replay log. */
|
|
|
|
void replay_char_write_event_load(int *res, int *offset);
|
|
|
|
/*! Reads information about read_all character event. */
|
|
|
|
int replay_char_read_all_load(uint8_t *buf);
|
|
|
|
/*! Writes character read_all error code into the replay log. */
|
|
|
|
void replay_char_read_all_save_error(int res);
|
|
|
|
/*! Writes character read_all execution result into the replay log. */
|
|
|
|
void replay_char_read_all_save_buf(uint8_t *buf, int offset);
|
|
|
|
|
2015-09-17 19:23:37 +03:00
|
|
|
#endif
|