PerfProfiler: Make perf record args accessible

... without creating a hard dependencies.

Change-Id: I07b40dd9f1a4f53c5279d36f44e2a9123a34fa74
Reviewed-by: Dominik Holland <dominik.holland@qt.io>
This commit is contained in:
hjk
2024-03-07 13:17:48 +01:00
parent b24acbc28b
commit 4c0991b25d
4 changed files with 23 additions and 15 deletions

View File

@@ -29,6 +29,7 @@ const char AnalyzerSettingsGroupId[] = "Analyzer";
const char PerfSettingsId[] = "Analyzer.Perf.Settings"; const char PerfSettingsId[] = "Analyzer.Perf.Settings";
const char PerfCallgraphDwarf[] = "dwarf"; const char PerfCallgraphDwarf[] = "dwarf";
const char PerfRecordArgsId[] = "PerfRecordArgsId";
const char PerfStreamMagic[] = "QPERFSTREAM"; const char PerfStreamMagic[] = "QPERFSTREAM";
const char PerfZqfileMagic[] = "PTQFILE4.10"; const char PerfZqfileMagic[] = "PTQFILE4.10";

View File

@@ -6,8 +6,6 @@
#include "perfdatareader.h" #include "perfdatareader.h"
#include "perfprofilertool.h" #include "perfprofilertool.h"
#include "perfprofilertr.h" #include "perfprofilertr.h"
#include "perfrunconfigurationaspect.h"
#include "perfsettings.h"
#include <coreplugin/icore.h> #include <coreplugin/icore.h>
#include <coreplugin/messagemanager.h> #include <coreplugin/messagemanager.h>
@@ -97,11 +95,6 @@ public:
void start() final void start() final
{ {
auto perfAspect = runControl()->aspect<PerfRunConfigurationAspect>();
QTC_ASSERT(perfAspect, reportFailure(); return);
PerfSettings *settings = static_cast<PerfSettings *>(perfAspect->currentSettings);
QTC_ASSERT(settings, reportFailure(); return);
m_process = new Process(this); m_process = new Process(this);
connect(m_process, &Process::started, this, &RunWorker::reportStarted); connect(m_process, &Process::started, this, &RunWorker::reportStarted);
@@ -121,8 +114,11 @@ public:
reportStopped(); reportStopped();
}); });
const Store perfArgs = runControl()->settingsData(PerfProfiler::Constants::PerfSettingsId);
const QString recordArgs = perfArgs[Constants::PerfRecordArgsId].toString();
CommandLine cmd({device()->filePath("perf"), {"record"}}); CommandLine cmd({device()->filePath("perf"), {"record"}});
settings->addPerfRecordArguments(&cmd); cmd.addArgs(recordArgs, CommandLine::Raw);
cmd.addArgs({"-o", "-", "--"}); cmd.addArgs({"-o", "-", "--"});
cmd.addCommandLineAsArgs(runControl()->commandLine(), CommandLine::Raw); cmd.addCommandLineAsArgs(runControl()->commandLine(), CommandLine::Raw);

View File

@@ -371,6 +371,8 @@ PerfSettings &globalSettings()
PerfSettings::PerfSettings(ProjectExplorer::Target *target) PerfSettings::PerfSettings(ProjectExplorer::Target *target)
{ {
setAutoApply(false); setAutoApply(false);
setId(Constants::PerfSettingsId);
period.setSettingsKey("Analyzer.Perf.Frequency"); period.setSettingsKey("Analyzer.Perf.Frequency");
period.setRange(250, 2147483647); period.setRange(250, 2147483647);
period.setDefaultValue(250); period.setDefaultValue(250);
@@ -448,7 +450,13 @@ void PerfSettings::writeGlobalSettings() const
settings->endGroup(); settings->endGroup();
} }
void PerfSettings::addPerfRecordArguments(CommandLine *cmd) const void PerfSettings::toMap(Store &map) const
{
AspectContainer::toMap(map);
map[Constants::PerfRecordArgsId] = perfRecordArguments();
}
QString PerfSettings::perfRecordArguments() const
{ {
QString callgraphArg = callgraphMode.itemValue().toString(); QString callgraphArg = callgraphMode.itemValue().toString();
if (callgraphArg == Constants::PerfCallgraphDwarf) if (callgraphArg == Constants::PerfCallgraphDwarf)
@@ -463,11 +471,13 @@ void PerfSettings::addPerfRecordArguments(CommandLine *cmd) const
} }
} }
cmd->addArgs({"-e", events, CommandLine cmd;
cmd.addArgs({"-e", events,
"--call-graph", callgraphArg, "--call-graph", callgraphArg,
sampleMode.itemValue().toString(), sampleMode.itemValue().toString(),
QString::number(period())}); QString::number(period())});
cmd->addArgs(extraArguments(), CommandLine::Raw); cmd.addArgs(extraArguments(), CommandLine::Raw);
return cmd.arguments();
} }
void PerfSettings::resetToDefault() void PerfSettings::resetToDefault()

View File

@@ -20,7 +20,8 @@ public:
void readGlobalSettings(); void readGlobalSettings();
void writeGlobalSettings() const; void writeGlobalSettings() const;
void addPerfRecordArguments(Utils::CommandLine *cmd) const; void toMap(Utils::Store &map) const override;
QString perfRecordArguments() const;
void resetToDefault(); void resetToDefault();