Commit fba9ab5f authored by hjk's avatar hjk
Browse files

debugger: refactoring

move the start mode variable to DebuggerStartParameters
parent 6439d545
......@@ -1176,7 +1176,7 @@ static QSharedPointer<RunConfiguration> activeRunConfiguration()
void DebuggerPlugin::startExternalApplication()
{
const QSharedPointer<DebuggerStartParameters> sp(new DebuggerStartParameters);
const DebuggerStartParametersPtr sp(new DebuggerStartParameters);
StartExternalDialog dlg(m_manager->mainWindow());
dlg.setExecutableFile(
configValue(_("LastExternalExecutableFile")).toString());
......@@ -1190,6 +1190,7 @@ void DebuggerPlugin::startExternalApplication()
setConfigValue(_("LastExternalExecutableArguments"),
dlg.executableArguments());
sp->executable = dlg.executableFile();
sp->startMode = StartExternal;
if (!dlg.executableArguments().isEmpty())
sp->processArgs = dlg.executableArguments().split(QLatin1Char(' '));
......@@ -1201,7 +1202,7 @@ void DebuggerPlugin::startExternalApplication()
rc = DebuggerRunner::createDefaultRunConfiguration(sp->executable);
if (RunControl *runControl = m_debuggerRunner
->run(rc, ProjectExplorer::Constants::DEBUGMODE, sp, StartExternal))
->run(rc, ProjectExplorer::Constants::DEBUGMODE, sp))
runControl->start();
}
......@@ -1218,21 +1219,21 @@ void DebuggerPlugin::attachExternalApplication(qint64 pid, const QString &crashP
QMessageBox::warning(m_manager->mainWindow(), tr("Warning"), tr("Cannot attach to PID 0"));
return;
}
const QSharedPointer<DebuggerStartParameters> sp(new DebuggerStartParameters);
const DebuggerStartParametersPtr sp(new DebuggerStartParameters);
sp->attachPID = pid;
sp->crashParameter = crashParameter;
const DebuggerStartMode dsm = crashParameter.isEmpty() ? AttachExternal : AttachCrashedExternal;
sp->startMode = crashParameter.isEmpty() ? AttachExternal : AttachCrashedExternal;
QSharedPointer<RunConfiguration> rc = activeRunConfiguration();
if (rc.isNull())
rc = DebuggerRunner::createDefaultRunConfiguration();
if (RunControl *runControl = m_debuggerRunner
->run(rc, ProjectExplorer::Constants::DEBUGMODE, sp, dsm))
->run(rc, ProjectExplorer::Constants::DEBUGMODE, sp))
runControl->start();
}
void DebuggerPlugin::attachCore()
{
const QSharedPointer<DebuggerStartParameters> sp(new DebuggerStartParameters);
const DebuggerStartParametersPtr sp(new DebuggerStartParameters);
AttachCoreDialog dlg(m_manager->mainWindow());
dlg.setExecutableFile(
configValue(_("LastExternalExecutableFile")).toString());
......@@ -1246,17 +1247,18 @@ void DebuggerPlugin::attachCore()
dlg.coreFile());
sp->executable = dlg.executableFile();
sp->coreFile = dlg.coreFile();
sp->startMode = AttachCore;
QSharedPointer<RunConfiguration> rc = activeRunConfiguration();
if (rc.isNull())
rc = DebuggerRunner::createDefaultRunConfiguration();
if (RunControl *runControl = m_debuggerRunner
->run(rc, ProjectExplorer::Constants::DEBUGMODE, sp, AttachCore))
->run(rc, ProjectExplorer::Constants::DEBUGMODE, sp))
runControl->start();
}
void DebuggerPlugin::startRemoteApplication()
{
const QSharedPointer<DebuggerStartParameters> sp(new DebuggerStartParameters);
const DebuggerStartParametersPtr sp(new DebuggerStartParameters);
StartRemoteDialog dlg(m_manager->mainWindow());
QStringList arches;
arches.append(_("i386:x86-64:intel"));
......@@ -1277,6 +1279,7 @@ void DebuggerPlugin::startRemoteApplication()
setConfigValue(_("LastUseServerStartScript"), dlg.useServerStartScript());
sp->remoteChannel = dlg.remoteChannel();
sp->remoteArchitecture = dlg.remoteArchitecture();
sp->startMode = StartRemote;
if (dlg.useServerStartScript())
sp->serverStartScript = dlg.serverStartScript();
......@@ -1284,13 +1287,13 @@ void DebuggerPlugin::startRemoteApplication()
if (rc.isNull())
rc = DebuggerRunner::createDefaultRunConfiguration();
if (RunControl *runControl = m_debuggerRunner
->run(rc, ProjectExplorer::Constants::DEBUGMODE, sp, StartRemote))
->run(rc, ProjectExplorer::Constants::DEBUGMODE, sp))
runControl->start();
}
void DebuggerPlugin::attachRemoteTcf()
{
const QSharedPointer<DebuggerStartParameters> sp(new DebuggerStartParameters);
const DebuggerStartParametersPtr sp(new DebuggerStartParameters);
AttachTcfDialog dlg(m_manager->mainWindow());
QStringList arches;
arches.append(_("i386:x86-64:intel"));
......@@ -1312,6 +1315,7 @@ void DebuggerPlugin::attachRemoteTcf()
sp->remoteChannel = dlg.remoteChannel();
sp->remoteArchitecture = dlg.remoteArchitecture();
sp->serverStartScript = dlg.serverStartScript();
sp->startMode = AttachTcf;
if (dlg.useServerStartScript())
sp->serverStartScript = dlg.serverStartScript();
......@@ -1319,7 +1323,7 @@ void DebuggerPlugin::attachRemoteTcf()
if (rc.isNull())
rc = DebuggerRunner::createDefaultRunConfiguration();
if (RunControl *runControl = m_debuggerRunner
->run(rc, ProjectExplorer::Constants::DEBUGMODE, sp, AttachTcf))
->run(rc, ProjectExplorer::Constants::DEBUGMODE, sp))
runControl->start();
}
......
......@@ -85,23 +85,21 @@ RunConfigurationPtr DebuggerRunner::createDefaultRunConfiguration(const QString
RunControl *DebuggerRunner::run(RunConfigurationPtr runConfiguration,
const QString &mode,
const QSharedPointer<DebuggerStartParameters> &sp,
DebuggerStartMode startMode)
const QSharedPointer<DebuggerStartParameters> &sp)
{
QTC_ASSERT(mode == ProjectExplorer::Constants::DEBUGMODE, return 0);
ApplicationRunConfigurationPtr rc =
runConfiguration.objectCast<ApplicationRunConfiguration>();
QTC_ASSERT(!rc.isNull(), return 0);
//qDebug() << "***** Debugging" << rc->name() << rc->executable();
DebuggerRunControl *runControl = new DebuggerRunControl(m_manager, startMode, sp, rc);
return runControl;
return new DebuggerRunControl(m_manager, sp, rc);
}
RunControl *DebuggerRunner::run(RunConfigurationPtr runConfiguration,
const QString &mode)
{
const QSharedPointer<DebuggerStartParameters> sp(new DebuggerStartParameters);
return run(runConfiguration, mode, sp, StartInternal);
sp->startMode = StartInternal;
return run(runConfiguration, mode, sp);
}
QWidget *DebuggerRunner::configurationWidget(RunConfigurationPtr runConfiguration)
......@@ -121,7 +119,6 @@ QWidget *DebuggerRunner::configurationWidget(RunConfigurationPtr runConfiguratio
DebuggerRunControl::DebuggerRunControl(DebuggerManager *manager,
DebuggerStartMode mode,
const QSharedPointer<DebuggerStartParameters> &startParameters,
QSharedPointer<ApplicationRunConfiguration> runConfiguration)
: RunControl(runConfiguration),
......@@ -146,7 +143,6 @@ DebuggerRunControl::DebuggerRunControl(DebuggerManager *manager,
// Enhance parameters by info from the project, but do not clobber
// arguments given in the dialogs
m_startParameters->startMode = mode;
if (m_startParameters->executable.isEmpty())
m_startParameters->executable = runConfiguration->executable();
if (m_startParameters->environment.empty())
......
......@@ -61,16 +61,15 @@ public:
// ProjectExplorer::IRunConfigurationRunner
bool canRun(RunConfigurationPtr runConfiguration, const QString &mode);
virtual ProjectExplorer::RunControl *run(RunConfigurationPtr runConfiguration, const QString &mode);
virtual ProjectExplorer::RunControl *run(RunConfigurationPtr runConfiguration,
const QString &mode);
virtual QString displayName() const;
virtual QWidget *configurationWidget(RunConfigurationPtr runConfiguration);
virtual ProjectExplorer::RunControl
*run(RunConfigurationPtr runConfiguration,
virtual ProjectExplorer::RunControl *run(RunConfigurationPtr runConfiguration,
const QString &mode,
const DebuggerStartParametersPtr &sp,
DebuggerStartMode startMode);
const DebuggerStartParametersPtr &sp);
static RunConfigurationPtr createDefaultRunConfiguration(const QString &executable = QString());
......@@ -87,7 +86,6 @@ class DebuggerRunControl
public:
DebuggerRunControl(DebuggerManager *manager,
DebuggerStartMode mode,
const DebuggerStartParametersPtr &startParamters,
ApplicationRunConfigurationPtr runConfiguration);
......
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