[Lldb-commits] [lldb] [llvm] [Obj2Yaml] Add support for minidump generation with 64b memory ranges. (PR #101272)
Jacob Lalonde via lldb-commits
lldb-commits at lists.llvm.org
Mon Aug 5 09:51:40 PDT 2024
================
@@ -336,3 +336,52 @@ TEST(MinidumpYAML, ExceptionStream_ExtraParameter) {
0xab, 0xad, 0xca, 0xfe}),
*ExpectedContext);
}
+
+TEST(MinidumpYAML, MemoryRegion_64bit) {
+ SmallString<0> Storage;
+ auto ExpectedFile = toBinary(Storage, R"(
+--- !minidump
+Streams:
+ - Type: Memory64List
+ Memory Ranges:
+ - Start of Memory Range: 0x7FFFFFCF0818283
+ Content: '68656c6c6f'
+ - Start of Memory Range: 0x7FFFFFFF0818283
+ Content: '776f726c64'
+ )");
+
+ ASSERT_THAT_EXPECTED(ExpectedFile, Succeeded());
+ object::MinidumpFile &File = **ExpectedFile;
+
+ ASSERT_EQ(1u, File.streams().size());
+
+ Expected<ArrayRef<minidump::MemoryDescriptor_64>> ExpectedMemoryList =
+ File.getMemory64List();
+
+ ASSERT_THAT_EXPECTED(ExpectedMemoryList, Succeeded());
+
+ ArrayRef<minidump::MemoryDescriptor_64> MemoryList = *ExpectedMemoryList;
+ ASSERT_EQ(2u, MemoryList.size());
+
+ const minidump::MemoryDescriptor_64 &DescOne = MemoryList[0];
+ ASSERT_EQ(0x7FFFFFCF0818283u, DescOne.StartOfMemoryRange);
+ ASSERT_EQ(5u, DescOne.DataSize);
+
+ const minidump::MemoryDescriptor_64 &DescTwo = MemoryList[1];
+ ASSERT_EQ(0x7FFFFFFF0818283u, DescTwo.StartOfMemoryRange);
+ ASSERT_EQ(5u, DescTwo.DataSize);
+
+ const std::optional<ArrayRef<uint8_t>> ExpectedContent =
+ File.getRawStream(StreamType::Memory64List);
+ ASSERT_TRUE(ExpectedContent);
+ const size_t ExpectedStreamSize = sizeof(Memory64ListHeader) + (sizeof(MemoryDescriptor_64) * 2);
+ ASSERT_EQ(ExpectedStreamSize, ExpectedContent->size());
+
+ Expected<ArrayRef<uint8_t>> DescOneExpectedContentSlice = File.getRawData(DescOne);
+ ASSERT_THAT_EXPECTED(DescOneExpectedContentSlice, Succeeded());
+ ASSERT_EQ("hello", reinterpret_cast<const char *>(DescOneExpectedContentSlice->data()));
----------------
Jlalond wrote:
Thank you for your detailed explanation!
https://github.com/llvm/llvm-project/pull/101272
More information about the lldb-commits
mailing list