Skip to content

Commit

Permalink
[lldb] Fix build on older Linux kernel versions
Browse files Browse the repository at this point in the history
PERF_COUNT_SW_DUMMY is introduced in Linux 3.12.

Differential Revision: https://reviews.llvm.org/D128707
  • Loading branch information
kongy committed Jun 28, 2022
1 parent 170c4d2 commit b83b82f
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lldb/source/Plugins/Process/Linux/Perf.cpp
Expand Up @@ -15,6 +15,7 @@
#include "llvm/Support/MathExtras.h"
#include "llvm/Support/MemoryBuffer.h"

#include <linux/version.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
#include <sys/syscall.h>
Expand All @@ -26,6 +27,7 @@ using namespace llvm;

Expected<LinuxPerfZeroTscConversion>
lldb_private::process_linux::LoadPerfTscConversionParameters() {
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0)
lldb::pid_t pid = getpid();
perf_event_attr attr;
memset(&attr, 0, sizeof(attr));
Expand Down Expand Up @@ -55,6 +57,10 @@ lldb_private::process_linux::LoadPerfTscConversionParameters() {
err_cap);
return llvm::createStringError(llvm::inconvertibleErrorCode(), err_msg);
}
#else
std::string err_msg = "PERF_COUNT_SW_DUMMY requires Linux 3.12";
return llvm::createStringError(llvm::inconvertibleErrorCode(), err_msg);
#endif
}

void resource_handle::MmapDeleter::operator()(void *ptr) {
Expand Down

0 comments on commit b83b82f

Please sign in to comment.