PerfProfiler: Add support for reading perf output from other processes

Instead of just using the "PerfConnection" property when a "PerfRecorder"
is started, it is now also possible to set a "PerfProcess" property
and read stdout and stderr from there directly.

Change-Id: I01bd60a7ef36ca1676c0e0bc3d1f3e87f08749a2
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Dominik Holland
2024-03-07 17:01:38 +01:00
parent a90d16beda
commit 33271804d2

View File

@@ -183,15 +183,21 @@ public:
&PerfProfilerTool::onRunControlFinished);
PerfDataReader *reader = m_perfParserWorker->reader();
Process *perfProcess = nullptr;
if (auto prw = qobject_cast<LocalPerfRecordWorker *>(m_perfRecordWorker)) {
// That's the local case.
Process *recorder = prw->recorder();
connect(recorder, &Process::readyReadStandardError, this, [this, recorder] {
appendMessage(QString::fromLocal8Bit(recorder->readAllRawStandardError()),
perfProcess = prw->recorder();
} else {
perfProcess = runControl()->property("PerfProcess").value<Process *>();
}
if (perfProcess) {
connect(perfProcess, &Process::readyReadStandardError, this, [this, perfProcess] {
appendMessage(QString::fromLocal8Bit(perfProcess->readAllRawStandardError()),
StdErrFormat);
});
connect(recorder, &Process::readyReadStandardOutput, this, [this, reader, recorder] {
if (!reader->feedParser(recorder->readAllRawStandardOutput()))
connect(perfProcess, &Process::readyReadStandardOutput, this, [this, reader, perfProcess] {
if (!reader->feedParser(perfProcess->readAllRawStandardOutput()))
reportFailure(Tr::tr("Failed to transfer Perf data to perfparser."));
});
}