diff --git a/core/experiments/hscsimple/experiment.cc b/core/experiments/hscsimple/experiment.cc index 60402821cfb87295b20a2cf0b2ad05408f725d98..c02d744a3fe8737d53a2dade07052e86ffbdbad3 100644 --- a/core/experiments/hscsimple/experiment.cc +++ b/core/experiments/hscsimple/experiment.cc @@ -6,42 +6,50 @@ #include "SAL/SALInst.hpp" #include "SAL/bochs/BochsRegister.hpp" #include "controller/Event.hpp" +#include "util/Logger.hpp" +#include "config/AspectConfig.hpp" + +// Check if configuration dependencies are satisfied: +#if !defined(CONFIG_EVENT_BREAKPOINTS) || !defined(CONFIG_SR_RESTORE) || !defined(CONFIG_SR_SAVE) + #error This experiment needs: breakpoints, save, and restore. Enable these in the configuration. +#endif -using std::cout; using std::endl; bool hscsimpleExperiment::run() { - cout << "[HSC] experiment start" << endl; + Logger log("HSC", false); + log << "experiment start" << endl; // do funny things here... -#if 0 +#if 1 + // STEP 1 fi::BPEvent mainbp(0x00003c34); sal::simulator.addEventAndWait(&mainbp); - cout << "[HSC] breakpoint reached, saving" << endl; - sal::simulator.save("hello.main"); + log << "breakpoint reached, saving" << endl; + sal::simulator.save("hello.state"); #elif 1 - cout << "[HSC] restoring ..." << endl; - sal::simulator.restore("hello.main"); - cout << "[HSC] restored!" << endl; + // STEP 2 + log << "restoring ..." << endl; + sal::simulator.restore("hello.state"); + log << "restored!" << endl; - cout << "[HSC] waiting for last square() instruction" << endl; + log << "waiting for last square() instruction" << endl; fi::BPEvent breakpoint(0x3c9e); // square(x) ret instruction sal::simulator.addEventAndWait(&breakpoint); - cout << "[HSC] injecting hellish fault" << endl; + log << "injecting hellish fault" << endl; #if BX_SUPPORT_X86_64 int reg = sal::RID_RAX; #else int reg = sal::RID_EAX; #endif sal::simulator.getRegisterManager().getRegister(reg)->setData(666); - cout << "[HSC] waiting for last main() instruction" << endl; + log << "waiting for last main() instruction" << endl; breakpoint.setWatchInstructionPointer(0x3c92); sal::simulator.addEventAndWait(&breakpoint); - cout << "[HSC] reached" << endl; + log << "reached" << endl; - // FIXME this shouldn't fail: sal::simulator.addEventAndWait(&breakpoint); #endif