Skip to content

Commit

Permalink
check if perf support libtraceevent
Browse files Browse the repository at this point in the history
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
  • Loading branch information
lievenhey committed Oct 11, 2023
1 parent fe691c3 commit e1477b1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/recordhost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions src/recordhost.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ class RecordHost : public QObject
bool canCompress = false;
bool canElevatePrivileges = false;
bool privilegesAlreadyElevated = false;
bool libtraceeventSupport = false;
};
PerfCapabilities perfCapabilities() const
{
Expand Down
8 changes: 8 additions & 0 deletions src/recordpage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit e1477b1

Please # to comment.