From 65e4409c90645f2f9ac788895e3c897ae2df23c0 Mon Sep 17 00:00:00 2001 From: Christoph Borchert Date: Fri, 19 Jun 2015 17:55:39 +0200 Subject: [PATCH] generic-tracing: add --restore command-line option This options performs a restore to the saved state of the machine immediately after saving (default: off). This option is needed when the state is used by other experiments that depend on the trace, which slighty differs without a restore. Change-Id: I4fdf4c5e03779bb9c6e0a0fa335ceae3e20608a5 --- src/experiments/generic-tracing/experiment.cc | 12 ++++++++++++ src/experiments/generic-tracing/experiment.hpp | 4 +++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/experiments/generic-tracing/experiment.cc b/src/experiments/generic-tracing/experiment.cc index e2d9201d..7ce02d6f 100644 --- a/src/experiments/generic-tracing/experiment.cc +++ b/src/experiments/generic-tracing/experiment.cc @@ -48,6 +48,10 @@ void GenericTracing::parseOptions() { CommandLine::option_handle TRACE_FILE = cmd.addOption("t", "trace-file", Arg::Required, "-t,--trace-file \tFile to save the execution trace to (default: trace.pb)\n"); + CommandLine::option_handle RESTORE = cmd.addOption("", "restore", Arg::None, + "--restore \tRestore to the saved state of the machine immediately after saving (default: off). " + "This option is needed when the state is used by other experiments that depend on the " + "trace, which slighty differs without a restore."); CommandLine::option_handle FULL_TRACE = cmd.addOption("", "full-trace", Arg::None, "--full-trace \tDo a full trace (more data, default: off)"); CommandLine::option_handle MEM_SYMBOL = cmd.addOption("m", "memory-symbol", Arg::Required, @@ -197,6 +201,9 @@ void GenericTracing::parseOptions() { } } + if (cmd[RESTORE]) { + this->restore = true; + } if (cmd[FULL_TRACE]) { this->full_trace = true; } @@ -248,6 +255,11 @@ bool GenericTracing::run() m_log << start_symbol << " reached, save ..." << std::endl; simulator.save(state_file); + if (restore) { + m_log << "restoring clean state ..." << std::endl; + simulator.restore(state_file); + } + m_log << "... and start tracing" << std::endl; // restrict memory access logging to injection target diff --git a/src/experiments/generic-tracing/experiment.hpp b/src/experiments/generic-tracing/experiment.hpp index 60eb0f6e..e605cf0b 100644 --- a/src/experiments/generic-tracing/experiment.hpp +++ b/src/experiments/generic-tracing/experiment.hpp @@ -22,6 +22,7 @@ class GenericTracing : public fail::ExperimentFlow { bool use_memory_map; fail::MemoryMap traced_memory_map; + bool restore; bool full_trace; fail::guest_address_t serial_port; @@ -34,7 +35,8 @@ public: void parseOptions(); bool run(); - GenericTracing() : full_trace(false), m_log("GenericTracing", false) {} + GenericTracing() : restore(false), + full_trace(false), m_log("GenericTracing", false) {} }; #endif // __TRACING_TEST_HPP__