From 0b8710872b684b0ad876b0df575a9808899e4209 Mon Sep 17 00:00:00 2001 From: adrian Date: Tue, 6 Nov 2012 11:40:05 +0000 Subject: [PATCH] Removed BochController debug stuff. Merged: BochsController::onBreakpoint -> SimCon::onBreakpoint. git-svn-id: https://www4.informatik.uni-erlangen.de/i4svn/danceos/trunk/devel/fail@1883 8c4709b5-6ec9-48aa-a5cd-a96041d1645a --- src/core/sal/SimulatorController.cc | 22 ++++--------- src/core/sal/bochs/BochsController.cc | 43 -------------------------- src/core/sal/bochs/BochsController.hpp | 40 +++++++----------------- 3 files changed, 18 insertions(+), 87 deletions(-) diff --git a/src/core/sal/SimulatorController.cc b/src/core/sal/SimulatorController.cc index ff924ca8..f9b47f72 100644 --- a/src/core/sal/SimulatorController.cc +++ b/src/core/sal/SimulatorController.cc @@ -54,29 +54,20 @@ void SimulatorController::initExperiments() void SimulatorController::onBreakpoint(address_t instrPtr, address_t address_space) { - assert(false && - "FIXME: SimulatorController::onBreakpoint() has not been tested before"); - // FIXME: Improve performance! - - // Loop through all listeners of type BP*Listener: + // Check for active breakpoint-events: ListenerManager::iterator it = m_LstList.begin(); BPEvent tmp(instrPtr, address_space); while (it != m_LstList.end()) { - BaseListener* pev = *it; - BPSingleListener* pbp; BPRangeListener* pbpr; - if ((pbp = dynamic_cast(pev)) && pbp->isMatching(&tmp)) { - pbp->setTriggerInstructionPointer(instrPtr); + BaseListener* pLi = *it; + BPListener* pBreakpt = dynamic_cast(pLi); + if (pBreakpt != NULL && pBreakpt->isMatching(&tmp)) { + pBreakpt->setTriggerInstructionPointer(instrPtr); it = m_LstList.makeActive(it); // "it" has already been set to the next element (by calling // makeActive()): continue; // -> skip iterator increment - } else if ((pbpr = dynamic_cast(pev)) && - pbpr->isMatching(&tmp)) { - pbpr->setTriggerInstructionPointer(instrPtr); - it = m_LstList.makeActive(it); - continue; // dito } - ++it; + it++; } m_LstList.triggerActiveListeners(); } @@ -84,7 +75,6 @@ void SimulatorController::onBreakpoint(address_t instrPtr, address_t address_spa void SimulatorController::onMemoryAccess(address_t addr, size_t len, bool is_write, address_t instrPtr) { - // FIXME: Improve performance! MemAccessEvent::access_type_t accesstype = is_write ? MemAccessEvent::MEM_WRITE : MemAccessEvent::MEM_READ; diff --git a/src/core/sal/bochs/BochsController.cc b/src/core/sal/bochs/BochsController.cc index 72a6b1e2..6c13e4ec 100644 --- a/src/core/sal/bochs/BochsController.cc +++ b/src/core/sal/bochs/BochsController.cc @@ -44,11 +44,6 @@ BochsController::BochsController() m_Regs->add(pReg); } #endif // BX_SUPPORT_X86_64 - #ifdef DEBUG - m_Regularity = 0; // disabled - m_Counter = 0; - m_pDest = NULL; - #endif // ------------------------------------- // Add the Program counter register: #if BX_SUPPORT_X86_64 @@ -79,44 +74,6 @@ BochsController::~BochsController() delete m_Mem; } -#ifdef DEBUG -void BochsController::dbgEnableInstrPtrOutput(unsigned regularity, std::ostream* dest) -{ - m_Regularity = regularity; - m_pDest = dest; - m_Counter = 0; -} -#endif // DEBUG - -void BochsController::onBreakpoint(address_t instrPtr, address_t address_space) -{ -#ifdef DEBUG - if (m_Regularity != 0 && ++m_Counter % m_Regularity == 0) - (*m_pDest) << "0x" << std::hex << instrPtr; -#endif - bool do_fire = false; - // Check for active breakpoint-events: - ListenerManager::iterator it = m_LstList.begin(); - BPEvent tmp(instrPtr, address_space); - while (it != m_LstList.end()) { - BaseListener* pLi = *it; - BPListener* pBreakpt = dynamic_cast(pLi); - 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()): - continue; // -> skip iterator increment - } - it++; - } - if (do_fire) - m_LstList.triggerActiveListeners(); - // Note: SimulatorController::onBreakpoint will not be invoked in this - // implementation. -} - void BochsController::updateBPEventInfo(BX_CPU_C *context, bxInstruction_c *instr) { assert(context != NULL && "FATAL ERROR: Bochs internal member was NULL (not expected)!"); diff --git a/src/core/sal/bochs/BochsController.hpp b/src/core/sal/bochs/BochsController.hpp index fdd889d5..bf288caf 100644 --- a/src/core/sal/bochs/BochsController.hpp +++ b/src/core/sal/bochs/BochsController.hpp @@ -17,6 +17,8 @@ #include "iodev/iodev.h" #include "pc_system.h" +#define DEBUG + namespace fail { class ExperimentFlow; @@ -24,17 +26,22 @@ class ExperimentFlow; /** * \class BochsController * Bochs-specific implementation of a SimulatorController. + * + * @note The instruction (IP) pointer modification handler (onBreakpoint()) + * is called (from the Breakpoints aspect) *every* time the Bochs-internal IP + * changes. The handler itself evaluates if a breakpoint event needs to be + * triggered. This handler needs to implement the breakpoint-mechanism in an + * indirect fashion because the Bochs simulator doesn't support native + * breakpoints. To be compatible with the interface specified by the simulator + * class, we need to provide the two members \c m_CPUContext and \c m_CacheEntry. + * The elements are being set before the handler is called (see + * \c updateBPEventInfo()) */ class BochsController : public SimulatorController { private: ExperimentFlow* m_CurrFlow; //!< Stores the current flow for save/restore-operations BX_CPU_C *m_CPUContext; //!< Additional information that is passed on occurence of a BPEvent bxInstruction_c *m_CurrentInstruction; //!< dito. - #ifdef DEBUG - unsigned m_Regularity; //! regularity of instruction ptr output - unsigned m_Counter; //! current instr-ptr counter - std::ostream* m_pDest; //! debug output object (defaults to \c std::cout) - #endif public: // Initialize the controller. BochsController(); @@ -42,20 +49,6 @@ public: /* ******************************************************************** * Standard Listener Handler API: * ********************************************************************/ - /** - * Instruction pointer modification handler implementing the onBreakpoint - * handler of the SimulatorController. This method is called (from - * the Breakpoints aspect) *every* time the Bochs-internal IP changes. - * The handler itself evaluates if a breakpoint event needs to be triggered. - * This handler needs to implement the breakpoint-mechanism in an indirect - * fashion because the Bochs simulator doesn't support native breakpoints. - * To match the interface specified by the simulator class, we need to provide - * the two members \c m_CPUContext and \c m_CacheEntry. The elements are - * being set before the handler is called (see \c updateBPEventInfo()). - * @param instrPtr the new instruction pointer - * @param address_space the address space the CPU is currently in - */ - void onBreakpoint(address_t instrPtr, address_t address_space); /** * I/O port communication handler. This method is called (from * the IOPortCom aspect) every time when Bochs performs a port I/O operation. @@ -123,15 +116,6 @@ public: /* ******************************************************************** * BochsController-specific (not implemented in SimulatorController!): * ********************************************************************/ - #ifdef DEBUG - /** - * Enables instruction pointer debugging output. - * @param regularity the output regularity; 1 to display every - * instruction pointer, 0 to disable - * @param dest specifies the output destition; defaults to \c std::cout - */ - void dbgEnableInstrPtrOutput(unsigned regularity, std::ostream* dest = &std::cout); - #endif /** * Retrieves the textual description (mnemonic) for the current * instruction. The format of the returned string is Bochs-specific.