From 4a061ba4d01b5c8aaa372b2e2e81fa6a717e5c68 Mon Sep 17 00:00:00 2001 From: hsc Date: Mon, 12 Mar 2012 09:51:34 +0000 Subject: [PATCH] hscsimple: config checks, use Logger git-svn-id: https://www4.informatik.uni-erlangen.de/i4svn/danceos/trunk/devel/fail@981 8c4709b5-6ec9-48aa-a5cd-a96041d1645a --- core/experiments/hscsimple/experiment.cc | 34 +++++++++++++++--------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/core/experiments/hscsimple/experiment.cc b/core/experiments/hscsimple/experiment.cc index 60402821..c02d744a 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