Skip to content
Open
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
14 changes: 4 additions & 10 deletions src/recordhost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ QByteArray perfBuildOptions(const QString& perfPath)

bool canTrace(const QString& path)
{
const QFileInfo info(QLatin1String("/sys/kernel/debug/tracing/") + path);
const QFileInfo info(QLatin1String("/sys/kernel/tracing/") + path);
if (!info.isDir() || !info.isReadable()) {
return false;
}
Expand Down Expand Up @@ -111,15 +111,9 @@ bool privsAlreadyElevated()
return false;
}

auto checkPerms = [](const char* path) {
const mode_t required = S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH; // 755
struct stat buf;
return stat(path, &buf) == 0 && ((buf.st_mode & 07777) & required) == required;
};
static const auto paths = {"/sys/kernel/debug", "/sys/kernel/debug/tracing"};
isElevated = std::all_of(paths.begin(), paths.end(), checkPerms);

return isElevated;
const mode_t required = S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH; // 755
struct stat buf;
return stat("/sys/kernel/tracing", &buf) == 0 && ((buf.st_mode & 07777) & required) == required;
}

RecordHost::PerfCapabilities fetchLocalPerfCapabilities(const QString& perfPath)
Expand Down
6 changes: 4 additions & 2 deletions src/recordpage.ui
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,8 @@
<item row="2" column="0">
<widget class="QLabel" name="offCpuLabel">
<property name="toolTip">
<string>Record scheduler switch events. This enables off-CPU profiling to measure sleep times etc. This requires elevated privileges.</string>
<string>Record scheduler switch events. This enables off-CPU profiling to measure sleep times etc.
This requires elevated privileges or both /sys/kernel/tracing to be readable and /proc/sys/kernel/perf_event_paranoid == -1.</string>
</property>
<property name="text">
<string>Off-CPU Profilin&amp;g:</string>
Expand All @@ -278,7 +279,8 @@
<item row="2" column="1">
<widget class="QCheckBox" name="offCpuCheckBox">
<property name="toolTip">
<string>Record scheduler switch events. This enables off-CPU profiling to measure sleep times etc. This requires elevated privileges.</string>
<string>Record scheduler switch events. This enables off-CPU profiling to measure sleep times etc.
This requires elevated privileges or both /sys/kernel/tracing to be readable and /proc/sys/kernel/perf_event_paranoid == -1.</string>
</property>
<property name="text">
<string/>
Expand Down
Loading