AppMan: Inline AppManInferiorRunner

Change-Id: I3e67d39de10f88b6b98fbf8ea0856bd0562de687
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Jarek Kobus
2024-11-20 16:14:54 +01:00
parent c6ff6d8a8f
commit 490a859ee9

View File

@@ -92,24 +92,18 @@ public:
} }
}; };
static RunWorker *createInferiorRunner(RunControl *runControl, QmlDebugServicesPreset qmlServices)
// AppManInferiorRunner
class AppManInferiorRunner : public SimpleTargetRunner
{ {
public: auto worker = new SimpleTargetRunner(runControl);
AppManInferiorRunner(RunControl *runControl, QmlDebugServicesPreset qmlServices) worker->setId(AppManager::Constants::DEBUG_LAUNCHER_ID);
: SimpleTargetRunner(runControl) worker->setEssential(true);
{
setId(AppManager::Constants::DEBUG_LAUNCHER_ID);
setEssential(true);
if (usesPerfChannel()) { if (worker->usesPerfChannel()) {
suppressDefaultStdOutHandling(); worker->suppressDefaultStdOutHandling();
runControl->setProperty("PerfProcess", QVariant::fromValue(process())); runControl->setProperty("PerfProcess", QVariant::fromValue(worker->process()));
} }
setStartModifier([this, runControl, qmlServices] { worker->setStartModifier([worker, runControl, qmlServices] {
FilePath controller = runControl->aspectData<AppManagerControllerAspect>()->filePath; FilePath controller = runControl->aspectData<AppManagerControllerAspect>()->filePath;
QString appId = runControl->aspectData<AppManagerIdAspect>()->value; QString appId = runControl->aspectData<AppManagerIdAspect>()->value;
QString instanceId = runControl->aspectData<AppManagerInstanceIdAspect>()->value; QString instanceId = runControl->aspectData<AppManagerInstanceIdAspect>()->value;
@@ -126,19 +120,19 @@ public:
cmd.addArg("debug-application"); cmd.addArg("debug-application");
if (usesDebugChannel() || usesQmlChannel()) { if (worker->usesDebugChannel() || worker->usesQmlChannel()) {
QStringList debugArgs; QStringList debugArgs;
debugArgs.append(envVars.join(' ')); debugArgs.append(envVars.join(' '));
if (usesDebugChannel()) if (worker->usesDebugChannel())
debugArgs.append(QString("gdbserver :%1").arg(debugChannel().port())); debugArgs.append(QString("gdbserver :%1").arg(worker->debugChannel().port()));
if (usesQmlChannel()) { if (worker->usesQmlChannel()) {
const QString qmlArgs = qmlDebugCommandLineArguments(qmlServices, const QString qmlArgs = qmlDebugCommandLineArguments(qmlServices,
QString("port:%1").arg(qmlChannel().port()), true); QString("port:%1").arg(worker->qmlChannel().port()), true);
debugArgs.append(QString("%program% %1 %arguments%") .arg(qmlArgs)); debugArgs.append(QString("%program% %1 %arguments%") .arg(qmlArgs));
} }
cmd.addArg(debugArgs.join(' ')); cmd.addArg(debugArgs.join(' '));
} }
if (usesPerfChannel()) { if (worker->usesPerfChannel()) {
const Store perfArgs = runControl->settingsData(PerfProfiler::Constants::PerfSettingsId); const Store perfArgs = runControl->settingsData(PerfProfiler::Constants::PerfSettingsId);
const QString recordArgs = perfArgs[PerfProfiler::Constants::PerfRecordArgsId].toString(); const QString recordArgs = perfArgs[PerfProfiler::Constants::PerfRecordArgsId].toString();
cmd.addArg(QString("perf record %1 -o - --").arg(recordArgs)); cmd.addArg(QString("perf record %1 -o - --").arg(recordArgs));
@@ -154,17 +148,16 @@ public:
// Always use the default environment to start the appman-controller in // Always use the default environment to start the appman-controller in
// The env variables from the EnvironmentAspect are set through the controller // The env variables from the EnvironmentAspect are set through the controller
setEnvironment({}); worker->setEnvironment({});
// Prevent the write channel to be closed, otherwise the appman-controller will exit // Prevent the write channel to be closed, otherwise the appman-controller will exit
setProcessMode(ProcessMode::Writer); worker->setProcessMode(ProcessMode::Writer);
setCommandLine(cmd); worker->setCommandLine(cmd);
appendMessage(Tr::tr("Starting Application Manager debugging..."), NormalMessageFormat); worker->appendMessage(Tr::tr("Starting Application Manager debugging..."), NormalMessageFormat);
appendMessage(Tr::tr("Using: %1.").arg(cmd.toUserOutput()), NormalMessageFormat); worker->appendMessage(Tr::tr("Using: %1.").arg(cmd.toUserOutput()), NormalMessageFormat);
}); });
return worker;
} }
};
// AppManagerDebugSupport // AppManagerDebugSupport
@@ -181,7 +174,7 @@ public:
if (isQmlDebugging()) if (isQmlDebugging())
runControl->requestQmlChannel(); runControl->requestQmlChannel();
auto debuggee = new AppManInferiorRunner(runControl, QmlDebuggerServices); auto debuggee = createInferiorRunner(runControl, QmlDebuggerServices);
addStartDependency(debuggee); addStartDependency(debuggee);
addStopDependency(debuggee); addStopDependency(debuggee);
@@ -260,7 +253,7 @@ public:
runControl->requestQmlChannel(); runControl->requestQmlChannel();
QmlDebugServicesPreset services = servicesForRunMode(runControl->runMode()); QmlDebugServicesPreset services = servicesForRunMode(runControl->runMode());
auto runner = new AppManInferiorRunner(runControl, services); auto runner = createInferiorRunner(runControl, services);
addStartDependency(runner); addStartDependency(runner);
addStopDependency(runner); addStopDependency(runner);
@@ -284,7 +277,7 @@ public:
setId("AppManagerPerfProfilerSupport"); setId("AppManagerPerfProfilerSupport");
runControl->requestPerfChannel(); runControl->requestPerfChannel();
auto profilee = new AppManInferiorRunner(runControl, NoQmlDebugServices); auto profilee = createInferiorRunner(runControl, NoQmlDebugServices);
addStartDependency(profilee); addStartDependency(profilee);
addStopDependency(profilee); addStopDependency(profilee);
} }