forked from qt-creator/qt-creator
debugger: streamline RunControl creation a bit
This commit is contained in:
@@ -76,18 +76,64 @@ QString DebuggerRunControlFactory::displayName() const
|
|||||||
return tr("Debug");
|
return tr("Debug");
|
||||||
}
|
}
|
||||||
|
|
||||||
RunControl *DebuggerRunControlFactory::create(const DebuggerStartParametersPtr &sp)
|
static DebuggerStartParametersPtr localStartParameters(RunConfiguration *runConfiguration)
|
||||||
{
|
{
|
||||||
return new DebuggerRunControl(m_manager, sp);
|
DebuggerStartParametersPtr sp(new DebuggerStartParameters());
|
||||||
|
QTC_ASSERT(runConfiguration, return sp);
|
||||||
|
LocalApplicationRunConfiguration *rc =
|
||||||
|
qobject_cast<LocalApplicationRunConfiguration *>(runConfiguration);
|
||||||
|
QTC_ASSERT(rc, return sp);
|
||||||
|
|
||||||
|
sp->startMode = StartInternal;
|
||||||
|
sp->executable = rc->executable();
|
||||||
|
sp->environment = rc->environment().toStringList();
|
||||||
|
sp->workingDirectory = rc->workingDirectory();
|
||||||
|
sp->processArgs = rc->commandLineArguments();
|
||||||
|
|
||||||
|
switch (sp->toolChainType) {
|
||||||
|
case ProjectExplorer::ToolChain::UNKNOWN:
|
||||||
|
case ProjectExplorer::ToolChain::INVALID:
|
||||||
|
sp->toolChainType = rc->toolChainType();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (rc->target()->project()) {
|
||||||
|
BuildConfiguration *bc = rc->target()->activeBuildConfiguration();
|
||||||
|
if (bc)
|
||||||
|
sp->buildDirectory = bc->buildDirectory();
|
||||||
|
}
|
||||||
|
sp->useTerminal = rc->runMode() == LocalApplicationRunConfiguration::Console;
|
||||||
|
sp->dumperLibrary = rc->dumperLibrary();
|
||||||
|
sp->dumperLibraryLocations = rc->dumperLibraryLocations();
|
||||||
|
|
||||||
|
QString qmakePath = ProjectExplorer::DebuggingHelperLibrary::findSystemQt(
|
||||||
|
rc->environment());
|
||||||
|
if (!qmakePath.isEmpty()) {
|
||||||
|
QProcess proc;
|
||||||
|
QStringList args;
|
||||||
|
args.append(QLatin1String("-query"));
|
||||||
|
args.append(QLatin1String("QT_INSTALL_HEADERS"));
|
||||||
|
proc.start(qmakePath, args);
|
||||||
|
proc.waitForFinished();
|
||||||
|
QByteArray ba = proc.readAllStandardOutput().trimmed();
|
||||||
|
QFileInfo fi(QString::fromLocal8Bit(ba) + "/..");
|
||||||
|
sp->qtInstallPath = fi.absoluteFilePath();
|
||||||
|
}
|
||||||
|
return sp;
|
||||||
}
|
}
|
||||||
|
|
||||||
RunControl *DebuggerRunControlFactory::create(RunConfiguration *runConfiguration,
|
RunControl *DebuggerRunControlFactory::create(RunConfiguration *runConfiguration,
|
||||||
const QString &mode)
|
const QString &mode)
|
||||||
{
|
{
|
||||||
QTC_ASSERT(mode == ProjectExplorer::Constants::DEBUGMODE, return 0);
|
QTC_ASSERT(mode == ProjectExplorer::Constants::DEBUGMODE, return 0);
|
||||||
LocalApplicationRunConfiguration *rc = qobject_cast<LocalApplicationRunConfiguration *>(runConfiguration);
|
DebuggerStartParametersPtr sp = localStartParameters(runConfiguration);
|
||||||
QTC_ASSERT(rc, return 0);
|
return new DebuggerRunControl(m_manager, sp, runConfiguration);
|
||||||
return new DebuggerRunControl(m_manager, rc);
|
}
|
||||||
|
|
||||||
|
RunControl *DebuggerRunControlFactory::create(const DebuggerStartParametersPtr &sp)
|
||||||
|
{
|
||||||
|
return new DebuggerRunControl(m_manager, sp, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
QWidget *DebuggerRunControlFactory::createConfigurationWidget(RunConfiguration *runConfiguration)
|
QWidget *DebuggerRunControlFactory::createConfigurationWidget(RunConfiguration *runConfiguration)
|
||||||
@@ -105,62 +151,10 @@ QWidget *DebuggerRunControlFactory::createConfigurationWidget(RunConfiguration *
|
|||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
DebuggerRunControl::DebuggerRunControl(DebuggerManager *manager,
|
DebuggerRunControl::DebuggerRunControl(DebuggerManager *manager,
|
||||||
LocalApplicationRunConfiguration *runConfiguration)
|
const DebuggerStartParametersPtr &startParameters,
|
||||||
: RunControl(runConfiguration, ProjectExplorer::Constants::DEBUGMODE),
|
ProjectExplorer::RunConfiguration *runConfiguration)
|
||||||
m_startParameters(new DebuggerStartParameters()),
|
: RunControl(runConfiguration, ProjectExplorer::Constants::DEBUGMODE),
|
||||||
m_manager(manager),
|
|
||||||
m_running(false)
|
|
||||||
{
|
|
||||||
init();
|
|
||||||
if (!runConfiguration)
|
|
||||||
return;
|
|
||||||
|
|
||||||
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) {
|
|
||||||
case ProjectExplorer::ToolChain::UNKNOWN:
|
|
||||||
case ProjectExplorer::ToolChain::INVALID:
|
|
||||||
m_startParameters->toolChainType = runConfiguration->toolChainType();
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (runConfiguration->target()->project()) {
|
|
||||||
BuildConfiguration *bc = runConfiguration->target()->activeBuildConfiguration();
|
|
||||||
if (bc)
|
|
||||||
m_startParameters->buildDirectory = bc->buildDirectory();
|
|
||||||
}
|
|
||||||
m_startParameters->useTerminal =
|
|
||||||
runConfiguration->runMode() == LocalApplicationRunConfiguration::Console;
|
|
||||||
m_startParameters->dumperLibrary =
|
|
||||||
runConfiguration->dumperLibrary();
|
|
||||||
m_startParameters->dumperLibraryLocations =
|
|
||||||
runConfiguration->dumperLibraryLocations();
|
|
||||||
|
|
||||||
QString qmakePath = ProjectExplorer::DebuggingHelperLibrary::findSystemQt(
|
|
||||||
runConfiguration->environment());
|
|
||||||
if (!qmakePath.isEmpty()) {
|
|
||||||
QProcess proc;
|
|
||||||
QStringList args;
|
|
||||||
args.append(QLatin1String("-query"));
|
|
||||||
args.append(QLatin1String("QT_INSTALL_HEADERS"));
|
|
||||||
proc.start(qmakePath, args);
|
|
||||||
proc.waitForFinished();
|
|
||||||
QByteArray ba = proc.readAllStandardOutput().trimmed();
|
|
||||||
QFileInfo fi(QString::fromLocal8Bit(ba) + "/..");
|
|
||||||
m_startParameters->qtInstallPath = fi.absoluteFilePath();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
DebuggerRunControl::DebuggerRunControl(DebuggerManager *manager, const DebuggerStartParametersPtr &startParameters)
|
|
||||||
: RunControl(0, ProjectExplorer::Constants::DEBUGMODE),
|
|
||||||
m_startParameters(startParameters),
|
m_startParameters(startParameters),
|
||||||
m_manager(manager),
|
m_manager(manager),
|
||||||
m_running(false)
|
m_running(false)
|
||||||
|
@@ -55,6 +55,7 @@ public:
|
|||||||
virtual QWidget *createConfigurationWidget(ProjectExplorer::RunConfiguration *runConfiguration);
|
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);
|
ProjectExplorer::RunControl *create(const DebuggerStartParametersPtr &sp);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -69,9 +70,11 @@ class DEBUGGER_EXPORT DebuggerRunControl
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DebuggerRunControl(DebuggerManager *manager,
|
// startParameters are primary. If the user code has a RunConfiguration
|
||||||
ProjectExplorer::LocalApplicationRunConfiguration *runConfiguration);
|
// (like the 'standard' LocalRunConfiguration), it should pass it so
|
||||||
DebuggerRunControl(DebuggerManager *manager, const DebuggerStartParametersPtr &startParameters);
|
// 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);
|
void setCustomEnvironment(ProjectExplorer::Environment env);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user