| From b83b82f9f431f20ae35cb3b11443049e31a71481 Mon Sep 17 00:00:00 2001 |
| From: Yi Kong <yikong@google.com> |
| Date: Tue, 28 Jun 2022 15:29:38 +0800 |
| Subject: [PATCH] [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 |
| --- |
| lldb/source/Plugins/Process/Linux/Perf.cpp | 6 ++++++ |
| 1 file changed, 6 insertions(+) |
| |
| diff --git a/lldb/source/Plugins/Process/Linux/Perf.cpp b/lldb/source/Plugins/Process/Linux/Perf.cpp |
| index ed65c61dc48..267d2e96dec 100644 |
| --- a/lldb/source/Plugins/Process/Linux/Perf.cpp |
| +++ b/lldb/source/Plugins/Process/Linux/Perf.cpp |
| @@ -11,6 +11,7 @@ |
| #include "llvm/Support/FormatVariadic.h" |
| #include "llvm/Support/MathExtras.h" |
| |
| +#include <linux/version.h> |
| #include <sys/mman.h> |
| #include <sys/syscall.h> |
| #include <unistd.h> |
| @@ -21,6 +22,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)); |
| @@ -48,6 +50,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) { |
| -- |
| 2.37.0.rc0.161.g10f37bed90-goog |
| |
| |