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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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