[Lldb-commits] [lldb] b83b82f - [lldb] Fix build on older Linux kernel versions
Yi Kong via lldb-commits
lldb-commits at lists.llvm.org
Tue Jun 28 05:24:06 PDT 2022
Author: Yi Kong
Date: 2022-06-28T20:23:33+08:00
New Revision: b83b82f9f431f20ae35cb3b11443049e31a71481
URL: https://github.com/llvm/llvm-project/commit/b83b82f9f431f20ae35cb3b11443049e31a71481
DIFF: https://github.com/llvm/llvm-project/commit/b83b82f9f431f20ae35cb3b11443049e31a71481.diff
LOG: [lldb] Fix build on older Linux kernel versions
PERF_COUNT_SW_DUMMY is introduced in Linux 3.12.
Differential Revision: https://reviews.llvm.org/D128707
Added:
Modified:
lldb/source/Plugins/Process/Linux/Perf.cpp
Removed:
################################################################################
diff --git a/lldb/source/Plugins/Process/Linux/Perf.cpp b/lldb/source/Plugins/Process/Linux/Perf.cpp
index bc2038c371712..fa4e8fb42e6cd 100644
--- a/lldb/source/Plugins/Process/Linux/Perf.cpp
+++ b/lldb/source/Plugins/Process/Linux/Perf.cpp
@@ -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>
@@ -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));
@@ -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) {
More information about the lldb-commits
mailing list