From a9982cac70d50a185c6f7018617394095d4df58a Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 8 Feb 2011 12:08:59 +0100 Subject: [PATCH] Debugger[CDB]: Enable engine restart. --- src/plugins/debugger/cdb/cdbengine.cpp | 49 +++++++++++++++++++++++++++++----- src/plugins/debugger/cdb/cdbengine.h | 2 ++ 2 files changed, 45 insertions(+), 6 deletions(-) diff --git a/src/plugins/debugger/cdb/cdbengine.cpp b/src/plugins/debugger/cdb/cdbengine.cpp index ebfbaf8771..4cbe298df7 100644 --- a/src/plugins/debugger/cdb/cdbengine.cpp +++ b/src/plugins/debugger/cdb/cdbengine.cpp @@ -408,7 +408,8 @@ CdbEngine::CdbEngine(const DebuggerStartParameters &sp, m_sourceStepInto(false), m_wX86BreakpointCount(0), m_watchPointX(0), - m_watchPointY(0) + m_watchPointY(0), + m_ignoreCdbOutput(false) { Utils::SavedAction *assemblerAction = theAssemblerAction(); m_operateByInstructionPending = assemblerAction->isChecked(); @@ -421,6 +422,31 @@ CdbEngine::CdbEngine(const DebuggerStartParameters &sp, connect(&m_process, SIGNAL(readyReadStandardError()), this, SLOT(readyReadStandardOut())); } +void CdbEngine::init() +{ + m_effectiveStartMode = NoStartMode; + m_inferiorPid = 0; + m_accessible = false; + m_specialStopMode = NoSpecialStop; + m_nextCommandToken = 0; + m_currentBuiltinCommandIndex = -1; + m_operateByInstructionPending = true; + m_operateByInstruction = true; // Default CDB setting + m_notifyEngineShutdownOnTermination = false; + m_hasDebuggee = false; + m_sourceStepInto = false; + m_wX86BreakpointCount = 0; + m_watchPointX = m_watchPointY = 0; + m_ignoreCdbOutput = false; + + m_outputBuffer.clear(); + m_builtinCommandQueue.clear(); + m_extensionCommandQueue.clear(); + m_extensionMessageBuffer.clear(); + m_pendingBreakpointMap.clear(); + QTC_ASSERT(m_process.state() != QProcess::Running, Utils::SynchronousProcess::stopProcess(m_process); ) +} + CdbEngine::~CdbEngine() { } @@ -592,7 +618,9 @@ void CdbEngine::setupEngine() &(m_options->symbolPaths))) m_options->toSettings(Core::ICore::instance()->settings()); - m_logTime.start(); + init(); + if (!m_logTime.elapsed()) + m_logTime.start(); QString errorMessage; // Console: Launch the stub with the suspended application and attach to it // CDB in theory has a command line option '-2' that launches a @@ -756,6 +784,11 @@ void CdbEngine::shutdownInferior() return; } if (!canInterruptInferior() || commandsPending()) { + QString msg = QLatin1String("Cannot interrupt the inferior"); + if (commandsPending()) + msg += QLatin1String(" (pending)"); + msg += QLatin1Char('.'); + showMessage(msg, LogWarning); STATE_DEBUG(state(), Q_FUNC_INFO, __LINE__, "notifyInferiorShutdownFailed") notifyInferiorShutdownFailed(); return; @@ -794,8 +827,7 @@ void CdbEngine::shutdownEngine() } // No longer trigger anything from messages - disconnect(&m_process, SIGNAL(readyReadStandardOutput()), this, 0); - disconnect(&m_process, SIGNAL(readyReadStandardError()), this, 0); + m_ignoreCdbOutput = true; // Go for kill if there are commands pending. if (m_accessible && !commandsPending()) { // detach: Wait for debugger to finish. @@ -1001,11 +1033,13 @@ void CdbEngine::doContinueInferior() bool CdbEngine::canInterruptInferior() const { - return m_effectiveStartMode != AttachToRemote; + return m_effectiveStartMode != AttachToRemote && m_inferiorPid; } void CdbEngine::interruptInferior() { + if (debug) + qDebug() << "CdbEngine::interruptInferior()" << stateName(state()); if (canInterruptInferior()) { doInterruptInferior(NoSpecialStop); } else { @@ -1025,9 +1059,10 @@ void CdbEngine::doInterruptInferior(SpecialStopMode sm) const SpecialStopMode oldSpecialMode = m_specialStopMode; m_specialStopMode = sm; QString errorMessage; + showMessage(QString::fromLatin1("Interrupting process %1...").arg(m_inferiorPid), LogMisc); if (!winDebugBreakProcess(m_inferiorPid, &errorMessage)) { m_specialStopMode = oldSpecialMode; - showMessage(errorMessage, LogError); + showMessage(QString::fromLatin1("Cannot interrupt process %1: %2").arg(m_inferiorPid).arg(errorMessage), LogError); } #else Q_UNUSED(sm) @@ -2057,6 +2092,8 @@ void CdbEngine::parseOutputLine(QByteArray line) void CdbEngine::readyReadStandardOut() { + if (m_ignoreCdbOutput) + return; m_outputBuffer += m_process.readAllStandardOutput(); // Split into lines and parse line by line. while (true) { diff --git a/src/plugins/debugger/cdb/cdbengine.h b/src/plugins/debugger/cdb/cdbengine.h index 7fc98ff648..2d4e02f02b 100644 --- a/src/plugins/debugger/cdb/cdbengine.h +++ b/src/plugins/debugger/cdb/cdbengine.h @@ -176,6 +176,7 @@ private: bool startConsole(const DebuggerStartParameters &sp, QString *errorMessage); + void init(); unsigned examineStopReason(const GdbMi &stopReason, QString *message, QString *exceptionBoxMessage); bool commandsPending() const; @@ -251,6 +252,7 @@ private: int m_watchPointY; PendingBreakPointMap m_pendingBreakpointMap; QHash m_fileNameModuleHash; + bool m_ignoreCdbOutput; }; } // namespace Internal -- 2.11.0