diff options
| author | Howard Hellyer <hhellyer@uk.ibm.com> | 2016-07-18 08:25:59 +0000 |
|---|---|---|
| committer | Howard Hellyer <hhellyer@uk.ibm.com> | 2016-07-18 08:25:59 +0000 |
| commit | 97be487728c242feb197410872ca191fc5f5de0f (patch) | |
| tree | e1f11eb6c69ee30bbc5ef57f8572e79c8a71ec24 /lldb/source/Plugins/Process/Windows/MiniDump | |
| parent | 6731f13458884f8fc8cf55706d5e4ac06daa6d5c (diff) | |
| download | bcm5719-llvm-97be487728c242feb197410872ca191fc5f5de0f.tar.gz bcm5719-llvm-97be487728c242feb197410872ca191fc5f5de0f.zip | |
Implement GetMemoryRegions() for Windows Minidumps and live processes.
Summary:
This patch fills in the implementation of GetMemoryRegions() on the Windows live process and minidump implementations of lldb_private::Process (ProcessWindowsLive::GetMemoryRegionInfo and ProcessWinMiniDump::Impl::GetMemoryRegionInfo.) The GetMemoryRegions API was added under: http://reviews.llvm.org/D20565
The existing Windows implementations didn’t fill in the start and end addresses within MemoryRegionInfo. This patch fixes that and adds support for the new mapped flag on MemoryRegionInfo that says whether a memory range is mapped into the process address space or not.
The behaviour of both live and core implementations should match the behaviour documented on Process::GetMemoryRegionInfo (in Process.h) which in turn should match the behaviour of the qMemoryRegionInfo query documented in lldb-gdb-remote.txt.
Reviewers: clayborg, amccarth
Subscribers: amccarth, lldb-commits
Differential Revision: https://reviews.llvm.org/D22352
llvm-svn: 275778
Diffstat (limited to 'lldb/source/Plugins/Process/Windows/MiniDump')
| -rw-r--r-- | lldb/source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.cpp | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/lldb/source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.cpp b/lldb/source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.cpp index f09872fa60c..05839667688 100644 --- a/lldb/source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.cpp +++ b/lldb/source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.cpp @@ -277,6 +277,7 @@ ProcessWinMiniDump::Impl::GetMemoryRegionInfo(lldb::addr_t load_addr, lldb_priva { Error error; size_t size; + info.Clear(); const auto list = reinterpret_cast<const MINIDUMP_MEMORY_INFO_LIST *>(FindDumpStream(MemoryInfoListStream, &size)); if (list == nullptr || size < sizeof(MINIDUMP_MEMORY_INFO_LIST)) { @@ -296,6 +297,8 @@ ProcessWinMiniDump::Impl::GetMemoryRegionInfo(lldb::addr_t load_addr, lldb_priva return error; } + const MINIDUMP_MEMORY_INFO *next_entry = nullptr; + for (int i = 0; i < list->NumberOfEntries; ++i) { const auto entry = reinterpret_cast<const MINIDUMP_MEMORY_INFO *>(reinterpret_cast<const char *>(list) + @@ -304,16 +307,34 @@ ProcessWinMiniDump::Impl::GetMemoryRegionInfo(lldb::addr_t load_addr, lldb_priva const auto tail = head + entry->RegionSize; if (head <= load_addr && load_addr < tail) { + info.GetRange().SetRangeBase((entry->State != MEM_FREE) ? head : load_addr); + info.GetRange().SetRangeEnd(tail); info.SetReadable(IsPageReadable(entry->Protect) ? MemoryRegionInfo::eYes : MemoryRegionInfo::eNo); info.SetWritable(IsPageWritable(entry->Protect) ? MemoryRegionInfo::eYes : MemoryRegionInfo::eNo); info.SetExecutable(IsPageExecutable(entry->Protect) ? MemoryRegionInfo::eYes : MemoryRegionInfo::eNo); + info.SetMapped((entry->State != MEM_FREE) ? MemoryRegionInfo::eYes : MemoryRegionInfo::eNo); return error; } + else if (head > load_addr && (next_entry == nullptr || head < next_entry->BaseAddress) ) + { + // In case there is no region containing load_addr keep track of the nearest region + // after load_addr so we can return the distance to it. + next_entry = entry; + } } + + // No containing region found. Create an unmapped region that extends to the next region + // or LLDB_INVALID_ADDRESS + info.GetRange().SetRangeBase(load_addr); + info.GetRange().SetRangeEnd((next_entry != nullptr)?next_entry->BaseAddress:LLDB_INVALID_ADDRESS); + info.SetReadable(MemoryRegionInfo::eNo); + info.SetWritable(MemoryRegionInfo::eNo); + info.SetExecutable(MemoryRegionInfo::eNo); + info.SetMapped(MemoryRegionInfo::eNo); + // Note that the memory info list doesn't seem to contain ranges in kernel space, // so if you're walking a stack that has kernel frames, the stack may appear // truncated. - error.SetErrorString("address is not in a known range"); return error; } |

