[Lldb-commits] [lldb] r361010 - minidump: Use MemoryList parsing code from llvm
Pavel Labath via lldb-commits
lldb-commits at lists.llvm.org
Fri May 17 02:47:34 PDT 2019
Author: labath
Date: Fri May 17 02:47:34 2019
New Revision: 361010
URL: http://llvm.org/viewvc/llvm-project?rev=361010&view=rev
Log:
minidump: Use MemoryList parsing code from llvm
Modified:
lldb/trunk/source/Plugins/Process/minidump/MinidumpParser.cpp
lldb/trunk/source/Plugins/Process/minidump/MinidumpTypes.cpp
lldb/trunk/source/Plugins/Process/minidump/MinidumpTypes.h
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=361010&r1=361009&r2=361010&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/minidump/MinidumpParser.cpp (original)
+++ lldb/trunk/source/Plugins/Process/minidump/MinidumpParser.cpp Fri May 17 02:47:34 2019
@@ -284,7 +284,7 @@ std::vector<const minidump::Module *> Mi
auto ExpectedName = m_file->getString(module.ModuleNameRVA);
if (!ExpectedName) {
LLDB_LOG_ERROR(log, ExpectedName.takeError(),
- "Failed to module name: {0}");
+ "Failed to get module name: {0}");
continue;
}
@@ -324,19 +324,15 @@ const MinidumpExceptionStream *MinidumpP
llvm::Optional<minidump::Range>
MinidumpParser::FindMemoryRange(lldb::addr_t addr) {
- llvm::ArrayRef<uint8_t> data = GetStream(StreamType::MemoryList);
llvm::ArrayRef<uint8_t> data64 = GetStream(StreamType::Memory64List);
+ Log *log = GetLogIfAnyCategoriesSet(LIBLLDB_LOG_MODULES);
- if (data.empty() && data64.empty())
- return llvm::None;
-
- if (!data.empty()) {
- llvm::ArrayRef<MemoryDescriptor> memory_list = ParseMemoryList(data);
-
- if (memory_list.empty())
- return llvm::None;
-
- for (const auto &memory_desc : memory_list) {
+ auto ExpectedMemory = GetMinidumpFile().getMemoryList();
+ if (!ExpectedMemory) {
+ LLDB_LOG_ERROR(log, ExpectedMemory.takeError(),
+ "Failed to read memory list: {0}");
+ } else {
+ for (const auto &memory_desc : *ExpectedMemory) {
const LocationDescriptor &loc_desc = memory_desc.Memory;
const lldb::addr_t range_start = memory_desc.StartOfMemoryRange;
const size_t range_size = loc_desc.DataSize;
@@ -345,8 +341,13 @@ MinidumpParser::FindMemoryRange(lldb::ad
return llvm::None;
if (range_start <= addr && addr < range_start + range_size) {
- return minidump::Range(range_start,
- GetData().slice(loc_desc.RVA, range_size));
+ auto ExpectedSlice = GetMinidumpFile().getRawData(loc_desc);
+ if (!ExpectedSlice) {
+ LLDB_LOG_ERROR(log, ExpectedSlice.takeError(),
+ "Failed to get memory slice: {0}");
+ return llvm::None;
+ }
+ return minidump::Range(range_start, *ExpectedSlice);
}
}
}
@@ -450,14 +451,15 @@ CreateRegionsCacheFromMemoryInfoList(Min
static bool
CreateRegionsCacheFromMemoryList(MinidumpParser &parser,
std::vector<MemoryRegionInfo> ®ions) {
- auto data = parser.GetStream(StreamType::MemoryList);
- if (data.empty())
+ Log *log = GetLogIfAnyCategoriesSet(LIBLLDB_LOG_MODULES);
+ auto ExpectedMemory = parser.GetMinidumpFile().getMemoryList();
+ if (!ExpectedMemory) {
+ LLDB_LOG_ERROR(log, ExpectedMemory.takeError(),
+ "Failed to read memory list: {0}");
return false;
- auto memory_list = ParseMemoryList(data);
- if (memory_list.empty())
- return false;
- regions.reserve(memory_list.size());
- for (const auto &memory_desc : memory_list) {
+ }
+ regions.reserve(ExpectedMemory->size());
+ for (const MemoryDescriptor &memory_desc : *ExpectedMemory) {
if (memory_desc.Memory.DataSize == 0)
continue;
MemoryRegionInfo region;
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=361010&r1=361009&r2=361010&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/minidump/MinidumpTypes.cpp (original)
+++ lldb/trunk/source/Plugins/Process/minidump/MinidumpTypes.cpp Fri May 17 02:47:34 2019
@@ -68,25 +68,6 @@ MinidumpExceptionStream::Parse(llvm::Arr
return exception_stream;
}
-llvm::ArrayRef<MemoryDescriptor>
-minidump::ParseMemoryList(llvm::ArrayRef<uint8_t> &data) {
- const auto orig_size = data.size();
- const llvm::support::ulittle32_t *mem_ranges_count;
- Status error = consumeObject(data, mem_ranges_count);
- if (error.Fail() ||
- *mem_ranges_count * sizeof(MemoryDescriptor) > data.size())
- return {};
-
- // Compilers might end up padding an extra 4 bytes depending on how the
- // structure is padded by the compiler and the #pragma pack settings.
- if (4 + *mem_ranges_count * sizeof(MemoryDescriptor) < orig_size)
- data = data.drop_front(4);
-
- return llvm::makeArrayRef(
- reinterpret_cast<const MemoryDescriptor *>(data.data()),
- *mem_ranges_count);
-}
-
std::pair<llvm::ArrayRef<MinidumpMemoryDescriptor64>, uint64_t>
MinidumpMemoryDescriptor64::ParseMemory64List(llvm::ArrayRef<uint8_t> &data) {
const llvm::support::ulittle64_t *mem_ranges_count;
Modified: lldb/trunk/source/Plugins/Process/minidump/MinidumpTypes.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/minidump/MinidumpTypes.h?rev=361010&r1=361009&r2=361010&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/minidump/MinidumpTypes.h (original)
+++ lldb/trunk/source/Plugins/Process/minidump/MinidumpTypes.h Fri May 17 02:47:34 2019
@@ -75,8 +75,6 @@ Status consumeObject(llvm::ArrayRef<uint
return error;
}
-llvm::ArrayRef<MemoryDescriptor> ParseMemoryList(llvm::ArrayRef<uint8_t> &data);
-
struct MinidumpMemoryDescriptor64 {
llvm::support::ulittle64_t start_of_memory_range;
llvm::support::ulittle64_t data_size;
More information about the lldb-commits
mailing list