AppMan: Add PerfProfiler support

Change-Id: I7873742ebd93af1aed1c57e473c85d0b06bbbbf3
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Dominik Holland
2024-03-07 17:16:30 +01:00
parent 33271804d2
commit aad2f6ecac
3 changed files with 46 additions and 18 deletions

View File

@@ -36,6 +36,7 @@ class AppManagerPlugin final : public ExtensionSystem::IPlugin
setupAppManagerRunWorker(); setupAppManagerRunWorker();
setupAppManagerDebugWorker(); setupAppManagerDebugWorker();
setupAppManagerQmlToolingWorker(); setupAppManagerQmlToolingWorker();
setupAppManagerPerfProfilerWorker();
} }
}; };

View File

@@ -15,6 +15,8 @@
#include <debugger/debuggerruncontrol.h> #include <debugger/debuggerruncontrol.h>
#include <debugger/debuggerkitaspect.h> #include <debugger/debuggerkitaspect.h>
#include <perfprofiler/perfprofilerconstants.h>
#include <projectexplorer/buildconfiguration.h> #include <projectexplorer/buildconfiguration.h>
#include <projectexplorer/buildsystem.h> #include <projectexplorer/buildsystem.h>
#include <projectexplorer/buildtargetinfo.h> #include <projectexplorer/buildtargetinfo.h>
@@ -99,15 +101,10 @@ public:
setId(AppManager::Constants::DEBUG_LAUNCHER_ID); setId(AppManager::Constants::DEBUG_LAUNCHER_ID);
setEssential(true); setEssential(true);
connect(&m_launcher, &Process::started, this, &RunWorker::reportStarted); if (usePerf) {
connect(&m_launcher, &Process::done, this, &RunWorker::reportStopped); suppressDefaultStdOutHandling();
runControl->setProperty("PerfProcess", QVariant::fromValue(process()));
connect(&m_launcher, &Process::readyReadStandardOutput, this, [this] { }
appendMessage(m_launcher.readAllStandardOutput(), StdOutFormat);
});
connect(&m_launcher, &Process::readyReadStandardError, this, [this] {
appendMessage(m_launcher.readAllStandardError(), StdErrFormat);
});
m_portsGatherer = new Debugger::DebugServerPortsGatherer(runControl); m_portsGatherer = new Debugger::DebugServerPortsGatherer(runControl);
m_portsGatherer->setUseGdbServer(useGdbServer || usePerf); m_portsGatherer->setUseGdbServer(useGdbServer || usePerf);
@@ -123,7 +120,6 @@ public:
if (auto envAspect = runControl->aspectData<EnvironmentAspect>()) if (auto envAspect = runControl->aspectData<EnvironmentAspect>())
envVars = envAspect->environment.toStringList(); envVars = envAspect->environment.toStringList();
// const int perfPort = m_portsGatherer->gdbServer().port();
const int gdbServerPort = m_portsGatherer->gdbServer().port(); const int gdbServerPort = m_portsGatherer->gdbServer().port();
const int qmlServerPort = m_portsGatherer->qmlServer().port(); const int qmlServerPort = m_portsGatherer->qmlServer().port();
@@ -147,14 +143,10 @@ public:
} }
cmd.addArg(debugArgs.join(' ')); cmd.addArg(debugArgs.join(' '));
} }
//FIXME UNTESTED CODE
if (m_usePerf) { if (m_usePerf) {
Store settingsData = runControl->settingsData("Analyzer.Perf.Settings"); const Store perfArgs = runControl->settingsData(PerfProfiler::Constants::PerfSettingsId);
QVariant perfRecordArgs = settingsData.value("Analyzer.Perf.RecordArguments"); const QString recordArgs = perfArgs[PerfProfiler::Constants::PerfRecordArgsId].toString();
QString args = Utils::transform(perfRecordArgs.toStringList(), [](QString arg) { cmd.addArg(QString("perf record %1 -o - --").arg(recordArgs));
return arg.replace(',', ",,");
}).join(',');
cmd.addArg(QString("perf record %1 -o - --").arg(args));
} }
cmd.addArg("-eio"); cmd.addArg("-eio");
@@ -185,7 +177,6 @@ private:
bool m_useGdbServer; bool m_useGdbServer;
bool m_useQmlServer; bool m_useQmlServer;
QmlDebug::QmlDebugServicesPreset m_qmlServices; QmlDebug::QmlDebugServicesPreset m_qmlServices;
Process m_launcher;
}; };
@@ -300,6 +291,25 @@ private:
RunWorker *m_worker = nullptr; RunWorker *m_worker = nullptr;
}; };
// AppManagerDevicePerfProfilerSupport
class AppManagerPerfProfilerSupport final : public RunWorker
{
public:
explicit AppManagerPerfProfilerSupport(RunControl *runControl)
: RunWorker(runControl)
{
setId("AppManagerPerfProfilerSupport");
m_profilee = new AppManInferiorRunner(runControl, true, false, false,
QmlDebug::NoQmlDebugServices);
addStartDependency(m_profilee);
addStopDependency(m_profilee);
}
private:
AppManInferiorRunner *m_profilee = nullptr;
};
// Factories // Factories
@@ -338,6 +348,17 @@ public:
} }
}; };
class AppManagerPerfProfilerWorkerFactory final : public RunWorkerFactory
{
public:
AppManagerPerfProfilerWorkerFactory()
{
setProduct<AppManagerPerfProfilerSupport>();
addSupportedRunMode("PerfRecorder");
addSupportedRunConfig(Constants::RUNANDDEBUGCONFIGURATION_ID);
}
};
void setupAppManagerRunWorker() void setupAppManagerRunWorker()
{ {
static AppManagerRunWorkerFactory theAppManagerRunWorkerFactory; static AppManagerRunWorkerFactory theAppManagerRunWorkerFactory;
@@ -353,4 +374,9 @@ void setupAppManagerQmlToolingWorker()
static AppManagerQmlToolingWorkerFactory theAppManagerQmlToolingWorkerFactory; static AppManagerQmlToolingWorkerFactory theAppManagerQmlToolingWorkerFactory;
} }
void setupAppManagerPerfProfilerWorker()
{
static AppManagerPerfProfilerWorkerFactory theAppManagerPerfProfilerWorkerFactory;
}
} // AppManager::Internal } // AppManager::Internal

View File

@@ -10,5 +10,6 @@ namespace AppManager::Internal {
void setupAppManagerRunWorker(); void setupAppManagerRunWorker();
void setupAppManagerDebugWorker(); void setupAppManagerDebugWorker();
void setupAppManagerQmlToolingWorker(); void setupAppManagerQmlToolingWorker();
void setupAppManagerPerfProfilerWorker();
} // AppManager::Internal } // AppManager::Internal