CdbEngine: Don't call blocking waitForStarted()

Connect to started() signal instead and continue
setup in its handler. Handle failed to start case
inside done() signal handler.

Change-Id: I23fd222a6c73147ee439381cac79f29cffad560c
Reviewed-by: David Schulz <david.schulz@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
Jarek Kobus
2022-06-21 18:00:03 +02:00
parent fd47b37298
commit 1e8139ecec
2 changed files with 18 additions and 11 deletions

View File

@@ -212,6 +212,7 @@ CdbEngine::CdbEngine() :
DebuggerSettings *s = debuggerSettings(); DebuggerSettings *s = debuggerSettings();
connect(s->createFullBacktrace.action(), &QAction::triggered, connect(s->createFullBacktrace.action(), &QAction::triggered,
this, &CdbEngine::createFullBacktrace); this, &CdbEngine::createFullBacktrace);
connect(&m_process, &QtcProcess::started, this, &CdbEngine::processStarted);
connect(&m_process, &QtcProcess::done, this, &CdbEngine::processDone); connect(&m_process, &QtcProcess::done, this, &CdbEngine::processDone);
connect(&m_process, &QtcProcess::readyReadStandardOutput, connect(&m_process, &QtcProcess::readyReadStandardOutput,
this, &CdbEngine::readyReadStandardOut); this, &CdbEngine::readyReadStandardOut);
@@ -382,12 +383,12 @@ void CdbEngine::setupEngine()
// Prepare command line. // Prepare command line.
CommandLine debugger{sp.debugger.command}; CommandLine debugger{sp.debugger.command};
const QString extensionFileName = extensionFi.fileName(); m_extensionFileName = extensionFi.fileName();
const bool isRemote = sp.startMode == AttachToRemoteServer; const bool isRemote = sp.startMode == AttachToRemoteServer;
if (isRemote) { // Must be first if (isRemote) { // Must be first
debugger.addArgs({"-remote", sp.remoteChannel}); debugger.addArgs({"-remote", sp.remoteChannel});
} else { } else {
debugger.addArg("-a" + extensionFileName); debugger.addArg("-a" + m_extensionFileName);
} }
// Source line info/No terminal breakpoint / Pull extension // Source line info/No terminal breakpoint / Pull extension
@@ -469,20 +470,19 @@ void CdbEngine::setupEngine()
m_process.setCommand(debugger); m_process.setCommand(debugger);
m_process.start(); m_process.start();
if (!m_process.waitForStarted()) {
handleSetupFailure(QString("Internal error: Cannot start process %1: %2").
arg(debugger.toUserOutput(), m_process.errorString()));
return;
} }
void CdbEngine::processStarted()
{
const qint64 pid = m_process.processId(); const qint64 pid = m_process.processId();
showMessage(QString("%1 running as %2").arg(debugger.executable().toUserOutput()).arg(pid), const FilePath execPath = runParameters().debugger.command.executable();
LogMisc); showMessage(QString("%1 running as %2").arg(execPath.toUserOutput()).arg(pid), LogMisc);
m_hasDebuggee = true; m_hasDebuggee = true;
m_initialSessionIdleHandled = false; m_initialSessionIdleHandled = false;
if (isRemote) { // We do not get an 'idle' in a remote session, but are accessible if (runParameters().startMode == AttachToRemoteServer) {
// We do not get an 'idle' in a remote session, but are accessible
m_accessible = true; m_accessible = true;
runCommand({".load " + extensionFileName, NoFlags}); runCommand({".load " + m_extensionFileName, NoFlags});
handleInitialSessionIdle(); handleInitialSessionIdle();
} }
} }
@@ -710,6 +710,11 @@ void CdbEngine::abortDebuggerProcess()
void CdbEngine::processDone() void CdbEngine::processDone()
{ {
if (m_process.result() == ProcessResult::StartFailed) {
handleSetupFailure(m_process.exitMessage());
return;
}
if (m_process.error() != QProcess::UnknownError) if (m_process.error() != QProcess::UnknownError)
showMessage(m_process.errorString(), LogError); showMessage(m_process.errorString(), LogError);

View File

@@ -106,6 +106,7 @@ public:
private: private:
void readyReadStandardOut(); void readyReadStandardOut();
void readyReadStandardError(); void readyReadStandardError();
void processStarted();
void processDone(); void processDone();
void runCommand(const DebuggerCommand &cmd) override; void runCommand(const DebuggerCommand &cmd) override;
void adjustOperateByInstruction(bool); void adjustOperateByInstruction(bool);
@@ -222,6 +223,7 @@ private:
wow64Stack64Bit wow64Stack64Bit
} m_wow64State = wow64Uninitialized; } m_wow64State = wow64Uninitialized;
QElapsedTimer m_logTimer; QElapsedTimer m_logTimer;
QString m_extensionFileName;
QString m_extensionMessageBuffer; QString m_extensionMessageBuffer;
bool m_sourceStepInto = false; bool m_sourceStepInto = false;
int m_watchPointX = 0; int m_watchPointX = 0;