Namespaces unified (sal+fi -> fail), Code cleanups (-> coding-style.txt), Doxygen-comments fixed.

git-svn-id: https://www4.informatik.uni-erlangen.de/i4svn/danceos/trunk/devel/fail@1319 8c4709b5-6ec9-48aa-a5cd-a96041d1645a
This commit is contained in:
adrian
2012-06-07 17:47:19 +00:00
parent cdd5379e19
commit b7d904140e
136 changed files with 1487 additions and 1554 deletions

View File

@ -5,9 +5,8 @@
#include "../controller/Event.hpp"
#include "ExperimentDataExample/FaultCoverageExperiment.pb.h"
using std::cout;
using std::endl;
using std::hex;
using namespace std;
using namespace fail;
#define MEMTEST86_BREAKPOINT 0x4EDC
@ -16,22 +15,22 @@ bool DataRetrievalExperiment::run()
cout << "[getExperimentDataExperiment] Experiment start." << endl;
// Breakpoint address for Memtest86:
fi::BPSingleEvent mainbp(MEMTEST86_BREAKPOINT);
sal::simulator.addEventAndWait(&mainbp);
BPSingleEvent mainbp(MEMTEST86_BREAKPOINT);
simulator.addEventAndWait(&mainbp);
cout << "[getExperimentDataExperiment] Breakpoint reached." << endl;
FaultCoverageExperimentData* test = NULL;
cout << "[getExperimentDataExperiment] Getting ExperimentData (FaultCoverageExperiment)..." << endl;
test = sal::simulator.getExperimentData<FaultCoverageExperimentData>();
test = simulator.getExperimentData<FaultCoverageExperimentData>();
cout << "[getExperimentDataExperiment] Content of ExperimentData (FaultCoverageExperiment):" << endl;
if(test->has_data_name())
if (test->has_data_name())
cout << "Name: "<< test->data_name() << endl;
// m_instrptr1 augeben
cout << "m_instrptr1: " << hex << test->m_instrptr1() << endl;
// m_instrptr2 augeben
cout << "m_instrptr2: " << hex << test->m_instrptr2() << endl;
sal::simulator.clearEvents(this);
simulator.clearEvents(this);
return true; // experiment successful
}

View File

@ -3,7 +3,7 @@
#include "../controller/ExperimentFlow.hpp"
class DataRetrievalExperiment : public fi::ExperimentFlow
class DataRetrievalExperiment : public fail::ExperimentFlow
{
public:
DataRetrievalExperiment() { }
@ -11,4 +11,4 @@ class DataRetrievalExperiment : public fi::ExperimentFlow
bool run();
};
#endif /* __DATA_RETRIEVAL_EXPERIMENT_HPP__ */
#endif // __DATA_RETRIEVAL_EXPERIMENT_HPP__

View File

