Commit b7563b3d authored by hjk's avatar hjk

debugger: streamline RunControl creation a bit

parent 628cf52f
......@@ -76,75 +76,39 @@ QString DebuggerRunControlFactory::displayName() const
return tr("Debug");
}
RunControl *DebuggerRunControlFactory::create(const DebuggerStartParametersPtr &sp)
static DebuggerStartParametersPtr localStartParameters(RunConfiguration *runConfiguration)
{
return new DebuggerRunControl(m_manager, sp);
}
RunControl *DebuggerRunControlFactory::create(RunConfiguration *runConfiguration,
const QString &mode)
{
QTC_ASSERT(mode == ProjectExplorer::Constants::DEBUGMODE, return 0);
LocalApplicationRunConfiguration *rc = qobject_cast<LocalApplicationRunConfiguration *>(runConfiguration);
QTC_ASSERT(rc, return 0);
return new DebuggerRunControl(m_manager, rc);
}
DebuggerStartParametersPtr sp(new DebuggerStartParameters());
QTC_ASSERT(runConfiguration, return sp);
LocalApplicationRunConfiguration *rc =
qobject_cast<LocalApplicationRunConfiguration *>(runConfiguration);
QTC_ASSERT(rc, return sp);
QWidget *DebuggerRunControlFactory::createConfigurationWidget(RunConfiguration *runConfiguration)
{
// NBS TODO: Add GDB-specific configuration widget
Q_UNUSED(runConfiguration)
return 0;
}
////////////////////////////////////////////////////////////////////////
//
// DebuggerRunControl
//
////////////////////////////////////////////////////////////////////////
DebuggerRunControl::DebuggerRunControl(DebuggerManager *manager,
LocalApplicationRunConfiguration *runConfiguration)
: RunControl(runConfiguration, ProjectExplorer::Constants::DEBUGMODE),
m_startParameters(new DebuggerStartParameters()),
m_manager(manager),
m_running(false)
{
init();
if (!runConfiguration)
return;
sp->startMode = StartInternal;
sp->executable = rc->executable();
sp->environment = rc->environment().toStringList();
sp->workingDirectory = rc->workingDirectory();
sp->processArgs = rc->commandLineArguments();
m_startParameters->startMode = StartInternal;
m_startParameters->executable = runConfiguration->executable();
m_startParameters->environment = runConfiguration->environment().toStringList();
m_startParameters->workingDirectory = runConfiguration->workingDirectory();
m_startParameters->processArgs = runConfiguration->commandLineArguments();
switch (m_startParameters->toolChainType) {
switch (sp->toolChainType) {
case ProjectExplorer::ToolChain::UNKNOWN:
case ProjectExplorer::ToolChain::INVALID:
m_startParameters->toolChainType = runConfiguration->toolChainType();
sp->toolChainType = rc->toolChainType();
break;
default:
break;
}
if (runConfiguration->target()->project()) {
BuildConfiguration *bc = runConfiguration->target()->activeBuildConfiguration();
if (rc->target()->project()) {
BuildConfiguration *bc = rc->target()->activeBuildConfiguration();
if (bc)
m_startParameters->buildDirectory = bc->buildDirectory();
sp->buildDirectory = bc->buildDirectory();
}
m_startParameters->useTerminal =
runConfiguration->runMode() == LocalApplicationRunConfiguration::Console;
m_startParameters->dumperLibrary =
runConfiguration->dumperLibrary();
m_startParameters->dumperLibraryLocations =
runConfiguration->dumperLibraryLocations();
sp->useTerminal = rc->runMode() == LocalApplicationRunConfiguration::Console;
sp->dumperLibrary = rc->dumperLibrary();
sp->dumperLibraryLocations = rc->dumperLibraryLocations();
QString qmakePath = ProjectExplorer::DebuggingHelperLibrary::findSystemQt(
runConfiguration->environment());
rc->environment());
if (!qmakePath.isEmpty()) {
QProcess proc;
QStringList args;
......@@ -154,13 +118,43 @@ DebuggerRunControl::DebuggerRunControl(DebuggerManager *manager,
proc.waitForFinished();
QByteArray ba = proc.readAllStandardOutput().trimmed();
QFileInfo fi(QString::fromLocal8Bit(ba) + "/..");
m_startParameters->qtInstallPath = fi.absoluteFilePath();
sp->qtInstallPath = fi.absoluteFilePath();
}
return sp;
}
RunControl *DebuggerRunControlFactory::create(RunConfiguration *runConfiguration,
const QString &mode)
{
QTC_ASSERT(mode == ProjectExplorer::Constants::DEBUGMODE, return 0);
DebuggerStartParametersPtr sp = localStartParameters(runConfiguration);
return new DebuggerRunControl(m_manager, sp, runConfiguration);
}
RunControl *DebuggerRunControlFactory::create(const DebuggerStartParametersPtr &sp)
{
return new DebuggerRunControl(m_manager, sp, 0);
}
QWidget *DebuggerRunControlFactory::createConfigurationWidget(RunConfiguration *runConfiguration)
{
// NBS TODO: Add GDB-specific configuration widget
Q_UNUSED(runConfiguration)
return 0;
}
DebuggerRunControl::DebuggerRunControl(DebuggerManager *manager, const DebuggerStartParametersPtr &startParameters)
: RunControl(0, ProjectExplorer::Constants::DEBUGMODE),
////////////////////////////////////////////////////////////////////////
//
// DebuggerRunControl
//
////////////////////////////////////////////////////////////////////////
DebuggerRunControl::DebuggerRunControl(DebuggerManager *manager,
const DebuggerStartParametersPtr &startParameters,
ProjectExplorer::RunConfiguration *runConfiguration)
: RunControl(runConfiguration, ProjectExplorer::Constants::DEBUGMODE),
m_startParameters(startParameters),
m_manager(manager),
m_running(false)
......
......@@ -55,6 +55,7 @@ public:
virtual QWidget *createConfigurationWidget(ProjectExplorer::RunConfiguration *runConfiguration);
// This is used by the "Non-Standard" scenarios, e.g. Attach to Core.
ProjectExplorer::RunControl *create(const DebuggerStartParametersPtr &sp);
private:
......@@ -69,9 +70,11 @@ class DEBUGGER_EXPORT DebuggerRunControl
Q_OBJECT
public:
DebuggerRunControl(DebuggerManager *manager,
ProjectExplorer::LocalApplicationRunConfiguration *runConfiguration);
DebuggerRunControl(DebuggerManager *manager, const DebuggerStartParametersPtr &startParameters);
// startParameters are primary. If the user code has a RunConfiguration
// (like the 'standard' LocalRunConfiguration), it should pass it so
// we can pass it down to the ProjectExplorer::RunControl constructor.
DebuggerRunControl(DebuggerManager *manager, const DebuggerStartParametersPtr &startParameters,
ProjectExplorer::RunConfiguration *runConfiguration = 0);
void setCustomEnvironment(ProjectExplorer::Environment env);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment