Experiment updates due to last commit.

git-svn-id: https://www4.informatik.uni-erlangen.de/i4svn/danceos/trunk/devel/fail@1449 8c4709b5-6ec9-48aa-a5cd-a96041d1645a
This commit is contained in:
adrian
2012-07-12 10:45:39 +00:00
parent a78911702a
commit 2076d21e61
13 changed files with 177 additions and 177 deletions

View File

@ -25,7 +25,7 @@ public:
void coroutine_entry()
{
run();
simulator.clearEvents(this); // remove residual events
simulator.clearListeners(this); // remove residual events
}
};

View File

@ -13,8 +13,8 @@
#include "sal/SALInst.hpp"
#include "sal/Memory.hpp"
#include "sal/bochs/BochsRegister.hpp"
#include "sal/bochs/BochsEvents.hpp"
#include "sal/Event.hpp"
#include "sal/bochs/BochsListener.hpp"
#include "sal/Listener.hpp"
// You need to have the tracing plugin enabled for this
#include "../plugins/tracing/TracingPlugin.hpp"
@ -36,21 +36,21 @@ bool ChecksumOOStuBSExperiment::run()
{
char const *statename = "checksum-oostubs.state";
Logger log("Checksum-OOStuBS", false);
BPSingleEvent bp;
BPSingleListener bp;
log << "startup" << endl;
#if 0
// STEP 0: record memory map with addresses of "interesting" objects
GuestEvent g;
GuestListener g;
while (true) {
simulator.addEventAndWait(&g);
simulator.addListenerAndResume(&g);
cout << g.getData() << flush;
}
#elif 0
// STEP 1: run until interesting function starts, and save state
bp.setWatchInstructionPointer(OOSTUBS_FUNC_ENTRY);
simulator.addEventAndWait(&bp);
simulator.addListenerAndResume(&bp);
log << "test function entry reached, saving state" << endl;
log << "EIP = " << hex << bp.getTriggerInstructionPointer() << endl;
log << "error_corrected = " << dec << ((int)simulator.getMemoryManager().getByte(OOSTUBS_ERROR_CORRECTED)) << endl;
@ -95,16 +95,16 @@ bool ChecksumOOStuBSExperiment::run()
bp.setWatchInstructionPointer(ANY_ADDR);
bp.setCounter(OOSTUBS_NUMINSTR);
#endif
simulator.addEvent(&bp);
BPSingleEvent ev_count(ANY_ADDR);
simulator.addEvent(&ev_count);
simulator.addListener(&bp);
BPSingleListener ev_count(ANY_ADDR);
simulator.addListener(&ev_count);
// count instructions
// FIXME add SAL functionality for this?
int instr_counter = 0;
while (simulator.waitAny() == &ev_count) {
while (simulator.resume() == &ev_count) {
++instr_counter;
simulator.addEvent(&ev_count);
simulator.addListener(&ev_count);
}
log << dec << "tracing finished after " << instr_counter << endl;
@ -120,7 +120,7 @@ bool ChecksumOOStuBSExperiment::run()
// serialize trace to file
if (of.fail()) {
log << "failed to write " << tracefile << endl;
simulator.clearEvents(this);
simulator.clearListeners(this);
return false;
}
of.close();
@ -173,8 +173,8 @@ bool ChecksumOOStuBSExperiment::run()
*/
// reaching finish() could happen before OR after FI
BPSingleEvent func_finish(OOSTUBS_FUNC_FINISH);
simulator.addEvent(&func_finish);
BPSingleListener func_finish(OOSTUBS_FUNC_FINISH);
simulator.addListener(&func_finish);
bool finish_reached = false;
// no need to wait if offset is 0
@ -182,15 +182,15 @@ bool ChecksumOOStuBSExperiment::run()
// XXX could be improved with intermediate states (reducing runtime until injection)
bp.setWatchInstructionPointer(ANY_ADDR);
bp.setCounter(instr_offset);
simulator.addEvent(&bp);
simulator.addListener(&bp);
// finish() before FI?
if (simulator.waitAny() == &func_finish) {
if (simulator.resume() == &func_finish) {
finish_reached = true;
log << "experiment reached finish() before FI" << endl;
// wait for bp
simulator.waitAny();
simulator.resume();
//TODO: why wait here? it seems that something went completely wrong?
}
}
@ -216,7 +216,7 @@ bool ChecksumOOStuBSExperiment::run()
result->set_latest_ip(injection_ip);
result->set_details(ss.str());
simulator.clearEvents();
simulator.clearListeners();
continue;
}
@ -234,22 +234,22 @@ bool ChecksumOOStuBSExperiment::run()
// - (XXX "sane" display?)
// catch traps as "extraordinary" ending
TrapEvent ev_trap(ANY_TRAP);
simulator.addEvent(&ev_trap);
TrapListener ev_trap(ANY_TRAP);
simulator.addListener(&ev_trap);
// jump outside text segment
BPRangeEvent ev_below_text(ANY_ADDR, OOSTUBS_TEXT_START - 1);
BPRangeEvent ev_beyond_text(OOSTUBS_TEXT_END + 1, ANY_ADDR);
simulator.addEvent(&ev_below_text);
simulator.addEvent(&ev_beyond_text);
BPRangeListener ev_below_text(ANY_ADDR, OOSTUBS_TEXT_START - 1);
BPRangeListener ev_beyond_text(OOSTUBS_TEXT_END + 1, ANY_ADDR);
simulator.addListener(&ev_below_text);
simulator.addListener(&ev_beyond_text);
// timeout (e.g., stuck in a HLT instruction)
// 10000us = 500000 instructions
TimerEvent ev_timeout(1000000); // 50,000,000 instructions !!
simulator.addEvent(&ev_timeout);
TimerListener ev_timeout(1000000); // 50,000,000 instructions !!
simulator.addListener(&ev_timeout);
// remaining instructions until "normal" ending
BPSingleEvent ev_end(ANY_ADDR);
BPSingleListener ev_end(ANY_ADDR);
ev_end.setCounter(OOSTUBS_NUMINSTR + OOSTUBS_RECOVERYINSTR - instr_offset);
simulator.addEvent(&ev_end);
simulator.addListener(&ev_end);
#if LOCAL && 0
// XXX debug
@ -261,7 +261,7 @@ bool ChecksumOOStuBSExperiment::run()
simulator.addFlow(&tp);
#endif
BaseEvent* ev = simulator.waitAny();
BaseListener* ev = simulator.resume();
// Do we reach finish() while waiting for ev_trap/ev_done?
if (ev == &func_finish) {
@ -269,7 +269,7 @@ bool ChecksumOOStuBSExperiment::run()
log << "experiment reached finish()" << endl;
// wait for ev_trap/ev_done
ev = simulator.waitAny();
ev = simulator.resume();
}
// record latest IP regardless of result
@ -307,12 +307,12 @@ bool ChecksumOOStuBSExperiment::run()
result->set_resulttype(result->UNKNOWN);
stringstream ss;
ss << "eventid " << ev->getId() << " EIP " << simulator.getRegisterManager().getInstructionPointer();
ss << "event addr " << ev << " EIP " << simulator.getRegisterManager().getInstructionPointer();
result->set_details(ss.str());
}
// explicitly remove all events before we leave their scope
// FIXME event destructors should remove them from the queues
simulator.clearEvents();
simulator.clearListeners();
}
// sanity check: do we have exactly 8 results?
if (param.msg.result_size() != 8) {

View File

@ -8,7 +8,7 @@
#include "sal/SALInst.hpp"
#include "sal/Memory.hpp"
#include "sal/bochs/BochsRegister.hpp"
#include "sal/Event.hpp"
#include "sal/Listener.hpp"
#include "config/FailConfig.hpp"
#if COOL_FAULTSPACE_PRUNING
@ -30,14 +30,14 @@ using namespace fail;
bool CoolChecksumExperiment::run()
{
Logger log("CoolChecksum", false);
BPSingleEvent bp;
BPSingleListener bp;
log << "startup" << endl;
#if 1
// STEP 1: run until interesting function starts, and save state
bp.setWatchInstructionPointer(COOL_ECC_FUNC_ENTRY);
simulator.addEventAndWait(&bp);
simulator.addListenerAndResume(&bp);
log << "test function entry reached, saving state" << endl;
log << "EIP = " << hex << bp.getTriggerInstructionPointer() << " or " << simulator.getRegisterManager().getInstructionPointer() << endl;
log << "error_corrected = " << dec << ((int)simulator.getMemoryManager().getByte(COOL_ECC_ERROR_CORRECTED)) << endl;
@ -74,7 +74,7 @@ bool CoolChecksumExperiment::run()
int count;
bp.setWatchInstructionPointer(ANY_ADDR);
for (count = 0; bp.getTriggerInstructionPointer() != COOL_ECC_CALCDONE; ++count) {
simulator.addEventAndWait(&bp);
simulator.addListenerAndResume(&bp);
// log << "EIP = " << hex << simulator.getRegisterManager().getInstructionPointer() << endl;
}
log << "test function calculation position reached after " << dec << count << " instructions" << endl;
@ -87,7 +87,7 @@ bool CoolChecksumExperiment::run()
// serialize trace to file
if (of.fail()) {
log << "failed to write trace.pb" << endl;
simulator.clearEvents(this);
simulator.clearListeners(this);
return false;
}
of.close();
@ -120,7 +120,7 @@ bool CoolChecksumExperiment::run()
// trace
bp.setWatchInstructionPointer(ANY_ADDR);
for (int count = 0; count < instr_offset; ++count) {
simulator.addEventAndWait(&bp);
simulator.addListenerAndResume(&bp);
}
// inject
@ -147,21 +147,21 @@ bool CoolChecksumExperiment::run()
param.msg.set_resultdata(injection_ip);
param.msg.set_details(ss.str());
simulator.clearEvents();
simulator.clearListeners();
m_jc.sendResult(param);
continue;
}
// aftermath
BPSingleEvent ev_done(COOL_ECC_CALCDONE);
simulator.addEvent(&ev_done);
BPSingleEvent ev_timeout(ANY_ADDR);
BPSingleListener ev_done(COOL_ECC_CALCDONE);
simulator.addListener(&ev_done);
BPSingleListener ev_timeout(ANY_ADDR);
ev_timeout.setCounter(COOL_ECC_NUMINSTR + 3000);
simulator.addEvent(&ev_timeout);
TrapEvent ev_trap(ANY_TRAP);
simulator.addEvent(&ev_trap);
simulator.addListener(&ev_timeout);
TrapListener ev_trap(ANY_TRAP);
simulator.addListener(&ev_trap);
BaseEvent* ev = simulator.waitAny();
BaseListener* ev = simulator.resume();
if (ev == &ev_done) {
Register* pRegRes = simulator.getRegisterManager().getRegister(RID_CDX);
int32_t data = pRegRes->getData();
@ -182,10 +182,10 @@ bool CoolChecksumExperiment::run()
param.msg.set_resultdata(simulator.getRegisterManager().getInstructionPointer());
stringstream ss;
ss << "eventid " << ev << " EIP " << simulator.getRegisterManager().getInstructionPointer();
ss << "event addr " << ev << " EIP " << simulator.getRegisterManager().getInstructionPointer();
param.msg.set_details(ss.str());
}
simulator.clearEvents();
simulator.clearListeners();
int32_t error_corrected = simulator.getMemoryManager().getByte(COOL_ECC_ERROR_CORRECTED);
param.msg.set_error_corrected(error_corrected);
m_jc.sendResult(param);
@ -196,6 +196,6 @@ bool CoolChecksumExperiment::run()
simulator.terminate();
#endif
// simulator continues to run
simulator.clearEvents(this);
simulator.clearListeners(this);
return true;
}

