L4-sys refactoring

move preparation steps into separate functions

Change-Id: I4930ec38f003302596f215a08cd8bf455f525571
This commit is contained in:
Björn Döbel
2013-08-27 10:02:38 +02:00
parent 64840c02e4
commit da7f9caf64
2 changed files with 43 additions and 11 deletions

View File

@ -203,14 +203,9 @@ void L4SysExperiment::terminateWithError(string details, int reason) {
terminate(reason); terminate(reason);
} }
bool L4SysExperiment::run() {
BPSingleListener bp(0, L4SYS_ADDRESS_SPACE);
srand(time(NULL));
log << "startup" << endl; void L4SysExperiment::startAndSaveInitState(fail::BPSingleListener& bp)
{
#if PREPARATION_STEP == 1
// STEP 1: run until interesting function starts, and save state
bp.setWatchInstructionPointer(L4SYS_FUNC_ENTRY); bp.setWatchInstructionPointer(L4SYS_FUNC_ENTRY);
simulator.addListenerAndResume(&bp); simulator.addListenerAndResume(&bp);
@ -221,8 +216,10 @@ bool L4SysExperiment::run() {
<< endl; << endl;
log << "check the source code if the two instruction pointers are not equal" << endl; log << "check the source code if the two instruction pointers are not equal" << endl;
simulator.save(L4SYS_STATE_FOLDER); simulator.save(L4SYS_STATE_FOLDER);
#elif PREPARATION_STEP == 2 }
// STEP 2: determine instructions executed
void L4SysExperiment::collectInstructionTrace(fail::BPSingleListener& bp)
{
log << "restoring state" << endl; log << "restoring state" << endl;
simulator.restore(L4SYS_STATE_FOLDER); simulator.restore(L4SYS_STATE_FOLDER);
log << "EIP = " << hex log << "EIP = " << hex
@ -288,9 +285,10 @@ bool L4SysExperiment::run() {
<< dec << count << " instructions; " << dec << count << " instructions; "
<< "ul: " << ul << ", kernel: " << kernel << endl; << "ul: " << ul << ", kernel: " << kernel << endl;
#endif #endif
}
#elif PREPARATION_STEP == 3 void L4SysExperiment::goldenRun(fail::BPSingleListener& bp)
// STEP 3: determine the output of a "golden run" {
log << "restoring state" << endl; log << "restoring state" << endl;
simulator.restore(L4SYS_STATE_FOLDER); simulator.restore(L4SYS_STATE_FOLDER);
log << "EIP = " << hex log << "EIP = " << hex
@ -316,6 +314,25 @@ bool L4SysExperiment::run() {
log << "saving output generated during normal execution" << endl; log << "saving output generated during normal execution" << endl;
golden_run_file.close(); golden_run_file.close();
}
bool L4SysExperiment::run() {
BPSingleListener bp(0, L4SYS_ADDRESS_SPACE);
srand(time(NULL));
log << "startup" << endl;
#if PREPARATION_STEP == 1
// STEP 1: run until interesting function starts, and save state
startAndSaveInitState(bp);
#elif PREPARATION_STEP == 2
// STEP 2: determine instructions executed
collectInstructionTrace(bp);
#elif PREPARATION_STEP == 3
// STEP 3: determine the output of a "golden run"
goldenRun(bp);
#elif PREPARATION_STEP == 0 #elif PREPARATION_STEP == 0
// LAST STEP: The actual experiment. // LAST STEP: The actual experiment.

View File

@ -6,6 +6,7 @@
#include "efw/ExperimentFlow.hpp" #include "efw/ExperimentFlow.hpp"
#include "efw/JobClient.hpp" #include "efw/JobClient.hpp"
#include "util/Logger.hpp" #include "util/Logger.hpp"
#include "sal/Listener.hpp"
class L4SysExperimentData; class L4SysExperimentData;
@ -106,6 +107,20 @@ private:
* Send back the experiment parameter set with a description of the error. * Send back the experiment parameter set with a description of the error.
*/ */
void terminateWithError(std::string details, int reason); void terminateWithError(std::string details, int reason);
/**
* Run until L4SYS_FUNC_ENTRY and save state (experiment preparation,
* phase 1)
*/
void startAndSaveInitState(fail::BPSingleListener& bp);
/**
* Collect list of executed instructions, considering instruction
* filtering if configured (experiment preparation, phase 2).
*/
void collectInstructionTrace(fail::BPSingleListener& bp);
/**
* Perform the golden run (experiment preparation, phase 3)
*/
void goldenRun(fail::BPSingleListener& bp);
}; };
#endif // __L4SYS_EXPERIMENT_HPP__ #endif // __L4SYS_EXPERIMENT_HPP__