From fa0771549e5ff0d701ae0e32ece59be377fd542d Mon Sep 17 00:00:00 2001 From: David Schulz Date: Thu, 23 Jun 2022 09:49:39 +0200 Subject: [PATCH] Debugger: Fix interrupting remote cdb process Since we can use the ctrlc stub for cdb now we also can use the interrupt functionality to force the debugger to halt. This also works for remote sessions. Fixes: QTCREATORBUG-21657 Change-Id: I049aea781e984c31ac5744f87f9590f910234679 Reviewed-by: hjk --- src/plugins/debugger/cdb/cdbengine.cpp | 33 +------------------------- src/plugins/debugger/cdb/cdbengine.h | 3 --- 2 files changed, 1 insertion(+), 35 deletions(-) diff --git a/src/plugins/debugger/cdb/cdbengine.cpp b/src/plugins/debugger/cdb/cdbengine.cpp index 60692a75a11..8474f6665c1 100644 --- a/src/plugins/debugger/cdb/cdbengine.cpp +++ b/src/plugins/debugger/cdb/cdbengine.cpp @@ -805,32 +805,9 @@ void CdbEngine::interruptInferior() if (debug) qDebug() << "CdbEngine::interruptInferior()" << stateName(state()); - if (!canInterruptInferior()) { - // Restore running state if inferior can't be stoped. - showMessage(tr("Interrupting is not possible in remote sessions."), LogError); - STATE_DEBUG(state(), Q_FUNC_INFO, __LINE__, "notifyInferiorStopOk") - notifyInferiorStopOk(); - STATE_DEBUG(state(), Q_FUNC_INFO, __LINE__, "notifyInferiorRunRequested") - notifyInferiorRunRequested(); - STATE_DEBUG(state(), Q_FUNC_INFO, __LINE__, "notifyInferiorRunOk") - notifyInferiorRunOk(); - return; - } doInterruptInferior(); } -void CdbEngine::handleDoInterruptInferior(const QString &errorMessage) -{ - if (errorMessage.isEmpty()) { - showMessage("Interrupted " + QString::number(inferiorPid())); - } else { - showMessage(errorMessage, LogError); - notifyInferiorStopFailed(); - } - m_signalOperation->disconnect(this); - m_signalOperation.clear(); -} - void CdbEngine::doInterruptInferior(const InterruptCallback &callback) { const bool requestInterrupt = m_stopMode == NoStopRequested; @@ -847,15 +824,7 @@ void CdbEngine::doInterruptInferior(const InterruptCallback &callback) if (!requestInterrupt) return; // we already requested a stop no need to interrupt twice showMessage(QString("Interrupting process %1...").arg(inferiorPid()), LogMisc); - QTC_ASSERT(!m_signalOperation, notifyInferiorStopFailed(); return); - QTC_ASSERT(device(), notifyInferiorRunFailed(); return); - m_signalOperation = device()->signalOperation(); - QTC_ASSERT(m_signalOperation, notifyInferiorStopFailed(); return;); - connect(m_signalOperation.data(), &DeviceProcessSignalOperation::finished, - this, &CdbEngine::handleDoInterruptInferior); - - m_signalOperation->setDebuggerCommand(runParameters().debugger.command.executable()); - m_signalOperation->interruptProcess(inferiorPid()); + m_process.interrupt(); } void CdbEngine::executeRunToLine(const ContextData &data) diff --git a/src/plugins/debugger/cdb/cdbengine.h b/src/plugins/debugger/cdb/cdbengine.h index 1209d0ad3a7..8dd3739dea0 100644 --- a/src/plugins/debugger/cdb/cdbengine.h +++ b/src/plugins/debugger/cdb/cdbengine.h @@ -113,8 +113,6 @@ private: void createFullBacktrace(); - void handleDoInterruptInferior(const QString &errorMessage); - typedef QPair SourcePathMapping; struct NormalizedSourceFileName // Struct for caching mapped/normalized source files. { @@ -207,7 +205,6 @@ private: //! Debugger accessible (expecting commands) bool m_accessible = false; StopMode m_stopMode = NoStopRequested; - ProjectExplorer::DeviceProcessSignalOperation::Ptr m_signalOperation; int m_nextCommandToken = 0; QHash m_commandForToken; QString m_currentBuiltinResponse;