[Lldb-commits] [lldb] b83b82f - [lldb] Fix build on older Linux kernel versions

2022-06-28 Thread Yi Kong via lldb-commits

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 
 #include 
 #include 
 #include 
@@ -26,6 +27,7 @@ using namespace llvm;
 
 Expected
 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) {



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] c0702ac - [PATCH] [lldb-server] Skip shared regions for memory allocation

2022-06-30 Thread Yi Kong via lldb-commits

Author: Emre Kultursay
Date: 2022-07-01T13:45:42+08:00
New Revision: c0702ac07b8e206f424930ff0331151954fb821c

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

LOG: [PATCH] [lldb-server] Skip shared regions for memory allocation

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

Added: 


Modified: 
lldb/include/lldb/Target/MemoryRegionInfo.h
lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp
lldb/source/Plugins/Process/Utility/LinuxProcMaps.cpp
lldb/unittests/Process/Utility/LinuxProcMapsTest.cpp
lldb/unittests/Process/Utility/MemoryTagManagerAArch64MTETest.cpp
lldb/unittests/Process/minidump/MinidumpParserTest.cpp

Removed: 




diff  --git a/lldb/include/lldb/Target/MemoryRegionInfo.h 
b/lldb/include/lldb/Target/MemoryRegionInfo.h
index 4e978d33b05d..3ef66b403e14 100644
--- a/lldb/include/lldb/Target/MemoryRegionInfo.h
+++ b/lldb/include/lldb/Target/MemoryRegionInfo.h
@@ -26,12 +26,14 @@ class MemoryRegionInfo {
 
   MemoryRegionInfo() = default;
   MemoryRegionInfo(RangeType range, OptionalBool read, OptionalBool write,
-   OptionalBool execute, OptionalBool mapped, ConstString name,
+   OptionalBool execute, OptionalBool shared,
+   OptionalBool mapped, ConstString name,
OptionalBool flash, lldb::offset_t blocksize,
OptionalBool memory_tagged, OptionalBool stack_memory)
   : m_range(range), m_read(read), m_write(write), m_execute(execute),
-m_mapped(mapped), m_name(name), m_flash(flash), m_blocksize(blocksize),
-m_memory_tagged(memory_tagged), m_is_stack_memory(stack_memory) {}
+m_shared(shared), m_mapped(mapped), m_name(name), m_flash(flash),
+m_blocksize(blocksize), m_memory_tagged(memory_tagged),
+m_is_stack_memory(stack_memory) {}
 
   RangeType &GetRange() { return m_range; }
 
@@ -45,6 +47,8 @@ class MemoryRegionInfo {
 
   OptionalBool GetExecutable() const { return m_execute; }
 
+  OptionalBool GetShared() const { return m_shared; }
+
   OptionalBool GetMapped() const { return m_mapped; }
 
   ConstString GetName() const { return m_name; }
@@ -57,6 +61,8 @@ class MemoryRegionInfo {
 
   void SetExecutable(OptionalBool val) { m_execute = val; }
 
+  void SetShared(OptionalBool val) { m_shared = val; }
+
   void SetMapped(OptionalBool val) { m_mapped = val; }
 
   void SetName(const char *name) { m_name = ConstString(name); }
@@ -95,6 +101,7 @@ class MemoryRegionInfo {
   bool operator==(const MemoryRegionInfo &rhs) const {
 return m_range == rhs.m_range && m_read == rhs.m_read &&
m_write == rhs.m_write && m_execute == rhs.m_execute &&
+   m_shared == rhs.m_shared &&
m_mapped == rhs.m_mapped && m_name == rhs.m_name &&
m_flash == rhs.m_flash && m_blocksize == rhs.m_blocksize &&
m_memory_tagged == rhs.m_memory_tagged &&
@@ -134,6 +141,7 @@ class MemoryRegionInfo {
   OptionalBool m_read = eDontKnow;
   OptionalBool m_write = eDontKnow;
   OptionalBool m_execute = eDontKnow;
+  OptionalBool m_shared = eDontKnow;
   OptionalBool m_mapped = eDontKnow;
   ConstString m_name;
   OptionalBool m_flash = eDontKnow;

diff  --git a/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp 
b/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp
index 0fb4c691118b..90118f9386da 100644
--- a/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp
+++ b/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp
@@ -1227,7 +1227,8 @@ llvm::Expected
 NativeProcessLinux::Syscall(llvm::ArrayRef args) {
   PopulateMemoryRegionCache();
   auto region_it = llvm::find_if(m_mem_region_cache, [](const auto &pair) {
-return pair.first.GetExecutable() == MemoryRegionInfo::eYes;
+return pair.first.GetExecutable() == MemoryRegionInfo::eYes &&
+pair.first.GetShared() != MemoryRegionInfo::eYes;
   });
   if (region_it == m_mem_region_cache.end())
 return llvm::createStringError(llvm::inconvertibleErrorCode(),

diff  --git a/lldb/source/Plugins/Process/Utility/LinuxProcMaps.cpp 
b/lldb/source/Plugins/Process/Utility/LinuxProcMaps.cpp
index 947b970edf6c..2a15f9813749 100644
--- a/lldb/source/Plugins/Process/Utility/LinuxProcMaps.cpp
+++ b/lldb/source/Plugins/Process/Utility/LinuxProcMaps.cpp
@@ -94,7 +94,15 @@ ParseMemoryRegionInfoFromProcMapsLine(llvm::StringRef 
maps_line,
 return ProcMapError("unexpected /proc/{pid}/%s exec permission char",
 maps_kind);
 
-  line_extractor.GetChar();  // Read the private bit
+  // Handle sharing status (private/shared).
+  const char sharing_char = line_extractor.GetChar();
+  if (sharing_char == 's')
+region.SetShared(MemoryRegionInfo::OptionalBool::eYes);
+  else if (sharing