[Lldb-commits] [lldb] [LLDB][Minidump] Fix ProcessMinidump::GetMemoryRegions to include 64b regions when /proc/pid maps are missing. (PR #101086)
Jacob Lalonde via lldb-commits
lldb-commits at lists.llvm.org
Thu Aug 15 17:03:18 PDT 2024
================
@@ -553,53 +547,49 @@ static bool
CreateRegionsCacheFromMemoryList(MinidumpParser &parser,
std::vector<MemoryRegionInfo> ®ions) {
Log *log = GetLog(LLDBLog::Modules);
+ // Cache the expected memory32 into an optional
+ // because double checking the expected triggers the unchecked warning.
+ std::optional<llvm::ArrayRef<MemoryDescriptor>> memory32_list;
auto ExpectedMemory = parser.GetMinidumpFile().getMemoryList();
if (!ExpectedMemory) {
LLDB_LOG_ERROR(log, ExpectedMemory.takeError(),
"Failed to read memory list: {0}");
- return false;
- }
- regions.reserve(ExpectedMemory->size());
- for (const MemoryDescriptor &memory_desc : *ExpectedMemory) {
- if (memory_desc.Memory.DataSize == 0)
- continue;
- MemoryRegionInfo region;
- region.GetRange().SetRangeBase(memory_desc.StartOfMemoryRange);
- region.GetRange().SetByteSize(memory_desc.Memory.DataSize);
- region.SetReadable(MemoryRegionInfo::eYes);
- region.SetMapped(MemoryRegionInfo::eYes);
- regions.push_back(region);
+ } else {
+ memory32_list = *ExpectedMemory;
}
- regions.shrink_to_fit();
- return !regions.empty();
-}
-static bool
-CreateRegionsCacheFromMemory64List(MinidumpParser &parser,
- std::vector<MemoryRegionInfo> ®ions) {
- llvm::ArrayRef<uint8_t> data =
- parser.GetStream(StreamType::Memory64List);
- if (data.empty())
- return false;
- llvm::ArrayRef<MinidumpMemoryDescriptor64> memory64_list;
- uint64_t base_rva;
- std::tie(memory64_list, base_rva) =
- MinidumpMemoryDescriptor64::ParseMemory64List(data);
+ if (memory32_list) {
+ for (const MemoryDescriptor &memory_desc : *memory32_list) {
----------------
Jlalond wrote:
@labath as an FYI, using the new fallible iterator API
https://github.com/llvm/llvm-project/pull/101086
More information about the lldb-commits
mailing list