Debugger: Pass RunControl in DebuggerStartParameters

.. to simplify DebuggerRunControlFactory::doCreate() call.

Change-Id: I4dd0c224968bb8a388ea7f095b940b66ee606ab1
Reviewed-by: Christian Stenger <christian.stenger@theqtcompany.com>
This commit is contained in:
hjk
2015-02-10 13:21:22 +01:00
parent 807c3a5ad2
commit bf6aa3cc2b
13 changed files with 74 additions and 67 deletions

View File

@@ -89,6 +89,7 @@ RunControl *AndroidDebugSupport::createDebugRunControl(AndroidRunConfiguration *
params.startMode = AttachToRemoteServer; params.startMode = AttachToRemoteServer;
params.displayName = AndroidManager::packageName(target); params.displayName = AndroidManager::packageName(target);
params.remoteSetupNeeded = true; params.remoteSetupNeeded = true;
params.runConfiguration = runConfig;
DebuggerRunConfigurationAspect *aspect DebuggerRunConfigurationAspect *aspect
= runConfig->extraAspect<DebuggerRunConfigurationAspect>(); = runConfig->extraAspect<DebuggerRunConfigurationAspect>();
@@ -119,7 +120,7 @@ RunControl *AndroidDebugSupport::createDebugRunControl(AndroidRunConfiguration *
} }
DebuggerRunControl * const debuggerRunControl DebuggerRunControl * const debuggerRunControl
= DebuggerRunControlFactory::doCreate(params, runConfig, errorMessage); = DebuggerRunControlFactory::doCreate(params, errorMessage);
new AndroidDebugSupport(runConfig, debuggerRunControl); new AndroidDebugSupport(runConfig, debuggerRunControl);
return debuggerRunControl; return debuggerRunControl;
} }

View File

