PerfProfiler: Re-organize general command line construction

... to avoid unnecessary argument splitting.

Also, make a potentially missing access to the settings
more noticeable to the user.

Task-number: QTCREATORBUG-28701
Change-Id: I7b7f7f5f6a68357dbec064516370bacbf00746dc
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
hjk
2023-05-16 19:01:54 +02:00
parent 07934fadcf
commit dfcfea478e
3 changed files with 13 additions and 16 deletions

View File

@@ -95,16 +95,15 @@ public:
: RunWorker(runControl) : RunWorker(runControl)
{ {
setId("LocalPerfRecordWorker"); setId("LocalPerfRecordWorker");
auto perfAspect = runControl->aspect<PerfRunConfigurationAspect>();
QTC_ASSERT(perfAspect, return);
PerfSettings *settings = static_cast<PerfSettings *>(perfAspect->currentSettings);
QTC_ASSERT(settings, return);
m_perfRecordArguments = settings->perfRecordArguments();
} }
void start() override void start() override
{ {
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);
@@ -125,7 +124,7 @@ public:
}); });
CommandLine cmd({device()->filePath("perf"), {"record"}}); CommandLine cmd({device()->filePath("perf"), {"record"}});
cmd.addArgs(m_perfRecordArguments); settings->addPerfRecordArguments(&cmd);
cmd.addArgs({"-o", "-", "--"}); cmd.addArgs({"-o", "-", "--"});
cmd.addCommandLineAsArgs(runControl()->commandLine(), CommandLine::Raw); cmd.addCommandLineAsArgs(runControl()->commandLine(), CommandLine::Raw);
@@ -145,7 +144,6 @@ public:
private: private:
QPointer<Process> m_process; QPointer<Process> m_process;
QStringList m_perfRecordArguments;
}; };

View File

@@ -103,7 +103,7 @@ void PerfSettings::writeGlobalSettings() const
settings->endGroup(); settings->endGroup();
} }
QStringList PerfSettings::perfRecordArguments() const void PerfSettings::addPerfRecordArguments(CommandLine *cmd) const
{ {
QString callgraphArg = callgraphMode.itemValue().toString(); QString callgraphArg = callgraphMode.itemValue().toString();
if (callgraphArg == Constants::PerfCallgraphDwarf) if (callgraphArg == Constants::PerfCallgraphDwarf)
@@ -118,11 +118,11 @@ QStringList PerfSettings::perfRecordArguments() const
} }
} }
return QStringList({"-e", events, cmd->addArgs({"-e", events,
"--call-graph", callgraphArg, "--call-graph", callgraphArg,
sampleMode.itemValue().toString(), sampleMode.itemValue().toString(),
QString::number(period.value())}) QString::number(period.value())});
+ ProcessArgs::splitArgs(extraArguments.value(), HostOsInfo::hostOs()); cmd->addArgs(extraArguments(), CommandLine::Raw);
} }
void PerfSettings::resetToDefault() void PerfSettings::resetToDefault()

View File

@@ -14,7 +14,6 @@ namespace PerfProfiler {
class PERFPROFILER_EXPORT PerfSettings final : public ProjectExplorer::ISettingsAspect class PERFPROFILER_EXPORT PerfSettings final : public ProjectExplorer::ISettingsAspect
{ {
Q_OBJECT Q_OBJECT
Q_PROPERTY(QStringList perfRecordArguments READ perfRecordArguments NOTIFY changed)
public: public:
explicit PerfSettings(ProjectExplorer::Target *target = nullptr); explicit PerfSettings(ProjectExplorer::Target *target = nullptr);
@@ -23,7 +22,7 @@ public:
void readGlobalSettings(); void readGlobalSettings();
void writeGlobalSettings() const; void writeGlobalSettings() const;
QStringList perfRecordArguments() const; void addPerfRecordArguments(Utils::CommandLine *cmd) const;
void resetToDefault(); void resetToDefault();