diff options
author | Adrian McCarthy <amccarth@google.com> | 2015-12-04 22:22:15 +0000 |
---|---|---|
committer | Adrian McCarthy <amccarth@google.com> | 2015-12-04 22:22:15 +0000 |
commit | 0c35cde9b1fd0e7b54e77e7ba14116af6aae0ea9 (patch) | |
tree | f71047ab9225277c30fa4cfe4a30d7596058c033 /lldb/source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.cpp | |
parent | 072bff80362c24ae81a4e5a3feff2caa128aec10 (diff) | |
download | bcm5719-llvm-0c35cde9b1fd0e7b54e77e7ba14116af6aae0ea9.tar.gz bcm5719-llvm-0c35cde9b1fd0e7b54e77e7ba14116af6aae0ea9.zip |
Implement GetMemoryRegionInfo for mini dumps.
Differential Revision: http://reviews.llvm.org/D15218
llvm-svn: 254780
Diffstat (limited to 'lldb/source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.cpp')
-rw-r--r-- | lldb/source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.cpp | 58 |
1 files changed, 52 insertions, 6 deletions
diff --git a/lldb/source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.cpp b/lldb/source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.cpp index 7279ae986d7..ca41dac73b8 100644 --- a/lldb/source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.cpp +++ b/lldb/source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.cpp @@ -17,21 +17,22 @@ #include <memory> #include <mutex> -#include "lldb/Core/PluginManager.h" +#include "Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.h" +#include "lldb/Core/DataBufferHeap.h" +#include "lldb/Core/Log.h" #include "lldb/Core/Module.h" #include "lldb/Core/ModuleSpec.h" +#include "lldb/Core/PluginManager.h" #include "lldb/Core/Section.h" #include "lldb/Core/State.h" -#include "lldb/Core/DataBufferHeap.h" -#include "lldb/Core/Log.h" +#include "lldb/Target/DynamicLoader.h" +#include "lldb/Target/MemoryRegionInfo.h" #include "lldb/Target/StopInfo.h" #include "lldb/Target/Target.h" -#include "lldb/Target/DynamicLoader.h" #include "lldb/Target/UnixSignals.h" +#include "llvm/Support/ConvertUTF.h" #include "llvm/Support/Format.h" #include "llvm/Support/raw_ostream.h" -#include "llvm/Support/ConvertUTF.h" -#include "Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.h" #include "ExceptionRecord.h" #include "ThreadWinMiniDump.h" @@ -272,6 +273,51 @@ ProcessWinMiniDump::DoReadMemory(lldb::addr_t addr, void *buf, size_t size, Erro return overlap; } +Error +ProcessWinMiniDump::GetMemoryRegionInfo(lldb::addr_t load_addr, lldb_private::MemoryRegionInfo &info) +{ + Error error; + size_t size; + const auto list = reinterpret_cast<const MINIDUMP_MEMORY_INFO_LIST *>(FindDumpStream(MemoryInfoListStream, &size)); + if (list == nullptr || size < sizeof(MINIDUMP_MEMORY_INFO_LIST)) + { + error.SetErrorString("the mini dump contains no memory range information"); + return error; + } + + if (list->SizeOfEntry < sizeof(MINIDUMP_MEMORY_INFO)) + { + error.SetErrorString("the entries in the mini dump memory info list are smaller than expected"); + return error; + } + + if (size < list->SizeOfHeader + list->SizeOfEntry * list->NumberOfEntries) + { + error.SetErrorString("the mini dump memory info list is incomplete"); + return error; + } + + for (int i = 0; i < list->NumberOfEntries; ++i) + { + const auto entry = reinterpret_cast<const MINIDUMP_MEMORY_INFO *>(reinterpret_cast<const char *>(list) + + list->SizeOfHeader + i * list->SizeOfEntry); + const auto head = entry->BaseAddress; + const auto tail = head + entry->RegionSize; + if (head <= load_addr && load_addr < 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); + return error; + } + } + // 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; +} + void ProcessWinMiniDump::Clear() { |