diff --git a/src/plugins/debugger/debuggermanager.cpp b/src/plugins/debugger/debuggermanager.cpp index 1898155a7ab085be491230b5e581a86857675ec1..203bfc5b6b9e8b85671520fe615268fc89668633 100644 --- a/src/plugins/debugger/debuggermanager.cpp +++ b/src/plugins/debugger/debuggermanager.cpp @@ -33,7 +33,6 @@ #include "debuggermanager.h" -#include "assert.h" #include "debuggerconstants.h" #include "idebuggerengine.h" @@ -58,6 +57,8 @@ #include "startexternaldialog.h" #include "attachexternaldialog.h" +#include <utils/qtcassert.h> + #include <QtCore/QDebug> #include <QtCore/QDir> #include <QtCore/QFileInfo> @@ -149,6 +150,7 @@ void DebuggerManager::init() { m_status = -1; m_busy = false; + m_shutdown = false; m_attachedPID = 0; m_startMode = startInternal; @@ -588,7 +590,18 @@ void DebuggerManager::showApplicationOutput(const QString &str) void DebuggerManager::shutdown() { //qDebug() << "DEBUGGER_MANAGER SHUTDOWN START"; - engine()->shutdown(); + m_shutdown = true; + if (m_engine) + m_engine->shutdown(); + m_engine = 0; + + delete scriptEngine; + scriptEngine = 0; + delete gdbEngine; + gdbEngine = 0; + delete winEngine; + winEngine = 0; + // Delete these manually before deleting the manager // (who will delete the models for most views) delete m_breakWindow; @@ -642,41 +655,49 @@ void DebuggerManager::toggleBreakpoint() void DebuggerManager::toggleBreakpoint(const QString &fileName, int lineNumber) { + QTC_ASSERT(m_engine, return); + QTC_ASSERT(m_breakHandler, return); int index = m_breakHandler->indexOf(fileName, lineNumber); if (index == -1) - breakHandler()->setBreakpoint(fileName, lineNumber); + m_breakHandler->setBreakpoint(fileName, lineNumber); else - breakHandler()->removeBreakpoint(index); - engine()->attemptBreakpointSynchronization(); + m_breakHandler->removeBreakpoint(index); + m_engine->attemptBreakpointSynchronization(); } void DebuggerManager::setToolTipExpression(const QPoint &pos, const QString &exp) { - engine()->setToolTipExpression(pos, exp); + QTC_ASSERT(m_engine, return); + m_engine->setToolTipExpression(pos, exp); } void DebuggerManager::updateWatchModel() { - engine()->updateWatchModel(); + QTC_ASSERT(m_engine, return); + m_engine->updateWatchModel(); } void DebuggerManager::expandChildren(const QModelIndex &idx) { - watchHandler()->expandChildren(idx); + QTC_ASSERT(m_watchHandler, return); + m_watchHandler->expandChildren(idx); } void DebuggerManager::collapseChildren(const QModelIndex &idx) { - watchHandler()->collapseChildren(idx); + QTC_ASSERT(m_watchHandler, return); + m_watchHandler->collapseChildren(idx); } void DebuggerManager::removeWatchExpression(const QString &exp) { - watchHandler()->removeWatchExpression(exp); + QTC_ASSERT(m_watchHandler, return); + m_watchHandler->removeWatchExpression(exp); } QVariant DebuggerManager::sessionValue(const QString &name) { + // this is answered by the plugin QVariant value; emit sessionValueRequested(name, &value); return value; @@ -684,16 +705,19 @@ QVariant DebuggerManager::sessionValue(const QString &name) void DebuggerManager::querySessionValue(const QString &name, QVariant *value) { + // this is answered by the plugin emit sessionValueRequested(name, value); } void DebuggerManager::setSessionValue(const QString &name, const QVariant &value) { + // this is answered by the plugin emit setSessionValueRequested(name, value); } QVariant DebuggerManager::configValue(const QString &name) { + // this is answered by the plugin QVariant value; emit configValueRequested(name, &value); return value; @@ -701,11 +725,13 @@ QVariant DebuggerManager::configValue(const QString &name) void DebuggerManager::queryConfigValue(const QString &name, QVariant *value) { + // this is answered by the plugin emit configValueRequested(name, value); } void DebuggerManager::setConfigValue(const QString &name, const QVariant &value) { + // this is answered by the plugin emit setConfigValueRequested(name, value); } @@ -788,7 +814,7 @@ bool DebuggerManager::startNewDebugger(StartMode mode) else setDebuggerType(GdbDebugger); - if (!engine()->startDebugger()) + if (!m_engine->startDebugger()) return false; m_busy = false; @@ -809,7 +835,10 @@ void DebuggerManager::cleanupViews() void DebuggerManager::exitDebugger() { - engine()->exitDebugger(); + if (m_shutdown) + return; + QTC_ASSERT(m_engine, return); + m_engine->exitDebugger(); cleanupViews(); setStatus(DebuggerProcessNotReady); setBusyCursor(false); @@ -818,62 +847,73 @@ void DebuggerManager::exitDebugger() void DebuggerManager::assignValueInDebugger(const QString &expr, const QString &value) { - engine()->assignValueInDebugger(expr, value); + QTC_ASSERT(m_engine, return); + m_engine->assignValueInDebugger(expr, value); } void DebuggerManager::activateFrame(int index) { - engine()->activateFrame(index); + QTC_ASSERT(m_engine, return); + m_engine->activateFrame(index); } void DebuggerManager::selectThread(int index) { - engine()->selectThread(index); + QTC_ASSERT(m_engine, return); + m_engine->selectThread(index); } void DebuggerManager::loadAllSymbols() { - engine()->loadAllSymbols(); + QTC_ASSERT(m_engine, return); + m_engine->loadAllSymbols(); } void DebuggerManager::loadSymbols(const QString &module) { - engine()->loadSymbols(module); + QTC_ASSERT(m_engine, return); + m_engine->loadSymbols(module); } void DebuggerManager::stepExec() { + QTC_ASSERT(m_engine, return); resetLocation(); - engine()->stepExec(); + m_engine->stepExec(); } void DebuggerManager::stepOutExec() { + QTC_ASSERT(m_engine, return); resetLocation(); - engine()->stepOutExec(); + m_engine->stepOutExec(); } void DebuggerManager::nextExec() { + QTC_ASSERT(m_engine, return); resetLocation(); - engine()->nextExec(); + m_engine->nextExec(); } void DebuggerManager::stepIExec() { + QTC_ASSERT(m_engine, return); resetLocation(); - engine()->stepIExec(); + m_engine->stepIExec(); } void DebuggerManager::nextIExec() { + QTC_ASSERT(m_engine, return); resetLocation(); - engine()->nextIExec(); + m_engine->nextIExec(); } void DebuggerManager::executeDebuggerCommand(const QString &command) { - engine()->executeDebuggerCommand(command); + QTC_ASSERT(m_engine, return); + m_engine->executeDebuggerCommand(command); } void DebuggerManager::sessionLoaded() @@ -891,16 +931,18 @@ void DebuggerManager::aboutToSaveSession() void DebuggerManager::loadSessionData() { + QTC_ASSERT(m_engine, return); m_breakHandler->loadSessionData(); m_watchHandler->loadSessionData(); - engine()->loadSessionData(); + m_engine->loadSessionData(); } void DebuggerManager::saveSessionData() { + QTC_ASSERT(m_engine, return); m_breakHandler->saveSessionData(); m_watchHandler->saveSessionData(); - engine()->saveSessionData(); + m_engine->saveSessionData(); } void DebuggerManager::dumpLog() @@ -959,19 +1001,24 @@ void DebuggerManager::addToWatchWindow() void DebuggerManager::watchExpression(const QString &expression) { - watchHandler()->watchExpression(expression); + QTC_ASSERT(m_watchHandler, return); + m_watchHandler->watchExpression(expression); } void DebuggerManager::setBreakpoint(const QString &fileName, int lineNumber) { - breakHandler()->setBreakpoint(fileName, lineNumber); - engine()->attemptBreakpointSynchronization(); + QTC_ASSERT(m_breakHandler, return); + QTC_ASSERT(m_engine, return); + m_breakHandler->setBreakpoint(fileName, lineNumber); + m_engine->attemptBreakpointSynchronization(); } void DebuggerManager::breakByFunction(const QString &functionName) { - breakHandler()->breakByFunction(functionName); - engine()->attemptBreakpointSynchronization(); + QTC_ASSERT(m_breakHandler, return); + QTC_ASSERT(m_engine, return); + m_breakHandler->breakByFunction(functionName); + m_engine->attemptBreakpointSynchronization(); } void DebuggerManager::breakByFunction() @@ -1081,14 +1128,16 @@ bool DebuggerManager::useCustomDumpers() const void DebuggerManager::setUseCustomDumpers(bool on) { + QTC_ASSERT(m_engine, return); m_settings.m_useCustomDumpers = on; - engine()->setUseCustomDumpers(on); + m_engine->setUseCustomDumpers(on); } void DebuggerManager::setDebugDumpers(bool on) { + QTC_ASSERT(m_engine, return); m_settings.m_debugDumpers = on; - engine()->setDebugDumpers(on); + m_engine->setDebugDumpers(on); } void DebuggerManager::setSkipKnownFrames(bool on) @@ -1104,29 +1153,31 @@ void DebuggerManager::queryCurrentTextEditor(QString *fileName, int *lineNumber, void DebuggerManager::continueExec() { - engine()->continueInferior(); + m_engine->continueInferior(); } void DebuggerManager::interruptDebuggingRequest() { + QTC_ASSERT(m_engine, return); //qDebug() << "INTERRUPTING AT" << status(); bool interruptIsExit = (status() != DebuggerInferiorRunning); if (interruptIsExit) exitDebugger(); else { setStatus(DebuggerInferiorStopRequested); - engine()->interruptInferior(); + m_engine->interruptInferior(); } } void DebuggerManager::runToLineExec() { + QTC_ASSERT(m_engine, return); QString fileName; int lineNumber = -1; emit currentTextEditorRequested(&fileName, &lineNumber, 0); if (!fileName.isEmpty()) - engine()->runToLineExec(fileName, lineNumber); + m_engine->runToLineExec(fileName, lineNumber); } void DebuggerManager::runToFunctionExec() @@ -1158,7 +1209,7 @@ void DebuggerManager::runToFunctionExec() } //qDebug() << "RUN TO FUNCTION " << functionName; if (!functionName.isEmpty()) - engine()->runToFunctionExec(functionName); + m_engine->runToFunctionExec(functionName); } void DebuggerManager::jumpToLineExec() @@ -1167,20 +1218,20 @@ void DebuggerManager::jumpToLineExec() int lineNumber = -1; emit currentTextEditorRequested(&fileName, &lineNumber, 0); if (!fileName.isEmpty()) - engine()->jumpToLineExec(fileName, lineNumber); + m_engine->jumpToLineExec(fileName, lineNumber); } void DebuggerManager::resetLocation() { - //m_watchHandler->removeMouseMoveCatcher(editor->widget()); + // connected to the plugin emit resetLocationRequested(); } void DebuggerManager::gotoLocation(const QString &fileName, int line, bool setMarker) { + // connected to the plugin emit gotoLocationRequested(fileName, line, setMarker); - //m_watchHandler->installMouseMoveCatcher(editor->widget()); } @@ -1192,9 +1243,10 @@ void DebuggerManager::gotoLocation(const QString &fileName, int line, void DebuggerManager::reloadDisassembler() { + QTC_ASSERT(m_engine, return); if (!m_disassemblerDock || !m_disassemblerDock->isVisible()) return; - engine()->reloadDisassembler(); + m_engine->reloadDisassembler(); } void DebuggerManager::disassemblerDockToggled(bool on) @@ -1214,7 +1266,7 @@ void DebuggerManager::reloadModules() { if (!m_modulesDock || !m_modulesDock->isVisible()) return; - engine()->reloadModules(); + m_engine->reloadModules(); } void DebuggerManager::modulesDockToggled(bool on) @@ -1232,11 +1284,13 @@ void DebuggerManager::modulesDockToggled(bool on) void DebuggerManager::showDebuggerOutput(const QString &prefix, const QString &msg) { + QTC_ASSERT(m_outputWindow, return); m_outputWindow->showOutput(prefix, msg); } void DebuggerManager::showDebuggerInput(const QString &prefix, const QString &msg) { + QTC_ASSERT(m_outputWindow, return); m_outputWindow->showInput(prefix, msg); } @@ -1257,7 +1311,7 @@ void DebuggerManager::reloadRegisters() { if (!m_registerDock || !m_registerDock->isVisible()) return; - engine()->reloadRegisters(); + m_engine->reloadRegisters(); } diff --git a/src/plugins/debugger/debuggermanager.h b/src/plugins/debugger/debuggermanager.h index a3407a0aa59c4f410d3a711929805d872f6d972e..bd10b7b025967d1793f5145304fd702dcaa0b46f 100644 --- a/src/plugins/debugger/debuggermanager.h +++ b/src/plugins/debugger/debuggermanager.h @@ -466,6 +466,8 @@ private: IDebuggerEngine *engine(); IDebuggerEngine *m_engine; DebuggerSettings m_settings; + // set during application shutdown + bool m_shutdown; }; } // namespace Internal