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
This commit is contained in:
Christoph Borchert
2015-06-19 17:55:39 +02:00
parent c4437e1bd3
commit 65e4409c90
2 changed files with 15 additions and 1 deletions

View File

@ -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

View File

@ -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__