diff options
Diffstat (limited to 'src/plugins/debugger/debuggerruncontrol.cpp')
-rw-r--r-- | src/plugins/debugger/debuggerruncontrol.cpp | 70 |
1 files changed, 34 insertions, 36 deletions
diff --git a/src/plugins/debugger/debuggerruncontrol.cpp b/src/plugins/debugger/debuggerruncontrol.cpp index ca76e8cfe1..f68d637e1f 100644 --- a/src/plugins/debugger/debuggerruncontrol.cpp +++ b/src/plugins/debugger/debuggerruncontrol.cpp @@ -31,6 +31,7 @@ #include "debuggeractions.h" #include "debuggercore.h" #include "debuggerengine.h" +#include "debuggerinternalconstants.h" #include "debuggerkitinformation.h" #include "debuggerplugin.h" #include "debuggerrunconfigurationaspect.h" @@ -97,8 +98,8 @@ class LocalProcessRunner : public RunWorker Q_DECLARE_TR_FUNCTIONS(Debugger::Internal::LocalProcessRunner) public: - LocalProcessRunner(DebuggerRunTool *runTool, const Runnable &runnable) - : RunWorker(runTool->runControl()), m_runTool(runTool), m_runnable(runnable) + LocalProcessRunner(DebuggerRunTool *runTool, const CommandLine &command) + : RunWorker(runTool->runControl()), m_runTool(runTool), m_command(command) { connect(&m_proc, &QProcess::errorOccurred, this, &LocalProcessRunner::handleError); @@ -112,7 +113,7 @@ public: void start() override { - m_proc.setCommand(m_runnable.executable, m_runnable.commandLineArguments); + m_proc.setCommand(m_command); m_proc.start(); } @@ -180,7 +181,7 @@ public: } QPointer<DebuggerRunTool> m_runTool; - Runnable m_runnable; + CommandLine m_command; Utils::QtcProcess m_proc; }; @@ -310,7 +311,7 @@ void DebuggerRunTool::setAttachPid(qint64 pid) m_runParameters.attachPID = ProcessHandle(pid); } -void DebuggerRunTool::setSysRoot(const Utils::FileName &sysRoot) +void DebuggerRunTool::setSysRoot(const Utils::FilePath &sysRoot) { m_runParameters.sysRoot = sysRoot; } @@ -399,14 +400,12 @@ void DebuggerRunTool::setCommandsForReset(const QString &commands) m_runParameters.commandsForReset = commands; } -void DebuggerRunTool::setServerStartScript(const QString &serverStartScript) +void DebuggerRunTool::setServerStartScript(const FilePath &serverStartScript) { if (!serverStartScript.isEmpty()) { // Provide script information about the environment - Runnable serverStarter; - serverStarter.executable = serverStartScript; - QtcProcess::addArg(&serverStarter.commandLineArguments, m_runParameters.inferior.executable); - QtcProcess::addArg(&serverStarter.commandLineArguments, m_runParameters.remoteChannel); + CommandLine serverStarter(serverStartScript, {}); + serverStarter.addArgs({m_runParameters.inferior.executable, m_runParameters.remoteChannel}); addStartDependency(new LocalProcessRunner(this, serverStarter)); } } @@ -516,15 +515,15 @@ void DebuggerRunTool::addExpectedSignal(const QString &signal) m_runParameters.expectedSignals.append(signal); } -void DebuggerRunTool::addSearchDirectory(const Utils::FileName &dir) +void DebuggerRunTool::addSearchDirectory(const Utils::FilePath &dir) { m_runParameters.additionalSearchDirectories.append(dir); } void DebuggerRunTool::start() { - TaskHub::clearTasks(Debugger::Constants::TASK_CATEGORY_DEBUGGER_DEBUGINFO); - TaskHub::clearTasks(Debugger::Constants::TASK_CATEGORY_DEBUGGER_RUNTIME); + TaskHub::clearTasks(Constants::TASK_CATEGORY_DEBUGGER_DEBUGINFO); + TaskHub::clearTasks(Constants::TASK_CATEGORY_DEBUGGER_RUNTIME); if (d->portsGatherer) { setRemoteChannel(d->portsGatherer->gdbServer()); @@ -648,7 +647,8 @@ void DebuggerRunTool::start() connect(m_engine, &DebuggerEngine::attachToCoreRequested, this, [this](const QString &coreFile) { auto runConfig = runControl()->runConfiguration(); QTC_ASSERT(runConfig, return); - auto rc = new RunControl(runConfig, ProjectExplorer::Constants::DEBUG_RUN_MODE); + auto rc = new RunControl(ProjectExplorer::Constants::DEBUG_RUN_MODE); + rc->setRunConfiguration(runConfig); auto name = QString(tr("%1 - Snapshot %2").arg(runControl()->displayName()).arg(++d->snapshotCounter)); auto debugger = new DebuggerRunTool(rc); debugger->setStartMode(AttachCore); @@ -884,7 +884,7 @@ Internal::TerminalRunner *DebuggerRunTool::terminalRunner() const return d->terminalRunner; } -DebuggerRunTool::DebuggerRunTool(RunControl *runControl, Kit *kit, bool allowTerminal) +DebuggerRunTool::DebuggerRunTool(RunControl *runControl, AllowTerminal allowTerminal) : RunWorker(runControl), d(new DebuggerRunToolPrivate) { setId("DebuggerRunTool"); @@ -897,8 +897,6 @@ DebuggerRunTool::DebuggerRunTool(RunControl *runControl, Kit *kit, bool allowTer d->runId = QString::number(++toolRunCount); - RunConfiguration *runConfig = runControl->runConfiguration(); - runControl->setIcon(ProjectExplorer::Icons::DEBUG_START_SMALL_TOOLBAR); runControl->setPromptToStop([](bool *optionalPrompt) { return RunControl::showPromptToStopDialog( @@ -910,27 +908,25 @@ DebuggerRunTool::DebuggerRunTool(RunControl *runControl, Kit *kit, bool allowTer QString(), QString(), optionalPrompt); }); - if (runConfig) { - m_runParameters.displayName = runConfig->displayName(); - if (auto symbolsAspect = runConfig->aspect<SymbolFileAspect>()) - m_runParameters.symbolFile = symbolsAspect->value(); - if (auto terminalAspect = runConfig->aspect<TerminalAspect>()) - m_runParameters.useTerminal = terminalAspect->useTerminal(); - } + m_runParameters.displayName = runControl->displayName(); - if (runConfig && !kit) - kit = runConfig->target()->kit(); + if (auto symbolsAspect = runControl->aspect<SymbolFileAspect>()) + m_runParameters.symbolFile = symbolsAspect->value(); + if (auto terminalAspect = runControl->aspect<TerminalAspect>()) + m_runParameters.useTerminal = terminalAspect->useTerminal(); + + Kit *kit = runControl->kit(); QTC_ASSERT(kit, return); - m_runParameters.sysRoot = SysRootKitInformation::sysRoot(kit); + m_runParameters.sysRoot = SysRootKitAspect::sysRoot(kit); m_runParameters.macroExpander = kit->macroExpander(); - m_runParameters.debugger = DebuggerKitInformation::runnable(kit); - m_runParameters.cppEngineType = DebuggerKitInformation::engineType(kit); + m_runParameters.debugger = DebuggerKitAspect::runnable(kit); + m_runParameters.cppEngineType = DebuggerKitAspect::engineType(kit); - if (QtSupport::BaseQtVersion *qtVersion = QtSupport::QtKitInformation::qtVersion(kit)) + if (QtSupport::BaseQtVersion *qtVersion = QtSupport::QtKitAspect::qtVersion(kit)) m_runParameters.qtPackageSourceLocation = qtVersion->qtPackageSourcePath().toString(); - if (auto aspect = runConfig ? runConfig->aspect<DebuggerRunConfigurationAspect>() : nullptr) { + if (auto aspect = runControl->aspect<DebuggerRunConfigurationAspect>()) { if (!aspect->useCppDebugger()) m_runParameters.cppEngineType = NoEngineType; m_runParameters.isQmlDebugging = aspect->useQmlDebugger(); @@ -941,19 +937,18 @@ DebuggerRunTool::DebuggerRunTool(RunControl *runControl, Kit *kit, bool allowTer // Normalize to work around QTBUG-17529 (QtDeclarative fails with 'File name case mismatch'...) m_runParameters.inferior.workingDirectory = FileUtils::normalizePathName(m_runParameters.inferior.workingDirectory); - setUseTerminal(allowTerminal && m_runParameters.useTerminal); + setUseTerminal(allowTerminal == DoAllowTerminal && m_runParameters.useTerminal); const QByteArray envBinary = qgetenv("QTC_DEBUGGER_PATH"); if (!envBinary.isEmpty()) m_runParameters.debugger.executable = QString::fromLocal8Bit(envBinary); - Project *project = runConfig ? runConfig->target()->project() : nullptr; - if (project) { + if (Project *project = runControl->project()) { m_runParameters.projectSourceDirectory = project->projectDirectory(); m_runParameters.projectSourceFiles = project->files(Project::SourceFiles); } - m_runParameters.toolChainAbi = ToolChainKitInformation::targetAbi(kit); + m_runParameters.toolChainAbi = ToolChainKitAspect::targetAbi(kit); bool ok = false; int nativeMixedOverride = qgetenv("QTC_DEBUGGER_NATIVE_MIXED").toInt(&ok); @@ -962,12 +957,13 @@ DebuggerRunTool::DebuggerRunTool(RunControl *runControl, Kit *kit, bool allowTer // This will only be shown in some cases, but we don't want to access // the kit at that time anymore. - const QList<Task> tasks = DebuggerKitInformation::validateDebugger(kit); + const Tasks tasks = DebuggerKitAspect::validateDebugger(kit); for (const Task &t : tasks) { if (t.type != Task::Warning) m_runParameters.validationErrors.append(t.description); } + RunConfiguration *runConfig = runControl->runConfiguration(); if (runConfig && runConfig->property("supportsDebugger").toBool()) { const QString mainScript = runConfig->property("mainScript").toString(); const QString interpreter = runConfig->property("interpreter").toString(); @@ -1015,6 +1011,8 @@ void DebuggerRunTool::showMessage(const QString &msg, int channel, int timeout) if (channel == ConsoleOutput) debuggerConsole()->printItem(ConsoleItem::DefaultType, msg); + QTC_ASSERT(m_engine, qDebug() << msg; return); + m_engine->showMessage(msg, channel, timeout); if (m_engine2) m_engine->showMessage(msg, channel, timeout); |