diff --git a/src/core/sal/SimulatorController.hpp b/src/core/sal/SimulatorController.hpp index 88ac55cb..22c22a76 100644 --- a/src/core/sal/SimulatorController.hpp +++ b/src/core/sal/SimulatorController.hpp @@ -40,16 +40,7 @@ protected: public: SimulatorController() : m_Mem(NULL) { } SimulatorController(MemoryManager* mem) : m_Mem(mem) { } - virtual ~SimulatorController() - { - std::vector::iterator it = m_CPUs.begin(); - while (it != m_CPUs.end()) { - delete *it; - it = m_CPUs.erase(it); - } - // FIXME: This expects the "ConcreteCPU" objects to be allocated on the heap... - // This should be part of the derived class...? - } + virtual ~SimulatorController() { } /** * @brief Initialization function each implementation needs to call on * startup diff --git a/src/core/sal/bochs/BochsController.cc b/src/core/sal/bochs/BochsController.cc index f8b7cdb8..6095f71f 100644 --- a/src/core/sal/bochs/BochsController.cc +++ b/src/core/sal/bochs/BochsController.cc @@ -27,6 +27,11 @@ BochsController::BochsController() BochsController::~BochsController() { delete m_Mem; + std::vector::iterator it = m_CPUs.begin(); + while (it != m_CPUs.end()) { + delete *it; + it = m_CPUs.erase(it); + } } void BochsController::updateBPEventInfo(BX_CPU_C *context, bxInstruction_c *instr) diff --git a/src/core/sal/gem5/Gem5Controller.cc b/src/core/sal/gem5/Gem5Controller.cc index 439e3f27..6658caaa 100644 --- a/src/core/sal/gem5/Gem5Controller.cc +++ b/src/core/sal/gem5/Gem5Controller.cc @@ -22,6 +22,15 @@ void Gem5Controller::startup() SimulatorController::startup(); } +Gem5Controller::~Gem5Controller() +{ + std::vector::iterator it = m_CPUs.begin(); + while (it != m_CPUs.end()) { + delete *it; + it = m_CPUs.erase(it); + } +} + bool Gem5Controller::save(const std::string &path) { connector.save(path); // FIXME: not working?! diff --git a/src/core/sal/gem5/Gem5Controller.hpp b/src/core/sal/gem5/Gem5Controller.hpp index f7309741..b8f569c7 100644 --- a/src/core/sal/gem5/Gem5Controller.hpp +++ b/src/core/sal/gem5/Gem5Controller.hpp @@ -15,6 +15,7 @@ namespace fail { class Gem5Controller : public SimulatorController { public: void startup(); + ~Gem5Controller(); bool save(const std::string &path); void restore(const std::string &path);