summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Object/Minidump.cpp
diff options
context:
space:
mode:
authorPavel Labath <pavel@labath.sk>2019-04-08 09:57:29 +0000
committerPavel Labath <pavel@labath.sk>2019-04-08 09:57:29 +0000
commitaaff480c68cac3c363420292ff58889c366aca5c (patch)
treea4a7271cc5adc38129070a2f37877bf1b1ad6b50 /llvm/lib/Object/Minidump.cpp
parent7b30751acb9c9bfcd449c2386ab8519092700a54 (diff)
downloadbcm5719-llvm-aaff480c68cac3c363420292ff58889c366aca5c.tar.gz
bcm5719-llvm-aaff480c68cac3c363420292ff58889c366aca5c.zip
Object/Minidump: Add support for reading the ModuleList stream
Summary: The ModuleList stream consists of an integer giving the number of entries in the list, followed by the list itself. Each entry in the list describes a module (dynamically loaded objects which were loaded in the process when it crashed (or when the minidump was generated). The code for reading the list is relatively straight-forward, with a single gotcha. Some minidump writers are emitting padding after the "count" field in order to align the subsequent list on 8 byte boundary (this depends on how their ModuleList type was defined and the native alignment of various types on their platform). Fortunately, the minidump format contains enough redundancy (in the form of the stream length field in the stream directory), which allows us to detect this situation and correct it. This patch just adds the ability to parse the stream. Code for conversion to/from yaml will come in a follow-up patch. Reviewers: zturner, amccarth, jhenderson, clayborg Subscribers: jdoerfert, markmentovai, lldb-commits, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D60121 llvm-svn: 357897
Diffstat (limited to 'llvm/lib/Object/Minidump.cpp')
-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