ProjectExplorer: Store some aspect data by value in the RunControl

Change-Id: Idb7e119b5b0b483ce91efeb21fb415b654cfed4f
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
hjk
2019-08-27 16:44:42 +02:00
parent c9c214057e
commit 758986ea0e
12 changed files with 47 additions and 42 deletions

View File

@@ -106,14 +106,12 @@ public:
upperPort = qmlServerPort; upperPort = qmlServerPort;
} }
if (m_usePerf) { if (m_usePerf) {
if (auto perfSettings = runControl()->settings("Analyzer.Perf.Settings")) { QVariantMap settingsData = runControl()->settingsData("Analyzer.Perf.Settings");
QStringList perfRecordArgs = perfSettings QVariant perfRecordArgs = settingsData.value("Analyzer.Perf.RecordArguments");
->property("perfRecordArguments").toStringList(); QString args = Utils::transform(perfRecordArgs.toStringList(), [](QString arg) {
args.append(QString::fromLatin1(" --profile-perf %1").arg(
Utils::transform(perfRecordArgs, [](QString arg) {
return arg.replace(',', ",,"); return arg.replace(',', ",,");
}).join(','))); }).join(',');
} args.append(QString(" --profile-perf %1").arg(args));
lowerPort = upperPort = perfPort; lowerPort = upperPort = perfPort;
} }
args.append(QString(" --port-range %1-%2 ").arg(lowerPort).arg(upperPort)); args.append(QString(" --port-range %1-%2 ").arg(lowerPort).arg(upperPort));

View File

@@ -56,6 +56,7 @@ const char PerfCallgraphModeId[] = "Analyzer.Perf.CallgraphMode";
const char PerfEventsId[] = "Analyzer.Perf.Events"; const char PerfEventsId[] = "Analyzer.Perf.Events";
const char PerfExtraArgumentsId[] = "Analyzer.Perf.ExtraArguments"; const char PerfExtraArgumentsId[] = "Analyzer.Perf.ExtraArguments";
const char PerfSettingsId[] = "Analyzer.Perf.Settings"; const char PerfSettingsId[] = "Analyzer.Perf.Settings";
const char PerfRecordArgumentsId[] = "Analyzer.Perf.RecordArguments";
const unsigned int PerfDefaultPeriod = 250; const unsigned int PerfDefaultPeriod = 250;
const unsigned int PerfDefaultStackSize = 4096; const unsigned int PerfDefaultStackSize = 4096;

View File

@@ -90,6 +90,7 @@ void PerfSettings::toMap(QVariantMap &map) const
map[QLatin1String(Constants::PerfCallgraphModeId)] = m_callgraphMode; map[QLatin1String(Constants::PerfCallgraphModeId)] = m_callgraphMode;
map[QLatin1String(Constants::PerfEventsId)] = m_events; map[QLatin1String(Constants::PerfEventsId)] = m_events;
map[QLatin1String(Constants::PerfExtraArgumentsId)] = m_extraArguments; map[QLatin1String(Constants::PerfExtraArgumentsId)] = m_extraArguments;
map[QLatin1String(Constants::PerfRecordArgumentsId)] = perfRecordArguments();
} }
void PerfSettings::fromMap(const QVariantMap &map) void PerfSettings::fromMap(const QVariantMap &map)

View File

@@ -292,6 +292,14 @@ RunConfiguration *RunConfiguration::startupRunConfiguration()
return nullptr; return nullptr;
} }
QMap<Core::Id, QVariantMap> RunConfiguration::aspectData() const
{
QMap<Core::Id, QVariantMap> data;
for (ProjectConfigurationAspect *aspect : m_aspects)
aspect->toMap(data[aspect->id()]);
return data;
}
bool RunConfiguration::isConfigured() const bool RunConfiguration::isConfigured() const
{ {
return true; return true;

View File

@@ -171,6 +171,8 @@ public:
addAspectFactory([](Target *target) { return new T(target); }); addAspectFactory([](Target *target) { return new T(target); });
} }
QMap<Core::Id, QVariantMap> aspectData() const;
signals: signals:
void configurationFinished(); void configurationFinished();
void enabledChanged(); void enabledChanged();

View File

