Debugger: Fix interrupting with cdb

It turns out sending ctrl+c events to cdb results in inconsistent
behavior when trying to interrupt with the range from interrupting twice
to not at all. Use the previous method of using signal operation for
local debugging, and use the ctrl+c event only when cdb is attached to a
remote server.

Fixes: QTCREATORBUG-28279
Change-Id: Iccd2016685ba707b375aebfd88eccc253dde1d1d
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
David Schulz
2022-10-12 11:59:26 +02:00
parent 767644967c
commit 17b1fa1618
2 changed files with 27 additions and 0 deletions

View File

@@ -763,6 +763,18 @@ void CdbEngine::interruptInferior()
doInterruptInferior(); 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) void CdbEngine::doInterruptInferior(const InterruptCallback &callback)
{ {
const bool requestInterrupt = m_stopMode == NoStopRequested; const bool requestInterrupt = m_stopMode == NoStopRequested;
@@ -779,6 +791,18 @@ void CdbEngine::doInterruptInferior(const InterruptCallback &callback)
if (!requestInterrupt) if (!requestInterrupt)
return; // we already requested a stop no need to interrupt twice return; // we already requested a stop no need to interrupt twice
showMessage(QString("Interrupting process %1...").arg(inferiorPid()), LogMisc); showMessage(QString("Interrupting process %1...").arg(inferiorPid()), LogMisc);
QTC_ASSERT(!m_signalOperation, notifyInferiorStopFailed(); return);
if (m_effectiveStartMode != AttachToRemoteServer && device()) {
m_signalOperation = device()->signalOperation();
if (m_signalOperation) {
connect(m_signalOperation.data(), &DeviceProcessSignalOperation::finished,
this, &CdbEngine::handleDoInterruptInferior);
m_signalOperation->setDebuggerCommand(runParameters().debugger.command.executable());
m_signalOperation->interruptProcess(inferiorPid());
return;
}
}
m_process.interrupt(); m_process.interrupt();
} }

View File

@@ -85,6 +85,8 @@ private:
void createFullBacktrace(); void createFullBacktrace();
void handleDoInterruptInferior(const QString &errorMessage);
typedef QPair<QString, QString> SourcePathMapping; typedef QPair<QString, QString> SourcePathMapping;
struct NormalizedSourceFileName // Struct for caching mapped/normalized source files. struct NormalizedSourceFileName // Struct for caching mapped/normalized source files.
{ {
@@ -175,6 +177,7 @@ private:
//! Debugger accessible (expecting commands) //! Debugger accessible (expecting commands)
bool m_accessible = false; bool m_accessible = false;
StopMode m_stopMode = NoStopRequested; StopMode m_stopMode = NoStopRequested;
ProjectExplorer::DeviceProcessSignalOperation::Ptr m_signalOperation;
int m_nextCommandToken = 0; int m_nextCommandToken = 0;
QHash<int, DebuggerCommand> m_commandForToken; QHash<int, DebuggerCommand> m_commandForToken;
QString m_currentBuiltinResponse; QString m_currentBuiltinResponse;