Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

check if perf support libtraceevent #520

Merged
merged 1 commit into from
Oct 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
10 changes: 9 additions & 1 deletion 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 Expand Up @@ -441,7 +449,7 @@ RecordPage::RecordPage(QWidget* parent)

auto updateOffCpuCheckboxState = [this](RecordHost::PerfCapabilities capabilities) {
const bool enableOffCpuProfiling = (ui->elevatePrivilegesCheckBox->isChecked() || capabilities.canProfileOffCpu)
&& capabilities.canSwitchEvents;
&& capabilities.canSwitchEvents && capabilities.libtraceeventSupport;

if (enableOffCpuProfiling == ui->offCpuCheckBox->isEnabled()) {
return;
Expand Down