generic-tracing: cleanups
Change-Id: I5c3d1131248910228cb4fee44cf107c750c01e21
This commit is contained in:
@ -25,26 +25,26 @@ void GenericTracing::parseOptions() {
|
|||||||
cmd.addOption("", "", Arg::None, "USAGE: fail-client -Wf,[option] -Wf,[option] ... <BochsOptions...>\n\n");
|
cmd.addOption("", "", Arg::None, "USAGE: fail-client -Wf,[option] -Wf,[option] ... <BochsOptions...>\n\n");
|
||||||
CommandLine::option_handle HELP = cmd.addOption("h", "help", Arg::None, "-h,--help \tPrint usage and exit");
|
CommandLine::option_handle HELP = cmd.addOption("h", "help", Arg::None, "-h,--help \tPrint usage and exit");
|
||||||
|
|
||||||
|
|
||||||
CommandLine::option_handle ELF_FILE = cmd.addOption("", "elf-file", Arg::Required,
|
CommandLine::option_handle ELF_FILE = cmd.addOption("", "elf-file", Arg::Required,
|
||||||
"--elf-file \tELF Binary File (default: $FAIL_ELF_PATH)");
|
"--elf-file \tELF Binary File (default: $FAIL_ELF_PATH)");
|
||||||
CommandLine::option_handle START_SYMBOL = cmd.addOption("s", "start-symbol", Arg::Required,
|
CommandLine::option_handle START_SYMBOL = cmd.addOption("s", "start-symbol", Arg::Required,
|
||||||
"-s,--start-symbol \tELF symbol to start tracing (default: main)");
|
"-s,--start-symbol \tELF symbol to start tracing (default: main)");
|
||||||
CommandLine::option_handle STOP_SYMBOL = cmd.addOption("e", "end-symbol", Arg::Required,
|
CommandLine::option_handle STOP_SYMBOL = cmd.addOption("e", "end-symbol", Arg::Required,
|
||||||
"-e,--end-symbol \tELF symbol to end tracing");
|
"-e,--end-symbol \tELF symbol to end tracing");
|
||||||
CommandLine::option_handle SAVE_SYMBOL = cmd.addOption("S", "save-symbol", Arg::Required,
|
CommandLine::option_handle SAVE_SYMBOL = cmd.addOption("S", "save-symbol", Arg::Required,
|
||||||
"-S,--save-symbol \tELF symbol to save the state of the machine (default: main)\n");
|
"-S,--save-symbol \tELF symbol to save the state of the machine (default: main)\n");
|
||||||
CommandLine::option_handle STATE_FILE = cmd.addOption("f", "state-file", Arg::Required,
|
CommandLine::option_handle STATE_FILE = cmd.addOption("f", "state-file", Arg::Required,
|
||||||
"-f,--state-file \tFile/dir to save the state to (default: state)");
|
"-f,--state-file \tFile/dir to save the state to (default: state)");
|
||||||
CommandLine::option_handle TRACE_FILE = cmd.addOption("t", "trace-file", Arg::Required,
|
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");
|
"-t,--trace-file \tFile to save the execution trace to (default: trace.pb)\n");
|
||||||
|
|
||||||
CommandLine::option_handle FULL_TRACE = cmd.addOption("", "full-trace", Arg::None, "--full-trace \tDo a full trace (more data, default: off)");
|
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,
|
CommandLine::option_handle MEM_SYMBOL = cmd.addOption("m", "memory-symbol", Arg::Required,
|
||||||
"-m,--memory-symbol \tELF symbol(s) to trace accesses (default: all mem read/writes are traced)");
|
"-m,--memory-symbol \tELF symbol(s) to trace accesses (default: all mem read/writes are traced)");
|
||||||
CommandLine::option_handle MEM_REGION = cmd.addOption("M", "memory-region", Arg::Required,
|
CommandLine::option_handle MEM_REGION = cmd.addOption("M", "memory-region", Arg::Required,
|
||||||
"-M,--memory-region \trestrict memory region which is traced"
|
"-M,--memory-region \trestrict memory region which is traced"
|
||||||
" (Possible formats: 0x<address>, 0x<address>:0x<address>, 0x<address>:<length>)");
|
" (Possible formats: 0x<address>, 0x<address>:0x<address>, 0x<address>:<length>)");
|
||||||
|
|
||||||
if (!cmd.parse()) {
|
if (!cmd.parse()) {
|
||||||
cerr << "Error parsing arguments." << endl;
|
cerr << "Error parsing arguments." << endl;
|
||||||
@ -56,10 +56,10 @@ void GenericTracing::parseOptions() {
|
|||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cmd[ELF_FILE].count() > 0)
|
if (cmd[ELF_FILE]) {
|
||||||
elf_file = cmd[ELF_FILE].first()->arg;
|
elf_file = cmd[ELF_FILE].first()->arg;
|
||||||
else {
|
} else {
|
||||||
char * elfpath = getenv("FAIL_ELF_PATH");
|
char *elfpath = getenv("FAIL_ELF_PATH");
|
||||||
if (elfpath == NULL) {
|
if (elfpath == NULL) {
|
||||||
m_log << "FAIL_ELF_PATH not set :( (alternative: --elf-file) " << std::endl;
|
m_log << "FAIL_ELF_PATH not set :( (alternative: --elf-file) " << std::endl;
|
||||||
exit(-1);
|
exit(-1);
|
||||||
@ -69,36 +69,40 @@ void GenericTracing::parseOptions() {
|
|||||||
}
|
}
|
||||||
m_elf = new ElfReader(elf_file.c_str());
|
m_elf = new ElfReader(elf_file.c_str());
|
||||||
|
|
||||||
if (cmd[START_SYMBOL].count() > 0)
|
if (cmd[START_SYMBOL]) {
|
||||||
start_symbol = cmd[START_SYMBOL].first()->arg;
|
start_symbol = cmd[START_SYMBOL].first()->arg;
|
||||||
else
|
} else {
|
||||||
start_symbol = "main";
|
start_symbol = "main";
|
||||||
|
}
|
||||||
|
|
||||||
if (cmd[STOP_SYMBOL].count() > 0)
|
if (cmd[STOP_SYMBOL]) {
|
||||||
stop_symbol = std::string(cmd[STOP_SYMBOL].first()->arg);
|
stop_symbol = std::string(cmd[STOP_SYMBOL].first()->arg);
|
||||||
else {
|
} else {
|
||||||
m_log << "You have to give an end symbol (-e,--end-symbol)!" << std::endl;
|
m_log << "You have to give an end symbol (-e,--end-symbol)!" << std::endl;
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cmd[SAVE_SYMBOL].count() > 0)
|
if (cmd[SAVE_SYMBOL]) {
|
||||||
save_symbol = std::string(cmd[SAVE_SYMBOL].first()->arg);
|
save_symbol = std::string(cmd[SAVE_SYMBOL].first()->arg);
|
||||||
else
|
} else {
|
||||||
save_symbol = "main";
|
save_symbol = "main";
|
||||||
|
}
|
||||||
|
|
||||||
if (cmd[STATE_FILE].count() > 0)
|
if (cmd[STATE_FILE]) {
|
||||||
state_file = std::string(cmd[STATE_FILE].first()->arg);
|
state_file = std::string(cmd[STATE_FILE].first()->arg);
|
||||||
else
|
} else {
|
||||||
state_file = "state";
|
state_file = "state";
|
||||||
|
}
|
||||||
|
|
||||||
if (cmd[TRACE_FILE].count() > 0)
|
if (cmd[TRACE_FILE]) {
|
||||||
trace_file = std::string(cmd[TRACE_FILE].first()->arg);
|
trace_file = std::string(cmd[TRACE_FILE].first()->arg);
|
||||||
else
|
} else {
|
||||||
trace_file = "trace.pb";
|
trace_file = "trace.pb";
|
||||||
|
}
|
||||||
|
|
||||||
use_memory_map = false;
|
use_memory_map = false;
|
||||||
|
|
||||||
if (cmd[MEM_SYMBOL].count() > 0) {
|
if (cmd[MEM_SYMBOL]) {
|
||||||
use_memory_map = true;
|
use_memory_map = true;
|
||||||
option::Option *opt = cmd[MEM_SYMBOL].first();
|
option::Option *opt = cmd[MEM_SYMBOL].first();
|
||||||
|
|
||||||
@ -114,7 +118,7 @@ void GenericTracing::parseOptions() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cmd[MEM_REGION].count() > 0) {
|
if (cmd[MEM_REGION]) {
|
||||||
use_memory_map = true;
|
use_memory_map = true;
|
||||||
option::Option *opt = cmd[MEM_REGION].first();
|
option::Option *opt = cmd[MEM_REGION].first();
|
||||||
|
|
||||||
@ -173,8 +177,6 @@ void GenericTracing::parseOptions() {
|
|||||||
m_log << "state file: " << state_file << std::endl;
|
m_log << "state file: " << state_file << std::endl;
|
||||||
m_log << "trace file: " << trace_file << std::endl;
|
m_log << "trace file: " << trace_file << std::endl;
|
||||||
m_log << "full-trace: " << this->full_trace << std::endl;
|
m_log << "full-trace: " << this->full_trace << std::endl;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GenericTracing::run()
|
bool GenericTracing::run()
|
||||||
@ -217,7 +219,6 @@ bool GenericTracing::run()
|
|||||||
m_log << start_symbol << " reached, save state" << std::endl;
|
m_log << start_symbol << " reached, save state" << std::endl;
|
||||||
simulator.save(state_file);
|
simulator.save(state_file);
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////
|
||||||
// Step 3: Continue to the stop point
|
// Step 3: Continue to the stop point
|
||||||
simulator.addListener(&l_stop_symbol);
|
simulator.addListener(&l_stop_symbol);
|
||||||
|
|||||||
@ -8,8 +8,6 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class GenericTracing : public fail::ExperimentFlow {
|
class GenericTracing : public fail::ExperimentFlow {
|
||||||
std::string start_symbol;
|
std::string start_symbol;
|
||||||
std::string stop_symbol;
|
std::string stop_symbol;
|
||||||
@ -31,7 +29,7 @@ public:
|
|||||||
void parseOptions();
|
void parseOptions();
|
||||||
bool run();
|
bool run();
|
||||||
|
|
||||||
GenericTracing() : full_trace(false), m_log("GenericTracing", false) {};
|
GenericTracing() : full_trace(false), m_log("GenericTracing", false) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // __TRACING_TEST_HPP__
|
#endif // __TRACING_TEST_HPP__
|
||||||
|
|||||||
Reference in New Issue
Block a user