[Lldb-commits] [lldb] r349767 - Overload GetMemoryRegions for the ProcessMinidump
Tatyana Krasnukha via lldb-commits
lldb-commits at lists.llvm.org
Thu Dec 20 07:05:44 PST 2018
Author: tkrasnukha
Date: Thu Dec 20 07:05:43 2018
New Revision: 349767
URL: http://llvm.org/viewvc/llvm-project?rev=349767&view=rev
Log:
Overload GetMemoryRegions for the ProcessMinidump
Differential Revision: https://reviews.llvm.org/D55841
Modified:
lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
lldb/trunk/scripts/interface/SBMemoryRegionInfo.i
lldb/trunk/source/Plugins/Process/minidump/MinidumpParser.cpp
lldb/trunk/source/Plugins/Process/minidump/MinidumpParser.h
lldb/trunk/source/Plugins/Process/minidump/MinidumpTypes.cpp
lldb/trunk/source/Plugins/Process/minidump/ProcessMinidump.cpp
lldb/trunk/source/Plugins/Process/minidump/ProcessMinidump.h
Modified: lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py?rev=349767&r1=349766&r2=349767&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/minidump-new/TestMiniDumpNew.py Thu Dec 20 07:05:43 2018
@@ -448,3 +448,65 @@ class MiniDumpNewTestCase(TestBase):
frame = thread.GetFrameAtIndex(1)
value = frame.EvaluateExpression('x')
self.assertEqual(value.GetValueAsSigned(), 3)
+
+ def test_memory_regions_in_minidump(self):
+ """Test memory regions from a Minidump"""
+ # target create -c regions-linux-map.dmp
+ self.dbg.CreateTarget(None)
+ self.target = self.dbg.GetSelectedTarget()
+ self.process = self.target.LoadCore("regions-linux-map.dmp")
+ self.check_state()
+
+ regions_count = 19
+ region_info_list = self.process.GetMemoryRegions()
+ self.assertEqual(region_info_list.GetSize(), regions_count)
+
+ def check_region(index, start, end, read, write, execute, mapped, name):
+ region_info = lldb.SBMemoryRegionInfo()
+ self.assertTrue(
+ self.process.GetMemoryRegionInfo(start, region_info).Success())
+ self.assertEqual(start, region_info.GetRegionBase())
+ self.assertEqual(end, region_info.GetRegionEnd())
+ self.assertEqual(read, region_info.IsReadable())
+ self.assertEqual(write, region_info.IsWritable())
+ self.assertEqual(execute, region_info.IsExecutable())
+ self.assertEqual(mapped, region_info.IsMapped())
+ self.assertEqual(name, region_info.GetName())
+
+ # Ensure we have the same regions as SBMemoryRegionInfoList contains.
+ if index >= 0 and index < regions_count:
+ region_info_from_list = lldb.SBMemoryRegionInfo()
+ self.assertTrue(region_info_list.GetMemoryRegionAtIndex(
+ index, region_info_from_list))
+ self.assertEqual(region_info_from_list, region_info)
+
+ a = "/system/bin/app_process"
+ b = "/system/bin/linker"
+ c = "/system/lib/liblog.so"
+ d = "/system/lib/libc.so"
+ n = None
+ max_int = 0xffffffffffffffff
+
+ # Test address before the first entry comes back with nothing mapped up
+ # to first valid region info
+ check_region(-1, 0x00000000, 0x400d9000, False, False, False, False, n)
+ check_region( 0, 0x400d9000, 0x400db000, True, False, True, True, a)
+ check_region( 1, 0x400db000, 0x400dc000, True, False, False, True, a)
+ check_region( 2, 0x400dc000, 0x400dd000, True, True, False, True, n)
+ check_region( 3, 0x400dd000, 0x400ec000, True, False, True, True, b)
+ check_region( 4, 0x400ec000, 0x400ed000, True, False, False, True, n)
+ check_region( 5, 0x400ed000, 0x400ee000, True, False, False, True, b)
+ check_region( 6, 0x400ee000, 0x400ef000, True, True, False, True, b)
+ check_region( 7, 0x400ef000, 0x400fb000, True, True, False, True, n)
+ check_region( 8, 0x400fb000, 0x400fc000, True, False, True, True, c)
+ check_region( 9, 0x400fc000, 0x400fd000, True, True, True, True, c)
+ check_region(10, 0x400fd000, 0x400ff000, True, False, True, True, c)
+ check_region(11, 0x400ff000, 0x40100000, True, False, False, True, c)
+ check_region(12, 0x40100000, 0x40101000, True, True, False, True, c)
+ check_region(13, 0x40101000, 0x40122000, True, False, True, True, d)
+ check_region(14, 0x40122000, 0x40123000, True, True, True, True, d)
+ check_region(15, 0x40123000, 0x40167000, True, False, True, True, d)
+ check_region(16, 0x40167000, 0x40169000, True, False, False, True, d)
+ check_region(17, 0x40169000, 0x4016b000, True, True, False, True, d)
+ check_region(18, 0x4016b000, 0x40176000, True, True, False, True, n)
+ check_region(-1, 0x40176000, max_int, False, False, False, False, n)
Modified: lldb/trunk/scripts/interface/SBMemoryRegionInfo.i
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/interface/SBMemoryRegionInfo.i?rev=349767&r1=349766&r2=349767&view=diff
==============================================================================
--- lldb/trunk/scripts/interface/SBMemoryRegionInfo.i (original)
+++ lldb/trunk/scripts/interface/SBMemoryRegionInfo.i Thu Dec 20 07:05:43 2018
@@ -44,6 +44,9 @@ public:
bool
IsMapped ();
+ const char *
+ GetName ();
+
bool
operator == (const lldb::SBMemoryRegionInfo &rhs) const;
Modified: lldb/trunk/source/Plugins/Process/minidump/MinidumpParser.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/minidump/MinidumpParser.cpp?rev=349767&r1=349766&r2=349767&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/minidump/MinidumpParser.cpp (original)
+++ lldb/trunk/source/Plugins/Process/minidump/MinidumpParser.cpp Thu Dec 20 07:05:43 2018
@@ -11,7 +11,6 @@
#include "NtStructures.h"
#include "RegisterContextMinidump_x86_32.h"
-#include "lldb/Target/MemoryRegionInfo.h"
#include "lldb/Utility/LLDBAssert.h"
#include "Plugins/Process/Utility/LinuxProcMaps.h"
@@ -537,6 +536,12 @@ MinidumpParser::FindMemoryRegion(lldb::a
MemoryRegionInfo
MinidumpParser::GetMemoryRegionInfo(lldb::addr_t load_addr) {
+ if (!m_parsed_regions)
+ GetMemoryRegions();
+ return FindMemoryRegion(load_addr);
+}
+
+const MemoryRegionInfos &MinidumpParser::GetMemoryRegions() {
if (!m_parsed_regions) {
m_parsed_regions = true;
// We haven't cached our memory regions yet we will create the region cache
@@ -552,7 +557,7 @@ MinidumpParser::GetMemoryRegionInfo(lldb
CreateRegionsCacheFromMemory64List(*this, m_regions);
std::sort(m_regions.begin(), m_regions.end());
}
- return FindMemoryRegion(load_addr);
+ return m_regions;
}
Status MinidumpParser::Initialize() {
Modified: lldb/trunk/source/Plugins/Process/minidump/MinidumpParser.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/minidump/MinidumpParser.h?rev=349767&r1=349766&r2=349767&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/minidump/MinidumpParser.h (original)
+++ lldb/trunk/source/Plugins/Process/minidump/MinidumpParser.h Thu Dec 20 07:05:43 2018
@@ -12,6 +12,7 @@
#include "MinidumpTypes.h"
+#include "lldb/Target/MemoryRegionInfo.h"
#include "lldb/Utility/ArchSpec.h"
#include "lldb/Utility/DataBuffer.h"
#include "lldb/Utility/Status.h"
@@ -87,6 +88,8 @@ public:
MemoryRegionInfo GetMemoryRegionInfo(lldb::addr_t load_addr);
+ const MemoryRegionInfos &GetMemoryRegions();
+
// Perform consistency checks and initialize internal data structures
Status Initialize();
@@ -106,7 +109,7 @@ private:
lldb::DataBufferSP m_data_sp;
llvm::DenseMap<uint32_t, MinidumpLocationDescriptor> m_directory_map;
ArchSpec m_arch;
- std::vector<MemoryRegionInfo> m_regions;
+ MemoryRegionInfos m_regions;
bool m_parsed_regions = false;
};
Modified: lldb/trunk/source/Plugins/Process/minidump/MinidumpTypes.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/minidump/MinidumpTypes.cpp?rev=349767&r1=349766&r2=349767&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/minidump/MinidumpTypes.cpp (original)
+++ lldb/trunk/source/Plugins/Process/minidump/MinidumpTypes.cpp Thu Dec 20 07:05:43 2018
@@ -242,6 +242,8 @@ MinidumpMemoryInfo::ParseMemoryInfoList(
return {};
std::vector<const MinidumpMemoryInfo *> result;
+ result.reserve(header->num_of_entries);
+
for (uint64_t i = 0; i < header->num_of_entries; ++i) {
result.push_back(reinterpret_cast<const MinidumpMemoryInfo *>(
data.data() + i * header->size_of_entry));
Modified: lldb/trunk/source/Plugins/Process/minidump/ProcessMinidump.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/minidump/ProcessMinidump.cpp?rev=349767&r1=349766&r2=349767&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/minidump/ProcessMinidump.cpp (original)
+++ lldb/trunk/source/Plugins/Process/minidump/ProcessMinidump.cpp Thu Dec 20 07:05:43 2018
@@ -295,6 +295,12 @@ Status ProcessMinidump::GetMemoryRegionI
return Status();
}
+Status ProcessMinidump::GetMemoryRegions(
+ lldb_private::MemoryRegionInfos ®ion_list) {
+ region_list = m_minidump_parser.GetMemoryRegions();
+ return Status();
+}
+
void ProcessMinidump::Clear() { Process::m_thread_list.Clear(); }
bool ProcessMinidump::UpdateThreadList(ThreadList &old_thread_list,
Modified: lldb/trunk/source/Plugins/Process/minidump/ProcessMinidump.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/minidump/ProcessMinidump.h?rev=349767&r1=349766&r2=349767&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/minidump/ProcessMinidump.h (original)
+++ lldb/trunk/source/Plugins/Process/minidump/ProcessMinidump.h Thu Dec 20 07:05:43 2018
@@ -80,6 +80,9 @@ public:
Status GetMemoryRegionInfo(lldb::addr_t load_addr,
MemoryRegionInfo &range_info) override;
+ Status GetMemoryRegions(
+ lldb_private::MemoryRegionInfos ®ion_list) override;
+
bool GetProcessInfo(ProcessInstanceInfo &info) override;
Status WillResume() override {
More information about the lldb-commits
mailing list