@ -1,5 +1,6 @@
#include <iostream>
#include <fstream>
#include "controller/ExperimentData.hpp"
#include "controller/ExperimentDataQueue.hpp"
#include "jobserver/JobServer.hpp"
@ -7,83 +8,56 @@
using namespace std;
int main(int argc, char* argv[]){
int main(int argc, char* argv[])
{
// FIXME: Translation missing.
ExperimentDataQueue exDaQu;
ExperimentData* readFromQueue;
fi::ExperimentDataQueue exDaQu;
fi::ExperimentData* readFromQueue;
//Daten in Struktur schreiben und in Datei speichern
// Daten in Struktur schreiben und in Datei speichern
ofstream fileWrite;
fileWrite.open("test.txt");
FaultCoverageExperimentData faultCovExWrite;
//Namen setzen
// Namen setzen
faultCovExWrite.set_data_name("Testfall 42");
//Instruktionpointer 1
// Instruktionpointer 1
faultCovExWrite.set_m_instrptr1(0x4711);
//Instruktionpointer 2
// Instruktionpointer 2
faultCovExWrite.set_m_instrptr2(0x1122);
//In ExperimentData verpacken
fi::ExperimentData exDaWrite(&faultCovExWrite);
//In Queue einbinden
// In ExperimentData verpacken
ExperimentData exDaWrite(&faultCovExWrite);
// In Queue einbinden
exDaQu.addData(&exDaWrite);
//Aus Queue holen
if(exDaQu.size() != 0)
// Aus Queue holen
if (exDaQu.size() != 0)
readFromQueue = exDaQu.getData();
//Serialisierung ueber Wrapper-Methode in ExperimentData
// Serialisierung ueber Wrapper-Methode in ExperimentData
readFromQueue->serialize(&fileWrite);
//cout << "Ausgabe: " << out << endl;
// cout << "Ausgabe: " << out << endl;
fileWrite.close();
//---------------------------------------------------------------
//-------------------------------------------------------------------------------------------------
//Daten aus Datei lesen und in Struktur schreiben
// Daten aus Datei lesen und in Struktur schreiben
ifstream fileRead;
fileRead.open("test.txt");
FaultCoverageExperimentData faultCovExRead;
fi::ExperimentData exDaRead(&faultCovExRead);
ExperimentData exDaRead(&faultCovExRead);
exDaRead.unserialize( &fileRead);
//Wenn Name, dann ausgeben
// Wenn Name, dann ausgeben
if(faultCovExRead.has_data_name()){
cout << "Name: "<< faultCovExRead.data_name() << endl;
}
//m_instrptr1 augeben
// m_instrptr1 augeben
cout << "m_instrptr1: " << faultCovExRead.m_instrptr1() << endl;
//m_instrptr2 augeben
// m_instrptr2 augeben
cout << "m_instrptr2: " << faultCovExRead.m_instrptr2() << endl;
fileRead.close();
return 0;
}

View File

@ -1,9 +1,6 @@
#ifndef __JUMP_AND_RUN_EXPERIMENT_HPP__
#define __JUMP_AND_RUN_EXPERIMENT_HPP__
// Author: Adrian Böckenkamp
// Date: 07.11.2011
#include <iostream>
#include "../controller/ExperimentFlow.hpp"
@ -16,69 +13,64 @@
#error Breakpoint- and jump-events needed! Enable aspects first (see FailConfig.hpp)!
#endif
using namespace fi;
using namespace std;
using namespace sal;
using namespace fail;
class JumpAndRunExperiment : public fi::ExperimentFlow
{
public:
bool run()
{
/************************************
* Description of experiment flow. *
************************************/
// Wait for function entry adresss:
cout << "[JumpAndRunExperiment] Setting up experiment. Allowing to "
<< "start now." << endl;
BPEvent mainFuncEntry(0x3c1f);
simulator.addEvent(&mainFuncEntry);
if(&mainFuncEntry != simulator.waitAny())
{
cerr << "[JumpAndRunExperiment] Now, we are completely lost! "
<< "It's time to cry! :-(" << endl;
class JumpAndRunExperiment : public fail::ExperimentFlow {
public:
bool run()
{
/************************************
* Description of experiment flow. *
************************************/
// Wait for function entry adresss:
cout << "[JumpAndRunExperiment] Setting up experiment. Allowing to "
<< "start now." << endl;
BPEvent mainFuncEntry(0x3c1f);
simulator.addEvent(&mainFuncEntry);
if (&mainFuncEntry != simulator.waitAny()) {
cerr << "[JumpAndRunExperiment] Now, we are completely lost! "
<< "It's time to cry! :-(" << endl;
simulator.clearEvents(this);
return false;
}
else
cout << "[JumpAndRunExperiment] Entry of main function reached! "
<< " Let's see who's jumping around here..." << endl;
const unsigned COUNTER = 20000;
unsigned i = 0;
BxFlagsReg* pFlags = dynamic_cast<BxFlagsReg*>(simulator.
getRegisterManager().getSetOfType(RT_ST).snatch());
assert(pFlags != NULL && "FATAL ERROR: NULL ptr not expected!");
JumpEvent ev;
// Catch the next "counter" jumps:
while (++i <= COUNTER) {
ev.setWatchInstructionPointer(ANY_INSTR);
simulator.addEvent(&ev);
if (simulator.waitAny() != &ev) {
cerr << "[JumpAndRunExperiment] Damn! Something went "
<< "terribly wrong! Who added that event?! :-(" << endl;
simulator.clearEvents(this);
return false;
}
else
cout << "[JumpAndRunExperiment] Entry of main function reached! "
<< " Let's see who's jumping around here..." << endl;
const unsigned COUNTER = 20000;
unsigned i = 0;
BxFlagsReg* pFlags = dynamic_cast<BxFlagsReg*>(simulator.
getRegisterManager().getSetOfType(RT_ST).snatch());
assert(pFlags != NULL && "FATAL ERROR: NULL ptr not expected!");
JumpEvent ev;
// Catch the next "counter" jumps:
while(++i <= COUNTER)
{
ev.setWatchInstructionPointer(ANY_INSTR);
simulator.addEvent(&ev);
if(simulator.waitAny() != &ev)
{
cerr << "[JumpAndRunExperiment] Damn! Something went "
<< "terribly wrong! Who added that event?! :-(" << endl;
simulator.clearEvents(this);
return false;
}
else
cout << "[JumpAndRunExperiment] Jump detected. Instruction: "
<< "0x" hex << ev.getTriggerInstructionPointer()
<< " -- FLAGS [CF, ZF, OF, PF, SF] = ["
<< pFlags->getCarryFlag() << ", "
<< pFlags->getZeroFlag() << ", "
<< pFlags->getOverflowFlag() << ", "
<< pFlags->getParityFlag() << ", "
<< pFlags->getSignFlag() << "]." << endl;
}
cout << "[JumpAndRunExperiment] " << dec << counter
<< " jump(s) detected -- enough for today...exiting! :-)"
<< endl;
simulator.clearEvents(this);
return true;
cout << "[JumpAndRunExperiment] Jump detected. Instruction: "
<< "0x" hex << ev.getTriggerInstructionPointer()
<< " -- FLAGS [CF, ZF, OF, PF, SF] = ["
<< pFlags->getCarryFlag() << ", "
<< pFlags->getZeroFlag() << ", "
<< pFlags->getOverflowFlag() << ", "
<< pFlags->getParityFlag() << ", "
<< pFlags->getSignFlag() << "]." << endl;
}
cout << "[JumpAndRunExperiment] " << dec << counter
<< " jump(s) detected -- enough for today...exiting! :-)"
<< endl;
simulator.clearEvents(this);
return true;
}
};
#endif /* __JUMP_AND_RUN_EXPERIMENT_HPP__ */
#endif // __JUMP_AND_RUN_EXPERIMENT_HPP__

View File

@ -1,9 +1,6 @@
#ifndef __MEM_WRITE_EXPERIMENT_HPP__
#define __MEM_WRITE_EXPERIMENT_HPP__
// Author: Adrian Böckenkamp
// Date: 16.06.2011
#include <iostream>
#include "../controller/ExperimentFlow.hpp"
@ -15,63 +12,60 @@
#error Event dependecies not satisfied! Enabled needed aspects in FailConfig.hpp!
#endif
using namespace fi;
using namespace std;
using sal::simulator;
using namespace fail;
class MemWriteExperiment : public ExperimentFlow
{
public:
bool run() // Example experiment (defines "what we wanna do")
{
/************************************
* Description of experiment flow. *
************************************/
class MemWriteExperiment : public fail::ExperimentFlow {
public:
bool run() // Example experiment (defines "what we wanna do")
{
/************************************
* Description of experiment flow. *
************************************/
// 1. Add some events (set up the experiment):
cout << "[MemWriteExperiment] Setting up experiment. Allowing to"
<< " start now." << endl;
MemWriteEvent mem1(0x000904F0), mem2(0x02ff0916), mem3(0x0050C8E8);
BPEvent breakpt(0x4ae6);
simulator.addEvent(&mem1);
simulator.addEvent(&mem2);
simulator.addEvent(&mem3);
simulator.addEvent(&breakpt);
// 1. Add some events (set up the experiment):
cout << "[MemWriteExperiment] Setting up experiment. Allowing to"
<< " start now." << endl;
MemWriteEvent mem1(0x000904F0), mem2(0x02ff0916), mem3(0x0050C8E8);
BPEvent breakpt(0x4ae6);
simulator.addEvent(&mem1);
simulator.addEvent(&mem2);
simulator.addEvent(&mem3);
simulator.addEvent(&breakpt);
// 2. Wait for event condition "(id1 && id2) || id3" to become true:
cout << "[MemWriteExperiment] Waiting for condition (1) (\"(id1 &&"
<< " id2) || id3\") to become true..." << endl;
bool f1 = false, f2 = false, f3 = false, f4 = false;
while(!(f1 || f2 || f3 || f4))
{
BPEvent* pev = simulator.waitAny();
cout << "[MemWriteExperiment] Received event id=" << id
<< "." << endl;
if(pev == &mem4)
f4 = true;
if(pev == &mem3)
f3 = true;
if(pev == &mem2)
f2 = true;
if(pev == &mem1)
f1 = true;
}
cout << "[MemWriteExperiment] Condition (1) satisfied! Ready to "
<< "add next event..." << endl;
// 3. Add a new event now:
cout << "[MemWriteExperiment] Adding new Event..."; cout.flush();
simulator.clearEvents(); // remove residual events in the buffer
// (we're just interested in the new event)
simulator.save("./bochs_save_point");
cout << "done!" << endl;
// 4. Continue simulation (waitAny) and inject bitflip:
// ...
simulator.clearEvents(this);
return true;
// 2. Wait for event condition "(id1 && id2) || id3" to become true:
cout << "[MemWriteExperiment] Waiting for condition (1) (\"(id1 &&"
<< " id2) || id3\") to become true..." << endl;
bool f1 = false, f2 = false, f3 = false, f4 = false;
while (!(f1 || f2 || f3 || f4)) {
BPEvent* pev = simulator.waitAny();
cout << "[MemWriteExperiment] Received event id=" << id
<< "." << endl;
if(pev == &mem4)
f4 = true;
if(pev == &mem3)
f3 = true;
if(pev == &mem2)
f2 = true;
if(pev == &mem1)
f1 = true;
}
cout << "[MemWriteExperiment] Condition (1) satisfied! Ready to "
<< "add next event..." << endl;
// 3. Add a new event now:
cout << "[MemWriteExperiment] Adding new Event..."; cout.flush();
simulator.clearEvents(); // remove residual events in the buffer
// (we're just interested in the new event)
simulator.save("./bochs_save_point");
cout << "done!" << endl;
// 4. Continue simulation (waitAny) and inject bitflip:
// ...
simulator.clearEvents(this);
return true;
}
};
#endif /* __MEM_WRITE_EXPERIMENT_HPP__ */
#endif // __MEM_WRITE_EXPERIMENT_HPP__

View File

@ -1,66 +1,60 @@
#ifndef __MY_EXPERIMENT_HPP__
#define __MY_EXPERIMENT_HPP__
// Author: Adrian Böckenkamp
// Date: 16.06.2011
#include <iostream>
#include "../controller/ExperimentFlow.hpp"
#include "../SAL/SALInst.hpp"
using namespace fi;
using namespace std;
using sal::simulator;
using namespace fail;
class MyExperiment : public fi::ExperimentFlow
{
public:
bool run() // Example experiment (defines "what we wanna do")
{
/************************************
* Description of experiment flow. *
************************************/
// 1. Add some events (set up the experiment):
cout << "[MyExperiment] Setting up experiment. Allowing to start"
<< " now." << endl;
BPEvent ev1(0x8048A00), ev2(0x8048F01), ev3(0x3c1f);
simulator.addEvent(&ev1);
simulator.addEvent(&ev2);
simulator.addEvent(&ev3);
class MyExperiment : public fail::ExperimentFlow {
public:
bool run() // Example experiment (defines "what we wanna do")
{
/************************************
* Description of experiment flow. *
************************************/
// 1. Add some events (set up the experiment):
cout << "[MyExperiment] Setting up experiment. Allowing to start"
<< " now." << endl;
BPEvent ev1(0x8048A00), ev2(0x8048F01), ev3(0x3c1f);
simulator.addEvent(&ev1);
simulator.addEvent(&ev2);
simulator.addEvent(&ev3);
// 2. Wait for event condition "(id1 && id2) || id3" to become true:
BPEvent* pev;
cout << "[MyExperiment] Waiting for condition (1) (\"(id1 && id2)"
<< " || id3\") to become true..." << endl;
bool f1 = false, f2 = false, f3 = false;
while(!((f1 && f2) || f3))
{
pev = simulator.waitAny();
cout << "[MyExperiment] Received event id=" << pev->getId()
<< "." << endl;
if(pev == &ev3)
f3 = true;
if(pev == &ev2)
f2 = true;
if(pev == &ev1)
f1 = true;
}
cout << "[MyExperiment] Condition (1) satisfied! Ready..." << endl;
// Remove residual (for all active experiments!)
// events in the buffer:
simulator.clearEvents();
BPEvent foobar(ANY_ADDR);
foobar.setCounter(400);
cout << "[MyExperiment] Adding breakpoint-event, firing after the"
<< " next 400 instructions..."; cout.flush();
simulator.addEventAndWait(&foobar);
cout << "cought! Exiting now." << endl;
simulator.clearEvents(this);
return true;
// 2. Wait for event condition "(id1 && id2) || id3" to become true:
BPEvent* pev;
cout << "[MyExperiment] Waiting for condition (1) (\"(id1 && id2)"
<< " || id3\") to become true..." << endl;
bool f1 = false, f2 = false, f3 = false;
while (!((f1 && f2) || f3)) {
pev = simulator.waitAny();
cout << "[MyExperiment] Received event id=" << pev->getId()
<< "." << endl;
if(pev == &ev3)
f3 = true;
if(pev == &ev2)
f2 = true;
if(pev == &ev1)
f1 = true;
}
cout << "[MyExperiment] Condition (1) satisfied! Ready..." << endl;
// Remove residual (for all active experiments!)
// events in the buffer:
simulator.clearEvents();
BPEvent foobar(ANY_ADDR);
foobar.setCounter(400);
cout << "[MyExperiment] Adding breakpoint-event, firing after the"
<< " next 400 instructions..."; cout.flush();
simulator.addEventAndWait(&foobar);
cout << "cought! Exiting now." << endl;
simulator.clearEvents(this);
return true;
}
};
#endif /* __MY_EXPERIMENT_HPP__ */
#endif // __MY_EXPERIMENT_HPP__

View File

@ -1,9 +1,6 @@
#ifndef __SINGLE_STEPPING_EXPERIMENT_HPP__
#define __SINGLE_STEPPING_EXPERIMENT_HPP__
// Author: Adrian Böckenkamp
// Date: 09.11.2011
#include <iostream>
#include "../controller/ExperimentFlow.hpp"
@ -16,52 +13,48 @@
#error Breakpoint-events needed! Enable aspect first (see FailConfig.hpp)!
#endif
using namespace fi;
using namespace std;
using namespace sal;
using namespace fail;
#define FUNCTION_ENTRY_ADDRESS 0x3c1f
class SingleSteppingExperiment : public fi::ExperimentFlow
{
public:
bool run()
{
/************************************
* Description of experiment flow. *
************************************/
// Wait for function entry adresss:
cout << "[SingleSteppingExperiment] Setting up experiment. Allowing"
<< " to start now." << endl;
BPEvent mainFuncEntry(FUNCTION_ENTRY_ADDRESS);
simulator.addEvent(&mainFuncEntry);
if(&mainFuncEntry != simulator.waitAny())
{
cerr << "[SingleSteppingExperiment] Now, we are completely lost!"
<< " It's time to cry! :-(" << endl;
simulator.clearEvents(this);
return false;
}
cout << "[SingleSteppingExperiment] Entry of main function reached!"
<< " Beginning single-stepping..." << endl;
char action;
while(true)
{
BPEvent bp(ANY_ADDR);
simulator.addEvent(&bp);
simulator.waitAny();
cout << "0x" << hex
<< simulator.getRegisterManager().getInstructionPointer()
<< endl;
cout << "Continue (y/n)? ";
cin >> action; cin.sync(); cin.clear();
if(action != 'y')
break;
}
class SingleSteppingExperiment : public fail::ExperimentFlow {
public:
bool run()
{
/************************************
* Description of experiment flow. *
************************************/
// Wait for function entry adresss:
cout << "[SingleSteppingExperiment] Setting up experiment. Allowing"
<< " to start now." << endl;
BPEvent mainFuncEntry(FUNCTION_ENTRY_ADDRESS);
simulator.addEvent(&mainFuncEntry);
if (&mainFuncEntry != simulator.waitAny()) {
cerr << "[SingleSteppingExperiment] Now, we are completely lost!"
<< " It's time to cry! :-(" << endl;
simulator.clearEvents(this);
return true;
return false;
}
cout << "[SingleSteppingExperiment] Entry of main function reached!"
<< " Beginning single-stepping..." << endl;
char action;
while (true) {
BPEvent bp(ANY_ADDR);
simulator.addEvent(&bp);
simulator.waitAny();
cout << "0x" << hex
<< simulator.getRegisterManager().getInstructionPointer()
<< endl;
cout << "Continue (y/n)? ";
cin >> action; cin.sync(); cin.clear();
if (action != 'y')
break;
}
simulator.clearEvents(this);
return true;
}
};
#endif /* __SINGLE_STEPPING_EXPERIMENT_HPP__ */
#endif // __SINGLE_STEPPING_EXPERIMENT_HPP__

View File

@ -8,8 +8,8 @@
aspect hscsimple {
hscsimpleExperiment experiment;
advice execution ("void sal::SimulatorController::initExperiments()") : after () {
sal::simulator.addFlow(&experiment);
advice execution ("void fail::SimulatorController::initExperiments()") : after () {
fail::simulator.addFlow(&experiment);
}
};