From e1477b119f1b13dc40d45c73c8dcc1a3495791d8 Mon Sep 17 00:00:00 2001 From: Lieven Hey Date: Wed, 11 Oct 2023 12:20:34 +0200 Subject: [PATCH] check if perf support libtraceevent Some distros **cough** ubuntu **cough** build perf without libtraceevent support. In this case tracepoints obviosly don't work. This patch adds a check for this and shows the user an error message. closes: #519 --- src/recordhost.cpp | 4 +++- src/recordhost.h | 1 + src/recordpage.cpp | 8 ++++++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/recordhost.cpp b/src/recordhost.cpp index df5b53f5..e588948c 100644 --- a/src/recordhost.cpp +++ b/src/recordhost.cpp @@ -130,9 +130,11 @@ RecordHost::PerfCapabilities fetchLocalPerfCapabilities(const QString& perfPath) const auto help = perfRecordHelp(perfPath); capabilities.canCompress = Zstd_FOUND && buildOptions.contains("zstd: [ on ]"); capabilities.canUseAio = buildOptions.contains("aio: [ on ]"); + capabilities.libtraceeventSupport = buildOptions.contains("libtraceevent: [ on ]"); capabilities.canSwitchEvents = help.contains("--switch-events"); capabilities.canSampleCpu = help.contains("--sample-cpu"); - capabilities.canProfileOffCpu = canTrace(QStringLiteral("events/sched/sched_switch")); + capabilities.canProfileOffCpu = + capabilities.libtraceeventSupport && canTrace(QStringLiteral("events/sched/sched_switch")); const auto isElevated = privsAlreadyElevated(); capabilities.privilegesAlreadyElevated = isElevated; diff --git a/src/recordhost.h b/src/recordhost.h index 5023d1cb..c914193c 100644 --- a/src/recordhost.h +++ b/src/recordhost.h @@ -79,6 +79,7 @@ class RecordHost : public QObject bool canCompress = false; bool canElevatePrivileges = false; bool privilegesAlreadyElevated = false; + bool libtraceeventSupport = false; }; PerfCapabilities perfCapabilities() const { diff --git a/src/recordpage.cpp b/src/recordpage.cpp index d3068635..9e9bd106 100644 --- a/src/recordpage.cpp +++ b/src/recordpage.cpp @@ -227,6 +227,14 @@ RecordPage::RecordPage(QWidget* parent) ui->compressionComboBox->setVisible(capabilities.canCompress); ui->compressionLabel->setVisible(capabilities.canCompress); + ui->offCpuCheckBox->setCheckable(capabilities.libtraceeventSupport); + + if (!capabilities.libtraceeventSupport) { + ui->offCpuCheckBox->setChecked(false); + ui->offCpuCheckBox->setText( + tr("perf doesn't support libtraceevent, you may need to build perf manually to support this")); + } + if (!capabilities.canElevatePrivileges) { ui->elevatePrivilegesCheckBox->setChecked(false); ui->elevatePrivilegesCheckBox->setEnabled(false);