diff --git a/src/plugins/debugger/debuggerdialogs.cpp b/src/plugins/debugger/debuggerdialogs.cpp index 8668243ab46..3a17544ab6c 100644 --- a/src/plugins/debugger/debuggerdialogs.cpp +++ b/src/plugins/debugger/debuggerdialogs.cpp @@ -406,8 +406,8 @@ void StartApplicationDialog::run(bool attachRemote) Kit *k = dialog.d->kitChooser->currentKit(); IDevice::ConstPtr dev = DeviceKitInformation::device(k); - DebuggerRunTool *debugger = DebuggerRunTool::createFromKit(k); - QTC_ASSERT(debugger, return); + auto runControl = new RunControl(nullptr, ProjectExplorer::Constants::DEBUG_RUN_MODE); + auto debugger = new DebuggerRunTool(runControl, k); const StartApplicationParameters newParameters = dialog.parameters(); if (newParameters != history.back()) { diff --git a/src/plugins/debugger/debuggerplugin.cpp b/src/plugins/debugger/debuggerplugin.cpp index 6f8985f711f..5637e4b18e6 100644 --- a/src/plugins/debugger/debuggerplugin.cpp +++ b/src/plugins/debugger/debuggerplugin.cpp @@ -1178,9 +1178,8 @@ bool DebuggerPluginPrivate::parseArgument(QStringList::const_iterator &it, if (!kit) kit = guessKitFromAbis(Abi::abisOfBinary(FileName::fromString(executable))); - auto debugger = DebuggerRunTool::createFromKit(kit); - QTC_ASSERT(debugger, return false); - + auto runControl = new RunControl(nullptr, ProjectExplorer::Constants::DEBUG_RUN_MODE); + auto debugger = new DebuggerRunTool(runControl, kit); if (pid) { debugger->setStartMode(AttachExternal); debugger->setCloseMode(DetachAtClose); @@ -1221,8 +1220,8 @@ bool DebuggerPluginPrivate::parseArgument(QStringList::const_iterator &it, return false; } qint64 pid = it->section(':', 1, 1).toULongLong(); - auto debugger = DebuggerRunTool::createFromKit(findUniversalCdbKit()); - QTC_ASSERT(debugger, return false); + auto runControl = new RunControl(nullptr, ProjectExplorer::Constants::DEBUG_RUN_MODE); + auto debugger = new DebuggerRunTool(runControl, findUniversalCdbKit()); debugger->setStartMode(AttachCrashedExternal); debugger->setCrashParameter(it->section(':', 0, 0)); debugger->setAttachPid(pid); @@ -1958,9 +1957,8 @@ void DebuggerPluginPrivate::attachCore() setConfigValue("LastExternalStartScript", dlg.overrideStartScript()); setConfigValue("LastForceLocalCoreFile", dlg.forcesLocalCoreFile()); - auto debugger = DebuggerRunTool::createFromKit(dlg.kit()); - QTC_ASSERT(debugger, return); - debugger->setMasterEngineType(DebuggerKitInformation::engineType(dlg.kit())); + auto runControl = new RunControl(nullptr, ProjectExplorer::Constants::DEBUG_RUN_MODE); + auto debugger = new DebuggerRunTool(runControl, dlg.kit()); debugger->setInferiorExecutable(dlg.localExecutableFile()); debugger->setCoreFileName(dlg.localCoreFile()); debugger->setRunControlName(tr("Core file \"%1\"") @@ -1986,8 +1984,8 @@ void DebuggerPluginPrivate::startRemoteCdbSession() return; setConfigValue(connectionKey, dlg.connection()); - auto debugger = DebuggerRunTool::createFromKit(kit); - QTC_ASSERT(debugger, return); + auto runControl = new RunControl(nullptr, ProjectExplorer::Constants::DEBUG_RUN_MODE); + auto debugger = new DebuggerRunTool(runControl, kit); debugger->setStartMode(AttachToRemoteServer); debugger->setCloseMode(KillAtClose); debugger->setRemoteChannel(dlg.connection()); @@ -2088,8 +2086,8 @@ RunControl *DebuggerPluginPrivate::attachToRunningProcess(Kit *kit, return 0; } - auto debugger = DebuggerRunTool::createFromKit(kit); - QTC_ASSERT(debugger, return nullptr); + auto runControl = new RunControl(nullptr, ProjectExplorer::Constants::DEBUG_RUN_MODE); + auto debugger = new DebuggerRunTool(runControl, kit); debugger->setAttachPid(ProcessHandle(process.pid)); debugger->setRunControlName(tr("Process %1").arg(process.pid)); debugger->setInferiorExecutable(process.exe); @@ -2104,20 +2102,14 @@ RunControl *DebuggerPluginPrivate::attachToRunningProcess(Kit *kit, void DebuggerPlugin::attachExternalApplication(RunControl *rc) { - DebuggerRunTool *debugger; - if (RunConfiguration *runConfig = rc->runConfiguration()) { - debugger = DebuggerRunTool::createFromRunConfiguration(runConfig); - } else { - Kit *kit = guessKitFromAbis({rc->abi()}); - debugger = DebuggerRunTool::createFromKit(kit); - } - QTC_ASSERT(debugger, return); ProcessHandle pid = rc->applicationProcessHandle(); + RunConfiguration *runConfig = rc->runConfiguration(); + auto runControl = new RunControl(runConfig, ProjectExplorer::Constants::DEBUG_RUN_MODE); + auto debugger = new DebuggerRunTool(runControl, guessKitFromAbis({rc->abi()})); debugger->setAttachPid(pid); debugger->setRunControlName(tr("Process %1").arg(pid.pid())); debugger->setStartMode(AttachExternal); debugger->setCloseMode(DetachAtClose); - debugger->setToolChainAbi(rc->abi()); debugger->startRunControl(); } @@ -2169,8 +2161,8 @@ void DebuggerPluginPrivate::attachToQmlPort() IDevice::ConstPtr device = DeviceKitInformation::device(kit); QTC_ASSERT(device, return); - auto debugger = DebuggerRunTool::createFromKit(kit); - QTC_ASSERT(debugger, return); + auto runControl = new RunControl(nullptr, ProjectExplorer::Constants::DEBUG_RUN_MODE); + auto debugger = new DebuggerRunTool(runControl, kit); QUrl qmlServer = device->toolControlChannel(IDevice::QmlControlChannel); qmlServer.setPort(dlg.port()); @@ -3657,7 +3649,9 @@ void DebuggerUnitTests::testStateMachine() RunConfiguration *rc = t->activeRunConfiguration(); QVERIFY(rc); - auto debugger = DebuggerRunTool::createFromRunConfiguration(rc); + auto runControl = new RunControl(rc, ProjectExplorer::Constants::DEBUG_RUN_MODE); + auto debugger = new DebuggerRunTool(runControl); + debugger->setInferior(rc->runnable().as()); debugger->setTestCase(TestNoBoundsOfCurrentFunction); diff --git a/src/plugins/debugger/debuggerruncontrol.cpp b/src/plugins/debugger/debuggerruncontrol.cpp index eeff836bc2f..e6832afe9aa 100644 --- a/src/plugins/debugger/debuggerruncontrol.cpp +++ b/src/plugins/debugger/debuggerruncontrol.cpp @@ -339,11 +339,6 @@ void DebuggerRunTool::setOverrideStartScript(const QString &script) m_runParameters.overrideStartScript = script; } -void DebuggerRunTool::setToolChainAbi(const Abi &abi) -{ - m_runParameters.toolChainAbi = abi; -} - void DebuggerRunTool::setInferior(const Runnable &runnable) { QTC_ASSERT(runnable.is(), reportFailure(); return); @@ -397,11 +392,6 @@ void DebuggerRunTool::addQmlServerInferiorCommandLineArgumentIfNeeded() } } -void DebuggerRunTool::setMasterEngineType(DebuggerEngineType engineType) -{ - m_runParameters.masterEngineType = engineType; -} - void DebuggerRunTool::setCrashParameter(const QString &event) { m_runParameters.crashParameter = event; @@ -737,7 +727,7 @@ bool DebuggerRunTool::fixupParameters() return true; } -DebuggerRunTool::DebuggerRunTool(RunControl *runControl) +DebuggerRunTool::DebuggerRunTool(RunControl *runControl, Kit *kit) : RunWorker(runControl) { setDisplayName("DebuggerRunTool"); @@ -773,7 +763,8 @@ DebuggerRunTool::DebuggerRunTool(RunControl *runControl) if (runConfig) m_runParameters.displayName = runConfig->displayName(); - const Kit *kit = runConfig->target()->kit(); + if (runConfig && !kit) + kit = runConfig->target()->kit(); QTC_ASSERT(kit, return); m_runParameters.macroExpander = kit->macroExpander(); @@ -807,7 +798,7 @@ DebuggerRunTool::DebuggerRunTool(RunControl *runControl) m_runParameters.validationErrors.append(t.description); } - if (runConfig->property("supportsDebugger").toBool()) { + if (runConfig && runConfig->property("supportsDebugger").toBool()) { const QString mainScript = runConfig->property("mainScript").toString(); const QString interpreter = runConfig->property("interpreter").toString(); if (!interpreter.isEmpty() && mainScript.endsWith(".py")) { @@ -819,6 +810,7 @@ DebuggerRunTool::DebuggerRunTool(RunControl *runControl) m_runParameters.inferior.commandLineArguments.append(' '); m_runParameters.inferior.commandLineArguments.append(args); } + m_runParameters.cppEngineType = PdbEngineType; m_runParameters.masterEngineType = PdbEngineType; } } @@ -829,45 +821,11 @@ DebuggerEngine *DebuggerRunTool::activeEngine() const return m_engine ? m_engine->activeEngine() : nullptr; } -class DummyProject : public Project -{ -public: - DummyProject() : Project(QString(""), FileName::fromString("")) {} -}; - -RunConfiguration *dummyRunConfigForKit(ProjectExplorer::Kit *kit) -{ - QTC_ASSERT(kit, return nullptr); // Caller needs to look for a suitable kit. - Project *project = SessionManager::startupProject(); - Target *target = project ? project->target(kit) : nullptr; - if (!target || !target->activeRunConfiguration()) { - project = new DummyProject; // FIXME: Leaks. - target = project->createTarget(kit); - } - QTC_ASSERT(target, return nullptr); - auto runConfig = target->activeRunConfiguration(); - return runConfig; -} - -DebuggerRunTool *DebuggerRunTool::createFromKit(Kit *kit) -{ - RunConfiguration *runConfig = dummyRunConfigForKit(kit); - return createFromRunConfiguration(runConfig); -} - void DebuggerRunTool::startRunControl() { ProjectExplorerPlugin::startRunControl(runControl()); } -DebuggerRunTool *DebuggerRunTool::createFromRunConfiguration(RunConfiguration *runConfig) -{ - QTC_ASSERT(runConfig, return nullptr); - auto runControl = new RunControl(runConfig, ProjectExplorer::Constants::DEBUG_RUN_MODE); - auto debugger = new DebuggerRunTool(runControl); - return debugger; -} - void DebuggerRunTool::addSolibSearchDir(const QString &str) { QString path = str; diff --git a/src/plugins/debugger/debuggerruncontrol.h b/src/plugins/debugger/debuggerruncontrol.h index ff46db5059f..b766a6d023d 100644 --- a/src/plugins/debugger/debuggerruncontrol.h +++ b/src/plugins/debugger/debuggerruncontrol.h @@ -42,14 +42,13 @@ class DEBUGGER_EXPORT DebuggerRunTool : public ProjectExplorer::RunWorker Q_OBJECT public: - explicit DebuggerRunTool(ProjectExplorer::RunControl *runControl); + explicit DebuggerRunTool(ProjectExplorer::RunControl *runControl, + ProjectExplorer::Kit *kit = nullptr); ~DebuggerRunTool(); Internal::DebuggerEngine *engine() const { return m_engine; } Internal::DebuggerEngine *activeEngine() const; - static DebuggerRunTool *createFromRunConfiguration(ProjectExplorer::RunConfiguration *runConfig); - static DebuggerRunTool *createFromKit(ProjectExplorer::Kit *kit); // Avoid, it's guessing. void startRunControl(); void showMessage(const QString &msg, int channel = LogDebug, int timeout = -1); @@ -87,7 +86,6 @@ public: void prependInferiorCommandLineArgument(const QString &arg); void addQmlServerInferiorCommandLineArgumentIfNeeded(); - void setMasterEngineType(DebuggerEngineType engineType); void setCrashParameter(const QString &event); void addExpectedSignal(const QString &signal); @@ -129,7 +127,6 @@ public: void setNeedFixup(bool) {} // FIXME: Remove after use in QtAppMan is gone. void setTestCase(int testCase); void setOverrideStartScript(const QString &script); - void setToolChainAbi(const ProjectExplorer::Abi &abi); signals: void aboutToNotifyInferiorSetupOk(); diff --git a/src/plugins/debugger/gdb/gdbengine.cpp b/src/plugins/debugger/gdb/gdbengine.cpp index ece1d1c87c4..89f57b6d559 100644 --- a/src/plugins/debugger/gdb/gdbengine.cpp +++ b/src/plugins/debugger/gdb/gdbengine.cpp @@ -3293,8 +3293,9 @@ void GdbEngine::handleMakeSnapshot(const DebuggerResponse &response, const QStri const StackFrame &frame = frames.at(0); function = frame.function + ":" + QString::number(frame.line); } - auto debugger = DebuggerRunTool::createFromRunConfiguration(runControl()->runConfiguration()); - QTC_ASSERT(debugger, return); + QTC_ASSERT(runControl()->runConfiguration(), return); + auto rc = new RunControl(runControl()->runConfiguration(), ProjectExplorer::Constants::DEBUG_RUN_MODE); + auto debugger = new DebuggerRunTool(rc); debugger->setStartMode(AttachCore); debugger->setRunControlName(function + ": " + QDateTime::currentDateTime().toString()); debugger->setCoreFileName(coreFile, true); diff --git a/src/plugins/debugger/gdb/startgdbserverdialog.cpp b/src/plugins/debugger/gdb/startgdbserverdialog.cpp index 7a0c8c65e3f..a9596269ca5 100644 --- a/src/plugins/debugger/gdb/startgdbserverdialog.cpp +++ b/src/plugins/debugger/gdb/startgdbserverdialog.cpp @@ -209,9 +209,8 @@ void GdbServerStarter::attach(int port) QString remoteChannel = QString("%1:%2").arg(d->device->sshParameters().host).arg(port); - auto debugger = DebuggerRunTool::createFromKit(d->kit); - QTC_ASSERT(debugger, return); - debugger->setMasterEngineType(GdbEngineType); + auto runControl = new RunControl(nullptr, ProjectExplorer::Constants::DEBUG_RUN_MODE); + auto debugger = new DebuggerRunTool(runControl, d->kit); debugger->setRemoteChannel(remoteChannel); debugger->setRunControlName(tr("Remote: \"%1\"").arg(remoteChannel)); debugger->setInferiorExecutable(localExecutable);