From 33271804d239cbb0c3f69a55ae45c1d4bf7c1b5d Mon Sep 17 00:00:00 2001 From: Dominik Holland Date: Thu, 7 Mar 2024 17:01:38 +0100 Subject: [PATCH] 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 --- .../perfprofiler/perfprofilerruncontrol.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/plugins/perfprofiler/perfprofilerruncontrol.cpp b/src/plugins/perfprofiler/perfprofilerruncontrol.cpp index 4c51b82b3f3..a0927260c14 100644 --- a/src/plugins/perfprofiler/perfprofilerruncontrol.cpp +++ b/src/plugins/perfprofiler/perfprofilerruncontrol.cpp @@ -183,15 +183,21 @@ public: &PerfProfilerTool::onRunControlFinished); PerfDataReader *reader = m_perfParserWorker->reader(); + Process *perfProcess = nullptr; if (auto prw = qobject_cast(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(); + } + + 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.")); }); }