diff --git a/src/core/sal/BufferCache.cc b/src/core/sal/BufferCache.cc index de8a94f4..0ef94a85 100644 --- a/src/core/sal/BufferCache.cc +++ b/src/core/sal/BufferCache.cc @@ -2,12 +2,12 @@ #include #include "BufferCache.hpp" #include "Event.hpp" -#include "EventList.hpp" +#include "EventManager.hpp" namespace fail { template -typename BufferCache::iterator BufferCache::makeActive(EventList &ev_list, BufferCache::iterator idx) +typename BufferCache::iterator BufferCache::makeActive(EventManager &ev_list, BufferCache::iterator idx) { assert(idx != end() && "FATAL ERROR: Index larger than cache!"); @@ -20,7 +20,7 @@ typename BufferCache::iterator BufferCache::makeActive(EventList &ev_list, ev->resetCounter(); // Note: This is the one and only situation in which remove() should NOT // store the removed item in the delete-list. - EventList::iterator it = std::find(ev_list.begin(), ev_list.end(), static_cast(ev)); + EventManager::iterator it = std::find(ev_list.begin(), ev_list.end(), static_cast(ev)); ev_list.m_remove(it, true); // remove event from buffer-list ev_list.m_FireList.push_back(ev); return erase(idx); diff --git a/src/core/sal/BufferCache.hpp b/src/core/sal/BufferCache.hpp index f87ca61c..17041646 100644 --- a/src/core/sal/BufferCache.hpp +++ b/src/core/sal/BufferCache.hpp @@ -6,7 +6,7 @@ namespace fail { -class EventList; +class EventManager; /** * \class BufferCache @@ -20,7 +20,7 @@ template class BufferCache { public: /** - * The list type inherent to this class. Like bufferlist_t in EventList.hpp, + * The list type inherent to this class. Like bufferlist_t in EventManager.hpp, * but dynamically typed. */ typedef std::list cachelist_t; @@ -34,8 +34,8 @@ public: private: cachelist_t m_Buffer; //!< The list holding the cached elements public: - BufferCache() {} - ~BufferCache() {} + BufferCache() { } + ~BufferCache() { } /** * Add an element to the array. The object pointed to remains untouched. * @param val the element to add @@ -79,14 +79,14 @@ public: */ inline iterator end() { return m_Buffer.end(); } /** - * Acts as a replacement for EventList::makeActive, manipulating - * the buffer cache exclusively. EventList::fireActiveEvents needs + * Acts as a replacement for EventManager::makeActive, manipulating + * the buffer cache exclusively. EventManager::fireActiveEvents needs * to be called to fire the active events (see there). - * This method is declared as a friend method in EventList. + * This method is declared as a friend method in EventManager. * @param idx the index of the event to trigger * @returns an updated index which can be used to update a loop counter */ - iterator makeActive(EventList &ev_list, iterator idx); + iterator makeActive(EventManager &ev_list, iterator idx); }; } // end-of-namespace: fail diff --git a/src/core/sal/CMakeLists.txt b/src/core/sal/CMakeLists.txt index bd6f6770..5de6337d 100644 --- a/src/core/sal/CMakeLists.txt +++ b/src/core/sal/CMakeLists.txt @@ -2,7 +2,7 @@ if(BUILD_BOCHS) set(SRCS BufferCache.cc Event.cc - EventList.cc + EventManager.cc Memory.cc Register.cc SimulatorController.cc @@ -13,7 +13,7 @@ else() set(SRCS BufferCache.cc Event.cc - EventList.cc + EventManager.cc Memory.cc Register.cc SimulatorController.cc diff --git a/src/core/sal/Event.hpp b/src/core/sal/Event.hpp index 98d41c2f..10e33f65 100644 --- a/src/core/sal/Event.hpp +++ b/src/core/sal/Event.hpp @@ -17,7 +17,7 @@ class ExperimentFlow; typedef unsigned long event_id_t; //!< type of event ids //! invalid event id (used as a return indicator) -const event_id_t INVALID_EVENT = static_cast(-1); +const event_id_t INVALID_EVENT = static_cast(-1); //! address wildcard (e.g. for BPEvent's) const address_t ANY_ADDR = static_cast(-1); //! instruction wildcard @@ -144,13 +144,11 @@ public: /** * Returns the address space register of this event. */ - address_t getCR3() const - { return m_CR3; } + address_t getCR3() const { return m_CR3; } /** * Sets the address space register for this event. */ - void setCR3(address_t iptr) - { m_CR3 = iptr; } + void setCR3(address_t iptr) { m_CR3 = iptr; } /** * Checks whether a given address space is matching. */ @@ -162,14 +160,12 @@ public: /** * Returns the instruction pointer that triggered this event. */ - address_t getTriggerInstructionPointer() const - { return m_TriggerInstrPtr; } + address_t getTriggerInstructionPointer() const { return m_TriggerInstrPtr; } /** * Sets the instruction pointer that triggered this event. Should not * be used by experiment code. */ - void setTriggerInstructionPointer(address_t iptr) - { m_TriggerInstrPtr = iptr; } + void setTriggerInstructionPointer(address_t iptr) { m_TriggerInstrPtr = iptr; } }; /** diff --git a/src/core/sal/EventList.cc b/src/core/sal/EventManager.cc similarity index 89% rename from src/core/sal/EventList.cc rename to src/core/sal/EventManager.cc index fde5eb2d..a13a4b6c 100644 --- a/src/core/sal/EventList.cc +++ b/src/core/sal/EventManager.cc @@ -1,11 +1,11 @@ #include -#include "EventList.hpp" +#include "EventManager.hpp" #include "SALInst.hpp" namespace fail { -void EventList::addToCaches(BaseEvent *ev) +void EventManager::addToCaches(BaseEvent *ev) { BPEvent *bps_ev; if ((bps_ev = dynamic_cast(ev)) != NULL) @@ -16,7 +16,7 @@ void EventList::addToCaches(BaseEvent *ev) m_Io_cache.add(io_ev); } -void EventList::removeFromCaches(BaseEvent *ev) +void EventManager::removeFromCaches(BaseEvent *ev) { BPEvent *bpr_ev; if ((bpr_ev = dynamic_cast(ev)) != NULL) @@ -27,13 +27,13 @@ void EventList::removeFromCaches(BaseEvent *ev) m_Io_cache.remove(io_ev); } -void EventList::clearCaches() +void EventManager::clearCaches() { m_Bp_cache.clear(); m_Io_cache.clear(); } -event_id_t EventList::add(BaseEvent* ev, ExperimentFlow* pExp) +event_id_t EventManager::add(BaseEvent* ev, ExperimentFlow* pExp) { assert(ev != NULL && "FATAL ERROR: Event (of base type BaseEvent*) cannot be NULL!"); // a zero counter does not make sense @@ -45,7 +45,7 @@ event_id_t EventList::add(BaseEvent* ev, ExperimentFlow* pExp) return ev->getId(); } -void EventList::remove(BaseEvent* ev) +void EventManager::remove(BaseEvent* ev) { // possible cases: // - ev == 0 -> remove all events @@ -77,12 +77,12 @@ void EventList::remove(BaseEvent* ev) } } -EventList::iterator EventList::remove(iterator it) +EventManager::iterator EventManager::remove(iterator it) { return m_remove(it, false); } -EventList::iterator EventList::m_remove(iterator it, bool skip_deletelist) +EventManager::iterator EventManager::m_remove(iterator it, bool skip_deletelist) { if (!skip_deletelist) { // If skip_deletelist = true, m_remove was called from makeActive. Accordingly, we @@ -105,7 +105,7 @@ EventList::iterator EventList::m_remove(iterator it, bool skip_deletelist) return m_BufferList.erase(it); } -void EventList::remove(ExperimentFlow* flow) +void EventManager::remove(ExperimentFlow* flow) { // all events? if (flow == 0) { @@ -141,12 +141,12 @@ void EventList::remove(ExperimentFlow* flow) } } -EventList::~EventList() +EventManager::~EventManager() { // nothing to do here yet } -BaseEvent* EventList::getEventFromId(event_id_t id) +BaseEvent* EventManager::getEventFromId(event_id_t id) { // Loop through all events: for (bufferlist_t::iterator it = m_BufferList.begin(); @@ -156,7 +156,7 @@ BaseEvent* EventList::getEventFromId(event_id_t id) return NULL; // Nothing found. } -EventList::iterator EventList::makeActive(iterator it) +EventManager::iterator EventManager::makeActive(iterator it) { assert(it != m_BufferList.end() && "FATAL ERROR: Iterator has already reached the end!"); @@ -174,7 +174,7 @@ EventList::iterator EventList::makeActive(iterator it) return it_next; } -void EventList::fireActiveEvents() +void EventManager::fireActiveEvents() { for (firelist_t::iterator it = m_FireList.begin(); it != m_FireList.end(); it++) { @@ -194,7 +194,7 @@ void EventList::fireActiveEvents() // Note: Do NOT call any event handlers here! } -size_t EventList::getContextCount() const +size_t EventManager::getContextCount() const { std::set uniqueFlows; // count unique ExperimentFlow-ptr for (bufferlist_t::const_iterator it = m_BufferList.begin(); diff --git a/src/core/sal/EventList.hpp b/src/core/sal/EventManager.hpp similarity index 94% rename from src/core/sal/EventList.hpp rename to src/core/sal/EventManager.hpp index 09d3ab8a..f0ce768a 100644 --- a/src/core/sal/EventList.hpp +++ b/src/core/sal/EventManager.hpp @@ -1,5 +1,5 @@ -#ifndef __EVENT_LIST_HPP__ - #define __EVENT_LIST_HPP__ +#ifndef __EVENT_MANAGER_HPP__ + #define __EVENT_MANAGER_HPP__ #include #include @@ -39,7 +39,7 @@ typedef bp_cache_t::iterator bp_iter_t; typedef BufferCache io_cache_t; typedef io_cache_t::iterator io_iter_t; /** - * \class EventList + * \class EventManager * * \brief This class manages the events of the Fail* implementation. * @@ -50,10 +50,10 @@ typedef io_cache_t::iterator io_iter_t; * be added to a -so called- delete-list. This ensures to prevent triggering * "active" events which have already been deleted by a previous experiment * flow. (See makeActive() and fireActiveEvent() for implementation specific - * details.) EventList is part of the SimulatorController and "outsources" + * details.) EventManager is part of the SimulatorController and "outsources" * it's event management. */ -class EventList { +class EventManager { private: // TODO: List separation of "critical types"? Hashing/sorted lists? (-> performance!) bufferlist_t m_BufferList; //!< the storage for events added by exp. @@ -62,8 +62,8 @@ private: BaseEvent* m_pFired; //!< the recently fired Event-object bp_cache_t m_Bp_cache; //!< the storage cache for breakpoint events io_cache_t m_Io_cache; //!< the storage cache for port i/o events - friend bp_iter_t bp_cache_t::makeActive(EventList &ev_list, bp_iter_t idx); - friend io_iter_t io_cache_t::makeActive(EventList &ev_list, io_iter_t idx); + friend bp_iter_t bp_cache_t::makeActive(EventManager &ev_list, bp_iter_t idx); + friend io_iter_t io_cache_t::makeActive(EventManager &ev_list, io_iter_t idx); public: /** * The iterator of this class used to loop through the list of @@ -73,8 +73,8 @@ public: */ typedef bufferlist_t::iterator iterator; - EventList() : m_pFired(NULL) { } - ~EventList(); + EventManager() : m_pFired(NULL) { } + ~EventManager(); /** * Adds the specified event object for the given ExperimentFlow to the * list of events to be watched for. @@ -220,4 +220,4 @@ private: } // end-of-namespace: fail -#endif // __EVENT_LIST_HPP__ +#endif // __EVENT_MANAGER_HPP__ diff --git a/src/core/sal/SimulatorController.cc b/src/core/sal/SimulatorController.cc index eedfb29d..5bd01de5 100644 --- a/src/core/sal/SimulatorController.cc +++ b/src/core/sal/SimulatorController.cc @@ -50,7 +50,7 @@ void SimulatorController::onBreakpointEvent(address_t instrPtr, address_t addres // FIXME: Improve performance! // Loop through all events of type BP*Event: - EventList::iterator it = m_EvList.begin(); + EventManager::iterator it = m_EvList.begin(); while (it != m_EvList.end()) { BaseEvent* pev = *it; BPSingleEvent* pbp; BPRangeEvent* pbpr; @@ -79,7 +79,7 @@ void SimulatorController::onMemoryAccessEvent(address_t addr, size_t len, is_write ? MemAccessEvent::MEM_WRITE : MemAccessEvent::MEM_READ; - EventList::iterator it = m_EvList.begin(); + EventManager::iterator it = m_EvList.begin(); while (it != m_EvList.end()) { // check for active events BaseEvent* pev = *it; MemAccessEvent* ev = dynamic_cast(pev); @@ -99,7 +99,7 @@ void SimulatorController::onMemoryAccessEvent(address_t addr, size_t len, void SimulatorController::onInterruptEvent(unsigned interruptNum, bool nmi) { - EventList::iterator it = m_EvList.begin(); + EventManager::iterator it = m_EvList.begin(); while (it != m_EvList.end()) { // check for active events BaseEvent* pev = *it; InterruptEvent* pie = dynamic_cast(pev); @@ -157,7 +157,7 @@ bool SimulatorController::removeSuppressedInterrupt(unsigned interruptNum) void SimulatorController::onTrapEvent(unsigned trapNum) { - EventList::iterator it = m_EvList.begin(); + EventManager::iterator it = m_EvList.begin(); while(it != m_EvList.end()) { // check for active events BaseEvent* pev = *it; TrapEvent* pte = dynamic_cast(pev); @@ -173,7 +173,7 @@ void SimulatorController::onTrapEvent(unsigned trapNum) void SimulatorController::onGuestSystemEvent(char data, unsigned port) { - EventList::iterator it = m_EvList.begin(); + EventManager::iterator it = m_EvList.begin(); while (it != m_EvList.end()) { // check for active events BaseEvent* pev = *it; GuestEvent* pge = dynamic_cast(pev); @@ -190,7 +190,7 @@ void SimulatorController::onGuestSystemEvent(char data, unsigned port) void SimulatorController::onJumpEvent(bool flagTriggered, unsigned opcode) { - EventList::iterator it = m_EvList.begin(); + EventManager::iterator it = m_EvList.begin(); while (it != m_EvList.end()) { // check for active events JumpEvent* pje = dynamic_cast(*it); if (pje != NULL) { diff --git a/src/core/sal/SimulatorController.hpp b/src/core/sal/SimulatorController.hpp index 9254d2d2..a3ace36e 100644 --- a/src/core/sal/SimulatorController.hpp +++ b/src/core/sal/SimulatorController.hpp @@ -7,7 +7,7 @@ #include #include "efw/CoroutineManager.hpp" -#include "EventList.hpp" +#include "EventManager.hpp" #include "SALConfig.hpp" #include "Event.hpp" @@ -33,13 +33,13 @@ class MemoryManager; */ class SimulatorController { protected: - EventList m_EvList; //!< storage where events are being buffered + EventManager m_EvList; //!< storage where events are being buffered CoroutineManager m_Flows; //!< managed experiment flows RegisterManager *m_Regs; //!< access to cpu register MemoryManager *m_Mem; //!< access to memory pool //! list of suppressed interrupts std::vector m_SuppressedInterrupts; - friend class EventList; //!< "outsources" the event management + friend class EventManager; //!< "outsources" the event management public: SimulatorController() : m_Regs(NULL), m_Mem(NULL) { } diff --git a/src/core/sal/bochs/BochsController.cc b/src/core/sal/bochs/BochsController.cc index b7ce1e84..7be109e9 100644 --- a/src/core/sal/bochs/BochsController.cc +++ b/src/core/sal/bochs/BochsController.cc @@ -218,7 +218,7 @@ void BochsController::onTimerTrigger(void* thisPtr) TimerEvent* pTmEv = static_cast(thisPtr); // Check for a matching TimerEvent. (In fact, we are only // interessted in the iterator pointing at pTmEv.): - EventList::iterator it = std::find(simulator.m_EvList.begin(), + EventManager::iterator it = std::find(simulator.m_EvList.begin(), simulator.m_EvList.end(), pTmEv); // TODO: This has O(|m_EvList|) time complexity. We can further improve this // by creating a method such that makeActive(pTmEv) works as well, diff --git a/src/core/sal/bochs/BochsController.hpp b/src/core/sal/bochs/BochsController.hpp index 245e9592..cf70c3a0 100644 --- a/src/core/sal/bochs/BochsController.hpp +++ b/src/core/sal/bochs/BochsController.hpp @@ -61,7 +61,7 @@ public: /** * Static internal event handler for TimerEvents. This static function is * called when a previously registered (Bochs) timer triggers. This function - * searches for the provided TimerEvent object within the EventList and + * searches for the provided TimerEvent object within the EventManager and * fires such an event by calling \c fireActiveEvents(). * @param thisPtr a pointer to the TimerEvent-object triggered * diff --git a/src/core/sal/ovp/OVPController.cc b/src/core/sal/ovp/OVPController.cc index 77688f65..454aeda6 100644 --- a/src/core/sal/ovp/OVPController.cc +++ b/src/core/sal/ovp/OVPController.cc @@ -85,10 +85,10 @@ void OVPController::onInstrPtrChanged(address_t instrPtr) // << " R0: 0x" << hex << r0 << " ST: 0x" << hex << st << endl; // Check for active breakpoint-events: - EventList::iterator it = m_EvList.begin(); + EventManager::iterator it = m_EvList.begin(); while (it != m_EvList.end()) { // FIXME: Performance verbessern (dazu muss entsprechend auch die Speicherung - // in EventList(.cc|.hpp) angepasst bzw. verbessert werden). + // in EventManager(.cc|.hpp) angepasst bzw. verbessert werden). BPSingleEvent* pEvBreakpt = dynamic_cast(*it); if (pEvBreakpt && (instrPtr == pEvBreakpt->getWatchInstructionPointer() || pEvBreakpt->getWatchInstructionPointer() == ANY_ADDR)) {