[llvm-branch-commits] [lldb] 6599b6e - Fix LLDB build on old Linux kernels (pre-4.1)

Tobias Hieta via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Thu Oct 13 01:04:07 PDT 2022


Author: David Spickett
Date: 2022-10-13T10:03:44+02:00
New Revision: 6599b6e5ae9ea95c857aff33b65f5e25e0bf8c27

URL: https://github.com/llvm/llvm-project/commit/6599b6e5ae9ea95c857aff33b65f5e25e0bf8c27
DIFF: https://github.com/llvm/llvm-project/commit/6599b6e5ae9ea95c857aff33b65f5e25e0bf8c27.diff

LOG: Fix LLDB build on old Linux kernels (pre-4.1)

These fields are guarded elsewhere, but were missing here.

Reviewed By: wallace

Differential Revision: https://reviews.llvm.org/D133778

(chery picked from a9ffb473453519bae158e5d9c72431aa0f6aac2b)

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 fa4e8fb42e6cd..c0a879555365a 100644
--- a/lldb/source/Plugins/Process/Linux/Perf.cpp
+++ b/lldb/source/Plugins/Process/Linux/Perf.cpp
@@ -127,6 +127,10 @@ llvm::Error PerfEvent::MmapMetadataAndDataBuffer(size_t num_data_pages,
 }
 
 llvm::Error PerfEvent::MmapAuxBuffer(size_t num_aux_pages) {
+#ifndef PERF_ATTR_SIZE_VER5
+  return createStringError(inconvertibleErrorCode(),
+                           "Intel PT Linux perf event not supported");
+#else
   if (num_aux_pages == 0)
     return Error::success();
 
@@ -143,6 +147,7 @@ llvm::Error PerfEvent::MmapAuxBuffer(size_t num_aux_pages) {
     return Error::success();
   } else
     return mmap_aux.takeError();
+#endif
 }
 
 llvm::Error PerfEvent::MmapMetadataAndBuffers(size_t num_data_pages,
@@ -172,16 +177,24 @@ perf_event_mmap_page &PerfEvent::GetMetadataPage() const {
 }
 
 ArrayRef<uint8_t> PerfEvent::GetDataBuffer() const {
+#ifndef PERF_ATTR_SIZE_VER5
+  llvm_unreachable("Intel PT Linux perf event not supported");
+#else
   perf_event_mmap_page &mmap_metadata = GetMetadataPage();
   return {reinterpret_cast<uint8_t *>(m_metadata_data_base.get()) +
               mmap_metadata.data_offset,
-           static_cast<size_t>(mmap_metadata.data_size)};
+          static_cast<size_t>(mmap_metadata.data_size)};
+#endif
 }
 
 ArrayRef<uint8_t> PerfEvent::GetAuxBuffer() const {
+#ifndef PERF_ATTR_SIZE_VER5
+  llvm_unreachable("Intel PT Linux perf event not supported");
+#else
   perf_event_mmap_page &mmap_metadata = GetMetadataPage();
   return {reinterpret_cast<uint8_t *>(m_aux_base.get()),
-           static_cast<size_t>(mmap_metadata.aux_size)};
+          static_cast<size_t>(mmap_metadata.aux_size)};
+#endif
 }
 
 Expected<std::vector<uint8_t>> PerfEvent::GetReadOnlyDataBuffer() {
@@ -190,6 +203,10 @@ Expected<std::vector<uint8_t>> PerfEvent::GetReadOnlyDataBuffer() {
   // this piece of code updates some pointers. See more about data_tail
   // in https://man7.org/linux/man-pages/man2/perf_event_open.2.html.
 
+#ifndef PERF_ATTR_SIZE_VER5
+  return createStringError(inconvertibleErrorCode(),
+                           "Intel PT Linux perf event not supported");
+#else
   bool was_enabled = m_enabled;
   if (Error err = DisableWithIoctl())
     return std::move(err);
@@ -226,6 +243,7 @@ Expected<std::vector<uint8_t>> PerfEvent::GetReadOnlyDataBuffer() {
   }
 
   return output;
+#endif
 }
 
 Expected<std::vector<uint8_t>> PerfEvent::GetReadOnlyAuxBuffer() {
@@ -234,6 +252,10 @@ Expected<std::vector<uint8_t>> PerfEvent::GetReadOnlyAuxBuffer() {
   // this piece of code updates some pointers. See more about aux_tail
   // in https://man7.org/linux/man-pages/man2/perf_event_open.2.html.
 
+#ifndef PERF_ATTR_SIZE_VER5
+  return createStringError(inconvertibleErrorCode(),
+                           "Intel PT Linux perf event not supported");
+#else
   bool was_enabled = m_enabled;
   if (Error err = DisableWithIoctl())
     return std::move(err);
@@ -266,6 +288,7 @@ Expected<std::vector<uint8_t>> PerfEvent::GetReadOnlyAuxBuffer() {
   }
 
   return output;
+#endif
 }
 
 Error PerfEvent::DisableWithIoctl() {
@@ -297,11 +320,15 @@ Error PerfEvent::EnableWithIoctl() {
 }
 
 size_t PerfEvent::GetEffectiveDataBufferSize() const {
+#ifndef PERF_ATTR_SIZE_VER5
+  llvm_unreachable("Intel PT Linux perf event not supported");
+#else
   perf_event_mmap_page &mmap_metadata = GetMetadataPage();
   if (mmap_metadata.data_head < mmap_metadata.data_size)
     return mmap_metadata.data_head;
   else
     return mmap_metadata.data_size; // The buffer has wrapped.
+#endif
 }
 
 Expected<PerfEvent>


        


More information about the llvm-branch-commits mailing list