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:
@ -8,13 +8,13 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "../SimulatorController.hpp"
|
||||
#include "../Listener.hpp"
|
||||
|
||||
struct CPUX86State;
|
||||
|
||||
namespace fail {
|
||||
|
||||
class ExperimentFlow;
|
||||
class TimerListener;
|
||||
|
||||
/**
|
||||
* \class QEMUController
|
||||
|
||||
60
src/core/sal/qemu/QEMUListener.ah
Normal file
60
src/core/sal/qemu/QEMUListener.ah
Normal file
@ -0,0 +1,60 @@
|
||||
#ifndef __QEMULISTENER_AH__
|
||||
#define __QEMULISTENER_AH__
|
||||
|
||||
#include "config/VariantConfig.hpp"
|
||||
#include "config/FailConfig.hpp"
|
||||
|
||||
#if defined(BUILD_QEMU) && defined(CONFIG_EVENT_BREAKPOINTS)
|
||||
|
||||
#include "../SALInst.hpp"
|
||||
|
||||
extern "C" {
|
||||
#include "qemu/failqemu.h"
|
||||
}
|
||||
|
||||
aspect QEMUListener
|
||||
{
|
||||
advice "fail::TimerListener" : slice class
|
||||
{
|
||||
public:
|
||||
bool onAddition()
|
||||
{
|
||||
//std::cout << "QEMUTimerListener::onAddition" << std::endl;
|
||||
setId(failqemu_register_timer(getTimeout(), (void *)this));
|
||||
//std::cout << "this = " << std::hex << (unsigned) this << std::endl;
|
||||
//std::cout << "id = " << std::hex << (unsigned) getId() << std::endl;
|
||||
return true;
|
||||
}
|
||||
|
||||
void onDeletion()
|
||||
{
|
||||
//std::cout << "QEMUTimerListener::onDeletion" << std::endl;
|
||||
//std::cout << "this = " << std::hex << (unsigned) this << std::endl;
|
||||
//std::cout << "id = " << std::hex << (unsigned) getId() << std::endl;
|
||||
failqemu_unregister_timer(getId());
|
||||
}
|
||||
};
|
||||
|
||||
advice "fail::MemWriteListener" : slice class
|
||||
{
|
||||
public:
|
||||
bool onAddition()
|
||||
{
|
||||
//std::cout << "QEMUMemWriteListener::onAddition" << std::endl;
|
||||
if (failqemu_add_watchpoint(simulator.m_cpuenv, m_WatchAddr, m_WatchWidth, 1) != 0) {
|
||||
std::cout << "adding watchpoint failed!" << std::endl;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void onDeletion()
|
||||
{
|
||||
//std::cout << "QEMUMemWriteListener::onDeletion" << std::endl;
|
||||
failqemu_remove_watchpoint(simulator.m_cpuenv, m_WatchAddr, m_WatchWidth, 1);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
#endif // BUILD_QEMU && CONFIG_EVENT_BREAKPOINTS
|
||||
#endif // __QEMULISTENER_AH__
|
||||
@ -1,45 +0,0 @@
|
||||
#include <iostream>
|
||||
|
||||
#include "QEMUListener.hpp"
|
||||
#include "../SALInst.hpp"
|
||||
|
||||
extern "C" {
|
||||
#include "qemu/failqemu.h"
|
||||
}
|
||||
|
||||
namespace fail {
|
||||
|
||||
bool QEMUMemWriteListener::onAddition()
|
||||
{
|
||||
//std::cout << "QEMUMemWriteListener::onAddition" << std::endl;
|
||||
if (failqemu_add_watchpoint(simulator.m_cpuenv, m_WatchAddr, m_WatchWidth, 1) != 0) {
|
||||
std::cout << "adding watchpoint failed!" << std::endl;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void QEMUMemWriteListener::onDeletion()
|
||||
{
|
||||
//std::cout << "QEMUMemWriteListener::onDeletion" << std::endl;
|
||||
failqemu_remove_watchpoint(simulator.m_cpuenv, m_WatchAddr, m_WatchWidth, 1);
|
||||
}
|
||||
|
||||
bool QEMUTimerListener::onAddition()
|
||||
{
|
||||
//std::cout << "QEMUTimerListener::onAddition" << std::endl;
|
||||
setId(failqemu_register_timer(getTimeout(), (void *)this));
|
||||
//std::cout << "this = " << std::hex << (unsigned) this << std::endl;
|
||||
//std::cout << "id = " << std::hex << (unsigned) getId() << std::endl;
|
||||
return true;
|
||||
}
|
||||
|
||||
void QEMUTimerListener::onDeletion()
|
||||
{
|
||||
//std::cout << "QEMUTimerListener::onDeletion" << std::endl;
|
||||
//std::cout << "this = " << std::hex << (unsigned) this << std::endl;
|
||||
//std::cout << "id = " << std::hex << (unsigned) getId() << std::endl;
|
||||
failqemu_unregister_timer(getId());
|
||||
}
|
||||
|
||||
} // end-of-namespace: fail
|
||||
@ -1,40 +0,0 @@
|
||||
#ifndef __QEMU_LISTENER_HPP__
|
||||
#define __QEMU_LISTENER_HPP__
|
||||
|
||||
#include "../Listener.hpp"
|
||||
|
||||
namespace fail {
|
||||
|
||||
typedef GenericBPSingleListener BPSingleListener;
|
||||
|
||||
/**
|
||||
* \class QEMUTimerListener
|
||||
* Concrete TimerListener implementation of GenericTimerListener for QEMU.
|
||||
*/
|
||||
class QEMUTimerListener : public GenericTimerListener {
|
||||
private:
|
||||
public:
|
||||
QEMUTimerListener(unsigned timeout)
|
||||
: GenericTimerListener(timeout) { }
|
||||
~QEMUTimerListener() { onDeletion(); } // FIXME ~BaseListener should automatically dequeue a Listener, and then indirectly calls onDeletion. In the current implementation, no dequeueing happens at all.
|
||||
bool onAddition();
|
||||
void onDeletion();
|
||||
};
|
||||
typedef QEMUTimerListener TimerListener;
|
||||
|
||||
class QEMUMemWriteListener : public GenericMemWriteListener {
|
||||
public:
|
||||
QEMUMemWriteListener()
|
||||
: GenericMemWriteListener() { }
|
||||
QEMUMemWriteListener(address_t addr)
|
||||
: GenericMemWriteListener(addr) { }
|
||||
|
||||
virtual bool onAddition();
|
||||
virtual void onDeletion();
|
||||
};
|
||||
|
||||
typedef QEMUMemWriteListener MemWriteListener;
|
||||
|
||||
} // end-of-namespace: fail
|
||||
|
||||
#endif // __QEMU_LISTENER_HPP__
|
||||
Reference in New Issue
Block a user