@@ -325,6 +325,7 @@ public:
MacroExpander *macroExpander; MacroExpander *macroExpander;
QPointer<RunConfiguration> runConfiguration; // Not owned. Avoid use. QPointer<RunConfiguration> runConfiguration; // Not owned. Avoid use.
QString buildKey; QString buildKey;
QMap<Core::Id, QVariantMap> settingsData;
Core::Id runConfigId; Core::Id runConfigId;
BuildTargetInfo buildTargetInfo; BuildTargetInfo buildTargetInfo;
Kit *kit = nullptr; // Not owned. Kit *kit = nullptr; // Not owned.
@@ -361,6 +362,8 @@ void RunControl::setRunConfiguration(RunConfiguration *runConfig)
d->displayName = runConfig->displayName(); d->displayName = runConfig->displayName();
d->macroExpander = runConfig->macroExpander(); d->macroExpander = runConfig->macroExpander();
d->buildKey = runConfig->buildKey(); d->buildKey = runConfig->buildKey();
d->settingsData = runConfig->aspectData();
setTarget(runConfig->target()); setTarget(runConfig->target());
} }
@@ -894,9 +897,9 @@ ProjectConfigurationAspect *RunControl::aspect(Core::Id id) const
return d->runConfiguration ? d->runConfiguration->aspect(id) : nullptr; return d->runConfiguration ? d->runConfiguration->aspect(id) : nullptr;
} }
ISettingsAspect *RunControl::settings(Core::Id id) const QVariantMap RunControl::settingsData(Core::Id id) const
{ {
return d->runConfiguration ? d->runConfiguration->currentSettings(id) : nullptr; return d->settingsData.value(id);
} }
QString RunControl::buildKey() const QString RunControl::buildKey() const

View File

@@ -227,9 +227,10 @@ public:
return runConfiguration() ? runConfiguration()->aspect<T>() : nullptr; return runConfiguration() ? runConfiguration()->aspect<T>() : nullptr;
} }
ISettingsAspect *settings(Core::Id id) const;
QString buildKey() const; QString buildKey() const;
QVariantMap settingsData(Core::Id id) const;
Utils::FilePath targetFilePath() const; Utils::FilePath targetFilePath() const;
Utils::FilePath projectFilePath() const; Utils::FilePath projectFilePath() const;

View File

