From 5d8bd5e03191f26d9340df260c02734167e66beb Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen <oswald.buddenhagen@nokia.com> Date: Thu, 7 May 2009 12:18:45 +0200 Subject: [PATCH] generalize auto-continue mechanism --- src/plugins/debugger/gdbengine.cpp | 34 ++++++++++++++---------------- src/plugins/debugger/gdbengine.h | 3 +-- 2 files changed, 17 insertions(+), 20 deletions(-) diff --git a/src/plugins/debugger/gdbengine.cpp b/src/plugins/debugger/gdbengine.cpp index e86b3a1208c..151c8f7e84e 100644 --- a/src/plugins/debugger/gdbengine.cpp +++ b/src/plugins/debugger/gdbengine.cpp @@ -192,7 +192,7 @@ void GdbEngine::initializeVariables() m_oldestAcceptableToken = -1; m_outputCodec = QTextCodec::codecForLocale(); m_pendingRequests = 0; - m_waitingForBreakpointSynchronizationToContinue = false; + m_autoContinue = false; m_waitingForFirstBreakpointToBeHit = false; m_commandsToRunOnTemporaryBreak.clear(); } @@ -522,8 +522,8 @@ void GdbEngine::handleResponse(const QByteArray &buff) void GdbEngine::handleStubAttached(const GdbResultRecord &, const QVariant &) { qq->notifyInferiorStopped(); - m_waitingForBreakpointSynchronizationToContinue = true; handleAqcuiredInferior(); + m_autoContinue = true; } void GdbEngine::stubStarted() @@ -713,6 +713,16 @@ void GdbEngine::handleResultRecord(const GdbResultRecord &record) PENDING_DEBUG(" UNKNOWN TYPE " << cmd.type << " LEAVES PENDING AT: " << m_pendingRequests << cmd.command); } + + // This is somewhat inefficient, as it makes the last command synchronous. + // An optimization would be requesting the continue immediately when the + // event loop is entered, and let individual commands have a flag to suppress + // that behavior. + if (m_cookieForToken.isEmpty() && m_autoContinue) { + m_autoContinue = false; + continueInferior(); + q->showStatusMessage(tr("Continuing after temporary stop.")); + } } void GdbEngine::executeDebuggerCommand(const QString &command) @@ -942,12 +952,6 @@ void GdbEngine::handleAqcuiredInferior() attemptBreakpointSynchronization(); } -void GdbEngine::handleAutoContinue(const GdbResultRecord &, const QVariant &) -{ - continueInferior(); - q->showStatusMessage(tr("Continuing after temporary stop.")); -} - void GdbEngine::handleAsyncOutput(const GdbMi &data) { const QByteArray &reason = data.findChild("reason").data(); @@ -980,8 +984,8 @@ void GdbEngine::handleAsyncOutput(const GdbMi &data) // This is handled now above. qq->notifyInferiorStopped(); - m_waitingForBreakpointSynchronizationToContinue = true; handleAqcuiredInferior(); + m_autoContinue = true; return; } @@ -996,8 +1000,8 @@ void GdbEngine::handleAsyncOutput(const GdbMi &data) .arg(cmd.command).arg(_(cmd.callbackName))); flushCommand(cmd); } - postCommand(_("p temporaryStop"), CB(handleAutoContinue)); - q->showStatusMessage(tr("Handling queued commands.")); + q->showStatusMessage(tr("Processing queued commands.")); + m_autoContinue = true; return; } @@ -1638,8 +1642,8 @@ void GdbEngine::handleTargetRemote(const GdbResultRecord &record, const QVariant { if (record.resultClass == GdbResultDone) { //postCommand(_("-exec-continue"), CB(handleExecRun)); - m_waitingForBreakpointSynchronizationToContinue = true; handleAqcuiredInferior(); + m_autoContinue = true; } else if (record.resultClass == GdbResultError) { // 16^error,msg="hd:5555: Connection timed out." QString msg = __(record.data.findChild("msg").data()); @@ -2218,12 +2222,6 @@ void GdbEngine::attemptBreakpointSynchronization() } } - if (!updateNeeded && m_waitingForBreakpointSynchronizationToContinue) { - m_waitingForBreakpointSynchronizationToContinue = false; - // we continue the execution - continueInferior(); - } - inBreakpointSychronization = false; } diff --git a/src/plugins/debugger/gdbengine.h b/src/plugins/debugger/gdbengine.h index 1500183ee68..418a5096bed 100644 --- a/src/plugins/debugger/gdbengine.h +++ b/src/plugins/debugger/gdbengine.h @@ -205,7 +205,6 @@ private: void handleAsyncOutput2(const GdbMi &data); void handleAsyncOutput(const GdbMi &data); void handleResultRecord(const GdbResultRecord &response); - void handleAutoContinue(const GdbResultRecord &, const QVariant &); void handleFileExecAndSymbols(const GdbResultRecord &response, const QVariant &); void handleExecRun(const GdbResultRecord &response, const QVariant &); void handleExecJumpToLine(const GdbResultRecord &response, const QVariant &); @@ -371,7 +370,7 @@ private: QString m_currentFrame; QMap<QString, QString> m_varToType; - bool m_waitingForBreakpointSynchronizationToContinue; + bool m_autoContinue; bool m_waitingForFirstBreakpointToBeHit; bool m_modulesListOutdated; -- GitLab