forked from qt-creator/qt-creator
Debugger: Dissolve createAndScheduleRun()
... into DebuggerRunTool creation and explicit RunParameter bulk setting, which later is to be replaced by setting individual parameters. Change-Id: Ic4d2c6d10d659287ae61fdb4db735e658e3a68ce Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -462,8 +462,6 @@ private:
|
||||
QPointer<DebuggerEngine> m_engine;
|
||||
};
|
||||
|
||||
ProjectExplorer::RunControl *createAndScheduleRun(const DebuggerRunParameters &rp, ProjectExplorer::Kit *kit);
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace Debugger
|
||||
|
||||
|
@@ -1940,8 +1940,12 @@ void DebuggerPluginPrivate::startAndDebugApplication()
|
||||
{
|
||||
DebuggerRunParameters rp;
|
||||
Kit *kit;
|
||||
if (StartApplicationDialog::run(ICore::dialogParent(), &rp, &kit))
|
||||
createAndScheduleRun(rp, kit);
|
||||
if (StartApplicationDialog::run(ICore::dialogParent(), &rp, &kit)) {
|
||||
auto debugger = DebuggerRunTool::createFromKit(kit);
|
||||
QTC_ASSERT(debugger, return);
|
||||
debugger->setRunParameters(rp);
|
||||
debugger->startRunControl();
|
||||
}
|
||||
}
|
||||
|
||||
void DebuggerPluginPrivate::attachCore()
|
||||
@@ -1976,7 +1980,11 @@ void DebuggerPluginPrivate::attachCore()
|
||||
rp.startMode = AttachCore;
|
||||
rp.closeMode = DetachAtClose;
|
||||
rp.overrideStartScript = dlg.overrideStartScript();
|
||||
createAndScheduleRun(rp, dlg.kit());
|
||||
|
||||
auto debugger = DebuggerRunTool::createFromKit(dlg.kit());
|
||||
QTC_ASSERT(debugger, return);
|
||||
debugger->setRunParameters(rp);
|
||||
debugger->startRunControl();
|
||||
}
|
||||
|
||||
void DebuggerPluginPrivate::startRemoteCdbSession()
|
||||
@@ -1996,7 +2004,11 @@ void DebuggerPluginPrivate::startRemoteCdbSession()
|
||||
return;
|
||||
rp.remoteChannel = dlg.connection();
|
||||
setConfigValue(connectionKey, rp.remoteChannel);
|
||||
createAndScheduleRun(rp, kit);
|
||||
|
||||
auto debugger = DebuggerRunTool::createFromKit(kit);
|
||||
QTC_ASSERT(debugger, return);
|
||||
debugger->setRunParameters(rp);
|
||||
debugger->startRunControl();
|
||||
}
|
||||
|
||||
void DebuggerPluginPrivate::attachToRemoteServer()
|
||||
@@ -2007,7 +2019,10 @@ void DebuggerPluginPrivate::attachToRemoteServer()
|
||||
rp.useContinueInsteadOfRun = true;
|
||||
if (StartApplicationDialog::run(ICore::dialogParent(), &rp, &kit)) {
|
||||
rp.closeMode = KillAtClose;
|
||||
createAndScheduleRun(rp, kit);
|
||||
auto debugger = DebuggerRunTool::createFromKit(kit);
|
||||
QTC_ASSERT(debugger, return);
|
||||
debugger->setRunParameters(rp);
|
||||
debugger->startRunControl();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2112,7 +2127,13 @@ RunControl *DebuggerPluginPrivate::attachToRunningProcess(Kit *kit,
|
||||
rp.startMode = AttachExternal;
|
||||
rp.closeMode = DetachAtClose;
|
||||
rp.continueAfterAttach = contAfterAttach;
|
||||
return createAndScheduleRun(rp, kit);
|
||||
|
||||
auto debugger = DebuggerRunTool::createFromKit(kit);
|
||||
QTC_ASSERT(debugger, return nullptr);
|
||||
debugger->setRunParameters(rp);
|
||||
debugger->startRunControl();
|
||||
|
||||
return debugger->runControl();
|
||||
}
|
||||
|
||||
void DebuggerPlugin::attachExternalApplication(RunControl *rc)
|
||||
@@ -2124,13 +2145,16 @@ void DebuggerPlugin::attachExternalApplication(RunControl *rc)
|
||||
rp.closeMode = DetachAtClose;
|
||||
rp.toolChainAbi = rc->abi();
|
||||
rp.languages = CppLanguage;
|
||||
DebuggerRunTool *debugger;
|
||||
if (RunConfiguration *runConfig = rc->runConfiguration()) {
|
||||
auto runControl = new RunControl(runConfig, ProjectExplorer::Constants::DEBUG_RUN_MODE);
|
||||
(void) new DebuggerRunTool(runControl, rp);
|
||||
ProjectExplorerPlugin::startRunControl(runControl);
|
||||
debugger = DebuggerRunTool::createFromRunConfiguration(runConfig);
|
||||
} else {
|
||||
createAndScheduleRun(rp, guessKitFromParameters(rp));
|
||||
Kit *kit = guessKitFromParameters(rp);
|
||||
debugger = DebuggerRunTool::createFromKit(kit);
|
||||
QTC_ASSERT(debugger, return);
|
||||
}
|
||||
debugger->setRunParameters(rp);
|
||||
debugger->startRunControl();
|
||||
}
|
||||
|
||||
void DebuggerPlugin::getEnginesState(QByteArray *json) const
|
||||
@@ -2210,7 +2234,11 @@ void DebuggerPluginPrivate::attachToQmlPort()
|
||||
rp.projectSourceDirectory =
|
||||
!projects.isEmpty() ? projects.first()->projectDirectory().toString() : QString();
|
||||
rp.projectSourceFiles = sourceFiles;
|
||||
createAndScheduleRun(rp, kit);
|
||||
|
||||
auto debugger = DebuggerRunTool::createFromKit(kit);
|
||||
QTC_ASSERT(debugger, return);
|
||||
debugger->setRunParameters(rp);
|
||||
debugger->startRunControl();
|
||||
}
|
||||
|
||||
void DebuggerPluginPrivate::enableReverseDebuggingTriggered(const QVariant &value)
|
||||
@@ -2223,8 +2251,12 @@ void DebuggerPluginPrivate::enableReverseDebuggingTriggered(const QVariant &valu
|
||||
|
||||
void DebuggerPluginPrivate::runScheduled()
|
||||
{
|
||||
for (const QPair<DebuggerRunParameters, Kit *> pair : m_scheduledStarts)
|
||||
createAndScheduleRun(pair.first, pair.second);
|
||||
for (const QPair<DebuggerRunParameters, Kit *> pair : m_scheduledStarts) {
|
||||
auto debugger = DebuggerRunTool::createFromKit(pair.second);
|
||||
QTC_ASSERT(debugger, return);
|
||||
debugger->setRunParameters(pair.first);
|
||||
debugger->startRunControl();
|
||||
}
|
||||
}
|
||||
|
||||
void DebuggerPluginPrivate::editorOpened(IEditor *editor)
|
||||
|
@@ -831,6 +831,45 @@ 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;
|
||||
@@ -876,44 +915,6 @@ void DebuggerRunTool::showMessage(const QString &msg, int channel, int timeout)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace Internal {
|
||||
|
||||
/**
|
||||
* Used for direct "special" starts from actions in the debugger plugin.
|
||||
*/
|
||||
|
||||
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;
|
||||
target = project->createTarget(kit);
|
||||
}
|
||||
QTC_ASSERT(target, return nullptr);
|
||||
auto runConfig = target->activeRunConfiguration();
|
||||
return runConfig;
|
||||
}
|
||||
|
||||
RunControl *createAndScheduleRun(const DebuggerRunParameters &rp, Kit *kit)
|
||||
{
|
||||
RunConfiguration *runConfig = dummyRunConfigForKit(kit);
|
||||
QTC_ASSERT(runConfig, return nullptr);
|
||||
auto runControl = new RunControl(runConfig, ProjectExplorer::Constants::DEBUG_RUN_MODE);
|
||||
(void) new DebuggerRunTool(runControl, rp);
|
||||
ProjectExplorerPlugin::startRunControl(runControl);
|
||||
return runControl;
|
||||
}
|
||||
|
||||
} // Internal
|
||||
|
||||
// GdbServerPortGatherer
|
||||
|
||||
GdbServerPortsGatherer::GdbServerPortsGatherer(RunControl *runControl)
|
||||
|
@@ -55,6 +55,10 @@ public:
|
||||
Internal::DebuggerEngine *engine() const { return m_engine; }
|
||||
Internal::DebuggerEngine *activeEngine() const;
|
||||
|
||||
static DebuggerRunTool *createFromRunConfiguration(ProjectExplorer::RunConfiguration *runConfig);
|
||||
static DebuggerRunTool *createFromKit(ProjectExplorer::Kit *kit);
|
||||
void startRunControl();
|
||||
|
||||
void showMessage(const QString &msg, int channel = LogDebug, int timeout = -1);
|
||||
|
||||
void start() override;
|
||||
|
@@ -214,7 +214,11 @@ void GdbServerStarter::attach(int port)
|
||||
rp.inferior.executable = localExecutable;
|
||||
rp.startMode = AttachToRemoteServer;
|
||||
rp.closeMode = KillAtClose;
|
||||
createAndScheduleRun(rp, d->kit);
|
||||
|
||||
auto debugger = DebuggerRunTool::createFromKit(d->kit);
|
||||
QTC_ASSERT(debugger, return);
|
||||
debugger->setRunParameters(rp);
|
||||
debugger->startRunControl();
|
||||
}
|
||||
|
||||
void GdbServerStarter::handleProcessClosed(int status)
|
||||
|
Reference in New Issue
Block a user