forked from qt-creator/qt-creator
Debugger: Avoid use of dummy RunConfigurations
Allow to rely on kit plus data directly specified in the dialogs. This means, RunControls with nullptr RunConfigurations are allowed again. Change-Id: I0b574b397603c0520c8187a8967bff2cf5e20ae8 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -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()) {
|
||||
|
@@ -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<StandardRunnable>());
|
||||
debugger->setTestCase(TestNoBoundsOfCurrentFunction);
|
||||
|
||||
|
@@ -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<StandardRunnable>(), 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;
|
||||
|
@@ -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();
|
||||
|
@@ -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);
|
||||
|
@@ -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);
|
||||
|
Reference in New Issue
Block a user