@@ -156,8 +156,8 @@ RunControl *BareMetalRunControlFactory::create(
if (p->startupMode() == GdbServerProvider::StartupOnNetwork) if (p->startupMode() == GdbServerProvider::StartupOnNetwork)
sp.remoteSetupNeeded = true; sp.remoteSetupNeeded = true;
DebuggerRunControl *runControl = sp.runConfiguration = rc;
DebuggerRunControlFactory::doCreate(sp, rc, errorMessage); DebuggerRunControl *runControl = DebuggerRunControlFactory::doCreate(sp, errorMessage);
if (runControl && sp.remoteSetupNeeded) { if (runControl && sp.remoteSetupNeeded) {
const auto debugSupport = new BareMetalDebugSupport(dev, runControl); const auto debugSupport = new BareMetalDebugSupport(dev, runControl);
Q_UNUSED(debugSupport); Q_UNUSED(debugSupport);

View File

@@ -378,11 +378,12 @@ RunControl *DebuggerRunControlFactory::create
if (mode == DebugRunModeWithBreakOnMain) if (mode == DebugRunModeWithBreakOnMain)
sp.breakOnMain = true; sp.breakOnMain = true;
return doCreate(sp, runConfiguration, errorMessage); sp.runConfiguration = runConfiguration;
return doCreate(sp, errorMessage);
} }
DebuggerRunControl *DebuggerRunControlFactory::doCreate DebuggerRunControl *DebuggerRunControlFactory::doCreate
(const DebuggerStartParameters &sp0, RunConfiguration *rc, QString *errorMessage) (const DebuggerStartParameters &sp0, QString *errorMessage)
{ {
TaskHub::clearTasks(Debugger::Constants::TASK_CATEGORY_DEBUGGER_DEBUGINFO); TaskHub::clearTasks(Debugger::Constants::TASK_CATEGORY_DEBUGGER_DEBUGINFO);
TaskHub::clearTasks(Debugger::Constants::TASK_CATEGORY_DEBUGGER_RUNTIME); TaskHub::clearTasks(Debugger::Constants::TASK_CATEGORY_DEBUGGER_RUNTIME);
@@ -406,7 +407,7 @@ DebuggerRunControl *DebuggerRunControlFactory::doCreate
if (sp.executable.endsWith(_(".py"))) { if (sp.executable.endsWith(_(".py"))) {
sp.masterEngineType = PdbEngineType; sp.masterEngineType = PdbEngineType;
} else { } else {
if (rc) { if (RunConfiguration *rc = sp.runConfiguration) {
DebuggerRunConfigurationAspect *aspect DebuggerRunConfigurationAspect *aspect
= rc->extraAspect<Debugger::DebuggerRunConfigurationAspect>(); = rc->extraAspect<Debugger::DebuggerRunConfigurationAspect>();
if (const Target *target = rc->target()) if (const Target *target = rc->target())
@@ -438,7 +439,7 @@ DebuggerRunControl *DebuggerRunControlFactory::doCreate
*errorMessage = error; *errorMessage = error;
return 0; return 0;
} }
return new DebuggerRunControl(rc, engine); return new DebuggerRunControl(sp.runConfiguration, engine);
} }
IRunConfigurationAspect *DebuggerRunControlFactory::createRunConfigurationAspect(RunConfiguration *rc) IRunConfigurationAspect *DebuggerRunControlFactory::createRunConfigurationAspect(RunConfiguration *rc)
@@ -449,7 +450,7 @@ IRunConfigurationAspect *DebuggerRunControlFactory::createRunConfigurationAspect
DebuggerRunControl *DebuggerRunControlFactory::createAndScheduleRun(const DebuggerStartParameters &sp) DebuggerRunControl *DebuggerRunControlFactory::createAndScheduleRun(const DebuggerStartParameters &sp)
{ {
QString errorMessage; QString errorMessage;
DebuggerRunControl *rc = doCreate(sp, 0, &errorMessage); DebuggerRunControl *rc = doCreate(sp, &errorMessage);
if (!rc) { if (!rc) {
ProjectExplorerPlugin::showRunErrorMessage(errorMessage); ProjectExplorerPlugin::showRunErrorMessage(errorMessage);
return 0; return 0;

View File

@@ -118,8 +118,7 @@ public:
static DebuggerRunControl *createAndScheduleRun(const DebuggerStartParameters &sp); static DebuggerRunControl *createAndScheduleRun(const DebuggerStartParameters &sp);
static DebuggerRunControl *doCreate(const DebuggerStartParameters &sp, static DebuggerRunControl *doCreate(const DebuggerStartParameters &sp, QString *errorMessage);
ProjectExplorer::RunConfiguration *rc, QString *errorMessage);
ProjectExplorer::IRunConfigurationAspect *createRunConfigurationAspect( ProjectExplorer::IRunConfigurationAspect *createRunConfigurationAspect(
ProjectExplorer::RunConfiguration *rc); ProjectExplorer::RunConfiguration *rc);

View File

@@ -39,6 +39,7 @@
#include <utils/environment.h> #include <utils/environment.h>
#include <projectexplorer/abi.h> #include <projectexplorer/abi.h>
#include <projectexplorer/kit.h> #include <projectexplorer/kit.h>
#include <projectexplorer/runconfiguration.h>
#include <projectexplorer/devicesupport/idevice.h> #include <projectexplorer/devicesupport/idevice.h>
#include <QMetaType> #include <QMetaType>
@@ -82,6 +83,7 @@ public:
firstSlaveEngineType(NoEngineType), firstSlaveEngineType(NoEngineType),
secondSlaveEngineType(NoEngineType), secondSlaveEngineType(NoEngineType),
cppEngineType(NoEngineType), cppEngineType(NoEngineType),
runConfiguration(0),
isSnapshot(false), isSnapshot(false),
attachPID(-1), attachPID(-1),
useTerminal(false), useTerminal(false),
@@ -112,6 +114,7 @@ public:
QString debuggerCommand; QString debuggerCommand;
ProjectExplorer::Abi toolChainAbi; ProjectExplorer::Abi toolChainAbi;
ProjectExplorer::IDevice::ConstPtr device; ProjectExplorer::IDevice::ConstPtr device;
QPointer<ProjectExplorer::RunConfiguration> runConfiguration;
QString platform; QString platform;
QString executable; QString executable;

View File

@@ -118,6 +118,7 @@ RunControl *IosDebugSupport::createDebugRunControl(IosRunConfiguration *runConfi
params.remoteSetupNeeded = true; params.remoteSetupNeeded = true;
if (!params.breakOnMain) if (!params.breakOnMain)
params.continueAfterAttach = true; params.continueAfterAttach = true;
params.runConfiguration = runConfig;
DebuggerRunConfigurationAspect *aspect DebuggerRunConfigurationAspect *aspect
= runConfig->extraAspect<DebuggerRunConfigurationAspect>(); = runConfig->extraAspect<DebuggerRunConfigurationAspect>();
@@ -170,7 +171,7 @@ RunControl *IosDebugSupport::createDebugRunControl(IosRunConfiguration *runConfi
} }
DebuggerRunControl * const debuggerRunControl DebuggerRunControl * const debuggerRunControl
= DebuggerRunControlFactory::doCreate(params, runConfig, errorMessage); = DebuggerRunControlFactory::doCreate(params, errorMessage);
if (debuggerRunControl) if (debuggerRunControl)
new IosDebugSupport(runConfig, debuggerRunControl, cppDebug, qmlDebug); new IosDebugSupport(runConfig, debuggerRunControl, cppDebug, qmlDebug);
return debuggerRunControl; return debuggerRunControl;

View File

@@ -114,6 +114,53 @@ static void createAnalyzerStartParameters(Analyzer::AnalyzerStartParameters *pSt
pStartParameters->analyzerPort = aspect->qmlDebugServerPort(); pStartParameters->analyzerPort = aspect->qmlDebugServerPort();
} }
static Debugger::DebuggerStartParameters startParameters(BlackBerryRunConfiguration *runConfig)
{
Debugger::DebuggerStartParameters params;
ProjectExplorer::Target *target = runConfig->target();
ProjectExplorer::Kit *k = target->kit();
params.startMode = Debugger::AttachToRemoteServer;
params.debuggerCommand = Debugger::DebuggerKitInformation::debuggerCommand(k).toString();
params.sysRoot = ProjectExplorer::SysRootKitInformation::sysRoot(k).toString();
params.useCtrlCStub = true;
params.runConfiguration = runConfig;
if (ProjectExplorer::ToolChain *tc = ProjectExplorer::ToolChainKitInformation::toolChain(k))
params.toolChainAbi = tc->targetAbi();
params.executable = runConfig->localExecutableFilePath();
params.displayName = runConfig->displayName();
params.remoteSetupNeeded = true;
Debugger::DebuggerRunConfigurationAspect *aspect
= runConfig->extraAspect<Debugger::DebuggerRunConfigurationAspect>();
if (aspect->useQmlDebugger()) {
BlackBerryDeviceConfiguration::ConstPtr device = BlackBerryDeviceConfiguration::device(runConfig->target()->kit());
if (device) {
params.qmlServerAddress = device->sshParameters().host;
params.qmlServerPort = aspect->qmlDebugServerPort();
params.languages |= Debugger::QmlLanguage;
}
}
if (aspect->useCppDebugger())
params.languages |= Debugger::CppLanguage;
if (const ProjectExplorer::Project *project = runConfig->target()->project()) {
params.projectSourceDirectory = project->projectDirectory().toString();
if (const ProjectExplorer::BuildConfiguration *buildConfig = runConfig->target()->activeBuildConfiguration())
params.projectBuildDirectory = buildConfig->buildDirectory().toString();
params.projectSourceFiles = project->files(ProjectExplorer::Project::ExcludeGeneratedFiles);
}
BlackBerryQtVersion *qtVersion =
dynamic_cast<BlackBerryQtVersion *>(QtSupport::QtKitInformation::qtVersion(k));
if (qtVersion)
params.solibSearchPath = QnxUtils::searchPaths(qtVersion);
return params;
}
ProjectExplorer::RunControl *BlackBerryRunControlFactory::create(ProjectExplorer::RunConfiguration *runConfiguration, ProjectExplorer::RunControl *BlackBerryRunControlFactory::create(ProjectExplorer::RunConfiguration *runConfiguration,
ProjectExplorer::RunMode mode, QString *errorMessage) ProjectExplorer::RunMode mode, QString *errorMessage)
{ {
@@ -161,7 +208,7 @@ ProjectExplorer::RunControl *BlackBerryRunControlFactory::create(ProjectExplorer
return runControl; return runControl;
} }
Debugger::DebuggerRunControl * const runControl = Debugger::DebuggerRunControl * const runControl =
Debugger::DebuggerRunControlFactory::doCreate(startParameters(rc), runConfiguration, errorMessage); Debugger::DebuggerRunControlFactory::doCreate(startParameters(rc), errorMessage);
if (!runControl) if (!runControl)
return 0; return 0;
@@ -169,50 +216,3 @@ ProjectExplorer::RunControl *BlackBerryRunControlFactory::create(ProjectExplorer
m_activeRunControls[rc->key()] = runControl; m_activeRunControls[rc->key()] = runControl;
return runControl; return runControl;
} }
Debugger::DebuggerStartParameters BlackBerryRunControlFactory::startParameters(
const BlackBerryRunConfiguration *runConfig)
{
Debugger::DebuggerStartParameters params;
ProjectExplorer::Target *target = runConfig->target();
ProjectExplorer::Kit *k = target->kit();
params.startMode = Debugger::AttachToRemoteServer;
params.debuggerCommand = Debugger::DebuggerKitInformation::debuggerCommand(k).toString();
params.sysRoot = ProjectExplorer::SysRootKitInformation::sysRoot(k).toString();
params.useCtrlCStub = true;
if (ProjectExplorer::ToolChain *tc = ProjectExplorer::ToolChainKitInformation::toolChain(k))
params.toolChainAbi = tc->targetAbi();
params.executable = runConfig->localExecutableFilePath();
params.displayName = runConfig->displayName();
params.remoteSetupNeeded = true;
Debugger::DebuggerRunConfigurationAspect *aspect
= runConfig->extraAspect<Debugger::DebuggerRunConfigurationAspect>();
if (aspect->useQmlDebugger()) {
BlackBerryDeviceConfiguration::ConstPtr device = BlackBerryDeviceConfiguration::device(runConfig->target()->kit());
if (device) {
params.qmlServerAddress = device->sshParameters().host;
params.qmlServerPort = aspect->qmlDebugServerPort();
params.languages |= Debugger::QmlLanguage;
}
}
if (aspect->useCppDebugger())
params.languages |= Debugger::CppLanguage;
if (const ProjectExplorer::Project *project = runConfig->target()->project()) {
params.projectSourceDirectory = project->projectDirectory().toString();
if (const ProjectExplorer::BuildConfiguration *buildConfig = runConfig->target()->activeBuildConfiguration())
params.projectBuildDirectory = buildConfig->buildDirectory().toString();
params.projectSourceFiles = project->files(ProjectExplorer::Project::ExcludeGeneratedFiles);
}
BlackBerryQtVersion *qtVersion =
dynamic_cast<BlackBerryQtVersion *>(QtSupport::QtKitInformation::qtVersion(k));
if (qtVersion)
params.solibSearchPath = QnxUtils::searchPaths(qtVersion);
return params;
}

View File

@@ -58,8 +58,6 @@ public:
QString *errorMessage); QString *errorMessage);
private: private:
static Debugger::DebuggerStartParameters startParameters( const BlackBerryRunConfiguration *runConfig);
mutable QMap<QString, QPointer<ProjectExplorer::RunControl> > m_activeRunControls; mutable QMap<QString, QPointer<ProjectExplorer::RunControl> > m_activeRunControls;
}; };

View File

@@ -132,7 +132,7 @@ void QnxAttachDebugSupport::attachToProcess()
sp.solibSearchPath = QnxUtils::searchPaths(qtVersion); sp.solibSearchPath = QnxUtils::searchPaths(qtVersion);
QString errorMessage; QString errorMessage;
Debugger::DebuggerRunControl * const runControl = Debugger::DebuggerRunControlFactory::doCreate(sp, 0, &errorMessage); Debugger::DebuggerRunControl * const runControl = Debugger::DebuggerRunControlFactory::doCreate(sp, &errorMessage);
if (!errorMessage.isEmpty()) { if (!errorMessage.isEmpty()) {
handleError(errorMessage); handleError(errorMessage);
stopPDebug(); stopPDebug();

View File

@@ -62,7 +62,7 @@ using namespace ProjectExplorer;
using namespace Qnx; using namespace Qnx;
using namespace Qnx::Internal; using namespace Qnx::Internal;
static DebuggerStartParameters createDebuggerStartParameters(const QnxRunConfiguration *runConfig) static DebuggerStartParameters createDebuggerStartParameters(QnxRunConfiguration *runConfig)
{ {
DebuggerStartParameters params; DebuggerStartParameters params;
Target *target = runConfig->target(); Target *target = runConfig->target();
@@ -76,6 +76,7 @@ static DebuggerStartParameters createDebuggerStartParameters(const QnxRunConfigu
params.debuggerCommand = DebuggerKitInformation::debuggerCommand(k).toString(); params.debuggerCommand = DebuggerKitInformation::debuggerCommand(k).toString();
params.sysRoot = SysRootKitInformation::sysRoot(k).toString(); params.sysRoot = SysRootKitInformation::sysRoot(k).toString();
params.useCtrlCStub = true; params.useCtrlCStub = true;
params.runConfiguration = runConfig;
if (ToolChain *tc = ToolChainKitInformation::toolChain(k)) if (ToolChain *tc = ToolChainKitInformation::toolChain(k))
params.toolChainAbi = tc->targetAbi(); params.toolChainAbi = tc->targetAbi();
@@ -179,7 +180,7 @@ RunControl *QnxRunControlFactory::create(RunConfiguration *runConfig, RunMode mo
return new QnxRunControl(rc); return new QnxRunControl(rc);
case DebugRunMode: { case DebugRunMode: {
const DebuggerStartParameters params = createDebuggerStartParameters(rc); const DebuggerStartParameters params = createDebuggerStartParameters(rc);
DebuggerRunControl * const runControl = DebuggerRunControlFactory::doCreate(params, rc, errorMessage); DebuggerRunControl * const runControl = DebuggerRunControlFactory::doCreate(params, errorMessage);
if (!runControl) if (!runControl)
return 0; return 0;

View File

@@ -106,8 +106,9 @@ RunControl *RemoteLinuxRunControlFactory::create(RunConfiguration *runConfig, Ru
DebuggerStartParameters params = LinuxDeviceDebugSupport::startParameters(rc); DebuggerStartParameters params = LinuxDeviceDebugSupport::startParameters(rc);
if (mode == DebugRunModeWithBreakOnMain) if (mode == DebugRunModeWithBreakOnMain)
params.breakOnMain = true; params.breakOnMain = true;
params.runConfiguration = rc;
DebuggerRunControl * const runControl DebuggerRunControl * const runControl
= DebuggerRunControlFactory::doCreate(params, rc, errorMessage); = DebuggerRunControlFactory::doCreate(params, errorMessage);
if (!runControl) if (!runControl)
return 0; return 0;
LinuxDeviceDebugSupport * const debugSupport = LinuxDeviceDebugSupport * const debugSupport =

View File

@@ -189,9 +189,10 @@ void MemcheckWithGdbRunControl::startDebugger()
sp.remoteChannel = QString::fromLatin1("| vgdb --pid=%1").arg(valgrindPid); sp.remoteChannel = QString::fromLatin1("| vgdb --pid=%1").arg(valgrindPid);
sp.useContinueInsteadOfRun = true; sp.useContinueInsteadOfRun = true;
sp.expectedSignals << "SIGTRAP"; sp.expectedSignals << "SIGTRAP";
sp.runConfiguration = rc;
QString errorMessage; QString errorMessage;
RunControl *gdbRunControl = Debugger::DebuggerRunControlFactory::doCreate(sp, rc, &errorMessage); RunControl *gdbRunControl = Debugger::DebuggerRunControlFactory::doCreate(sp, &errorMessage);
QTC_ASSERT(gdbRunControl, return); QTC_ASSERT(gdbRunControl, return);
connect(gdbRunControl, &RunControl::finished, connect(gdbRunControl, &RunControl::finished,
gdbRunControl, &RunControl::deleteLater); gdbRunControl, &RunControl::deleteLater);

View File

@@ -119,8 +119,9 @@ RunControl *WinRtDebugSupport::createDebugRunControl(WinRtRunConfiguration *runC
return 0; return 0;
} }
server.close(); server.close();
params.runConfiguration = runConfig;
Debugger::DebuggerRunControl *debugRunControl Debugger::DebuggerRunControl *debugRunControl
= DebuggerRunControlFactory::doCreate(params, runConfig, errorMessage); = DebuggerRunControlFactory::doCreate(params, errorMessage);
runner->setRunControl(debugRunControl); runner->setRunControl(debugRunControl);
new WinRtDebugSupport(debugRunControl, runner); new WinRtDebugSupport(debugRunControl, runner);
return debugRunControl; return debugRunControl;