Skip to content
Snippets Groups Projects
Commit 5c4b1325 authored by Adrian Böckenkamp's avatar Adrian Böckenkamp
Browse files

~SimulatorController: do not free ConcreteCPU object ptr in the base class

In fact, delete should be called in the destructor of each derived class (BochsController and Gem5Controller at the moment).

Additionally, this is the reason why ~SimulatorController is declared as virtual.

git-svn-id: https://www4.informatik.uni-erlangen.de/i4svn/danceos/trunk/devel/fail@2064 8c4709b5-6ec9-48aa-a5cd-a96041d1645a
parent 552a5fb4
No related branches found
No related tags found
No related merge requests found
......@@ -40,16 +40,7 @@ protected:
public:
SimulatorController() : m_Mem(NULL) { }
SimulatorController(MemoryManager* mem) : m_Mem(mem) { }
virtual ~SimulatorController()
{
std::vector<ConcreteCPU*>::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
......
......@@ -27,6 +27,11 @@ BochsController::BochsController()
BochsController::~BochsController()
{
delete m_Mem;
std::vector<ConcreteCPU*>::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)
......
......@@ -22,6 +22,15 @@ void Gem5Controller::startup()
SimulatorController::startup();
}
Gem5Controller::~Gem5Controller()
{
std::vector<ConcreteCPU*>::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?!
......
......@@ -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);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment