summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorPavel Labath <pavel@labath.sk>2019-04-02 11:58:37 +0000
committerPavel Labath <pavel@labath.sk>2019-04-02 11:58:37 +0000
commit3cee663e71f6d90ed48eeb5e37de70d14b661eab (patch)
treea5449caea1fa4dcf9a12013f0f1ff8688af77655 /llvm/lib
parent07ef786652e7bd2236733a1d209f4f485901eda6 (diff)
downloadbcm5719-llvm-3cee663e71f6d90ed48eeb5e37de70d14b661eab.tar.gz
bcm5719-llvm-3cee663e71f6d90ed48eeb5e37de70d14b661eab.zip
Add minidump support to obj2yaml
Summary: This patch adds the code needed to parse a minidump file into the MinidumpYAML model, and the necessary glue code so that obj2yaml can recognise the minidump files and process them. Reviewers: jhenderson, zturner, clayborg Subscribers: mgorny, lldb-commits, amccarth, markmentovai, aprantl, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D59634 llvm-svn: 357469
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/ObjectYAML/MinidumpYAML.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/llvm/lib/ObjectYAML/MinidumpYAML.cpp b/llvm/lib/ObjectYAML/MinidumpYAML.cpp
index bd017c82fb4..a2e0b209da5 100644
--- a/llvm/lib/ObjectYAML/MinidumpYAML.cpp
+++ b/llvm/lib/ObjectYAML/MinidumpYAML.cpp
@@ -383,3 +383,35 @@ Error MinidumpYAML::writeAsBinary(StringRef Yaml, raw_ostream &OS) {
writeAsBinary(Obj, OS);
return Error::success();
}
+
+Expected<std::unique_ptr<Stream>>
+Stream::create(const Directory &StreamDesc, const object::MinidumpFile &File) {
+ StreamKind Kind = getKind(StreamDesc.Type);
+ switch (Kind) {
+ case StreamKind::RawContent:
+ return make_unique<RawContentStream>(StreamDesc.Type,
+ File.getRawStream(StreamDesc));
+ case StreamKind::SystemInfo: {
+ auto ExpectedInfo = File.getSystemInfo();
+ if (!ExpectedInfo)
+ return ExpectedInfo.takeError();
+ return make_unique<SystemInfoStream>(*ExpectedInfo);
+ }
+ case StreamKind::TextContent:
+ return make_unique<TextContentStream>(
+ StreamDesc.Type, toStringRef(File.getRawStream(StreamDesc)));
+ }
+ llvm_unreachable("Unhandled stream kind!");
+}
+
+Expected<Object> Object::create(const object::MinidumpFile &File) {
+ std::vector<std::unique_ptr<Stream>> Streams;
+ Streams.reserve(File.streams().size());
+ for (const Directory &StreamDesc : File.streams()) {
+ auto ExpectedStream = Stream::create(StreamDesc, File);
+ if (!ExpectedStream)
+ return ExpectedStream.takeError();
+ Streams.push_back(std::move(*ExpectedStream));
+ }
+ return Object(File.header(), std::move(Streams));
+}
OpenPOWER on IntegriCloud