Commit bea726e8 authored by hjk's avatar hjk

Analyzer: Replace StartMode with a useStartupProject boolean

This is what it is on the top level. The change makes it obvious
that in the valgrind(-derived) plugins the value is later wrongly
used to make a decision on whether to run the valgrind process
locally or remotely. But that's isolated in valgrind now and
can be fixed there.

Change-Id: I6fa5e669dec1f9e2cdebe42a1591d15144082a21
Reviewed-by: default avatarAnton Kreuzkamp <anton.kreuzkamp@kdab.com>
Reviewed-by: default avatarChristian Stenger <christian.stenger@theqtcompany.com>
Reviewed-by: default avatarUlf Hermann <ulf.hermann@theqtcompany.com>
parent 8ee5b1c2
......@@ -35,18 +35,6 @@
#include <QtGlobal>
namespace Analyzer {
// Special values for currently used start modes.
// Their meaning is interpreted by the individual tools.
// FIXME: The plan is to remove this entirely from the
// public interface and let the tools handle that internally.
enum StartMode
{
StartLocal = -1,
StartRemote = -2
};
namespace Constants {
// Mode and its priority.
......
......@@ -74,8 +74,6 @@ public:
/// The start parameters for this engine.
const AnalyzerStartParameters &startParameters() const { return m_sp; }
StartMode mode() const { return m_sp.startMode; }
virtual void notifyRemoteSetupDone(quint16) {}
virtual void notifyRemoteFinished() {}
......
......@@ -50,11 +50,12 @@ class ANALYZER_EXPORT AnalyzerStartParameters
{
public:
AnalyzerStartParameters()
: localRunMode(ProjectExplorer::ApplicationLauncher::Gui)
, analyzerPort(0)
: useStartupProject(true),
localRunMode(ProjectExplorer::ApplicationLauncher::Gui),
analyzerPort(0)
{}
StartMode startMode;
bool useStartupProject;
ProjectExplorer::RunMode runMode;
QSsh::SshConnectionParameters connParams;
ProjectExplorer::ApplicationLauncher::Mode localRunMode;
......
......@@ -59,12 +59,12 @@ using namespace ProjectExplorer;
namespace Analyzer {
AnalyzerAction::AnalyzerAction(QObject *parent)
: QAction(parent)
: QAction(parent), m_useStartupProject(true)
{}
bool AnalyzerAction::isRunnable(QString *reason) const
{
if (m_startMode == StartRemote)
if (!m_useStartupProject)
return true;
return ProjectExplorerPlugin::canRun(SessionManager::startupProject(), m_runMode, reason);
......@@ -72,7 +72,7 @@ bool AnalyzerAction::isRunnable(QString *reason) const
AnalyzerRunControl *AnalyzerAction::tryCreateRunControl(const AnalyzerStartParameters &sp, RunConfiguration *runConfiguration) const
{
if (m_runMode == sp.runMode && m_startMode == sp.startMode)
if (m_runMode == sp.runMode && m_useStartupProject == sp.useStartupProject)
return m_runControlCreator(sp, runConfiguration);
return 0;
}
......@@ -150,7 +150,7 @@ bool checkForRemoteStart(AnalyzerStartParameters *sp)
if (dlg.exec() != QDialog::Accepted)
return false;
sp->startMode = StartRemote;
sp->useStartupProject = false;
sp->connParams = dlg.sshParams();
sp->debuggee = dlg.executable();
sp->debuggeeArgs = dlg.arguments();
......
......@@ -80,7 +80,7 @@ public:
explicit AnalyzerAction(QObject *parent = 0);
public:
void setStartMode(StartMode startMode) { m_startMode = startMode; }
void setUseSpecialStart() { m_useStartupProject = false; }
Core::Id menuGroup() const { return m_menuGroup; }
void setMenuGroup(Core::Id menuGroup) { m_menuGroup = menuGroup; }
......@@ -114,7 +114,7 @@ public:
void setToolStarter(const ToolStarter &toolStarter) { m_toolStarter = toolStarter; }
protected:
StartMode m_startMode;
bool m_useStartupProject;
Core::Id m_menuGroup;
Core::Id m_actionId;
Core::Id m_toolId;
......
......@@ -66,7 +66,6 @@ RunControl *AndroidAnalyzeSupport::createAnalyzeRunControl(AndroidRunConfigurati
QTC_ASSERT(server.listen(QHostAddress::LocalHost)
|| server.listen(QHostAddress::LocalHostIPv6), return 0);
params.analyzerHost = server.serverAddress().toString();
params.startMode = StartLocal;
}
AnalyzerRunControl *analyzerRunControl = AnalyzerManager::createRunControl(params, runConfig);
......
......@@ -86,7 +86,6 @@ RunControl *IosAnalyzeSupport::createAnalyzeRunControl(IosRunConfiguration *runC
AnalyzerStartParameters params;
params.runMode = QmlProfilerRunMode;
params.sysroot = SysRootKitInformation::sysRoot(target->kit()).toString();
params.startMode = StartLocal;
params.debuggee = runConfig->localExecutable().toUserOutput();
params.debuggeeArgs = Utils::QtcProcess::joinArgs(runConfig->commandLineArguments());
params.analyzerHost = QLatin1String("localhost");
......
......@@ -119,7 +119,7 @@ LocalQmlProfilerRunner::~LocalQmlProfilerRunner()
void LocalQmlProfilerRunner::start()
{
if (m_engine->mode() != Analyzer::StartLocal)
if (!m_engine->startParameters().useStartupProject)
return;
QString arguments = QString::fromLatin1("-qmljsdebugger=port:%1,block").arg(m_configuration.port);
......@@ -157,7 +157,7 @@ void LocalQmlProfilerRunner::spontaneousStop(int exitCode, QProcess::ExitStatus
void LocalQmlProfilerRunner::stop()
{
if (m_engine->mode() != Analyzer::StartLocal)
if (!m_engine->startParameters().useStartupProject)
return;
if (QmlProfilerPlugin::debugOutput)
......
......@@ -113,7 +113,7 @@ bool QmlProfilerRunControl::startEngine()
d->m_profilerState->setCurrentState(QmlProfilerStateManager::AppStarting);
if (startParameters().startMode == StartLocal)
if (startParameters().useStartupProject)
d->m_noDebugOutputTimer.start();
else if (startParameters().analyzerPort != 0)
emit processRunning(startParameters().analyzerPort);
......
......@@ -74,7 +74,6 @@ bool QmlProfilerPlugin::initialize(const QStringList &arguments, QString *errorS
action->setRunMode(ProjectExplorer::QmlProfilerRunMode);
action->setText(tr("QML Profiler"));
action->setToolTip(description);
action->setStartMode(StartLocal);
action->setMenuGroup(Constants::G_ANALYZER_TOOLS);
AnalyzerManager::addAction(action);
......@@ -87,7 +86,7 @@ bool QmlProfilerPlugin::initialize(const QStringList &arguments, QString *errorS
action->setRunMode(ProjectExplorer::QmlProfilerRunMode);
action->setText(tr("QML Profiler (External)"));
action->setToolTip(description);
action->setStartMode(StartRemote);
action->setUseSpecialStart();
action->setMenuGroup(Constants::G_ANALYZER_REMOTE_TOOLS);
AnalyzerManager::addAction(action);
......
......@@ -83,8 +83,6 @@ static AnalyzerStartParameters createQmlProfilerStartParameters(RunConfiguration
if (localPort == 0)
return sp;
sp.analyzerPort = localPort;
sp.startMode = StartLocal;
return sp;
}
......
......@@ -484,7 +484,7 @@ void QmlProfilerTool::startRemoteTool()
}
AnalyzerStartParameters sp;
sp.startMode = StartRemote;
sp.useStartupProject = false;
IDevice::ConstPtr device = DeviceKitInformation::device(kit);
if (device) {
......
......@@ -125,8 +125,6 @@ static AnalyzerStartParameters createAnalyzerStartParameters(const QnxRunConfigu
if (device.isNull())
return params;
if (mode == QmlProfilerRunMode)
params.startMode = StartLocal;
params.runMode = mode;
params.debuggee = runConfig->remoteExecutableFilePath();
params.debuggeeArgs = runConfig->arguments().join(QLatin1Char(' '));
......
......@@ -78,8 +78,6 @@ AnalyzerStartParameters RemoteLinuxAnalyzeSupport::startParameters(const RunConf
RunMode runMode)
{
AnalyzerStartParameters params;
if (runMode == QmlProfilerRunMode)
params.startMode = StartLocal;
params.runMode = runMode;
params.connParams = DeviceKitInformation::device(runConfig->target()->kit())->sshParameters();
params.displayName = runConfig->displayName();
......
......@@ -101,7 +101,9 @@ bool MemcheckRunner::start()
QTC_ASSERT(d->parser, return false);
// The remote case is handled in localHostAddressRetrieved().
if (startMode() == Analyzer::StartLocal) {
// FIXME: We start confusing "use startup project" with a "local/remote"
// decision here.
if (useStartupProject()) {
startServers(QHostAddress(QHostAddress::LocalHost));
setValgrindArguments(memcheckLogArguments() + valgrindArguments());
}
......
......@@ -100,7 +100,7 @@ bool ValgrindRunControl::startEngine()
run->setDebuggeeArguments(sp.debuggeeArgs);
run->setEnvironment(sp.environment);
run->setConnectionParameters(sp.connParams);
run->setStartMode(sp.startMode);
run->setUseStartupProject(sp.useStartupProject);
run->setLocalRunMode(sp.localRunMode);
connect(run, &ValgrindRunner::processOutputReceived,
......
......@@ -156,7 +156,6 @@ bool ValgrindPlugin::initialize(const QStringList &, QString *)
action->setText(tr("Valgrind Memory Analyzer"));
action->setToolTip(memcheckToolTip);
action->setMenuGroup(Constants::G_ANALYZER_TOOLS);
action->setStartMode(StartLocal);
action->setEnabled(false);
AnalyzerManager::addAction(action);
......@@ -170,7 +169,6 @@ bool ValgrindPlugin::initialize(const QStringList &, QString *)
action->setText(tr("Valgrind Memory Analyzer with GDB"));
action->setToolTip(memcheckWithGdbToolTip);
action->setMenuGroup(Constants::G_ANALYZER_TOOLS);
action->setStartMode(StartLocal);
action->setEnabled(false);
AnalyzerManager::addAction(action);
......@@ -184,7 +182,6 @@ bool ValgrindPlugin::initialize(const QStringList &, QString *)
action->setText(tr("Valgrind Function Profiler"));
action->setToolTip(callgrindToolTip);
action->setMenuGroup(Constants::G_ANALYZER_TOOLS);
action->setStartMode(StartLocal);
action->setEnabled(false);
AnalyzerManager::addAction(action);
}
......@@ -199,7 +196,7 @@ bool ValgrindPlugin::initialize(const QStringList &, QString *)
action->setText(tr("Valgrind Memory Analyzer (External Remote Application)"));
action->setToolTip(memcheckToolTip);
action->setMenuGroup(Constants::G_ANALYZER_REMOTE_TOOLS);
action->setStartMode(StartRemote);
action->setUseSpecialStart();
AnalyzerManager::addAction(action);
action = new AnalyzerAction(this);
......@@ -212,7 +209,7 @@ bool ValgrindPlugin::initialize(const QStringList &, QString *)
action->setText(tr("Valgrind Function Profiler (External Remote Application)"));
action->setToolTip(callgrindToolTip);
action->setMenuGroup(Constants::G_ANALYZER_REMOTE_TOOLS);
action->setStartMode(StartRemote);
action->setUseSpecialStart();
AnalyzerManager::addAction(action);
addAutoReleasedObject(new ValgrindRunControlFactory());
......
......@@ -94,11 +94,10 @@ RunControl *ValgrindRunControlFactory::create(RunConfiguration *runConfiguration
}
sp.connParams.host = server.serverAddress().toString();
sp.connParams.port = server.serverPort();
sp.startMode = StartLocal;
sp.localRunMode = static_cast<ApplicationLauncher::Mode>(rc1->runMode());
} else if (RemoteLinux::AbstractRemoteLinuxRunConfiguration *rc2 =
qobject_cast<RemoteLinux::AbstractRemoteLinuxRunConfiguration *>(runConfiguration)) {
sp.startMode = StartRemote;
sp.useStartupProject = false; // FIXME: This is wrong.
sp.debuggee = rc2->remoteExecutableFilePath();
sp.connParams = DeviceKitInformation::device(rc2->target()->kit())->sshParameters();
sp.debuggeeArgs = rc2->arguments().join(QLatin1Char(' '));
......
......@@ -51,7 +51,7 @@ public:
process(0),
channelMode(QProcess::SeparateChannels),
finished(false),
startMode(Analyzer::StartLocal),
useStartupProject(true),
localRunMode(ProjectExplorer::ApplicationLauncher::Gui)
{
}
......@@ -68,7 +68,7 @@ public:
QString debuggeeExecutable;
QString debuggeeArguments;
QString workingdir;
Analyzer::StartMode startMode;
bool useStartupProject;
ProjectExplorer::ApplicationLauncher::Mode localRunMode;
QSsh::SshConnectionParameters connParams;
};
......@@ -178,11 +178,6 @@ void ValgrindRunner::setDebuggeeArguments(const QString &arguments)
d->debuggeeArguments = arguments;
}
Analyzer::StartMode ValgrindRunner::startMode() const
{
return d->startMode;
}
void ValgrindRunner::setLocalRunMode(ProjectExplorer::ApplicationLauncher::Mode localRunMode)
{
d->localRunMode = localRunMode;
......@@ -193,11 +188,6 @@ ProjectExplorer::ApplicationLauncher::Mode ValgrindRunner::localRunMode() const
return d->localRunMode;
}
void ValgrindRunner::setStartMode(Analyzer::StartMode startMode)
{
d->startMode = startMode;
}
const QSsh::SshConnectionParameters &ValgrindRunner::connectionParameters() const
{
return d->connParams;
......@@ -228,6 +218,16 @@ void ValgrindRunner::setProcessChannelMode(QProcess::ProcessChannelMode mode)
d->channelMode = mode;
}
void ValgrindRunner::setUseStartupProject(bool useStartupProject)
{
d->useStartupProject = useStartupProject;
}
bool ValgrindRunner::useStartupProject() const
{
return d->useStartupProject;
}
void ValgrindRunner::waitForFinished() const
{
if (d->finished || !d->process)
......@@ -240,7 +240,8 @@ void ValgrindRunner::waitForFinished() const
bool ValgrindRunner::start()
{
d->run(new ValgrindProcess(d->startMode == Analyzer::StartLocal, d->connParams, 0, this));
// FIXME: This wrongly uses "useStartupProject" for a Local/Remote decision.
d->run(new ValgrindProcess(d->useStartupProject, d->connParams, 0, this));
return true;
}
......
......@@ -72,8 +72,8 @@ public:
void setEnvironment(const Utils::Environment &environment);
void setProcessChannelMode(QProcess::ProcessChannelMode mode);
void setStartMode(Analyzer::StartMode startMode);
Analyzer::StartMode startMode() const;
void setUseStartupProject(bool useStartupProject);
bool useStartupProject() const;
void setLocalRunMode(ProjectExplorer::ApplicationLauncher::Mode localRunMode);
ProjectExplorer::ApplicationLauncher::Mode localRunMode() const;
......
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