@@ -77,18 +77,16 @@ QStringList CallgrindToolRunner::toolArguments() const
{ {
QStringList arguments = {"--tool=callgrind"}; QStringList arguments = {"--tool=callgrind"};
QTC_ASSERT(m_settings, return arguments); if (m_settings.enableCacheSim())
if (m_settings->enableCacheSim())
arguments << "--cache-sim=yes"; arguments << "--cache-sim=yes";
if (m_settings->enableBranchSim()) if (m_settings.enableBranchSim())
arguments << "--branch-sim=yes"; arguments << "--branch-sim=yes";
if (m_settings->collectBusEvents()) if (m_settings.collectBusEvents())
arguments << "--collect-bus=yes"; arguments << "--collect-bus=yes";
if (m_settings->collectSystime()) if (m_settings.collectSystime())
arguments << "--collect-systime=yes"; arguments << "--collect-systime=yes";
if (m_markAsPaused) if (m_markAsPaused)

View File

@@ -786,13 +786,11 @@ void CallgrindToolPrivate::setupRunner(CallgrindToolRunner *toolRunner)
QTC_ASSERT(m_visualization, return); QTC_ASSERT(m_visualization, return);
// apply project settings // apply project settings
auto settings ValgrindProjectSettings settings;
= qobject_cast<ValgrindBaseSettings *>(runControl->settings(ANALYZER_VALGRIND_SETTINGS)); settings.fromMap(runControl->settingsData(ANALYZER_VALGRIND_SETTINGS));
if (settings) { m_visualization->setMinimumInclusiveCostRatio(settings.visualisationMinimumInclusiveCostRatio() / 100.0);
m_visualization->setMinimumInclusiveCostRatio(settings->visualisationMinimumInclusiveCostRatio() / 100.0); m_proxyModel.setMinimumInclusiveCostRatio(settings.minimumInclusiveCostRatio() / 100.0);
m_proxyModel.setMinimumInclusiveCostRatio(settings->minimumInclusiveCostRatio() / 100.0); m_dataModel.setVerboseToolTipsEnabled(settings.enableEventToolTips());
m_dataModel.setVerboseToolTipsEnabled(settings->enableEventToolTips());
}
m_toolBusy = true; m_toolBusy = true;
updateRunActions(); updateRunActions();

View File

@@ -191,16 +191,14 @@ QStringList MemcheckToolRunner::toolArguments() const
{ {
QStringList arguments = {"--tool=memcheck", "--gen-suppressions=all"}; QStringList arguments = {"--tool=memcheck", "--gen-suppressions=all"};
QTC_ASSERT(m_settings, return arguments); if (m_settings.trackOrigins())
if (m_settings->trackOrigins())
arguments << "--track-origins=yes"; arguments << "--track-origins=yes";
if (m_settings->showReachable()) if (m_settings.showReachable())
arguments << "--show-reachable=yes"; arguments << "--show-reachable=yes";
QString leakCheckValue; QString leakCheckValue;
switch (m_settings->leakCheckOnFinish()) { switch (m_settings.leakCheckOnFinish()) {
case ValgrindBaseSettings::LeakCheckOnFinishNo: case ValgrindBaseSettings::LeakCheckOnFinishNo:
leakCheckValue = "no"; leakCheckValue = "no";
break; break;
@@ -214,10 +212,10 @@ QStringList MemcheckToolRunner::toolArguments() const
} }
arguments << "--leak-check=" + leakCheckValue; arguments << "--leak-check=" + leakCheckValue;
foreach (const QString &file, m_settings->suppressionFiles()) foreach (const QString &file, m_settings.suppressionFiles())
arguments << QString("--suppressions=%1").arg(file); arguments << QString("--suppressions=%1").arg(file);
arguments << QString("--num-callers=%1").arg(m_settings->numCallers()); arguments << QString("--num-callers=%1").arg(m_settings.numCallers());
if (m_withGdb) if (m_withGdb)
arguments << "--vgdb=yes" << "--vgdb-error=0"; arguments << "--vgdb=yes" << "--vgdb-error=0";
@@ -227,7 +225,7 @@ QStringList MemcheckToolRunner::toolArguments() const
QStringList MemcheckToolRunner::suppressionFiles() const QStringList MemcheckToolRunner::suppressionFiles() const
{ {
return m_settings->suppressionFiles(); return m_settings.suppressionFiles();
} }
void MemcheckToolRunner::startDebugger(qint64 valgrindPid) void MemcheckToolRunner::startDebugger(qint64 valgrindPid)

View File

@@ -58,11 +58,7 @@ ValgrindToolRunner::ValgrindToolRunner(RunControl *runControl)
runControl->setIcon(ProjectExplorer::Icons::ANALYZER_START_SMALL_TOOLBAR); runControl->setIcon(ProjectExplorer::Icons::ANALYZER_START_SMALL_TOOLBAR);
setSupportsReRunning(false); setSupportsReRunning(false);
m_settings = m_settings.fromMap(runControl->settingsData(ANALYZER_VALGRIND_SETTINGS));
qobject_cast<ValgrindBaseSettings *>(runControl->settings(ANALYZER_VALGRIND_SETTINGS));
if (!m_settings)
m_settings = ValgrindGlobalSettings::instance();
} }
void ValgrindToolRunner::start() void ValgrindToolRunner::start()
@@ -81,7 +77,7 @@ void ValgrindToolRunner::start()
emit outputReceived(tr("Command line arguments: %1").arg(runnable().debuggeeArgs), DebugFormat); emit outputReceived(tr("Command line arguments: %1").arg(runnable().debuggeeArgs), DebugFormat);
#endif #endif
CommandLine valgrind{m_settings->valgrindExecutable()}; CommandLine valgrind{m_settings.valgrindExecutable()};
valgrind.addArgs(genericToolArguments()); valgrind.addArgs(genericToolArguments());
valgrind.addArgs(toolArguments()); valgrind.addArgs(toolArguments());
@@ -125,9 +121,9 @@ FilePath ValgrindToolRunner::executable() const
QStringList ValgrindToolRunner::genericToolArguments() const QStringList ValgrindToolRunner::genericToolArguments() const
{ {
QTC_ASSERT(m_settings, return QStringList());
QString smcCheckValue; QString smcCheckValue;
switch (m_settings->selfModifyingCodeDetection()) {
switch (m_settings.selfModifyingCodeDetection()) {
case ValgrindBaseSettings::DetectSmcNo: case ValgrindBaseSettings::DetectSmcNo:
smcCheckValue = "none"; smcCheckValue = "none";
break; break;
@@ -178,7 +174,7 @@ void ValgrindToolRunner::receiveProcessOutput(const QString &output, OutputForma
void ValgrindToolRunner::receiveProcessError(const QString &message, QProcess::ProcessError error) void ValgrindToolRunner::receiveProcessError(const QString &message, QProcess::ProcessError error)
{ {
if (error == QProcess::FailedToStart) { if (error == QProcess::FailedToStart) {
const QString valgrind = m_settings->valgrindExecutable(); const QString valgrind = m_settings.valgrindExecutable();
if (!valgrind.isEmpty()) if (!valgrind.isEmpty())
appendMessage(tr("Error: \"%1\" could not be started: %2").arg(valgrind, message), ErrorMessageFormat); appendMessage(tr("Error: \"%1\" could not be started: %2").arg(valgrind, message), ErrorMessageFormat);
else else

View File

@@ -26,10 +26,11 @@
#pragma once #pragma once
#include "valgrindsettings.h"
#include <projectexplorer/runcontrol.h> #include <projectexplorer/runcontrol.h>
#include <utils/environment.h> #include <utils/environment.h>
#include <valgrind/valgrindrunner.h> #include <valgrind/valgrindrunner.h>
#include <valgrind/valgrindsettings.h>
#include <QFutureInterface> #include <QFutureInterface>
#include <QFutureWatcher> #include <QFutureWatcher>
@@ -53,7 +54,7 @@ protected:
virtual QString progressTitle() const = 0; virtual QString progressTitle() const = 0;
virtual QStringList toolArguments() const = 0; virtual QStringList toolArguments() const = 0;
ValgrindBaseSettings *m_settings = nullptr; ValgrindProjectSettings m_settings;
QFutureInterface<void> m_progress; QFutureInterface<void> m_progress;
ValgrindRunner m_runner; ValgrindRunner m_runner;