Zachary Turner | 7120a47 | 2016-06-06 20:37:05 +0000 | [diff] [blame] | 1 | //===- YAMLOutputStyle.cpp ------------------------------------ *- C++ --*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | #include "YAMLOutputStyle.h" |
| 11 | |
| 12 | #include "PdbYaml.h" |
| 13 | #include "llvm-pdbdump.h" |
| 14 | |
| 15 | #include "llvm/DebugInfo/PDB/Raw/PDBFile.h" |
| 16 | |
| 17 | using namespace llvm; |
| 18 | using namespace llvm::pdb; |
| 19 | |
| 20 | YAMLOutputStyle::YAMLOutputStyle(PDBFile &File) : File(File), Out(outs()) {} |
| 21 | |
| 22 | Error YAMLOutputStyle::dumpFileHeaders() { |
| 23 | if (!opts::DumpHeaders) |
| 24 | return Error::success(); |
| 25 | |
| 26 | yaml::MsfHeaders Headers; |
Zachary Turner | 07c229c | 2016-06-14 18:51:35 +0000 | [diff] [blame] | 27 | Headers.BlockCount = File.getBlockCount(); |
| 28 | Headers.BlockMapIndex = File.getBlockMapIndex(); |
| 29 | Headers.BlockMapOffset = File.getBlockMapOffset(); |
| 30 | Headers.BlockSize = File.getBlockSize(); |
Zachary Turner | 7120a47 | 2016-06-06 20:37:05 +0000 | [diff] [blame] | 31 | auto Blocks = File.getDirectoryBlockArray(); |
Zachary Turner | 07c229c | 2016-06-14 18:51:35 +0000 | [diff] [blame] | 32 | Headers.DirectoryBlocks.assign(Blocks.begin(), Blocks.end()); |
| 33 | Headers.NumDirectoryBlocks = File.getNumDirectoryBlocks(); |
| 34 | Headers.NumDirectoryBytes = File.getNumDirectoryBytes(); |
| 35 | Headers.NumStreams = File.getNumStreams(); |
| 36 | Headers.Unknown0 = File.getUnknown0(); |
| 37 | Headers.Unknown1 = File.getUnknown1(); |
| 38 | |
| 39 | Obj.Headers.emplace(Headers); |
Zachary Turner | 7120a47 | 2016-06-06 20:37:05 +0000 | [diff] [blame] | 40 | |
| 41 | return Error::success(); |
| 42 | } |
| 43 | |
| 44 | Error YAMLOutputStyle::dumpStreamSummary() { |
| 45 | if (!opts::DumpStreamSummary) |
| 46 | return Error::success(); |
| 47 | |
Zachary Turner | 07c229c | 2016-06-14 18:51:35 +0000 | [diff] [blame] | 48 | std::vector<yaml::StreamSizeEntry> Sizes; |
| 49 | for (uint32_t I = 0; I < File.getNumStreams(); ++I) { |
| 50 | yaml::StreamSizeEntry Entry; |
| 51 | Entry.Size = File.getStreamByteSize(I); |
| 52 | Sizes.push_back(Entry); |
| 53 | } |
| 54 | Obj.StreamSizes.emplace(Sizes); |
Zachary Turner | 7120a47 | 2016-06-06 20:37:05 +0000 | [diff] [blame] | 55 | return Error::success(); |
| 56 | } |
| 57 | |
| 58 | Error YAMLOutputStyle::dumpStreamBlocks() { |
| 59 | if (!opts::DumpStreamBlocks) |
| 60 | return Error::success(); |
| 61 | |
Zachary Turner | 07c229c | 2016-06-14 18:51:35 +0000 | [diff] [blame] | 62 | std::vector<yaml::StreamMapEntry> Blocks; |
| 63 | for (uint32_t I = 0; I < File.getNumStreams(); ++I) { |
| 64 | yaml::StreamMapEntry Entry; |
| 65 | auto BlockList = File.getStreamBlockList(I); |
| 66 | Entry.Blocks.assign(BlockList.begin(), BlockList.end()); |
| 67 | Blocks.push_back(Entry); |
Zachary Turner | 25e8b05 | 2016-06-06 20:37:17 +0000 | [diff] [blame] | 68 | } |
Zachary Turner | 07c229c | 2016-06-14 18:51:35 +0000 | [diff] [blame] | 69 | Obj.StreamMap.emplace(Blocks); |
Zachary Turner | 25e8b05 | 2016-06-06 20:37:17 +0000 | [diff] [blame] | 70 | |
Zachary Turner | 7120a47 | 2016-06-06 20:37:05 +0000 | [diff] [blame] | 71 | return Error::success(); |
| 72 | } |
| 73 | |
| 74 | Error YAMLOutputStyle::dumpStreamData() { |
| 75 | uint32_t StreamCount = File.getNumStreams(); |
| 76 | StringRef DumpStreamStr = opts::DumpStreamDataIdx; |
| 77 | uint32_t DumpStreamNum; |
| 78 | if (DumpStreamStr.getAsInteger(/*Radix=*/0U, DumpStreamNum) || |
| 79 | DumpStreamNum >= StreamCount) |
| 80 | return Error::success(); |
| 81 | |
| 82 | return Error::success(); |
| 83 | } |
| 84 | |
| 85 | Error YAMLOutputStyle::dumpInfoStream() { |
| 86 | if (!opts::DumpHeaders) |
| 87 | return Error::success(); |
| 88 | return Error::success(); |
| 89 | } |
| 90 | |
| 91 | Error YAMLOutputStyle::dumpNamedStream() { |
| 92 | if (opts::DumpStreamDataName.empty()) |
| 93 | return Error::success(); |
| 94 | |
| 95 | return Error::success(); |
| 96 | } |
| 97 | |
| 98 | Error YAMLOutputStyle::dumpTpiStream(uint32_t StreamIdx) { |
| 99 | return Error::success(); |
| 100 | } |
| 101 | |
| 102 | Error YAMLOutputStyle::dumpDbiStream() { return Error::success(); } |
| 103 | |
| 104 | Error YAMLOutputStyle::dumpSectionContribs() { |
| 105 | if (!opts::DumpSectionContribs) |
| 106 | return Error::success(); |
| 107 | |
| 108 | return Error::success(); |
| 109 | } |
| 110 | |
| 111 | Error YAMLOutputStyle::dumpSectionMap() { |
| 112 | if (!opts::DumpSectionMap) |
| 113 | return Error::success(); |
| 114 | |
| 115 | return Error::success(); |
| 116 | } |
| 117 | |
| 118 | Error YAMLOutputStyle::dumpPublicsStream() { |
| 119 | if (!opts::DumpPublics) |
| 120 | return Error::success(); |
| 121 | |
| 122 | return Error::success(); |
| 123 | } |
| 124 | |
| 125 | Error YAMLOutputStyle::dumpSectionHeaders() { |
| 126 | if (!opts::DumpSectionHeaders) |
| 127 | return Error::success(); |
| 128 | |
| 129 | return Error::success(); |
| 130 | } |
| 131 | |
| 132 | Error YAMLOutputStyle::dumpFpoStream() { |
| 133 | if (!opts::DumpFpo) |
| 134 | return Error::success(); |
| 135 | |
| 136 | return Error::success(); |
| 137 | } |
| 138 | |
| 139 | void YAMLOutputStyle::flush() { |
| 140 | Out << Obj; |
| 141 | outs().flush(); |
| 142 | } |