aboutsummaryrefslogtreecommitdiff
path: root/replay/replay-internal.c
diff options
context:
space:
mode:
authorPavel Dovgalyuk <Pavel.Dovgaluk@ispras.ru>2015-09-17 19:23:54 +0300
committerPaolo Bonzini <pbonzini@redhat.com>2015-11-05 12:19:09 +0100
commit26bc60ac82f88d14e65be5387eb4a136edf94f1b (patch)
tree978afbc06fc76ae179e5a1fceab66439bc5eef05 /replay/replay-internal.c
parentc16861ef1b7b27803b4c068ef778ba0f80fba1c2 (diff)
replay: introduce icount event
This patch adds icount event to the replay subsystem. This event corresponds to execution of several instructions and used to synchronize input events in the replay phase. Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Pavel Dovgalyuk <pavel.dovgaluk@ispras.ru> Message-Id: <20150917162354.8676.31351.stgit@PASHA-ISP.def.inno> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'replay/replay-internal.c')
-rw-r--r--replay/replay-internal.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/replay/replay-internal.c b/replay/replay-internal.c
index efae672dfa..35cff44a36 100644
--- a/replay/replay-internal.c
+++ b/replay/replay-internal.c
@@ -10,6 +10,7 @@
*/
#include "qemu-common.h"
+#include "sysemu/replay.h"
#include "replay-internal.h"
#include "qemu/error-report.h"
#include "sysemu/sysemu.h"
@@ -36,6 +37,7 @@ void replay_put_byte(uint8_t byte)
void replay_put_event(uint8_t event)
{
+ assert(event < EVENT_COUNT);
replay_put_byte(event);
}
@@ -149,8 +151,15 @@ void replay_fetch_data_kind(void)
if (replay_file) {
if (!replay_has_unread_data) {
replay_data_kind = replay_get_byte();
+ if (replay_data_kind == EVENT_INSTRUCTION) {
+ replay_state.instructions_count = replay_get_dword();
+ }
replay_check_error();
replay_has_unread_data = 1;
+ if (replay_data_kind >= EVENT_COUNT) {
+ error_report("Replay: unknown event kind %d", replay_data_kind);
+ exit(1);
+ }
}
}
}
@@ -180,3 +189,18 @@ void replay_mutex_unlock(void)
{
qemu_mutex_unlock(&lock);
}
+
+/*! Saves cached instructions. */
+void replay_save_instructions(void)
+{
+ if (replay_file && replay_mode == REPLAY_MODE_RECORD) {
+ replay_mutex_lock();
+ int diff = (int)(replay_get_current_step() - replay_state.current_step);
+ if (diff > 0) {
+ replay_put_event(EVENT_INSTRUCTION);
+ replay_put_dword(diff);
+ replay_state.current_step += diff;
+ }
+ replay_mutex_unlock();
+ }
+}