From 329e5571addd7e1f9369010d4bced8d7b4f51794 Mon Sep 17 00:00:00 2001 From: Tobias Stumpf Date: Thu, 19 Jun 2014 19:23:46 +0200 Subject: [PATCH] Add config parameter to specify the hostname or ip addr. of the campain server. Add some documentiation to experiment.hpp --- src/experiments/l4-sys/experiment.cc | 3 ++- src/experiments/l4-sys/experiment.conf | 1 + src/experiments/l4-sys/experiment.hpp | 27 ++++++++++++++----- src/experiments/l4-sys/experimentParameter.cc | 20 ++++++++++++-- 4 files changed, 41 insertions(+), 10 deletions(-) diff --git a/src/experiments/l4-sys/experiment.cc b/src/experiments/l4-sys/experiment.cc index 328f7c9c..728cb6f7 100644 --- a/src/experiments/l4-sys/experiment.cc +++ b/src/experiments/l4-sys/experiment.cc @@ -9,7 +9,7 @@ using namespace std; using namespace fail; L4SysExperiment::L4SysExperiment() - : m_jc("localhost"), log("L4Sys", false) + : log("L4Sys", false) { param = new L4SysExperimentData; } @@ -71,6 +71,7 @@ bool L4SysExperiment::run() } default: { BPSingleListener *bp = 0; + m_jc = fail::JobClient(conf.campain_server.c_str()); doExperiments(bp); } } diff --git a/src/experiments/l4-sys/experiment.conf b/src/experiments/l4-sys/experiment.conf index 06ed823f..cb2d7a42 100644 --- a/src/experiments/l4-sys/experiment.conf +++ b/src/experiments/l4-sys/experiment.conf @@ -24,6 +24,7 @@ totinstr=58401 #default config emul_ips=5000000 max_instr_bytes=15 +campain_server=localhost #default files state_folder=l4sys.state diff --git a/src/experiments/l4-sys/experiment.hpp b/src/experiments/l4-sys/experiment.hpp index 3a6114d9..9d1f9cd5 100644 --- a/src/experiments/l4-sys/experiment.hpp +++ b/src/experiments/l4-sys/experiment.hpp @@ -82,22 +82,22 @@ private: */ void terminateWithError(std::string details, int reason, L4SysProtoMsg_Result*); /** - * Run until L4SYS_FUNC_ENTRY and save state (experiment preparation, - * phase 1) + * Run until reaching the entry point of the experiment and save + * state. */ void runToStart(fail::BPSingleListener *bp); /** * Collect list of executed instructions, considering instruction - * filtering if configured (experiment preparation, phase 2). + * filtering if configured. */ void collectInstructionTrace(fail::BPSingleListener* bp); /** - * Perform the golden run (experiment preparation, phase 3) + * Perform the golden run. */ void goldenRun(fail::BPSingleListener* bp); /** - * Doing fault injection expiriments (experiment preparation, phase 0) + * Doing fault injection expiriments. */ void doExperiments(fail::BPSingleListener *bp); @@ -141,12 +141,24 @@ private: */ void doRegisterInjection(int regDesc, int bit); - int updateConfig(std::string parameter, std::string value); - void setupFilteredBreakpoint(fail::BPSingleListener* bp, int instOffset, std::string instr_list); + /** + * Updates a parameter of the config file or adds a new one + * if the parameter was not specified. + */ + int updateConfig(std::string parameter, std::string value); + + /** + * Adds the value of the config file to the parameter list and + * parse the parameter list. This function makes use of the + * CommandLine Parser from the fail* framework. + */ void parseOptions(L4SysConfig&); + /** + * Configuration Setup. + */ class L4SysConfig { public: unsigned long int max_instr_bytes; @@ -167,6 +179,7 @@ private: std::string golden_run; std::string filter; std::string trace; + std::string campain_server; unsigned long int numinstr; unsigned long int totinstr; diff --git a/src/experiments/l4-sys/experimentParameter.cc b/src/experiments/l4-sys/experimentParameter.cc index d1d9c93a..2d3c43d5 100644 --- a/src/experiments/l4-sys/experimentParameter.cc +++ b/src/experiments/l4-sys/experimentParameter.cc @@ -133,6 +133,8 @@ void L4SysExperiment::parseOptions(L4SysConfig &conf) { cmd.addOption("", "filter", Arg::Optional, "--filter \t define L4SYS_FILTER"); CommandLine::option_handle OPT_TRACE = cmd.addOption("", "trace", Arg::Optional, "--trace \t define outputfile for trace (default trace.pb)"); + CommandLine::option_handle OPT_CAMPAIN_SERVER = + cmd.addOption("", "campain_server", Arg::Optional, "--campain_server \t specify the hostname of the campain server (default localhost)"); if (!cmd.parse()) { @@ -153,8 +155,12 @@ void L4SysExperiment::parseOptions(L4SysConfig &conf) { if (cmd[OPT_ADDRESS_SPACE]) { conf.address_space = strtol(cmd[OPT_ADDRESS_SPACE].arg, NULL, 16); log << "address_space: "<< hex << conf.address_space << endl; + + //Confi address_space=0 means no address space filtering + if (conf.address_space == 0) + conf.address_space = fail::ANY_ADDR; } else { - parameterMissing(log, "adress_space"); + conf.address_space = fail::ANY_ADDR; } if (cmd[OPT_ADDRESS_SPACE_TRACE]) { @@ -163,11 +169,14 @@ void L4SysExperiment::parseOptions(L4SysConfig &conf) { conf.address_space_trace = conf.address_space; else log << "address_space_trace: "<< hex << conf.address_space_trace << endl; - } else { conf.address_space_trace = conf.address_space; } + + if (conf.address_space_trace == 0) + conf.address_space_trace = fail::ANY_ADDR; + if (cmd[OPT_FUNC_ENTRY]) { conf.func_entry = strtol(cmd[OPT_FUNC_ENTRY].arg, NULL, 16); log << "func_entry: "<< hex << conf.func_entry << endl; @@ -273,6 +282,13 @@ void L4SysExperiment::parseOptions(L4SysConfig &conf) { conf.trace = "trace.pb"; } + if (cmd[OPT_CAMPAIN_SERVER]) { + conf.campain_server = std::string(cmd[OPT_CAMPAIN_SERVER].arg); + log << "campain_server: "<< conf.campain_server << endl; + } else { + conf.campain_server = "localhost"; + } + if (cmd[STEP]) { if (!std::string("cr3").compare(cmd[STEP].arg) ) { log << "calculate cr3" << endl;