From 5831d818beef22833e9d4f1da3863c74bb57202b Mon Sep 17 00:00:00 2001 From: Jarek Kobus Date: Thu, 17 Apr 2025 10:09:35 +0200 Subject: [PATCH] Debugger: Get rid of DebuggerRunTool Task-number: QTCREATORBUG-29168 Change-Id: If663b684825ae63f11bd6025be7382cf07a067a7 Reviewed-by: hjk --- src/plugins/debugger/cdb/cdbengine.cpp | 2 +- src/plugins/debugger/debuggerruncontrol.cpp | 105 -------------------- src/plugins/debugger/debuggerruncontrol.h | 22 ---- src/plugins/debugger/uvsc/uvscengine.cpp | 2 +- src/plugins/ios/iosrunner.cpp | 4 +- 5 files changed, 4 insertions(+), 131 deletions(-) diff --git a/src/plugins/debugger/cdb/cdbengine.cpp b/src/plugins/debugger/cdb/cdbengine.cpp index 81e235f9467..e813c5c1839 100644 --- a/src/plugins/debugger/cdb/cdbengine.cpp +++ b/src/plugins/debugger/cdb/cdbengine.cpp @@ -135,7 +135,7 @@ namespace Internal { static const char localsPrefixC[] = "local."; -// Accessed by DebuggerRunTool +// Accessed by debuggerRecipe() DebuggerEngine *createCdbEngine() { return new CdbEngine; diff --git a/src/plugins/debugger/debuggerruncontrol.cpp b/src/plugins/debugger/debuggerruncontrol.cpp index c29fb2b188c..acc942b7539 100644 --- a/src/plugins/debugger/debuggerruncontrol.cpp +++ b/src/plugins/debugger/debuggerruncontrol.cpp @@ -33,7 +33,6 @@ #include #include -#include #include #include @@ -125,16 +124,6 @@ private: int m_snapshotCounter = 0; }; -class DebuggerRunToolPrivate -{ -public: - DebuggerRunTool *q = nullptr; - DebuggerRunParameters m_runParameters; - - // TaskTree - Tasking::TaskTreeRunner m_taskTreeRunner = {}; -}; - } // namespace Internal ExecutableItem coreFileRecipe(RunControl *runControl, @@ -727,65 +716,6 @@ void EnginesDriver::showMessage(const QString &msg, int channel, int timeout) } } -void DebuggerRunTool::start() -{ - const Storage parametersStorage; - const Storage driverStorage; - const Storage tempCoreFileStorage; - const Storage> terminalStorage; - - const auto onSetup = [this, parametersStorage] { - RunInterface *iface = runStorage().activeStorage(); - connect(this, &DebuggerRunTool::canceled, iface, &RunInterface::canceled); - connect(iface, &RunInterface::started, this, &RunWorker::reportStarted); - *parametersStorage = d->m_runParameters; - parametersStorage->setAttachPid(runControl()->attachPid()); - }; - - const auto terminalKicker = [parametersStorage, driverStorage, terminalStorage] - (const SingleBarrier &barrier) { - return terminalRecipe(parametersStorage, driverStorage, terminalStorage, barrier); - }; - - const auto debugServerKicker = [runControl = runControl(), parametersStorage](const SingleBarrier &barrier) { - return debugServerRecipe(runControl, parametersStorage, barrier); - }; - - const auto onDone = [parametersStorage, tempCoreFileStorage] { - if (tempCoreFileStorage->exists()) - tempCoreFileStorage->removeFile(); - if (parametersStorage->isSnapshot() && !parametersStorage->coreFile().isEmpty()) - parametersStorage->coreFile().removeFile(); - }; - - const Group recipe { - runStorage(), - parametersStorage, - driverStorage, - terminalStorage, - tempCoreFileStorage, - continueOnError, - onGroupSetup(onSetup), - Group { - coreFileRecipe(runControl(), parametersStorage, tempCoreFileStorage), - When (terminalKicker) >> Do { - fixupParamsRecipe(runControl(), parametersStorage), - When (debugServerKicker) >> Do { - startEnginesRecipe(runControl(), parametersStorage, driverStorage) - } - } - }.withCancel(canceler()), - finalizeRecipe(driverStorage, terminalStorage), - onGroupDone(onDone) - }; - d->m_taskTreeRunner.start(recipe, {}, [this](DoneWith result) { - if (result == DoneWith::Success) - reportStopped(); - else - reportFailure(); - }); -} - Group debuggerRecipe(RunControl *runControl, const DebuggerRunParameters &initialParameters, const std::function ¶metersModifier) { @@ -843,41 +773,6 @@ RunWorker *createDebuggerWorker(RunControl *runControl, const DebuggerRunParamet debuggerRecipe(runControl, initialParameters, parametersModifier)); } -void DebuggerRunTool::stop() -{ - if (!d->m_taskTreeRunner.isRunning()) - return; - - emit canceled(); -} - -DebuggerRunParameters &DebuggerRunTool::runParameters() -{ - return d->m_runParameters; -} - -DebuggerRunTool::DebuggerRunTool(RunControl *runControl) - : RunWorker(runControl) - , d(new DebuggerRunToolPrivate{this, DebuggerRunParameters::fromRunControl(runControl)}) -{ - setId("DebuggerRunTool"); - runControl->setIcon(ProjectExplorer::Icons::DEBUG_START_SMALL_TOOLBAR); - runControl->setPromptToStop([](bool *optionalPrompt) { - return RunControl::showPromptToStopDialog( - Tr::tr("Close Debugging Session"), - Tr::tr("A debugging session is still in progress. " - "Terminating the session in the current" - " state can leave the target in an inconsistent state." - " Would you still like to terminate it?"), - QString(), QString(), optionalPrompt); - }); -} - -DebuggerRunTool::~DebuggerRunTool() -{ - delete d; -} - class DebuggerRunWorkerFactory final : public ProjectExplorer::RunWorkerFactory { public: diff --git a/src/plugins/debugger/debuggerruncontrol.h b/src/plugins/debugger/debuggerruncontrol.h index 618e661218f..735d4636e2a 100644 --- a/src/plugins/debugger/debuggerruncontrol.h +++ b/src/plugins/debugger/debuggerruncontrol.h @@ -12,8 +12,6 @@ namespace Debugger { -namespace Internal { class DebuggerRunToolPrivate; } - DEBUGGER_EXPORT Tasking::Group debuggerRecipe( ProjectExplorer::RunControl *runControl, const DebuggerRunParameters &initialParameters, @@ -24,26 +22,6 @@ DEBUGGER_EXPORT ProjectExplorer::RunWorker *createDebuggerWorker( const DebuggerRunParameters &initialParameters, const std::function ¶metersModifier = {}); -class DEBUGGER_EXPORT DebuggerRunTool final : public ProjectExplorer::RunWorker -{ - Q_OBJECT - -public: - explicit DebuggerRunTool(ProjectExplorer::RunControl *runControl); - ~DebuggerRunTool() override; - - void start() final; - void stop() final; - - DebuggerRunParameters &runParameters(); - -signals: - void canceled(); - -private: - Internal::DebuggerRunToolPrivate *d; -}; - void setupDebuggerRunWorker(); class SimpleDebugRunnerFactory final : public ProjectExplorer::RunWorkerFactory diff --git a/src/plugins/debugger/uvsc/uvscengine.cpp b/src/plugins/debugger/uvsc/uvscengine.cpp index 2125122d9ac..71802309ca9 100644 --- a/src/plugins/debugger/uvsc/uvscengine.cpp +++ b/src/plugins/debugger/uvsc/uvscengine.cpp @@ -58,7 +58,7 @@ static void allowRootLocals(const FilePath &projectFile) } } -// Accessed by DebuggerRunTool. +// Accessed by debuggerRecipe() DebuggerEngine *createUvscEngine() { return new UvscEngine; diff --git a/src/plugins/ios/iosrunner.cpp b/src/plugins/ios/iosrunner.cpp index 82bec17605f..4268623f5a5 100644 --- a/src/plugins/ios/iosrunner.cpp +++ b/src/plugins/ios/iosrunner.cpp @@ -858,10 +858,10 @@ static RunWorker *createWorker(RunControl *runControl) QTC_ASSERT(isIosDeviceInstance == isIosDeviceType, runControl->postMessage(Tr::tr("Internal error."), ErrorMessageFormat); return nullptr); DebuggerRunParameters rp = DebuggerRunParameters::fromRunControl(runControl); - // TODO cannot use setupPortsGatherer() from DebuggerRunTool, because that also requests + // TODO cannot use setupPortsGatherer(), because that also requests // the "debugChannel", which then results in runControl trying to retrieve ports&URL for that // via IDevice, which doesn't really work with the iOS setup, and also completely changes - // how the DebuggerRunTool works, breaking debugging on iOS <= 16 devices. + // how the debuggerRecipe() works, breaking debugging on iOS <= 16 devices. if (rp.isQmlDebugging()) runControl->requestQmlChannel();