diff options
| author | Pavel Labath <pavel@labath.sk> | 2019-05-16 15:17:30 +0000 |
|---|---|---|
| committer | Pavel Labath <pavel@labath.sk> | 2019-05-16 15:17:30 +0000 |
| commit | 2d29e16c308699d19c591675deb10fa3c544558b (patch) | |
| tree | c31a014ca26f6ca1f108dc67988ddbfd17b98994 /llvm/lib/ObjectYAML | |
| parent | 738e42efb3c48d27d482a2093df912cf870cd396 (diff) | |
| download | bcm5719-llvm-2d29e16c308699d19c591675deb10fa3c544558b.tar.gz bcm5719-llvm-2d29e16c308699d19c591675deb10fa3c544558b.zip | |
Minidump: Add support for the MemoryList stream
Summary:
the stream format is exactly the same as for ThreadList and ModuleList
streams, only the entry types are slightly different, so the changes in
this patch are just straight-forward applications of established
patterns.
Reviewers: amccarth, jhenderson, clayborg
Subscribers: markmentovai, lldb-commits, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D61885
llvm-svn: 360908
Diffstat (limited to 'llvm/lib/ObjectYAML')
| -rw-r--r-- | llvm/lib/ObjectYAML/MinidumpYAML.cpp | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/llvm/lib/ObjectYAML/MinidumpYAML.cpp b/llvm/lib/ObjectYAML/MinidumpYAML.cpp index c012e86c927..f5f2acd0cc4 100644 --- a/llvm/lib/ObjectYAML/MinidumpYAML.cpp +++ b/llvm/lib/ObjectYAML/MinidumpYAML.cpp @@ -168,6 +168,8 @@ Stream::~Stream() = default; Stream::StreamKind Stream::getKind(StreamType Type) { switch (Type) { + case StreamType::MemoryList: + return StreamKind::MemoryList; case StreamType::ModuleList: return StreamKind::ModuleList; case StreamType::SystemInfo: @@ -190,6 +192,8 @@ Stream::StreamKind Stream::getKind(StreamType Type) { std::unique_ptr<Stream> Stream::create(StreamType Type) { StreamKind Kind = getKind(Type); switch (Kind) { + case StreamKind::MemoryList: + return llvm::make_unique<MemoryListStream>(); case StreamKind::ModuleList: return llvm::make_unique<ModuleListStream>(); case StreamKind::RawContent: @@ -353,6 +357,16 @@ static StringRef streamValidate(RawContentStream &Stream) { return ""; } +void yaml::MappingTraits<MemoryListStream::entry_type>::mapping( + IO &IO, MemoryListStream::entry_type &Range) { + MappingContextTraits<MemoryDescriptor, yaml::BinaryRef>::mapping( + IO, Range.Entry, Range.Content); +} + +static void streamMapping(yaml::IO &IO, MemoryListStream &Stream) { + IO.mapRequired("Memory Ranges", Stream.Entries); +} + static void streamMapping(yaml::IO &IO, ModuleListStream &Stream) { IO.mapRequired("Modules", Stream.Entries); } @@ -421,6 +435,9 @@ void yaml::MappingTraits<std::unique_ptr<Stream>>::mapping( if (!IO.outputting()) S = MinidumpYAML::Stream::create(Type); switch (S->Kind) { + case MinidumpYAML::Stream::StreamKind::MemoryList: + streamMapping(IO, llvm::cast<MemoryListStream>(*S)); + break; case MinidumpYAML::Stream::StreamKind::ModuleList: streamMapping(IO, llvm::cast<ModuleListStream>(*S)); break; @@ -444,6 +461,7 @@ StringRef yaml::MappingTraits<std::unique_ptr<Stream>>::validate( switch (S->Kind) { case MinidumpYAML::Stream::StreamKind::RawContent: return streamValidate(cast<RawContentStream>(*S)); + case MinidumpYAML::Stream::StreamKind::MemoryList: case MinidumpYAML::Stream::StreamKind::ModuleList: case MinidumpYAML::Stream::StreamKind::SystemInfo: case MinidumpYAML::Stream::StreamKind::TextContent: @@ -466,6 +484,10 @@ static LocationDescriptor layout(BlobAllocator &File, yaml::BinaryRef Data) { support::ulittle32_t(File.allocateBytes(Data))}; } +static void layout(BlobAllocator &File, MemoryListStream::entry_type &Range) { + Range.Entry.Memory = layout(File, Range.Content); +} + static void layout(BlobAllocator &File, ModuleListStream::entry_type &M) { M.Entry.ModuleNameRVA = File.allocateString(M.Name); @@ -502,6 +524,9 @@ static Directory layout(BlobAllocator &File, Stream &S) { Result.Location.RVA = File.tell(); Optional<size_t> DataEnd; switch (S.Kind) { + case Stream::StreamKind::MemoryList: + DataEnd = layout(File, cast<MemoryListStream>(S)); + break; case Stream::StreamKind::ModuleList: DataEnd = layout(File, cast<ModuleListStream>(S)); break; @@ -566,6 +591,19 @@ Expected<std::unique_ptr<Stream>> Stream::create(const Directory &StreamDesc, const object::MinidumpFile &File) { StreamKind Kind = getKind(StreamDesc.Type); switch (Kind) { + case StreamKind::MemoryList: { + auto ExpectedList = File.getMemoryList(); + if (!ExpectedList) + return ExpectedList.takeError(); + std::vector<MemoryListStream::entry_type> Ranges; + for (const MemoryDescriptor &MD : *ExpectedList) { + auto ExpectedContent = File.getRawData(MD.Memory); + if (!ExpectedContent) + return ExpectedContent.takeError(); + Ranges.push_back({MD, *ExpectedContent}); + } + return llvm::make_unique<MemoryListStream>(std::move(Ranges)); + } case StreamKind::ModuleList: { auto ExpectedList = File.getModuleList(); if (!ExpectedList) |

