Simulator specific listener are now implemented using aspects instead of an additional inheritance level

git-svn-id: https://www4.informatik.uni-erlangen.de/i4svn/danceos/trunk/devel/fail@1706 8c4709b5-6ec9-48aa-a5cd-a96041d1645a
This commit is contained in:
friemel
2012-10-02 11:42:18 +00:00
parent 4d5bab72b6
commit 7d49b6f063
20 changed files with 176 additions and 296 deletions

View File

@ -35,18 +35,21 @@ void Gem5Controller::reboot()
void Gem5Controller::onBreakpoint(address_t instrPtr, address_t address_space)
{
bool do_fire = false;
BPEvent tmp(instrPtr, address_space);
// Check for active breakpoint-events:
for (ListenerManager::iterator it = m_LstList.begin(); it != m_LstList.end(); it++) {
ListenerManager::iterator it = m_LstList.begin();
BPEvent tmp(instrPtr, address_space);
while (it != m_LstList.end()) {
BaseListener* pLi = *it;
BPListener* pBreakpt = dynamic_cast<BPListener*>(pLi);
if(pBreakpt != NULL && pBreakpt->isMatching(&tmp)) {
if (pBreakpt != NULL && pBreakpt->isMatching(&tmp)) {
pBreakpt->setTriggerInstructionPointer(instrPtr);
it = m_LstList.makeActive(it);
do_fire = true;
// "it" has already been set to the next element (by calling makeActive()):
// "it" has already been set to the next element (by calling
// makeActive()):
continue; // -> skip iterator increment
}
it++;
}
if (do_fire)
m_LstList.triggerActiveListeners();

View File

@ -0,0 +1,39 @@
#ifndef __GEM5LISTENER_AH__
#define __GEM5LISTENER_AH__
#include "config/VariantConfig.hpp"
#include "config/FailConfig.hpp"
#if defined(BUILD_GEM5) && defined(CONFIG_EVENT_BREAKPOINTS)
#include "Gem5PCEvent.hh"
#include "sim/system.hh"
aspect Gem5Listener
{
advice "fail::BPSingleListener" : slice class
{
private:
Gem5PCEvent* m_Breakpoint;
public:
virtual bool onAddition()
{
System* sys = *System::systemList.begin();
m_Breakpoint = new Gem5PCEvent(&sys->pcEventQueue, this->m_WatchInstrPtr);
return true;
}
virtual void onDeletion()
{
if(m_Breakpoint)
{
delete m_Breakpoint;
m_Breakpoint = 0;
}
}
};
};
#endif // BUILD_GEM5 && CONFIG_EVENT_BREAKPOINTS
#endif // __GEM5LISTENER_AH__

View File

@ -1,33 +0,0 @@
#include "Gem5Listener.hpp"
#include "../SALInst.hpp"
#include "sim/system.hh"
namespace fail {
Gem5BPSingleListener::Gem5BPSingleListener(address_t ip)
: GenericBPSingleListener(ip)
{
}
bool Gem5BPSingleListener::onAddition()
{
if(!m_Breakpoint)
{
System* sys = *System::systemList.begin();
m_Breakpoint = new Gem5PCEvent(&sys->pcEventQueue, this->m_WatchInstrPtr);
return true;
}
return false;
}
Gem5BPSingleListener::~Gem5BPSingleListener()
{
if(m_Breakpoint)
{
delete m_Breakpoint;
}
}
} // end-of-namespace: fail

View File

@ -1,25 +0,0 @@
#ifndef __GEM5_LISTENER_HPP__
#define __GEM5_LISTENER_HPP__
#include "../Listener.hpp"
#include "Gem5PCEvent.hh"
namespace fail {
typedef GenericMemWriteListener MemWriteListener;
class Gem5BPSingleListener : public GenericBPSingleListener
{
public:
Gem5BPSingleListener(address_t ip = 0);
virtual bool onAddition();
~Gem5BPSingleListener();
private:
Gem5PCEvent* m_Breakpoint;
};
typedef Gem5BPSingleListener BPSingleListener;
} // end-of-namespace: fail
#endif // __GEM5_LISTENER_HPP__