forked from qt-creator/qt-creator
Fix startExternal, attachExternal &more to not use a RunConfiguration
Removes around 50 lines of code, one completly unecessary class and makes the code paths easier to understand.
This commit is contained in:
@@ -1179,15 +1179,6 @@ void DebuggerPlugin::showSettingsDialog()
|
|||||||
QLatin1String(Debugger::Constants::DEBUGGER_COMMON_SETTINGS_PAGE));
|
QLatin1String(Debugger::Constants::DEBUGGER_COMMON_SETTINGS_PAGE));
|
||||||
}
|
}
|
||||||
|
|
||||||
static RunConfigurationPtr activeRunConfiguration()
|
|
||||||
{
|
|
||||||
ProjectExplorer::Project *project =
|
|
||||||
ProjectExplorerPlugin::instance()->currentProject();
|
|
||||||
if (project)
|
|
||||||
return project->activeRunConfiguration();
|
|
||||||
return RunConfigurationPtr();
|
|
||||||
}
|
|
||||||
|
|
||||||
void DebuggerPlugin::startExternalApplication()
|
void DebuggerPlugin::startExternalApplication()
|
||||||
{
|
{
|
||||||
const DebuggerStartParametersPtr sp(new DebuggerStartParameters);
|
const DebuggerStartParametersPtr sp(new DebuggerStartParameters);
|
||||||
@@ -1211,13 +1202,8 @@ void DebuggerPlugin::startExternalApplication()
|
|||||||
if (dlg.breakAtMain())
|
if (dlg.breakAtMain())
|
||||||
m_manager->breakByFunctionMain();
|
m_manager->breakByFunctionMain();
|
||||||
|
|
||||||
RunConfigurationPtr rc = activeRunConfiguration();
|
if (RunControl *runControl = m_debuggerRunControlFactory->create(sp, ProjectExplorer::Constants::DEBUGMODE))
|
||||||
if (rc.isNull())
|
ProjectExplorerPlugin::instance()->startRunControl(runControl, ProjectExplorer::Constants::DEBUGMODE);
|
||||||
rc = DebuggerRunControlFactory::createDefaultRunConfiguration(sp->executable);
|
|
||||||
|
|
||||||
if (RunControl *runControl = m_debuggerRunControlFactory
|
|
||||||
->create(rc, ProjectExplorer::Constants::DEBUGMODE, sp))
|
|
||||||
runControl->start();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DebuggerPlugin::attachExternalApplication()
|
void DebuggerPlugin::attachExternalApplication()
|
||||||
@@ -1237,12 +1223,8 @@ void DebuggerPlugin::attachExternalApplication(qint64 pid, const QString &crashP
|
|||||||
sp->attachPID = pid;
|
sp->attachPID = pid;
|
||||||
sp->crashParameter = crashParameter;
|
sp->crashParameter = crashParameter;
|
||||||
sp->startMode = crashParameter.isEmpty() ? AttachExternal : AttachCrashedExternal;
|
sp->startMode = crashParameter.isEmpty() ? AttachExternal : AttachCrashedExternal;
|
||||||
RunConfigurationPtr rc = activeRunConfiguration();
|
if (RunControl *runControl = m_debuggerRunControlFactory->create(sp, ProjectExplorer::Constants::DEBUGMODE))
|
||||||
if (rc.isNull())
|
ProjectExplorerPlugin::instance()->startRunControl(runControl, ProjectExplorer::Constants::DEBUGMODE);
|
||||||
rc = DebuggerRunControlFactory::createDefaultRunConfiguration();
|
|
||||||
if (RunControl *runControl = m_debuggerRunControlFactory
|
|
||||||
->create(rc, ProjectExplorer::Constants::DEBUGMODE, sp))
|
|
||||||
runControl->start();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DebuggerPlugin::attachCmdLineCore()
|
void DebuggerPlugin::attachCmdLineCore()
|
||||||
@@ -1273,12 +1255,9 @@ void DebuggerPlugin::attachCore(const QString &core, const QString &exe)
|
|||||||
sp->executable = exe;
|
sp->executable = exe;
|
||||||
sp->coreFile = core;
|
sp->coreFile = core;
|
||||||
sp->startMode = AttachCore;
|
sp->startMode = AttachCore;
|
||||||
RunConfigurationPtr rc = activeRunConfiguration();
|
|
||||||
if (rc.isNull())
|
|
||||||
rc = DebuggerRunControlFactory::createDefaultRunConfiguration();
|
|
||||||
if (RunControl *runControl = m_debuggerRunControlFactory
|
if (RunControl *runControl = m_debuggerRunControlFactory
|
||||||
->create(rc, ProjectExplorer::Constants::DEBUGMODE, sp))
|
->create(sp, ProjectExplorer::Constants::DEBUGMODE))
|
||||||
runControl->start();
|
ProjectExplorerPlugin::instance()->startRunControl(runControl, ProjectExplorer::Constants::DEBUGMODE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DebuggerPlugin::startRemoteApplication()
|
void DebuggerPlugin::startRemoteApplication()
|
||||||
@@ -1312,12 +1291,8 @@ void DebuggerPlugin::startRemoteApplication()
|
|||||||
sp->serverStartScript = dlg.serverStartScript();
|
sp->serverStartScript = dlg.serverStartScript();
|
||||||
sp->sysRoot = dlg.sysroot();
|
sp->sysRoot = dlg.sysroot();
|
||||||
|
|
||||||
RunConfigurationPtr rc = activeRunConfiguration();
|
if (RunControl *runControl = m_debuggerRunControlFactory->create(sp, ProjectExplorer::Constants::DEBUGMODE))
|
||||||
if (rc.isNull())
|
ProjectExplorerPlugin::instance()->startRunControl(runControl, ProjectExplorer::Constants::DEBUGMODE);
|
||||||
rc = DebuggerRunControlFactory::createDefaultRunConfiguration();
|
|
||||||
if (RunControl *runControl = m_debuggerRunControlFactory
|
|
||||||
->create(rc, ProjectExplorer::Constants::DEBUGMODE, sp))
|
|
||||||
runControl->start();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "debuggerplugin.moc"
|
#include "debuggerplugin.moc"
|
||||||
|
@@ -51,12 +51,6 @@ using ProjectExplorer::RunConfiguration;
|
|||||||
using ProjectExplorer::RunControl;
|
using ProjectExplorer::RunControl;
|
||||||
using ProjectExplorer::LocalApplicationRunConfiguration;
|
using ProjectExplorer::LocalApplicationRunConfiguration;
|
||||||
|
|
||||||
DefaultLocalApplicationRunConfiguration::DefaultLocalApplicationRunConfiguration(const QString &executable) :
|
|
||||||
ProjectExplorer::LocalApplicationRunConfiguration(0),
|
|
||||||
m_executable(executable)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// DebuggerRunControlFactory
|
// DebuggerRunControlFactory
|
||||||
@@ -79,28 +73,19 @@ QString DebuggerRunControlFactory::displayName() const
|
|||||||
return tr("Debug");
|
return tr("Debug");
|
||||||
}
|
}
|
||||||
|
|
||||||
RunConfigurationPtr DebuggerRunControlFactory::createDefaultRunConfiguration(const QString &executable)
|
RunControl *DebuggerRunControlFactory::create(const DebuggerStartParametersPtr &sp, const QString &mode)
|
||||||
{
|
{
|
||||||
return RunConfigurationPtr(new DefaultLocalApplicationRunConfiguration(executable));
|
return new DebuggerRunControl(m_manager, sp);
|
||||||
}
|
|
||||||
|
|
||||||
RunControl *DebuggerRunControlFactory::create(const RunConfigurationPtr &runConfiguration,
|
|
||||||
const QString &mode,
|
|
||||||
const DebuggerStartParametersPtr &sp)
|
|
||||||
{
|
|
||||||
QTC_ASSERT(mode == ProjectExplorer::Constants::DEBUGMODE, return 0);
|
|
||||||
LocalApplicationRunConfigurationPtr rc =
|
|
||||||
runConfiguration.objectCast<LocalApplicationRunConfiguration>();
|
|
||||||
QTC_ASSERT(!rc.isNull(), return 0);
|
|
||||||
return new DebuggerRunControl(m_manager, sp, rc);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RunControl *DebuggerRunControlFactory::create(const RunConfigurationPtr &runConfiguration,
|
RunControl *DebuggerRunControlFactory::create(const RunConfigurationPtr &runConfiguration,
|
||||||
const QString &mode)
|
const QString &mode)
|
||||||
{
|
{
|
||||||
const DebuggerStartParametersPtr sp(new DebuggerStartParameters);
|
QTC_ASSERT(mode == ProjectExplorer::Constants::DEBUGMODE, return 0);
|
||||||
sp->startMode = StartInternal;
|
LocalApplicationRunConfigurationPtr rc =
|
||||||
return create(runConfiguration, mode, sp);
|
runConfiguration.objectCast<LocalApplicationRunConfiguration>();
|
||||||
|
QTC_ASSERT(!rc.isNull(), return 0);
|
||||||
|
return new DebuggerRunControl(m_manager, rc);
|
||||||
}
|
}
|
||||||
|
|
||||||
QWidget *DebuggerRunControlFactory::configurationWidget(const RunConfigurationPtr &runConfiguration)
|
QWidget *DebuggerRunControlFactory::configurationWidget(const RunConfigurationPtr &runConfiguration)
|
||||||
@@ -120,38 +105,22 @@ QWidget *DebuggerRunControlFactory::configurationWidget(const RunConfigurationPt
|
|||||||
|
|
||||||
|
|
||||||
DebuggerRunControl::DebuggerRunControl(DebuggerManager *manager,
|
DebuggerRunControl::DebuggerRunControl(DebuggerManager *manager,
|
||||||
const DebuggerStartParametersPtr &startParameters,
|
|
||||||
QSharedPointer<LocalApplicationRunConfiguration> runConfiguration)
|
QSharedPointer<LocalApplicationRunConfiguration> runConfiguration)
|
||||||
: RunControl(runConfiguration),
|
: RunControl(runConfiguration),
|
||||||
m_startParameters(startParameters),
|
m_startParameters(new DebuggerStartParameters()),
|
||||||
m_manager(manager),
|
m_manager(manager),
|
||||||
m_running(false)
|
m_running(false)
|
||||||
{
|
{
|
||||||
connect(m_manager, SIGNAL(debuggingFinished()),
|
init();
|
||||||
this, SLOT(debuggingFinished()),
|
|
||||||
Qt::QueuedConnection);
|
|
||||||
connect(m_manager, SIGNAL(applicationOutputAvailable(QString)),
|
|
||||||
this, SLOT(slotAddToOutputWindowInline(QString)),
|
|
||||||
Qt::QueuedConnection);
|
|
||||||
connect(m_manager, SIGNAL(inferiorPidChanged(qint64)),
|
|
||||||
this, SLOT(bringApplicationToForeground(qint64)),
|
|
||||||
Qt::QueuedConnection);
|
|
||||||
connect(this, SIGNAL(stopRequested()),
|
|
||||||
m_manager, SLOT(exitDebugger()));
|
|
||||||
|
|
||||||
if (!runConfiguration)
|
if (!runConfiguration)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Enhance parameters by info from the project, but do not clobber
|
m_startParameters->startMode = StartInternal;
|
||||||
// arguments given in the dialogs
|
|
||||||
if (m_startParameters->executable.isEmpty())
|
|
||||||
m_startParameters->executable = runConfiguration->executable();
|
m_startParameters->executable = runConfiguration->executable();
|
||||||
if (m_startParameters->environment.empty())
|
|
||||||
m_startParameters->environment = runConfiguration->environment().toStringList();
|
m_startParameters->environment = runConfiguration->environment().toStringList();
|
||||||
if (m_startParameters->workingDir.isEmpty())
|
|
||||||
m_startParameters->workingDir = runConfiguration->workingDirectory();
|
m_startParameters->workingDir = runConfiguration->workingDirectory();
|
||||||
if (m_startParameters->startMode != StartExternal)
|
|
||||||
m_startParameters->processArgs = runConfiguration->commandLineArguments();
|
m_startParameters->processArgs = runConfiguration->commandLineArguments();
|
||||||
|
|
||||||
switch (m_startParameters->toolChainType) {
|
switch (m_startParameters->toolChainType) {
|
||||||
case ProjectExplorer::ToolChain::UNKNOWN:
|
case ProjectExplorer::ToolChain::UNKNOWN:
|
||||||
case ProjectExplorer::ToolChain::INVALID:
|
case ProjectExplorer::ToolChain::INVALID:
|
||||||
@@ -172,6 +141,34 @@ DebuggerRunControl::DebuggerRunControl(DebuggerManager *manager,
|
|||||||
runConfiguration->dumperLibraryLocations();
|
runConfiguration->dumperLibraryLocations();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DebuggerRunControl::DebuggerRunControl(DebuggerManager *manager, const DebuggerStartParametersPtr &startParameters)
|
||||||
|
: RunControl(RunConfigurationPtr(0)),
|
||||||
|
m_startParameters(startParameters),
|
||||||
|
m_manager(manager),
|
||||||
|
m_running(false)
|
||||||
|
{
|
||||||
|
init();
|
||||||
|
|
||||||
|
if (m_startParameters->environment.empty())
|
||||||
|
m_startParameters->environment = ProjectExplorer::Environment::Environment().toStringList();
|
||||||
|
m_startParameters->useTerminal = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DebuggerRunControl::init()
|
||||||
|
{
|
||||||
|
connect(m_manager, SIGNAL(debuggingFinished()),
|
||||||
|
this, SLOT(debuggingFinished()),
|
||||||
|
Qt::QueuedConnection);
|
||||||
|
connect(m_manager, SIGNAL(applicationOutputAvailable(QString)),
|
||||||
|
this, SLOT(slotAddToOutputWindowInline(QString)),
|
||||||
|
Qt::QueuedConnection);
|
||||||
|
connect(m_manager, SIGNAL(inferiorPidChanged(qint64)),
|
||||||
|
this, SLOT(bringApplicationToForeground(qint64)),
|
||||||
|
Qt::QueuedConnection);
|
||||||
|
connect(this, SIGNAL(stopRequested()),
|
||||||
|
m_manager, SLOT(exitDebugger()));
|
||||||
|
}
|
||||||
|
|
||||||
void DebuggerRunControl::start()
|
void DebuggerRunControl::start()
|
||||||
{
|
{
|
||||||
m_running = true;
|
m_running = true;
|
||||||
|
@@ -67,11 +67,7 @@ public:
|
|||||||
|
|
||||||
virtual QWidget *configurationWidget(const RunConfigurationPtr &runConfiguration);
|
virtual QWidget *configurationWidget(const RunConfigurationPtr &runConfiguration);
|
||||||
|
|
||||||
virtual ProjectExplorer::RunControl *create(const RunConfigurationPtr &runConfiguration,
|
ProjectExplorer::RunControl *create(const DebuggerStartParametersPtr &sp, const QString &mode);
|
||||||
const QString &mode,
|
|
||||||
const DebuggerStartParametersPtr &sp);
|
|
||||||
|
|
||||||
static RunConfigurationPtr createDefaultRunConfiguration(const QString &executable = QString());
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DebuggerStartParametersPtr m_startParameters;
|
DebuggerStartParametersPtr m_startParameters;
|
||||||
@@ -86,8 +82,8 @@ class DebuggerRunControl
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
DebuggerRunControl(DebuggerManager *manager,
|
DebuggerRunControl(DebuggerManager *manager,
|
||||||
const DebuggerStartParametersPtr &startParamters,
|
|
||||||
LocalApplicationRunConfigurationPtr runConfiguration);
|
LocalApplicationRunConfigurationPtr runConfiguration);
|
||||||
|
DebuggerRunControl(DebuggerManager *manager, const DebuggerStartParametersPtr &startParameters);
|
||||||
|
|
||||||
// ProjectExplorer::RunControl
|
// ProjectExplorer::RunControl
|
||||||
virtual void start();
|
virtual void start();
|
||||||
@@ -104,36 +100,12 @@ private slots:
|
|||||||
void slotAddToOutputWindowInline(const QString &output);
|
void slotAddToOutputWindowInline(const QString &output);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void init();
|
||||||
DebuggerStartParametersPtr m_startParameters;
|
DebuggerStartParametersPtr m_startParameters;
|
||||||
DebuggerManager *m_manager;
|
DebuggerManager *m_manager;
|
||||||
bool m_running;
|
bool m_running;
|
||||||
};
|
};
|
||||||
|
|
||||||
// A default run configuration for external executables or attaching to
|
|
||||||
// running processes by id.
|
|
||||||
class DefaultLocalApplicationRunConfiguration
|
|
||||||
: public ProjectExplorer::LocalApplicationRunConfiguration
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
public:
|
|
||||||
explicit DefaultLocalApplicationRunConfiguration(const QString &executable = QString());
|
|
||||||
|
|
||||||
virtual QString executable() const { return m_executable; }
|
|
||||||
virtual RunMode runMode() const { return Gui; }
|
|
||||||
virtual QString workingDirectory() const { return QString(); }
|
|
||||||
virtual QStringList commandLineArguments() const { return QStringList(); }
|
|
||||||
virtual ProjectExplorer::Environment environment() const
|
|
||||||
{ return ProjectExplorer::Environment(); }
|
|
||||||
virtual QString dumperLibrary() const { return QString(); }
|
|
||||||
virtual QStringList dumperLibraryLocations() const { return QStringList(); }
|
|
||||||
virtual ProjectExplorer::ToolChain::ToolChainType toolChainType() const
|
|
||||||
{ return ProjectExplorer::ToolChain::UNKNOWN; }
|
|
||||||
virtual QWidget *configurationWidget() { return 0; }
|
|
||||||
|
|
||||||
private:
|
|
||||||
const QString m_executable;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
} // namespace Debugger
|
} // namespace Debugger
|
||||||
|
|
||||||
|
@@ -212,7 +212,11 @@ void OutputPane::createNewOutputWindow(RunControl *rc)
|
|||||||
agg->add(ow);
|
agg->add(ow);
|
||||||
agg->add(new Find::BaseTextFind(ow));
|
agg->add(new Find::BaseTextFind(ow));
|
||||||
m_outputWindows.insert(rc, ow);
|
m_outputWindows.insert(rc, ow);
|
||||||
m_tabWidget->addTab(ow, rc->runConfiguration()->name());
|
// TODO add a displayName to RunControl, can't rely on there always beeing a runconfiguration
|
||||||
|
QString name = "External Application";
|
||||||
|
if (rc->runConfiguration())
|
||||||
|
name = rc->runConfiguration()->name();
|
||||||
|
m_tabWidget->addTab(ow, name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -244,7 +248,7 @@ void OutputPane::insertLine()
|
|||||||
void OutputPane::reRunRunControl()
|
void OutputPane::reRunRunControl()
|
||||||
{
|
{
|
||||||
RunControl *rc = runControlForTab(m_tabWidget->currentIndex());
|
RunControl *rc = runControlForTab(m_tabWidget->currentIndex());
|
||||||
if (rc->runConfiguration()->project() != 0)
|
if (rc->runConfiguration() && rc->runConfiguration()->project() != 0)
|
||||||
rc->start();
|
rc->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -283,7 +287,7 @@ void OutputPane::tabChanged(int i)
|
|||||||
} else {
|
} else {
|
||||||
RunControl *rc = runControlForTab(i);
|
RunControl *rc = runControlForTab(i);
|
||||||
m_stopAction->setEnabled(rc->isRunning());
|
m_stopAction->setEnabled(rc->isRunning());
|
||||||
m_reRunButton->setEnabled(!rc->isRunning() && rc->runConfiguration()->project());
|
m_reRunButton->setEnabled(!rc->isRunning() && rc->runConfiguration() && rc->runConfiguration()->project());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -300,7 +304,7 @@ void OutputPane::runControlFinished()
|
|||||||
{
|
{
|
||||||
RunControl *rc = runControlForTab(m_tabWidget->currentIndex());
|
RunControl *rc = runControlForTab(m_tabWidget->currentIndex());
|
||||||
if (rc == qobject_cast<RunControl *>(sender())) {
|
if (rc == qobject_cast<RunControl *>(sender())) {
|
||||||
m_reRunButton->setEnabled(rc->runConfiguration()->project());
|
m_reRunButton->setEnabled(rc->runConfiguration() && rc->runConfiguration()->project());
|
||||||
m_stopAction->setEnabled(false);
|
m_stopAction->setEnabled(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -106,6 +106,8 @@ public:
|
|||||||
void setProjectExplorerSettings(const Internal::ProjectExplorerSettings &pes);
|
void setProjectExplorerSettings(const Internal::ProjectExplorerSettings &pes);
|
||||||
Internal::ProjectExplorerSettings projectExplorerSettings() const;
|
Internal::ProjectExplorerSettings projectExplorerSettings() const;
|
||||||
|
|
||||||
|
void ProjectExplorerPlugin::startRunControl(RunControl *runControl, const QString &mode);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void aboutToShowContextMenu(ProjectExplorer::Project *project,
|
void aboutToShowContextMenu(ProjectExplorer::Project *project,
|
||||||
ProjectExplorer::Node *node);
|
ProjectExplorer::Node *node);
|
||||||
@@ -184,8 +186,6 @@ private slots:
|
|||||||
void loadProject(const QString &project) { openProject(project); }
|
void loadProject(const QString &project) { openProject(project); }
|
||||||
void currentModeChanged(Core::IMode *mode);
|
void currentModeChanged(Core::IMode *mode);
|
||||||
|
|
||||||
void ProjectExplorerPlugin::startRunControl(RunControl *runControl, const QString &mode);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void runProjectImpl(Project *pro);
|
void runProjectImpl(Project *pro);
|
||||||
void executeRunConfiguration(const QSharedPointer<RunConfiguration> &, const QString &mode);
|
void executeRunConfiguration(const QSharedPointer<RunConfiguration> &, const QString &mode);
|
||||||
|
Reference in New Issue
Block a user