emrekultursay created this revision.
Herald added a project: All.
emrekultursay requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D128832

Files:
  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

Index: lldb/unittests/Process/minidump/MinidumpParserTest.cpp
===================================================================
--- lldb/unittests/Process/minidump/MinidumpParserTest.cpp
+++ lldb/unittests/Process/minidump/MinidumpParserTest.cpp
@@ -378,15 +378,15 @@
       parser->BuildMemoryRegions(),
       testing::Pair(
           testing::ElementsAre(
-              MemoryRegionInfo({0x0, 0x10000}, no, no, no, no, ConstString(),
+              MemoryRegionInfo({0x0, 0x10000}, no, no, no, unknown, no, ConstString(),
                                unknown, 0, unknown, unknown),
-              MemoryRegionInfo({0x10000, 0x21000}, yes, yes, no, yes,
+              MemoryRegionInfo({0x10000, 0x21000}, yes, yes, no, unknown, yes,
                                ConstString(), unknown, 0, unknown, unknown),
-              MemoryRegionInfo({0x40000, 0x1000}, yes, no, no, yes,
+              MemoryRegionInfo({0x40000, 0x1000}, yes, no, no, unknown, yes,
                                ConstString(), unknown, 0, unknown, unknown),
-              MemoryRegionInfo({0x7ffe0000, 0x1000}, yes, no, no, yes,
+              MemoryRegionInfo({0x7ffe0000, 0x1000}, yes, no, no, unknown, yes,
                                ConstString(), unknown, 0, unknown, unknown),
-              MemoryRegionInfo({0x7ffe1000, 0xf000}, no, no, no, yes,
+              MemoryRegionInfo({0x7ffe1000, 0xf000}, no, no, no, unknown, yes,
                                ConstString(), unknown, 0, unknown, unknown)),
           true));
 }
@@ -412,9 +412,9 @@
       parser->BuildMemoryRegions(),
       testing::Pair(
           testing::ElementsAre(
-              MemoryRegionInfo({0x1000, 0x10}, yes, unknown, unknown, yes,
+              MemoryRegionInfo({0x1000, 0x10}, yes, unknown, unknown, unknown, yes,
                                ConstString(), unknown, 0, unknown, unknown),
-              MemoryRegionInfo({0x2000, 0x20}, yes, unknown, unknown, yes,
+              MemoryRegionInfo({0x2000, 0x20}, yes, unknown, unknown, unknown, yes,
                                ConstString(), unknown, 0, unknown, unknown)),
           false));
 }
@@ -428,9 +428,9 @@
       parser->BuildMemoryRegions(),
       testing::Pair(
           testing::ElementsAre(
-              MemoryRegionInfo({0x1000, 0x10}, yes, unknown, unknown, yes,
+              MemoryRegionInfo({0x1000, 0x10}, yes, unknown, unknown, unknown, yes,
                                ConstString(), unknown, 0, unknown, unknown),
-              MemoryRegionInfo({0x2000, 0x20}, yes, unknown, unknown, yes,
+              MemoryRegionInfo({0x2000, 0x20}, yes, unknown, unknown, unknown, yes,
                                ConstString(), unknown, 0, unknown, unknown)),
           false));
 }
@@ -460,17 +460,17 @@
       parser->BuildMemoryRegions(),
       testing::Pair(
           testing::ElementsAre(
-              MemoryRegionInfo({0x400d9000, 0x2000}, yes, no, yes, yes,
+              MemoryRegionInfo({0x400d9000, 0x2000}, yes, no, yes, no, yes,
                                app_process, unknown, 0, unknown, unknown),
-              MemoryRegionInfo({0x400db000, 0x1000}, yes, no, no, yes,
+              MemoryRegionInfo({0x400db000, 0x1000}, yes, no, no, no, yes,
                                app_process, unknown, 0, unknown, unknown),
-              MemoryRegionInfo({0x400dc000, 0x1000}, yes, yes, no, yes,
+              MemoryRegionInfo({0x400dc000, 0x1000}, yes, yes, no, no, yes,
                                ConstString(), unknown, 0, unknown, unknown),
-              MemoryRegionInfo({0x400ec000, 0x1000}, yes, no, no, yes,
+              MemoryRegionInfo({0x400ec000, 0x1000}, yes, no, no, no, yes,
                                ConstString(), unknown, 0, unknown, unknown),
-              MemoryRegionInfo({0x400ee000, 0x1000}, yes, yes, no, yes, linker,
+              MemoryRegionInfo({0x400ee000, 0x1000}, yes, yes, no, no, yes, linker,
                                unknown, 0, unknown, unknown),
-              MemoryRegionInfo({0x400fc000, 0x1000}, yes, yes, yes, yes, liblog,
+              MemoryRegionInfo({0x400fc000, 0x1000}, yes, yes, yes, no, yes, liblog,
                                unknown, 0, unknown, unknown)),
           true));
 }
@@ -491,7 +491,7 @@
   EXPECT_THAT(
       parser->BuildMemoryRegions(),
       testing::Pair(testing::ElementsAre(MemoryRegionInfo(
-                        {0x400fc000, 0x1000}, yes, yes, yes, yes,
+                        {0x400fc000, 0x1000}, yes, yes, yes, no, yes,
                         ConstString(nullptr), unknown, 0, unknown, unknown)),
                     true));
 }
Index: lldb/unittests/Process/Utility/MemoryTagManagerAArch64MTETest.cpp
===================================================================
--- lldb/unittests/Process/Utility/MemoryTagManagerAArch64MTETest.cpp
+++ lldb/unittests/Process/Utility/MemoryTagManagerAArch64MTETest.cpp
@@ -134,8 +134,10 @@
 static MemoryRegionInfo MakeRegionInfo(lldb::addr_t base, lldb::addr_t size,
                                        bool tagged) {
   return MemoryRegionInfo(
-      MemoryRegionInfo::RangeType(base, size), MemoryRegionInfo::eYes,
+      MemoryRegionInfo::RangeType(base, size),
       MemoryRegionInfo::eYes, MemoryRegionInfo::eYes, MemoryRegionInfo::eYes,
+      MemoryRegionInfo::eNo,
+      MemoryRegionInfo::eYes,
       ConstString(), MemoryRegionInfo::eNo, 0,
       /*memory_tagged=*/
       tagged ? MemoryRegionInfo::eYes : MemoryRegionInfo::eNo,
Index: lldb/unittests/Process/Utility/LinuxProcMapsTest.cpp
===================================================================
--- lldb/unittests/Process/Utility/LinuxProcMapsTest.cpp
+++ lldb/unittests/Process/Utility/LinuxProcMapsTest.cpp
@@ -87,8 +87,8 @@
             "0-0 rwzp 00000000 00:00 0\n"
             "2-3 r-xp 00000000 00:00 0 [def]\n",
             MemoryRegionInfos{
-                MemoryRegionInfo(make_range(0, 1), MemoryRegionInfo::eYes,
-                                 MemoryRegionInfo::eYes, MemoryRegionInfo::eNo,
+                MemoryRegionInfo(make_range(0, 1), MemoryRegionInfo::eYes, MemoryRegionInfo::eYes, MemoryRegionInfo::eNo,
+                                 MemoryRegionInfo::eNo,
                                  MemoryRegionInfo::eYes, ConstString("[abc]"),
                                  MemoryRegionInfo::eDontKnow, 0,
                                  MemoryRegionInfo::eDontKnow,
@@ -101,8 +101,9 @@
             MemoryRegionInfos{
                 MemoryRegionInfo(
                     make_range(0x55a4512f7000, 0x55a451b68000),
-                    MemoryRegionInfo::eYes, MemoryRegionInfo::eYes,
-                    MemoryRegionInfo::eNo, MemoryRegionInfo::eYes,
+                    MemoryRegionInfo::eYes, MemoryRegionInfo::eYes, MemoryRegionInfo::eNo,
+                    MemoryRegionInfo::eNo,
+                    MemoryRegionInfo::eYes,
                     ConstString("[heap]"), MemoryRegionInfo::eDontKnow, 0,
                     MemoryRegionInfo::eDontKnow, MemoryRegionInfo::eDontKnow),
             },
@@ -115,14 +116,16 @@
             MemoryRegionInfos{
                 MemoryRegionInfo(
                     make_range(0x7fc090021000, 0x7fc094000000),
-                    MemoryRegionInfo::eNo, MemoryRegionInfo::eNo,
-                    MemoryRegionInfo::eNo, MemoryRegionInfo::eYes,
+                    MemoryRegionInfo::eNo, MemoryRegionInfo::eNo, MemoryRegionInfo::eNo,
+                    MemoryRegionInfo::eNo,
+                    MemoryRegionInfo::eYes,
                     ConstString(nullptr), MemoryRegionInfo::eDontKnow, 0,
                     MemoryRegionInfo::eDontKnow, MemoryRegionInfo::eDontKnow),
                 MemoryRegionInfo(
                     make_range(0xffffffffff600000, 0xffffffffff601000),
-                    MemoryRegionInfo::eYes, MemoryRegionInfo::eNo,
-                    MemoryRegionInfo::eYes, MemoryRegionInfo::eYes,
+                    MemoryRegionInfo::eYes, MemoryRegionInfo::eNo, MemoryRegionInfo::eYes,
+                    MemoryRegionInfo::eNo,
+                    MemoryRegionInfo::eYes,
                     ConstString("[vsyscall]"), MemoryRegionInfo::eDontKnow, 0,
                     MemoryRegionInfo::eDontKnow, MemoryRegionInfo::eDontKnow),
             },
@@ -146,8 +149,9 @@
             "0/0 rw-p 00000000 00:00 0",
             MemoryRegionInfos{
                 MemoryRegionInfo(
-                    make_range(0x1111, 0x2222), MemoryRegionInfo::eYes,
-                    MemoryRegionInfo::eYes, MemoryRegionInfo::eNo,
+                    make_range(0x1111, 0x2222),
+                    MemoryRegionInfo::eYes, MemoryRegionInfo::eYes, MemoryRegionInfo::eNo,
+                    MemoryRegionInfo::eNo,
                     MemoryRegionInfo::eYes, ConstString("[foo]"),
                     MemoryRegionInfo::eDontKnow, 0, MemoryRegionInfo::eDontKnow,
                     MemoryRegionInfo::eDontKnow),
@@ -166,8 +170,9 @@
             "1111-2222 rw-p 00000000 00:00 0    [foo]",
             MemoryRegionInfos{
                 MemoryRegionInfo(
-                    make_range(0x1111, 0x2222), MemoryRegionInfo::eYes,
-                    MemoryRegionInfo::eYes, MemoryRegionInfo::eNo,
+                    make_range(0x1111, 0x2222),
+                    MemoryRegionInfo::eYes, MemoryRegionInfo::eYes, MemoryRegionInfo::eNo,
+                    MemoryRegionInfo::eNo,
                     MemoryRegionInfo::eYes, ConstString("[foo]"),
                     MemoryRegionInfo::eDontKnow, 0, MemoryRegionInfo::eDontKnow,
                     MemoryRegionInfo::eDontKnow),
@@ -181,8 +186,9 @@
             "VmFlags: mt",
             MemoryRegionInfos{
                 MemoryRegionInfo(
-                    make_range(0x1111, 0x2222), MemoryRegionInfo::eYes,
-                    MemoryRegionInfo::eYes, MemoryRegionInfo::eNo,
+                    make_range(0x1111, 0x2222),
+                    MemoryRegionInfo::eYes, MemoryRegionInfo::eYes, MemoryRegionInfo::eNo,
+                    MemoryRegionInfo::eNo,
                     MemoryRegionInfo::eYes, ConstString("[foo]"),
                     MemoryRegionInfo::eDontKnow, 0, MemoryRegionInfo::eYes,
                     MemoryRegionInfo::eDontKnow),
@@ -193,8 +199,9 @@
             "0-0 rw-p 00000000 00:00 0\n"
             "VmFlags:      mt      ",
             MemoryRegionInfos{
-                MemoryRegionInfo(make_range(0, 0), MemoryRegionInfo::eYes,
-                                 MemoryRegionInfo::eYes, MemoryRegionInfo::eNo,
+                MemoryRegionInfo(make_range(0, 0),
+                                 MemoryRegionInfo::eYes, MemoryRegionInfo::eYes, MemoryRegionInfo::eNo,
+                                 MemoryRegionInfo::eNo,
                                  MemoryRegionInfo::eYes, ConstString(nullptr),
                                  MemoryRegionInfo::eDontKnow, 0,
                                  MemoryRegionInfo::eYes,
@@ -206,8 +213,9 @@
             "0-0 rw-p 00000000 00:00 0\n"
             "VmFlags:         ",
             MemoryRegionInfos{
-                MemoryRegionInfo(make_range(0, 0), MemoryRegionInfo::eYes,
-                                 MemoryRegionInfo::eYes, MemoryRegionInfo::eNo,
+                MemoryRegionInfo(make_range(0, 0),
+                                 MemoryRegionInfo::eYes, MemoryRegionInfo::eYes, MemoryRegionInfo::eNo,
+                                 MemoryRegionInfo::eNo,
                                  MemoryRegionInfo::eYes, ConstString(nullptr),
                                  MemoryRegionInfo::eDontKnow, 0,
                                  MemoryRegionInfo::eNo,
@@ -223,14 +231,15 @@
             "VmFlags: mt",
             MemoryRegionInfos{
                 MemoryRegionInfo(
-                    make_range(0x1111, 0x2222), MemoryRegionInfo::eYes,
-                    MemoryRegionInfo::eYes, MemoryRegionInfo::eNo,
+                    make_range(0x1111, 0x2222),
+                    MemoryRegionInfo::eYes, MemoryRegionInfo::eYes, MemoryRegionInfo::eNo,
+                    MemoryRegionInfo::eNo,
                     MemoryRegionInfo::eYes, ConstString("[foo]"),
                     MemoryRegionInfo::eDontKnow, 0, MemoryRegionInfo::eDontKnow,
                     MemoryRegionInfo::eDontKnow),
                 MemoryRegionInfo(
-                    make_range(0x3333, 0x4444), MemoryRegionInfo::eYes,
-                    MemoryRegionInfo::eNo, MemoryRegionInfo::eYes,
+                    make_range(0x3333, 0x4444), MemoryRegionInfo::eYes, MemoryRegionInfo::eNo, MemoryRegionInfo::eYes,
+                    MemoryRegionInfo::eNo,
                     MemoryRegionInfo::eYes, ConstString("[bar]"),
                     MemoryRegionInfo::eDontKnow, 0, MemoryRegionInfo::eYes,
                     MemoryRegionInfo::eDontKnow),
@@ -246,14 +255,16 @@
             "MMUPageSize:           4 kB\n",
             MemoryRegionInfos{
                 MemoryRegionInfo(
-                    make_range(0x1111, 0x2222), MemoryRegionInfo::eYes,
-                    MemoryRegionInfo::eYes, MemoryRegionInfo::eNo,
+                    make_range(0x1111, 0x2222),
+                    MemoryRegionInfo::eYes, MemoryRegionInfo::eYes, MemoryRegionInfo::eNo,
+                    MemoryRegionInfo::eNo,
                     MemoryRegionInfo::eYes, ConstString(nullptr),
                     MemoryRegionInfo::eDontKnow, 0, MemoryRegionInfo::eDontKnow,
                     MemoryRegionInfo::eDontKnow),
                 MemoryRegionInfo(
-                    make_range(0x3333, 0x4444), MemoryRegionInfo::eYes,
-                    MemoryRegionInfo::eNo, MemoryRegionInfo::eYes,
+                    make_range(0x3333, 0x4444),
+                    MemoryRegionInfo::eYes, MemoryRegionInfo::eNo, MemoryRegionInfo::eYes,
+                    MemoryRegionInfo::eNo,
                     MemoryRegionInfo::eYes, ConstString(nullptr),
                     MemoryRegionInfo::eDontKnow, 0, MemoryRegionInfo::eDontKnow,
                     MemoryRegionInfo::eDontKnow),
Index: lldb/source/Plugins/Process/Utility/LinuxProcMaps.cpp
===================================================================
--- lldb/source/Plugins/Process/Utility/LinuxProcMaps.cpp
+++ lldb/source/Plugins/Process/Utility/LinuxProcMaps.cpp
@@ -94,7 +94,15 @@
     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_char == 'p')
+    region.SetShared(MemoryRegionInfo::OptionalBool::eNo);
+  else
+    region.SetShared(MemoryRegionInfo::OptionalBool::eDontKnow);
+
   line_extractor.SkipSpaces();           // Skip the separator
   line_extractor.GetHexMaxU64(false, 0); // Read the offset
   line_extractor.GetHexMaxU64(false, 0); // Read the major device number
Index: lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp
===================================================================
--- lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp
+++ lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp
@@ -1227,7 +1227,8 @@
 NativeProcessLinux::Syscall(llvm::ArrayRef<uint64_t> 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(),
Index: lldb/include/lldb/Target/MemoryRegionInfo.h
===================================================================
--- lldb/include/lldb/Target/MemoryRegionInfo.h
+++ lldb/include/lldb/Target/MemoryRegionInfo.h
@@ -26,12 +26,14 @@
 
   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 @@
 
   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 @@
 
   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 @@
   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 @@
   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;
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to