View File

@ -38,11 +38,11 @@ bool FaultCoverageExperiment::run()
// set breakpoint at start address of the function to be analyzed ("observed");
// wait until instruction pointer reaches that address
cout << "[FaultCoverageExperiment] Setting up experiment. Allowing to start now." << endl;
BPSingleEvent ev_func_start(INST_ADDR_FUNC_START);
simulator.addEvent(&ev_func_start);
BPSingleListener ev_func_start(INST_ADDR_FUNC_START);
simulator.addListener(&ev_func_start);
cout << "[FaultCoverageExperiment] Waiting for function start address..." << endl;
while (simulator.waitAny() != &ev_func_start)
while (simulator.resume() != &ev_func_start)
;
// store current state
@ -63,7 +63,7 @@ bool FaultCoverageExperiment::run()
// loop over all instruction addresses of observed function
for (int instr = 0; ; ++instr) {
// clear event queues
simulator.clearEvents();
simulator.clearListeners();
// restore previously saved simulator state
cout << "[FaultCoverageExperiment] Restoring previous simulator state..."; cout.flush();
@ -71,19 +71,19 @@ bool FaultCoverageExperiment::run()
cout << "done!" << endl;
// breakpoint at function exit
BPSingleEvent ev_func_end(INST_ADDR_FUNC_END);
simulator.addEvent(&ev_func_end);
BPSingleListener ev_func_end(INST_ADDR_FUNC_END);
simulator.addListener(&ev_func_end);
// no need to continue simulation if we want to
// inject *now*
if (instr > 0) {
// breakpoint $instr instructions in the future
BPSingleEvent ev_instr_reached(ANY_ADDR);
BPSingleListener ev_instr_reached(ANY_ADDR);
ev_instr_reached.setCounter(instr);
simulator.addEvent(&ev_instr_reached);
simulator.addListener(&ev_instr_reached);
// if we reach the exit first, this round is done
if (simulator.waitAny() == &ev_func_end)
if (simulator.resume() == &ev_func_end)
break;
}
@ -93,14 +93,14 @@ bool FaultCoverageExperiment::run()
pReg->setData(data); // write back data to register
// catch traps and timeout
TrapEvent ev_trap; // any traps
simulator.addEvent(&ev_trap);
BPSingleEvent ev_timeout(ANY_ADDR);
TrapListener ev_trap; // any traps
simulator.addListener(&ev_trap);
BPSingleListener ev_timeout(ANY_ADDR);
ev_timeout.setCounter(1000);
simulator.addEvent(&ev_timeout);
simulator.addListener(&ev_timeout);
// wait for function exit, trap or timeout
BaseEvent* ev = simulator.waitAny();
BaseListener* ev = simulator.resume();
if (ev == &ev_func_end) {
// log result
#if BX_SUPPORT_X86_64
@ -130,6 +130,6 @@ bool FaultCoverageExperiment::run()
}
}
simulator.clearEvents(this);
simulator.clearListeners(this);
return true;
}

