diff --git a/src/core/sal/SimulatorController.hpp b/src/core/sal/SimulatorController.hpp index 21ab86e4..53779aab 100644 --- a/src/core/sal/SimulatorController.hpp +++ b/src/core/sal/SimulatorController.hpp @@ -108,8 +108,9 @@ public: /** * Save simulator state. * @param path Location to store state information + * @return \c true if the state has been successfully saved, \c false otherwise */ - virtual void save(const std::string& path) = 0; + virtual bool save(const std::string& path) = 0; /** * Restore simulator state. Implicitly discards all previously * registered listeners. diff --git a/src/core/sal/bochs/BochsController.cc b/src/core/sal/bochs/BochsController.cc index d1c83a93..72a6b1e2 100644 --- a/src/core/sal/bochs/BochsController.cc +++ b/src/core/sal/bochs/BochsController.cc @@ -159,20 +159,23 @@ void BochsController::onIOPort(unsigned char data, unsigned port, bool out) { m_LstList.triggerActiveListeners(); } -void BochsController::save(const std::string& path) +bool BochsController::save(const std::string& path) { int stat; stat = mkdir(path.c_str(), 0777); - if (!(stat == 0 || errno == EEXIST)) - std::cout << "[FAIL] Can not create target-directory to save!" << std::endl; + if (!(stat == 0 || errno == EEXIST)) { + return false; + // std::cout << "[FAIL] Can not create target-directory to save!" << std::endl; // TODO: (Non-)Verbose-Mode? Log-level? Maybe better: use return value to indicate failure? + } save_bochs_request = true; BX_CPU(0)->async_event |= 1; sr_path = path; m_CurrFlow = m_Flows.getCurrent(); m_Flows.resume(); + return true; } void BochsController::saveDone() diff --git a/src/core/sal/bochs/BochsController.hpp b/src/core/sal/bochs/BochsController.hpp index 46263e55..fdd889d5 100644 --- a/src/core/sal/bochs/BochsController.hpp +++ b/src/core/sal/bochs/BochsController.hpp @@ -87,8 +87,9 @@ public: /** * Save simulator state. * @param path Location to store state information + * @return \c true if the state has been successfully saved, \c false otherwise */ - void save(const std::string& path); + bool save(const std::string& path); /** * Save finished: Callback from Simulator */ diff --git a/src/core/sal/gem5/Gem5Controller.cc b/src/core/sal/gem5/Gem5Controller.cc index eb5cfa50..e8d9f4f5 100644 --- a/src/core/sal/gem5/Gem5Controller.cc +++ b/src/core/sal/gem5/Gem5Controller.cc @@ -10,7 +10,7 @@ namespace fail { -void Gem5Controller::save(const std::string &path) +bool Gem5Controller::save(const std::string &path) { // Takes a snapshot in the m5out dir Tick when = curTick() + 1; @@ -22,6 +22,7 @@ void Gem5Controller::save(const std::string &path) std::ofstream file(path.c_str()); root->serialize(file); file.close();*/ + return false; // TODO } void Gem5Controller::restore(const std::string &path) diff --git a/src/core/sal/gem5/Gem5Controller.hpp b/src/core/sal/gem5/Gem5Controller.hpp index f7fe168d..f4cb6a58 100644 --- a/src/core/sal/gem5/Gem5Controller.hpp +++ b/src/core/sal/gem5/Gem5Controller.hpp @@ -11,9 +11,9 @@ class Gem5Controller : public SimulatorController { public: void onBreakpoint(address_t instrPtr, address_t address_space); - virtual void save(const std::string &path); - virtual void restore(const std::string &path); - virtual void reboot(); + bool save(const std::string &path); + void restore(const std::string &path); + void reboot(); }; } // end-of-namespace: fail diff --git a/src/core/sal/ovp/OVPController.cc b/src/core/sal/ovp/OVPController.cc index 9df2a051..eeea2036 100644 --- a/src/core/sal/ovp/OVPController.cc +++ b/src/core/sal/ovp/OVPController.cc @@ -109,10 +109,11 @@ void OVPController::onInstrPtrChanged(address_t instrPtr) m_EvList.fireActiveListeners(); } -void OVPController::save(const string& path) +bool OVPController::save(const string& path) { // TODO! ovpplatform.save(path); + return false; // TODO } void OVPController::restore(const string& path) diff --git a/src/core/sal/ovp/OVPController.hpp b/src/core/sal/ovp/OVPController.hpp index 6be63705..33f1ac13 100644 --- a/src/core/sal/ovp/OVPController.hpp +++ b/src/core/sal/ovp/OVPController.hpp @@ -35,22 +35,23 @@ public: * Initialize the controller. */ OVPController(); - virtual ~OVPController(); - virtual void onInstrPtrChanged(address_t instrPtr); + ~OVPController(); + void onInstrPtrChanged(address_t instrPtr); /** * Save simulator state. * @param path Location to store state information + * @return \c true if the state has been successfully saved, \c false otherwise */ - virtual void save(const std::string& path); + bool save(const std::string& path); /** * Restore simulator state. * @param path Location to previously saved state information */ - virtual void restore(const std::string& path); + void restore(const std::string& path); /** * Reboot simulator. */ - virtual void reboot(); + void reboot(); /** * Returns the current instruction pointer. * @return the current eip diff --git a/src/core/sal/qemu/QEMUController.hpp b/src/core/sal/qemu/QEMUController.hpp index f341285d..04408e13 100644 --- a/src/core/sal/qemu/QEMUController.hpp +++ b/src/core/sal/qemu/QEMUController.hpp @@ -47,8 +47,9 @@ public: /** * Save simulator state. TODO. * @param path Location to store state information + * @return \c true if the state has been successfully saved, \c false otherwise */ - void save(const std::string& path) {} + bool save(const std::string& path) { return false; } /** * Restore simulator state. Clears all Listeners. TODO. * @param path Location to previously saved state information