summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Object
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/Object')
-rw-r--r--llvm/lib/Object/Minidump.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/llvm/lib/Object/Minidump.cpp b/llvm/lib/Object/Minidump.cpp
index 1a22491ce3c..4b1abe52994 100644
--- a/llvm/lib/Object/Minidump.cpp
+++ b/llvm/lib/Object/Minidump.cpp
@@ -53,6 +53,27 @@ Expected<std::string> MinidumpFile::getString(size_t Offset) const {
return Result;
}
+Expected<ArrayRef<Module>> MinidumpFile::getModuleList() const {
+ auto OptionalStream = getRawStream(StreamType::ModuleList);
+ if (!OptionalStream)
+ return createError("No such stream");
+ auto ExpectedSize =
+ getDataSliceAs<support::ulittle32_t>(*OptionalStream, 0, 1);
+ if (!ExpectedSize)
+ return ExpectedSize.takeError();
+
+ size_t ListSize = ExpectedSize.get()[0];
+
+ size_t ListOffset = 4;
+ // Some producers insert additional padding bytes to align the module list to
+ // 8-byte boundary. Check for that by comparing the module list size with the
+ // overall stream size.
+ if (ListOffset + sizeof(Module) * ListSize < OptionalStream->size())
+ ListOffset = 8;
+
+ return getDataSliceAs<Module>(*OptionalStream, ListOffset, ListSize);
+}
+
Expected<ArrayRef<uint8_t>>
MinidumpFile::getDataSlice(ArrayRef<uint8_t> Data, size_t Offset, size_t Size) {
// Check for overflow.
OpenPOWER on IntegriCloud