View File

@ -12,7 +12,7 @@
#include "experiment.hpp"
#include "sal/SALInst.hpp"
#include "sal/Event.hpp"
#include "sal/Listener.hpp"
#include "util/Logger.hpp"
#include "config/FailConfig.hpp"
@ -33,8 +33,8 @@ bool FireInterruptExperiment::run()
while (true) {
int j = 0;
for (j = 0; j <= 100; j++) {
BPSingleEvent mainbp(0x1045f5);
simulator.addEventAndWait(&mainbp);
BPSingleListener mainbp(0x1045f5);
simulator.addListenerAndResume(&mainbp);
}
simulator.fireInterrupt(1);
}
@ -42,6 +42,6 @@ bool FireInterruptExperiment::run()
simulator.dbgEnableInstrPtrOutput(500);
#endif
simulator.clearEvents(this);
simulator.clearListeners(this);
return true;
}

View File

@ -4,7 +4,7 @@
#include "experiment.hpp"
#include "sal/SALInst.hpp"
#include "sal/bochs/BochsRegister.hpp"
#include "sal/Event.hpp"
#include "sal/Listener.hpp"
#include "util/Logger.hpp"
#include "config/FailConfig.hpp"
@ -24,8 +24,8 @@ bool HSCSimpleExperiment::run()
// do funny things here...
#if 1
// STEP 1
BPSingleEvent mainbp(0x00003c34);
simulator.addEventAndWait(&mainbp);
BPSingleListener mainbp(0x00003c34);
simulator.addListenerAndResume(&mainbp);
log << "breakpoint reached, saving" << endl;
simulator.save("hello.state");
#elif 0
@ -35,20 +35,20 @@ bool HSCSimpleExperiment::run()
log << "restored!" << endl;
log << "waiting for last square() instruction" << endl;
BPSingleEvent breakpoint(0x3c9e); // square(x) ret instruction
simulator.addEventAndWait(&breakpoint);
BPSingleListener breakpoint(0x3c9e); // square(x) ret instruction
simulator.addListenerAndResume(&breakpoint);
log << "injecting hellish fault" << endl;
// RID_CAX is the RAX register in 64 bit mode and EAX in 32 bit mode:
simulator.getRegisterManager().getRegister(RID_CAX)->setData(666);
log << "waiting for last main() instruction" << endl;
breakpoint.setWatchInstructionPointer(0x3c92);
simulator.addEventAndWait(&breakpoint);
simulator.addListenerAndResume(&breakpoint);
log << "reached" << endl;
simulator.addEventAndWait(&breakpoint);
simulator.addListenerAndResume(&breakpoint);
#endif
simulator.clearEvents(this);
simulator.clearListeners(this);
return true;
}

