aboutsummaryrefslogtreecommitdiff
path: root/replay
diff options
context:
space:
mode:
Diffstat (limited to 'replay')
-rw-r--r--replay/replay-events.c2
-rw-r--r--replay/replay-internal.c10
-rw-r--r--replay/replay-internal.h10
-rw-r--r--replay/replay-snapshot.c13
-rw-r--r--replay/replay-time.c36
-rw-r--r--replay/replay.c30
6 files changed, 47 insertions, 54 deletions
diff --git a/replay/replay-events.c b/replay/replay-events.c
index 60d17f6..008e80f 100644
--- a/replay/replay-events.c
+++ b/replay/replay-events.c
@@ -124,7 +124,7 @@ void replay_add_event(ReplayAsyncEventKind event_kind,
void replay_bh_schedule_event(QEMUBH *bh)
{
if (events_enabled) {
- uint64_t id = replay_get_current_step();
+ uint64_t id = replay_get_current_icount();
replay_add_event(REPLAY_ASYNC_EVENT_BH, bh, NULL, id);
} else {
qemu_bh_schedule(bh);
diff --git a/replay/replay-internal.c b/replay/replay-internal.c
index c013b23..eba8246 100644
--- a/replay/replay-internal.c
+++ b/replay/replay-internal.c
@@ -173,7 +173,7 @@ void replay_fetch_data_kind(void)
if (!replay_state.has_unread_data) {
replay_state.data_kind = replay_get_byte();
if (replay_state.data_kind == EVENT_INSTRUCTION) {
- replay_state.instructions_count = replay_get_dword();
+ replay_state.instruction_count = replay_get_dword();
}
replay_check_error();
replay_state.has_unread_data = 1;
@@ -227,9 +227,9 @@ void replay_mutex_unlock(void)
}
}
-void replay_advance_current_step(uint64_t current_step)
+void replay_advance_current_icount(uint64_t current_icount)
{
- int diff = (int)(replay_get_current_step() - replay_state.current_step);
+ int diff = (int)(current_icount - replay_state.current_icount);
/* Time can only go forward */
assert(diff >= 0);
@@ -237,7 +237,7 @@ void replay_advance_current_step(uint64_t current_step)
if (diff > 0) {
replay_put_event(EVENT_INSTRUCTION);
replay_put_dword(diff);
- replay_state.current_step += diff;
+ replay_state.current_icount += diff;
}
}
@@ -246,6 +246,6 @@ void replay_save_instructions(void)
{
if (replay_file && replay_mode == REPLAY_MODE_RECORD) {
g_assert(replay_mutex_locked());
- replay_advance_current_step(replay_get_current_step());
+ replay_advance_current_icount(replay_get_current_icount());
}
}
diff --git a/replay/replay-internal.h b/replay/replay-internal.h
index af6f4d5..afba9a3 100644
--- a/replay/replay-internal.h
+++ b/replay/replay-internal.h
@@ -64,10 +64,10 @@ typedef enum ReplayAsyncEventKind ReplayAsyncEventKind;
typedef struct ReplayState {
/*! Cached clock values. */
int64_t cached_clock[REPLAY_CLOCK_COUNT];
- /*! Current step - number of processed instructions and timer events. */
- uint64_t current_step;
+ /*! Current icount - number of processed instructions. */
+ uint64_t current_icount;
/*! Number of instructions to be executed before other events happen. */
- int instructions_count;
+ int instruction_count;
/*! Type of the currently executed event. */
unsigned int data_kind;
/*! Flag which indicates that event is not processed yet. */
@@ -122,8 +122,8 @@ void replay_finish_event(void);
data_kind variable. */
void replay_fetch_data_kind(void);
-/*! Advance replay_state.current_step to the specified value. */
-void replay_advance_current_step(uint64_t current_step);
+/*! Advance replay_state.current_icount to the specified value. */
+void replay_advance_current_icount(uint64_t current_icount);
/*! Saves queued events (like instructions and sound). */
void replay_save_instructions(void);
diff --git a/replay/replay-snapshot.c b/replay/replay-snapshot.c
index 5dd8680..e26fa4c 100644
--- a/replay/replay-snapshot.c
+++ b/replay/replay-snapshot.c
@@ -23,7 +23,6 @@ static int replay_pre_save(void *opaque)
{
ReplayState *state = opaque;
state->file_offset = ftell(replay_file);
- state->host_clock_last = qemu_clock_get_last(QEMU_CLOCK_HOST);
return 0;
}
@@ -33,14 +32,13 @@ static int replay_post_load(void *opaque, int version_id)
ReplayState *state = opaque;
if (replay_mode == REPLAY_MODE_PLAY) {
fseek(replay_file, state->file_offset, SEEK_SET);
- qemu_clock_set_last(QEMU_CLOCK_HOST, state->host_clock_last);
/* If this was a vmstate, saved in recording mode,
we need to initialize replay data fields. */
replay_fetch_data_kind();
} else if (replay_mode == REPLAY_MODE_RECORD) {
/* This is only useful for loading the initial state.
Therefore reset all the counters. */
- state->instructions_count = 0;
+ state->instruction_count = 0;
state->block_request_id = 0;
}
@@ -49,19 +47,18 @@ static int replay_post_load(void *opaque, int version_id)
static const VMStateDescription vmstate_replay = {
.name = "replay",
- .version_id = 1,
- .minimum_version_id = 1,
+ .version_id = 2,
+ .minimum_version_id = 2,
.pre_save = replay_pre_save,
.post_load = replay_post_load,
.fields = (VMStateField[]) {
VMSTATE_INT64_ARRAY(cached_clock, ReplayState, REPLAY_CLOCK_COUNT),
- VMSTATE_UINT64(current_step, ReplayState),
- VMSTATE_INT32(instructions_count, ReplayState),
+ VMSTATE_UINT64(current_icount, ReplayState),
+ VMSTATE_INT32(instruction_count, ReplayState),
VMSTATE_UINT32(data_kind, ReplayState),
VMSTATE_UINT32(has_unread_data, ReplayState),
VMSTATE_UINT64(file_offset, ReplayState),
VMSTATE_UINT64(block_request_id, ReplayState),
- VMSTATE_UINT64(host_clock_last, ReplayState),
VMSTATE_INT32(read_event_kind, ReplayState),
VMSTATE_UINT64(read_event_id, ReplayState),
VMSTATE_INT32(read_event_checkpoint, ReplayState),
diff --git a/replay/replay-time.c b/replay/replay-time.c
index 5154cb0..43357c9 100644
--- a/replay/replay-time.c
+++ b/replay/replay-time.c
@@ -14,18 +14,19 @@
#include "replay-internal.h"
#include "qemu/error-report.h"
-int64_t replay_save_clock(ReplayClockKind kind, int64_t clock, int64_t raw_icount)
+int64_t replay_save_clock(ReplayClockKind kind, int64_t clock,
+ int64_t raw_icount)
{
- if (replay_file) {
- g_assert(replay_mutex_locked());
+ g_assert(replay_file);
+ g_assert(replay_mutex_locked());
- /* Due to the caller's locking requirements we get the icount from it
- * instead of using replay_save_instructions().
- */
- replay_advance_current_step(raw_icount);
- replay_put_event(EVENT_CLOCK + kind);
- replay_put_qword(clock);
- }
+ /*
+ * Due to the caller's locking requirements we get the icount from it
+ * instead of using replay_save_instructions().
+ */
+ replay_advance_current_icount(raw_icount);
+ replay_put_event(EVENT_CLOCK + kind);
+ replay_put_qword(clock);
return clock;
}
@@ -47,20 +48,15 @@ void replay_read_next_clock(ReplayClockKind kind)
/*! Reads next clock event from the input. */
int64_t replay_read_clock(ReplayClockKind kind)
{
+ int64_t ret;
g_assert(replay_file && replay_mutex_locked());
replay_account_executed_instructions();
- if (replay_file) {
- int64_t ret;
- if (replay_next_event_is(EVENT_CLOCK + kind)) {
- replay_read_next_clock(kind);
- }
- ret = replay_state.cached_clock[kind];
-
- return ret;
+ if (replay_next_event_is(EVENT_CLOCK + kind)) {
+ replay_read_next_clock(kind);
}
+ ret = replay_state.cached_clock[kind];
- error_report("REPLAY INTERNAL ERROR %d", __LINE__);
- exit(1);
+ return ret;
}
diff --git a/replay/replay.c b/replay/replay.c
index 7fc9891..713395b 100644
--- a/replay/replay.c
+++ b/replay/replay.c
@@ -39,20 +39,20 @@ bool replay_next_event_is(int event)
bool res = false;
/* nothing to skip - not all instructions used */
- if (replay_state.instructions_count != 0) {
+ if (replay_state.instruction_count != 0) {
assert(replay_state.data_kind == EVENT_INSTRUCTION);
return event == EVENT_INSTRUCTION;
}
while (true) {
- if (event == replay_state.data_kind) {
+ unsigned int data_kind = replay_state.data_kind;
+ if (event == data_kind) {
res = true;
}
- switch (replay_state.data_kind) {
+ switch (data_kind) {
case EVENT_SHUTDOWN ... EVENT_SHUTDOWN_LAST:
replay_finish_event();
- qemu_system_shutdown_request(replay_state.data_kind -
- EVENT_SHUTDOWN);
+ qemu_system_shutdown_request(data_kind - EVENT_SHUTDOWN);
break;
default:
/* clock, time_t, checkpoint and other events */
@@ -62,7 +62,7 @@ bool replay_next_event_is(int event)
return res;
}
-uint64_t replay_get_current_step(void)
+uint64_t replay_get_current_icount(void)
{
return cpu_get_icount_raw();
}
@@ -72,7 +72,7 @@ int replay_get_instructions(void)
int res = 0;
replay_mutex_lock();
if (replay_next_event_is(EVENT_INSTRUCTION)) {
- res = replay_state.instructions_count;
+ res = replay_state.instruction_count;
}
replay_mutex_unlock();
return res;
@@ -82,16 +82,16 @@ void replay_account_executed_instructions(void)
{
if (replay_mode == REPLAY_MODE_PLAY) {
g_assert(replay_mutex_locked());
- if (replay_state.instructions_count > 0) {
- int count = (int)(replay_get_current_step()
- - replay_state.current_step);
+ if (replay_state.instruction_count > 0) {
+ int count = (int)(replay_get_current_icount()
+ - replay_state.current_icount);
/* Time can only go forward */
assert(count >= 0);
- replay_state.instructions_count -= count;
- replay_state.current_step += count;
- if (replay_state.instructions_count == 0) {
+ replay_state.instruction_count -= count;
+ replay_state.current_icount += count;
+ if (replay_state.instruction_count == 0) {
assert(replay_state.data_kind == EVENT_INSTRUCTION);
replay_finish_event();
/* Wake up iothread. This is required because
@@ -273,8 +273,8 @@ static void replay_enable(const char *fname, int mode)
replay_mutex_init();
replay_state.data_kind = -1;
- replay_state.instructions_count = 0;
- replay_state.current_step = 0;
+ replay_state.instruction_count = 0;
+ replay_state.current_icount = 0;
replay_state.has_unread_data = 0;
/* skip file header for RECORD and check it for PLAY */