forked from qt-creator/qt-creator
Perf: FilePathify PerfDataReader
Change-Id: I253cfd3724a15d40ef39dafd4f4497ca331ad596 Reviewed-by: Orgad Shaneh <orgads@gmail.com> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
@@ -35,6 +35,7 @@
|
|||||||
#include <QtEndian>
|
#include <QtEndian>
|
||||||
|
|
||||||
using namespace ProjectExplorer;
|
using namespace ProjectExplorer;
|
||||||
|
using namespace Utils;
|
||||||
|
|
||||||
namespace PerfProfiler {
|
namespace PerfProfiler {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
@@ -125,20 +126,25 @@ PerfDataReader::~PerfDataReader()
|
|||||||
qDeleteAll(m_buffer);
|
qDeleteAll(m_buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PerfDataReader::loadFromFile(const QString &filePath, const QString &executableDirPath,
|
void PerfDataReader::loadFromFile(const FilePath &filePath, const QString &executableDirPath,
|
||||||
ProjectExplorer::Kit *kit)
|
Kit *kit)
|
||||||
{
|
{
|
||||||
createParser(collectArguments(executableDirPath, kit) << QLatin1String("--input") << filePath);
|
CommandLine cmd{findPerfParser()};
|
||||||
|
collectArguments(&cmd, executableDirPath, kit);
|
||||||
|
cmd.addArg("--input");
|
||||||
|
cmd.addArg(filePath.nativePath());
|
||||||
|
createParser(cmd);
|
||||||
|
|
||||||
m_remoteProcessStart = 0; // Don't try to guess the timestamps
|
m_remoteProcessStart = 0; // Don't try to guess the timestamps
|
||||||
m_input.start(QIODevice::ReadOnly);
|
m_input.start(QIODevice::ReadOnly);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PerfDataReader::createParser(const QStringList &arguments)
|
void PerfDataReader::createParser(const CommandLine &cmd)
|
||||||
{
|
{
|
||||||
clear();
|
clear();
|
||||||
QString program = findPerfParser();
|
const QString program = cmd.executable().path();
|
||||||
m_input.setProgram(program);
|
m_input.setProgram(program);
|
||||||
m_input.setArguments(arguments);
|
m_input.setArguments(cmd.splitArguments());
|
||||||
m_input.setWorkingDirectory(QFileInfo(program).dir().absolutePath());
|
m_input.setWorkingDirectory(QFileInfo(program).dir().absolutePath());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -269,35 +275,39 @@ bool PerfDataReader::acceptsSamples() const
|
|||||||
return m_recording;
|
return m_recording;
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList PerfDataReader::collectArguments(const QString &executableDirPath, const Kit *kit) const
|
void PerfDataReader::collectArguments(CommandLine *cmd, const QString &exe, const Kit *kit) const
|
||||||
{
|
{
|
||||||
QStringList arguments;
|
if (!exe.isEmpty()) {
|
||||||
if (!executableDirPath.isEmpty())
|
cmd->addArg("--app");
|
||||||
arguments << "--app" << executableDirPath;
|
cmd->addArg(exe);
|
||||||
|
}
|
||||||
|
|
||||||
if (QtSupport::QtVersion *qt = QtSupport::QtKitAspect::qtVersion(kit)) {
|
if (QtSupport::QtVersion *qt = QtSupport::QtKitAspect::qtVersion(kit)) {
|
||||||
arguments << "--extra" << QString("%1%5%2%5%3%5%4")
|
cmd->addArg("--extra");
|
||||||
.arg(QDir::toNativeSeparators(qt->libraryPath().toString()))
|
cmd->addArg(QString("%1%5%2%5%3%5%4")
|
||||||
.arg(QDir::toNativeSeparators(qt->pluginPath().toString()))
|
.arg(qt->libraryPath().nativePath())
|
||||||
.arg(QDir::toNativeSeparators(qt->hostBinPath().toString()))
|
.arg(qt->pluginPath().nativePath())
|
||||||
.arg(QDir::toNativeSeparators(qt->qmlPath().toString()))
|
.arg(qt->hostBinPath().nativePath())
|
||||||
.arg(QDir::listSeparator());
|
.arg(qt->qmlPath().nativePath())
|
||||||
|
.arg(cmd->executable().osType() == OsTypeWindows ? u';' : u':'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (auto toolChain = ToolChainKitAspect::cxxToolChain(kit)) {
|
if (auto toolChain = ToolChainKitAspect::cxxToolChain(kit)) {
|
||||||
Abi::Architecture architecture = toolChain->targetAbi().architecture();
|
Abi::Architecture architecture = toolChain->targetAbi().architecture();
|
||||||
if (architecture == Abi::ArmArchitecture && toolChain->targetAbi().wordWidth() == 64) {
|
if (architecture == Abi::ArmArchitecture && toolChain->targetAbi().wordWidth() == 64) {
|
||||||
arguments << "--arch" << "aarch64";
|
cmd->addArg("--arch");
|
||||||
|
cmd->addArg("aarch64");
|
||||||
} else if (architecture != Abi::UnknownArchitecture) {
|
} else if (architecture != Abi::UnknownArchitecture) {
|
||||||
arguments << "--arch" << Abi::toString(architecture);
|
cmd->addArg("--arch");
|
||||||
|
cmd->addArg(Abi::toString(architecture));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QString sysroot = SysRootKitAspect::sysRoot(kit).toString();
|
const FilePath sysroot = SysRootKitAspect::sysRoot(kit);
|
||||||
if (!sysroot.isEmpty())
|
if (!sysroot.isEmpty()) {
|
||||||
arguments << "--sysroot" << sysroot;
|
cmd->addArg("--sysroot");
|
||||||
|
cmd->addArg(sysroot.nativePath());
|
||||||
return arguments;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool checkedWrite(QIODevice *device, const QByteArray &input)
|
static bool checkedWrite(QIODevice *device, const QByteArray &input)
|
||||||
@@ -372,21 +382,21 @@ bool PerfDataReader::feedParser(const QByteArray &input)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList PerfDataReader::findTargetArguments(const ProjectExplorer::RunControl *runControl) const
|
void PerfDataReader::addTargetArguments(CommandLine *cmd, const RunControl *runControl) const
|
||||||
{
|
{
|
||||||
ProjectExplorer::Kit *kit = runControl->kit();
|
ProjectExplorer::Kit *kit = runControl->kit();
|
||||||
QTC_ASSERT(kit, return QStringList());
|
QTC_ASSERT(kit, return);
|
||||||
ProjectExplorer::BuildConfiguration *buildConfig = runControl->target()->activeBuildConfiguration();
|
ProjectExplorer::BuildConfiguration *buildConfig = runControl->target()->activeBuildConfiguration();
|
||||||
QString buildDir = buildConfig ? buildConfig->buildDirectory().toString() : QString();
|
QString buildDir = buildConfig ? buildConfig->buildDirectory().toString() : QString();
|
||||||
return collectArguments(buildDir, kit);
|
collectArguments(cmd, buildDir, kit);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString PerfDataReader::findPerfParser()
|
FilePath findPerfParser()
|
||||||
{
|
{
|
||||||
QString filePath = Utils::qtcEnvironmentVariable("PERFPROFILER_PARSER_FILEPATH");
|
FilePath filePath = FilePath::fromUserInput(qtcEnvironmentVariable("PERFPROFILER_PARSER_FILEPATH"));
|
||||||
if (filePath.isEmpty())
|
if (filePath.isEmpty())
|
||||||
filePath = Core::ICore::libexecPath("perfparser" QTC_HOST_EXE_SUFFIX).toString();
|
filePath = Core::ICore::libexecPath("perfparser" QTC_HOST_EXE_SUFFIX);
|
||||||
return QDir::toNativeSeparators(QDir::cleanPath(filePath));
|
return filePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
@@ -19,6 +19,8 @@ class RunControl;
|
|||||||
namespace PerfProfiler {
|
namespace PerfProfiler {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
|
Utils::FilePath findPerfParser();
|
||||||
|
|
||||||
class PerfDataReader : public PerfProfilerTraceFile
|
class PerfDataReader : public PerfProfilerTraceFile
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@@ -26,14 +28,14 @@ public:
|
|||||||
explicit PerfDataReader(QObject *parent = nullptr);
|
explicit PerfDataReader(QObject *parent = nullptr);
|
||||||
~PerfDataReader() override;
|
~PerfDataReader() override;
|
||||||
|
|
||||||
void loadFromFile(const QString &filePath, const QString &executableDirPath,
|
void loadFromFile(const Utils::FilePath &filePath, const QString &executableDirPath,
|
||||||
ProjectExplorer::Kit *kit);
|
ProjectExplorer::Kit *kit);
|
||||||
|
|
||||||
void createParser(const QStringList &arguments);
|
void createParser(const Utils::CommandLine &arguments);
|
||||||
void startParser();
|
void startParser();
|
||||||
void stopParser();
|
void stopParser();
|
||||||
|
|
||||||
QStringList findTargetArguments(const ProjectExplorer::RunControl *runControl) const;
|
void addTargetArguments(Utils::CommandLine *cmd, const ProjectExplorer::RunControl *runControl) const;
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
bool feedParser(const QByteArray &input);
|
bool feedParser(const QByteArray &input);
|
||||||
@@ -63,8 +65,9 @@ protected:
|
|||||||
private:
|
private:
|
||||||
static const int s_maxBufferSize = 1 << 29;
|
static const int s_maxBufferSize = 1 << 29;
|
||||||
|
|
||||||
QStringList collectArguments(const QString &executableDirPath,
|
void collectArguments(Utils::CommandLine *cmd,
|
||||||
const ProjectExplorer::Kit *kit) const;
|
const QString &executableDirPath,
|
||||||
|
const ProjectExplorer::Kit *kit) const;
|
||||||
void writeChunk();
|
void writeChunk();
|
||||||
|
|
||||||
bool m_recording;
|
bool m_recording;
|
||||||
@@ -77,7 +80,6 @@ private:
|
|||||||
qint64 m_remoteProcessStart;
|
qint64 m_remoteProcessStart;
|
||||||
qint64 m_lastRemoteTimestamp;
|
qint64 m_lastRemoteTimestamp;
|
||||||
|
|
||||||
static QString findPerfParser();
|
|
||||||
qint64 delay(qint64 currentTime);
|
qint64 delay(qint64 currentTime);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -60,13 +60,14 @@ public:
|
|||||||
|
|
||||||
void start() override
|
void start() override
|
||||||
{
|
{
|
||||||
QStringList args = m_reader.findTargetArguments(runControl());
|
CommandLine cmd{findPerfParser()};
|
||||||
|
m_reader.addTargetArguments(&cmd, runControl());
|
||||||
QUrl url = runControl()->property("PerfConnection").toUrl();
|
QUrl url = runControl()->property("PerfConnection").toUrl();
|
||||||
if (url.isValid()) {
|
if (url.isValid()) {
|
||||||
args.append(QStringList{"--host", url.host(), "--port", QString::number(url.port())});
|
cmd.addArgs({"--host", url.host(), "--port", QString::number(url.port())});
|
||||||
}
|
}
|
||||||
appendMessage("PerfParser args: " + args.join(' '), Utils::NormalMessageFormat);
|
appendMessage("PerfParser args: " + cmd.arguments(), NormalMessageFormat);
|
||||||
m_reader.createParser(args);
|
m_reader.createParser(cmd);
|
||||||
m_reader.startParser();
|
m_reader.startParser();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -593,7 +593,7 @@ void PerfProfilerTool::showLoadPerfDialog()
|
|||||||
m_fileFinder.setAdditionalSearchDirectories(collectQtIncludePaths(kit));
|
m_fileFinder.setAdditionalSearchDirectories(collectQtIncludePaths(kit));
|
||||||
m_fileFinder.setSysroot(sysroot(kit));
|
m_fileFinder.setSysroot(sysroot(kit));
|
||||||
m_fileFinder.setProjectFiles(sourceFiles());
|
m_fileFinder.setProjectFiles(sourceFiles());
|
||||||
m_traceManager->loadFromPerfData(dlg.traceFilePath(), dlg.executableDirPath(), kit);
|
m_traceManager->loadFromPerfData(FilePath::fromUserInput(dlg.traceFilePath()), dlg.executableDirPath(), kit);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PerfProfilerTool::showLoadTraceDialog()
|
void PerfProfilerTool::showLoadTraceDialog()
|
||||||
@@ -612,7 +612,7 @@ void PerfProfilerTool::showLoadTraceDialog()
|
|||||||
const Kit *kit = target ? target->kit() : nullptr;
|
const Kit *kit = target ? target->kit() : nullptr;
|
||||||
populateFileFinder(currentProject, kit);
|
populateFileFinder(currentProject, kit);
|
||||||
|
|
||||||
m_traceManager->loadFromTraceFile(filePath.toString());
|
m_traceManager->loadFromTraceFile(filePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PerfProfilerTool::showSaveTraceDialog()
|
void PerfProfilerTool::showSaveTraceDialog()
|
||||||
@@ -627,7 +627,7 @@ void PerfProfilerTool::showSaveTraceDialog()
|
|||||||
filePath = filePath.stringAppended(".ptq");
|
filePath = filePath.stringAppended(".ptq");
|
||||||
|
|
||||||
setToolActionsEnabled(false);
|
setToolActionsEnabled(false);
|
||||||
m_traceManager->saveToTraceFile(filePath.toString());
|
m_traceManager->saveToTraceFile(filePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PerfProfilerTool::setAggregated(bool aggregated)
|
void PerfProfilerTool::setAggregated(bool aggregated)
|
||||||
|
@@ -12,9 +12,10 @@
|
|||||||
|
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
#include <QFileInfo>
|
|
||||||
#include <QFutureInterface>
|
#include <QFutureInterface>
|
||||||
|
|
||||||
|
using namespace Utils;
|
||||||
|
|
||||||
namespace PerfProfiler {
|
namespace PerfProfiler {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
@@ -575,19 +576,19 @@ qint32 PerfProfilerTraceManager::symbolLocation(qint32 locationId) const
|
|||||||
return symbol(locationId).name != -1 ? locationId : location(locationId).parentLocationId;
|
return symbol(locationId).name != -1 ? locationId : location(locationId).parentLocationId;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PerfProfilerTraceManager::loadFromTraceFile(const QString &filePath)
|
void PerfProfilerTraceManager::loadFromTraceFile(const FilePath &filePath)
|
||||||
{
|
{
|
||||||
Core::ProgressManager::addTask(load(filePath), Tr::tr("Loading Trace Data"),
|
Core::ProgressManager::addTask(load(filePath.toFSPathString()), Tr::tr("Loading Trace Data"),
|
||||||
Constants::PerfProfilerTaskLoadTrace);
|
Constants::PerfProfilerTaskLoadTrace);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PerfProfilerTraceManager::saveToTraceFile(const QString &filePath)
|
void PerfProfilerTraceManager::saveToTraceFile(const FilePath &filePath)
|
||||||
{
|
{
|
||||||
Core::ProgressManager::addTask(save(filePath), Tr::tr("Saving Trace Data"),
|
Core::ProgressManager::addTask(save(filePath.toFSPathString()), Tr::tr("Saving Trace Data"),
|
||||||
Constants::PerfProfilerTaskSaveTrace);
|
Constants::PerfProfilerTaskSaveTrace);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PerfProfilerTraceManager::loadFromPerfData(const QString &filePath,
|
void PerfProfilerTraceManager::loadFromPerfData(const FilePath &filePath,
|
||||||
const QString &executableDirPath,
|
const QString &executableDirPath,
|
||||||
ProjectExplorer::Kit *kit)
|
ProjectExplorer::Kit *kit)
|
||||||
{
|
{
|
||||||
@@ -604,7 +605,7 @@ void PerfProfilerTraceManager::loadFromPerfData(const QString &filePath,
|
|||||||
connect(reader, &QObject::destroyed, this, &TimelineTraceManager::loadFinished);
|
connect(reader, &QObject::destroyed, this, &TimelineTraceManager::loadFinished);
|
||||||
|
|
||||||
const int fileMegabytes = static_cast<int>(
|
const int fileMegabytes = static_cast<int>(
|
||||||
qMin(QFileInfo(filePath).size() >> 20,
|
qMin(filePath.fileSize() >> 20,
|
||||||
static_cast<qint64>(std::numeric_limits<int>::max())));
|
static_cast<qint64>(std::numeric_limits<int>::max())));
|
||||||
Core::FutureProgress *fp = Core::ProgressManager::addTimedTask(
|
Core::FutureProgress *fp = Core::ProgressManager::addTimedTask(
|
||||||
reader->future(), Tr::tr("Loading Trace Data"), Constants::PerfProfilerTaskLoadPerf,
|
reader->future(), Tr::tr("Loading Trace Data"), Constants::PerfProfilerTaskLoadPerf,
|
||||||
|
@@ -139,9 +139,9 @@ public:
|
|||||||
const QHash<qint32, TracePoint> &tracePoints() const { return m_tracePoints; }
|
const QHash<qint32, TracePoint> &tracePoints() const { return m_tracePoints; }
|
||||||
const QHash<quint32, Thread> &threads() const { return m_threads; }
|
const QHash<quint32, Thread> &threads() const { return m_threads; }
|
||||||
|
|
||||||
void loadFromTraceFile(const QString &filePath);
|
void loadFromTraceFile(const Utils::FilePath &filePath);
|
||||||
void saveToTraceFile(const QString &filePath);
|
void saveToTraceFile(const Utils::FilePath &filePath);
|
||||||
void loadFromPerfData(const QString &filePath, const QString &executableDirPath,
|
void loadFromPerfData(const Utils::FilePath &filePath, const QString &executableDirPath,
|
||||||
ProjectExplorer::Kit *kit);
|
ProjectExplorer::Kit *kit);
|
||||||
|
|
||||||
void finalize() override;
|
void finalize() override;
|
||||||
|
Reference in New Issue
Block a user