View File

@ -15,7 +15,7 @@
#include "sal/SALInst.hpp"
#include "sal/Memory.hpp"
#include "sal/bochs/BochsRegister.hpp"
#include "sal/Event.hpp"
#include "sal/Listener.hpp"
#include "config/FailConfig.hpp"
#include "l4sys.pb.h"
@ -67,15 +67,15 @@ string L4SysExperiment::sanitised(const string &in_str) {
return result;
}
BaseEvent* L4SysExperiment::waitIOOrOther(bool clear_output) {
IOPortEvent ev_ioport(0x3F8, true);
BaseEvent* ev = NULL;
BaseListener* L4SysExperiment::waitIOOrOther(bool clear_output) {
IOPortListener ev_ioport(0x3F8, true);
BaseListener* ev = NULL;
if (clear_output)
output.clear();
while (true) {
simulator.addEvent(&ev_ioport);
ev = simulator.waitAny();
simulator.removeEvent(&ev_ioport);
simulator.addListener(&ev_ioport);
ev = simulator.resume();
simulator.removeListener(&ev_ioport);
if (ev == &ev_ioport) {
output += ev_ioport.getData();
} else {
@ -153,10 +153,10 @@ void L4SysExperiment::changeBochsInstruction(bxInstruction_c *dest,
memcpy(dest, src, sizeof(bxInstruction_c));
// execute the faulty instruction, then return
BPSingleEvent singlestepping_event(ANY_ADDR, L4SYS_ADDRESS_SPACE);
simulator.addEvent(&singlestepping_event);
BPSingleListener singlestepping_event(ANY_ADDR, L4SYS_ADDRESS_SPACE);
simulator.addListener(&singlestepping_event);
waitIOOrOther(false);
simulator.removeEvent(&singlestepping_event);
simulator.removeListener(&singlestepping_event);
//restore the old instruction
memcpy(dest, &old_instr, sizeof(bxInstruction_c));
@ -164,7 +164,7 @@ void L4SysExperiment::changeBochsInstruction(bxInstruction_c *dest,
bool L4SysExperiment::run() {
Logger log("L4Sys", false);
BPSingleEvent bp(0, L4SYS_ADDRESS_SPACE);
BPSingleListener bp(0, L4SYS_ADDRESS_SPACE);
srand(time(NULL));
log << "startup" << endl;
@ -173,7 +173,7 @@ bool L4SysExperiment::run() {
// STEP 1: run until interesting function starts, and save state
if (stat(L4SYS_STATE_FOLDER, &teststruct) == -1) {
bp.setWatchInstructionPointer(L4SYS_FUNC_ENTRY);
simulator.addEventAndWait(&bp);
simulator.addListenerAndResume(&bp);
log << "test function entry reached, saving state" << endl;
log << "EIP = " << hex << bp.getTriggerInstructionPointer() << " or "
@ -205,7 +205,7 @@ bool L4SysExperiment::run() {
map<address_t, unsigned> times_called_map;
while (bp.getTriggerInstructionPointer() != L4SYS_FUNC_EXIT) {
simulator.addEventAndWait(&bp);
simulator.addListenerAndResume(&bp);
//short sanity check
address_t curr_addr = bp.getTriggerInstructionPointer();
assert(
@ -258,8 +258,8 @@ bool L4SysExperiment::run() {
ofstream golden_run_file(L4SYS_CORRECT_OUTPUT);
bp.setWatchInstructionPointer(L4SYS_FUNC_EXIT);
bp.setCounter(L4SYS_ITERATION_COUNT);
simulator.addEvent(&bp);
BaseEvent* ev = waitIOOrOther(true);
simulator.addListener(&bp);
BaseListener* ev = waitIOOrOther(true);
if (ev == &bp) {
golden_run.assign(output.c_str());
golden_run_file << output.c_str();
@ -271,7 +271,7 @@ bool L4SysExperiment::run() {
golden_run_file.close();
simulator.terminate(10);
}
simulator.clearEvents();
simulator.clearListeners();
bp.setCounter(1);
log << "saving output generated during normal execution" << endl;
golden_run_file.close();
@ -307,7 +307,7 @@ bool L4SysExperiment::run() {
bp.setWatchInstructionPointer(ANY_ADDR);
bp.setCounter(instr_offset);
simulator.addEvent(&bp);
simulator.addListener(&bp);
//and log the output
waitIOOrOther(true);
@ -328,7 +328,7 @@ bool L4SysExperiment::run() {
param.msg.set_resultdata(injection_ip);
param.msg.set_details(ss.str());
simulator.clearEvents();
simulator.clearListeners();
m_jc.sendResult(param);
simulator.terminate(20);
}
@ -464,10 +464,10 @@ bool L4SysExperiment::run() {
}
// execute the instruction
BPSingleEvent execute_single_instr(ANY_INSTR, L4SYS_ADDRESS_SPACE);
simulator.addEvent(&execute_single_instr);
BPSingleListener execute_single_instr(ANY_INSTR, L4SYS_ADDRESS_SPACE);
simulator.addListener(&execute_single_instr);
waitIOOrOther(false);
simulator.removeEvent(&execute_single_instr);
simulator.removeListener(&execute_single_instr);
// restore
if (rnd > 0) {
@ -492,24 +492,24 @@ bool L4SysExperiment::run() {
}
// aftermath
BPSingleEvent ev_done(L4SYS_FUNC_EXIT, L4SYS_ADDRESS_SPACE);
BPSingleListener ev_done(L4SYS_FUNC_EXIT, L4SYS_ADDRESS_SPACE);
ev_done.setCounter(L4SYS_ITERATION_COUNT);
simulator.addEvent(&ev_done);
simulator.addListener(&ev_done);
const unsigned instr_run = L4SYS_ITERATION_COUNT * L4SYS_NUMINSTR;
BPSingleEvent ev_timeout(ANY_ADDR, L4SYS_ADDRESS_SPACE);
BPSingleListener ev_timeout(ANY_ADDR, L4SYS_ADDRESS_SPACE);
ev_timeout.setCounter(instr_run + 3000);
simulator.addEvent(&ev_timeout);
TrapEvent ev_trap(ANY_TRAP);
simulator.addListener(&ev_timeout);
TrapListener ev_trap(ANY_TRAP);
//one trap for each 150 instructions justifies an exception
ev_trap.setCounter(instr_run / 150);
simulator.addEvent(&ev_trap);
InterruptEvent ev_intr(ANY_INTERRUPT);
simulator.addListener(&ev_trap);
InterruptListener ev_intr(ANY_INTERRUPT);
//one interrupt for each 100 instructions justifies an exception (timeout mostly)
ev_intr.setCounter(instr_run / 100);
simulator.addEvent(&ev_intr);
simulator.addListener(&ev_intr);
//do not discard output recorded so far
BaseEvent *ev = waitIOOrOther(false);
BaseListener *ev = waitIOOrOther(false);
/* copying a string object that contains control sequences
* unfortunately does not work with the library I am using,
@ -558,7 +558,7 @@ bool L4SysExperiment::run() {
param.msg.set_details(ss.str());
}
simulator.clearEvents();
simulator.clearListeners();
m_jc.sendResult(param);
#ifdef HEADLESS_EXPERIMENT

View File

@ -28,7 +28,7 @@ private:
* @param clear_output if true, the output logged so far is deleted, thus the buffer is reset (cleared)
* @returns the event returned by waitAny, as long as it did not log output
*/
fail::BaseEvent* waitIOOrOther(bool clear_output);
fail::BaseListener* waitIOOrOther(bool clear_output);
/**
* Calculates the address where Bochs will read the current instruction from.
* This code is copied from various Bochs methods and should be reviewed as

View File

@ -4,7 +4,7 @@
#include "MHTestCampaign.hpp"
#include "sal/SALInst.hpp"
#include "sal/Register.hpp"
#include "sal/Event.hpp"
#include "sal/Listener.hpp"
// FIXME: You should provide a dependency check here!
@ -15,8 +15,8 @@ bool MHTestExperiment::run()
{
cout << "[MHTestExperiment] Let's go" << endl;
#if 0
BPSingleEvent mainbp(0x00003c34);
simulator.addEventAndWait(&mainbp);
BPSingleListener mainbp(0x00003c34);
simulator.addListenerAndResume(&mainbp);
cout << "[MHTestExperiment] breakpoint reached, saving" << endl;
simulator.save("hello.main");
#else
@ -25,9 +25,9 @@ bool MHTestExperiment::run()
int num = par.msg.input();
cout << "[MHExperiment] stepping " << num << " instructions" << endl;
if (num > 0) {
BPSingleEvent nextbp(ANY_ADDR);
BPSingleListener nextbp(ANY_ADDR);
nextbp.setCounter(num);
simulator.addEventAndWait(&nextbp);
simulator.addListenerAndResume(&nextbp);
}
address_t instr = simulator.getRegisterManager().getInstructionPointer();
cout << "[MHTestExperiment] Reached instruction: "
@ -39,7 +39,7 @@ bool MHTestExperiment::run()
cout << "No data for me? :(" << endl;
}
#endif
simulator.clearEvents(this);
simulator.clearListeners(this);
simulator.terminate();
return true;

View File

@ -21,7 +21,7 @@ bool TracingTest::run()
#if 0
// STEP 1: run until interesting function starts, and save state
BPSingleEvent breakpoint(0x00101658);
simulator.addEventAndWait(&breakpoint);
simulator.addEventAndResume(&breakpoint);
cout << "[TracingTest] main() reached, saving" << endl;
simulator.save("state");
@ -43,7 +43,7 @@ bool TracingTest::run()
simulator.addEvent(&timeout);
InterruptEvent ie(ANY_INTERRUPT);
while (simulator.addEventAndWait(&ie) != &timeout) {
while (simulator.addEventAndResume(&ie) != &timeout) {
cout << "INTERRUPT #" << ie.getTriggerNumber() << "\n";
}

View File

@ -12,8 +12,8 @@
#include "sal/SALInst.hpp"
#include "sal/Memory.hpp"
#include "sal/bochs/BochsRegister.hpp"
#include "sal/bochs/BochsEvents.hpp"
#include "sal/Event.hpp"
#include "sal/bochs/BochsListener.hpp"
#include "sal/Listener.hpp"
using namespace std;
@ -77,25 +77,25 @@ bool VEZSExperiment::run()
// - #loop iterations before/after FI
// catch traps as "extraordinary" ending
TrapEvent ev_trap(ANY_TRAP);
simulator.addEvent(&ev_trap);
TrapListener ev_trap(ANY_TRAP);
simulator.addListener(&ev_trap);
// jump outside text segment
BPRangeEvent ev_below_text(ANY_ADDR, OOSTUBS_TEXT_START - 1);
BPRangeEvent ev_beyond_text(OOSTUBS_TEXT_END + 1, ANY_ADDR);
simulator.addEvent(&ev_below_text);
simulator.addEvent(&ev_beyond_text);
BPRangeListener ev_below_text(ANY_ADDR, OOSTUBS_TEXT_START - 1);
BPRangeListener ev_beyond_text(OOSTUBS_TEXT_END + 1, ANY_ADDR);
simulator.addListener(&ev_below_text);
simulator.addListener(&ev_beyond_text);
// timeout (e.g., stuck in a HLT instruction)
// 10000us = 500000 instructions
TimerEvent ev_timeout(1000000); // 50,000,000 instructions !!
simulator.addEvent(&ev_timeout);
TimerListener ev_timeout(1000000); // 50,000,000 instructions !!
simulator.addListener(&ev_timeout);
// remaining instructions until "normal" ending
BPSingleEvent ev_end(ANY_ADDR);
BPSingleListener ev_end(ANY_ADDR);
ev_end.setCounter(OOSTUBS_NUMINSTR - instr_offset);
simulator.addEvent(&ev_end);
simulator.addListener(&ev_end);
// Start simulator and wait for any result
BaseEvent* ev = simulator.waitAny();
BaseListener* ev = simulator.resume();
// record latest IP regardless of result
injection_ip = simulator.getRegisterManager().getInstructionPointer();
@ -115,7 +115,7 @@ bool VEZSExperiment::run()
log << "@ ip 0x" << hex << injection_ip << endl;
// explicitly remove all events before we leave their scope
// FIXME event destructors should remove them from the queues
simulator.clearEvents();
simulator.clearListeners();
}
#endif

View File

@ -14,8 +14,8 @@
#include "sal/SALInst.hpp"
#include "sal/Memory.hpp"
#include "sal/bochs/BochsRegister.hpp"
#include "sal/bochs/BochsEvents.hpp"
#include "sal/Event.hpp"
#include "sal/bochs/BochsListener.hpp"
#include "sal/Listener.hpp"
// you need to have the tracing plugin enabled for this
#include "../plugins/tracing/TracingPlugin.hpp"
@ -37,21 +37,21 @@ bool WeatherMonitorExperiment::run()
{
char const *statename = "bochs.state" WEATHER_SUFFIX;
Logger log("Weathermonitor", false);
BPSingleEvent bp;
BPSingleListener bp;
log << "startup" << endl;
#if 1
// STEP 0: record memory map with vptr addresses
GuestEvent g;
GuestListener g;
while (true) {
simulator.addEventAndWait(&g);
simulator.addListenerAndResume(&g);
cout << g.getData() << flush;
}
#elif 0
// STEP 1: run until interesting function starts, and save state
bp.setWatchInstructionPointer(WEATHER_FUNC_MAIN);
simulator.addEventAndWait(&bp);
simulator.addListenerAndResume(&bp);
log << "test function entry reached, saving state" << endl;
log << "EIP = " << hex << bp.getTriggerInstructionPointer() << endl;
simulator.save(statename);
@ -96,16 +96,16 @@ bool WeatherMonitorExperiment::run()
bp.setWatchInstructionPointer(ANY_ADDR);
bp.setCounter(WEATHER_NUMINSTR_TRACING);
#endif
simulator.addEvent(&bp);
BPSingleEvent ev_count(ANY_ADDR);
simulator.addEvent(&ev_count);
simulator.addListener(&bp);
BPSingleListener ev_count(ANY_ADDR);
simulator.addListener(&ev_count);
// count instructions
// FIXME add SAL functionality for this?
int instr_counter = 0;
while (simulator.waitAny() == &ev_count) {
while (simulator.resume() == &ev_count) {
++instr_counter;
simulator.addEvent(&ev_count);
simulator.addListener(&ev_count);
}
log << dec << "tracing finished after " << instr_counter
@ -115,7 +115,7 @@ bool WeatherMonitorExperiment::run()
// serialize trace to file
if (of.fail()) {
log << "failed to write " << tracefile << endl;
simulator.clearEvents(this); // cleanup
simulator.clearListeners(this); // cleanup
return false;
}
of.close();
@ -124,14 +124,14 @@ bool WeatherMonitorExperiment::run()
// wait another WEATHER_NUMITER_AFTER measurement loop iterations
bp.setWatchInstructionPointer(WEATHER_FUNC_WAIT_END);
bp.setCounter(WEATHER_NUMITER_AFTER);
simulator.addEvent(&bp);
simulator.addListener(&bp);
// count instructions
// FIXME add SAL functionality for this?
instr_counter = 0;
while (simulator.waitAny() == &ev_count) {
while (simulator.resume() == &ev_count) {
++instr_counter;
simulator.addEvent(&ev_count);
simulator.addListener(&ev_count);
}
log << dec << "experiment finished after " << instr_counter
@ -184,15 +184,15 @@ bool WeatherMonitorExperiment::run()
*/
// this marks THE END
BPSingleEvent ev_end(ANY_ADDR);
BPSingleListener ev_end(ANY_ADDR);
ev_end.setCounter(WEATHER_NUMINSTR_TRACING + WEATHER_NUMINSTR_AFTER);
simulator.addEvent(&ev_end);
simulator.addListener(&ev_end);
// count loop iterations by counting wait_begin() calls
// FIXME would be nice to have a callback API for this as this needs to
// be done "in parallel"
BPSingleEvent ev_wait_begin(WEATHER_FUNC_WAIT_BEGIN);
simulator.addEvent(&ev_wait_begin);
BPSingleListener ev_wait_begin(WEATHER_FUNC_WAIT_BEGIN);
simulator.addListener(&ev_wait_begin);
int count_loop_iter_before = 0;
// no need to wait if offset is 0
@ -200,12 +200,12 @@ bool WeatherMonitorExperiment::run()
// XXX could be improved with intermediate states (reducing runtime until injection)
bp.setWatchInstructionPointer(ANY_ADDR);
bp.setCounter(instr_offset);
simulator.addEvent(&bp);
simulator.addListener(&bp);
// count loop iterations until FI
while (simulator.waitAny() == &ev_wait_begin) {
while (simulator.resume() == &ev_wait_begin) {
++count_loop_iter_before;
simulator.addEvent(&ev_wait_begin);
simulator.addListener(&ev_wait_begin);
}
}
@ -232,7 +232,7 @@ bool WeatherMonitorExperiment::run()
result->set_details(ss.str());
result->set_iter_after_fi(0);
simulator.clearEvents();
simulator.clearListeners();
continue;
}
@ -250,20 +250,20 @@ bool WeatherMonitorExperiment::run()
// - (XXX "sane" display?)
// catch traps as "extraordinary" ending
TrapEvent ev_trap(ANY_TRAP);
simulator.addEvent(&ev_trap);
TrapListener ev_trap(ANY_TRAP);
simulator.addListener(&ev_trap);
// jump outside text segment
BPRangeEvent ev_below_text(ANY_ADDR, WEATHER_TEXT_START - 1);
BPRangeEvent ev_beyond_text(WEATHER_TEXT_END + 1, ANY_ADDR);
simulator.addEvent(&ev_below_text);
simulator.addEvent(&ev_beyond_text);
BPRangeListener ev_below_text(ANY_ADDR, WEATHER_TEXT_START - 1);
BPRangeListener ev_beyond_text(WEATHER_TEXT_END + 1, ANY_ADDR);
simulator.addListener(&ev_below_text);
simulator.addListener(&ev_beyond_text);
// error detected
BPSingleEvent ev_detected(WEATHER_FUNC_VPTR_PANIC);
simulator.addEvent(&ev_detected);
BPSingleListener ev_detected(WEATHER_FUNC_VPTR_PANIC);
simulator.addListener(&ev_detected);
// timeout (e.g., stuck in a HLT instruction)
// 10000us = 500000 instructions
TimerEvent ev_timeout(10000);
simulator.addEvent(&ev_timeout);
TimerListener ev_timeout(10000);
simulator.addListener(&ev_timeout);
#if LOCAL && 0
// XXX debug
@ -275,13 +275,13 @@ bool WeatherMonitorExperiment::run()
simulator.addFlow(&tp);
#endif
BaseEvent* ev;
BaseListener* ev;
// count loop iterations
int count_loop_iter_after = 0;
while ((ev = simulator.waitAny()) == &ev_wait_begin) {
while ((ev = simulator.resume()) == &ev_wait_begin) {
++count_loop_iter_after;
simulator.addEvent(&ev_wait_begin);
simulator.addListener(&ev_wait_begin);
}
result->set_iter_after_fi(count_loop_iter_after);

View File

@ -9,25 +9,25 @@ using namespace fail;
bool TracingPlugin::run()
{
MemAccessEvent ev_mem(ANY_ADDR);
BPSingleEvent ev_step(ANY_ADDR);
BaseEvent *ev;
MemAccessListener ev_mem(ANY_ADDR);
BPSingleListener ev_step(ANY_ADDR);
BaseListener *ev;
if (m_iponly || !m_memonly) {
simulator.addEvent(&ev_step);
simulator.addListener(&ev_step);
}
if (m_memonly || !m_iponly) {
simulator.addEvent(&ev_mem);
simulator.addListener(&ev_mem);
}
if(m_protoStreamFile) {
ps = new ProtoOStream(m_protoStreamFile);
}
while (true) {
ev = simulator.waitAny();
ev = simulator.resume();
if (ev == &ev_step) {
simulator.addEvent(&ev_step);
simulator.addListener(&ev_step);
address_t ip = ev_step.getTriggerInstructionPointer();
if (m_ipMap && !m_ipMap->isMatching(ip)) {
@ -42,7 +42,7 @@ bool TracingPlugin::run()
ps->writeMessage(&e);
}
} else if (ev == &ev_mem) {
simulator.addEvent(&ev_mem);
simulator.addListener(&ev_mem);
address_t ip = ev_mem.getTriggerInstructionPointer();
address_t addr = ev_mem.getTriggerAddress();
@ -55,7 +55,7 @@ bool TracingPlugin::run()
if (m_os)
*m_os << hex << "[Tracing] MEM "
<< ((ev_mem.getTriggerAccessType() &
MemAccessEvent::MEM_READ) ? "R " : "W ")
MemAccessListener::MEM_READ) ? "R " : "W ")
<< addr << " width " << width << " IP " << ip << "\n";
if (m_protoStreamFile) {
Trace_Event e;
@ -63,7 +63,7 @@ bool TracingPlugin::run()
e.set_memaddr(addr);
e.set_width(width);
e.set_accesstype(
(ev_mem.getTriggerAccessType() & MemAccessEvent::MEM_READ) ?
(ev_mem.getTriggerAccessType() & MemAccessListener::MEM_READ) ?
e.READ : e.WRITE);
ps->writeMessage(&e);
}