From c7e57ced3a2737be500afe66101402d32bacf25f Mon Sep 17 00:00:00 2001 From: hjk Date: Tue, 5 Jan 2021 12:02:18 +0100 Subject: [PATCH] Debugger: Simplify gdb startup The reason for the special callback setup is lost in history. A possibility is that the extra roundtrip was needed for synchronization with earlier gdb versions and/or start up sequences. It seems to works fine without nowadays. Change-Id: I28c95aec2f065e9c6f0730f1ffbc3db1a3d819da Reviewed-by: Christian Stenger --- src/plugins/debugger/gdb/gdbengine.cpp | 31 ++------------------------ src/plugins/debugger/gdb/gdbengine.h | 9 +------- 2 files changed, 3 insertions(+), 37 deletions(-) diff --git a/src/plugins/debugger/gdb/gdbengine.cpp b/src/plugins/debugger/gdb/gdbengine.cpp index 5f0b661fda7..6cf3ac5a766 100644 --- a/src/plugins/debugger/gdb/gdbengine.cpp +++ b/src/plugins/debugger/gdb/gdbengine.cpp @@ -980,21 +980,7 @@ void GdbEngine::handleResultRecord(DebuggerResponse *response) if (cmd.callback) cmd.callback(*response); - // Continue only if there are no commands wire anymore, so this will - // be fully synchronous. - // 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_commandsDoneCallback && m_commandForToken.isEmpty()) { - showMessage("ALL COMMANDS DONE; INVOKING CALLBACK"); - CommandsDoneCallback cont = m_commandsDoneCallback; - m_commandsDoneCallback = nullptr; - if (response->resultClass != ResultRunning) //only start if the thing is not already running - (this->*cont)(); - } else { - PENDING_DEBUG("MISSING TOKENS: " << m_commandForToken.keys()); - } + PENDING_DEBUG("MISSING TOKENS: " << m_commandForToken.keys()); if (m_commandForToken.isEmpty()) m_commandTimer.stop(); @@ -3863,7 +3849,6 @@ void GdbEngine::handleAdapterStartFailed(const QString &msg, Id settingsIdHint) void GdbEngine::prepareForRestart() { m_rerunPending = false; - m_commandsDoneCallback = nullptr; m_commandForToken.clear(); m_flagsForToken.clear(); } @@ -3880,18 +3865,6 @@ void GdbEngine::handleInferiorPrepared() runCommand({command, NativeCommand}); } - if (m_commandForToken.isEmpty()) { - finishInferiorSetup(); - } else { - QTC_CHECK(m_commandsDoneCallback == nullptr); - m_commandsDoneCallback = &GdbEngine::finishInferiorSetup; - } -} - -void GdbEngine::finishInferiorSetup() -{ - CHECK_STATE(EngineSetupRequested); - if (runParameters().startMode != AttachCore) { // No breakpoints in core files. const bool onAbort = boolSetting(BreakOnAbort); const bool onWarning = boolSetting(BreakOnWarning); @@ -4385,7 +4358,7 @@ void GdbEngine::shutdownEngine() CHECK_STATE(EngineShutdownRequested); showMessage(QString("INITIATE GDBENGINE SHUTDOWN, PROC STATE: %1").arg(m_gdbProc.state())); - m_commandsDoneCallback = nullptr; + switch (m_gdbProc.state()) { case QProcess::Running: { if (runParameters().closeMode == KillAndExitMonitorAtClose) diff --git a/src/plugins/debugger/gdb/gdbengine.h b/src/plugins/debugger/gdb/gdbengine.h index a955a3bc4a7..31c076f5f1c 100644 --- a/src/plugins/debugger/gdb/gdbengine.h +++ b/src/plugins/debugger/gdb/gdbengine.h @@ -103,11 +103,8 @@ private: ////////// General Interface ////////// void handleAdapterStartFailed(const QString &msg, Utils::Id settingsIdHint = Utils::Id()); - // This triggers the initial breakpoint synchronization and causes - // finishInferiorSetup() being called once done. + // Called after target setup. void handleInferiorPrepared(); - // This notifies the base of a successful inferior setup. - void finishInferiorSetup(); void handleDebugInfoLocation(const DebuggerResponse &response); @@ -156,10 +153,6 @@ private: ////////// General Interface ////////// int m_oldestAcceptableToken = -1; int m_nonDiscardableCount = 0; - using CommandsDoneCallback = void (GdbEngine::*)(); - // This function is called after all previous responses have been received. - CommandsDoneCallback m_commandsDoneCallback = nullptr; - bool m_rerunPending = false; ////////// Gdb Output, State & Capability Handling //////////