PerfProfiler: Use QtcProcess instead of IDevice::createProcess()

And pass a device path to command instead. The QtcProcess
should automatically select the device's process implementation
when the process is running.

Change-Id: Id3fed8656999af58ce1a5ba0632f94c3dc76ab04
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Jarek Kobus
2022-04-29 17:08:17 +02:00
parent ddb4ecae32
commit 645d71b3db
3 changed files with 7 additions and 12 deletions

View File

@@ -144,12 +144,8 @@ void PerfConfigWidget::setTarget(ProjectExplorer::Target *target)
QTC_ASSERT(device, return);
QTC_CHECK(!m_process || m_process->state() == QProcess::NotRunning);
m_process.reset(device->createProcess(nullptr));
if (!m_process) {
useTracePointsButton->setEnabled(false);
return;
}
m_process.reset(new QtcProcess);
m_process->setCommand({device->mapToGlobalPath("perf"), {"probe", "-l"}});
connect(m_process.get(), &QtcProcess::done,
this, &PerfConfigWidget::handleProcessDone);
@@ -174,7 +170,6 @@ void PerfConfigWidget::readTracePoints()
messageBox.setText(tr("Replace events with trace points read from the device?"));
messageBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
if (messageBox.exec() == QMessageBox::Yes) {
m_process->setCommand({"perf", {"probe", "-l"}});
m_process->start();
useTracePointsButton->setEnabled(false);
}

View File

@@ -124,7 +124,7 @@ public:
void start() override
{
m_process = device()->createProcess(this);
m_process = new QtcProcess(this);
if (!m_process) {
reportFailure(tr("Could not start device process."));
return;
@@ -147,7 +147,7 @@ public:
Runnable perfRunnable = runnable();
CommandLine cmd({"perf", {"record"}});
CommandLine cmd({device()->mapToGlobalPath("perf"), {"record"}});
cmd.addArgs(m_perfRecordArguments);
cmd.addArgs({"-o", "-", "--"});
cmd.addCommandLineAsArgs(perfRunnable.command, CommandLine::Raw);

View File

@@ -89,15 +89,15 @@ void PerfTracePointDialog::runScript()
m_ui->privilegesChooser->setEnabled(false);
m_ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
m_process.reset(m_device->createProcess(this));
m_process.reset(new QtcProcess(this));
m_process->setWriteData(m_ui->textEdit->toPlainText().toUtf8());
m_ui->textEdit->clear();
const QString elevate = m_ui->privilegesChooser->currentText();
if (elevate != QLatin1String("n.a."))
m_process->setCommand({FilePath::fromString(elevate), {"sh"}});
m_process->setCommand({m_device->mapToGlobalPath(FilePath::fromString(elevate)), {"sh"}});
else
m_process->setCommand({"sh", {}});
m_process->setCommand({m_device->mapToGlobalPath("sh"), {}});
connect(m_process.get(), &QtcProcess::done, this, &PerfTracePointDialog::handleProcessDone);
m_process->start();