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 | 1dc9fd3 | 2016-06-14 20:48:36 +0000 | [diff] [blame^] | 27 | Obj.Headers.SuperBlock.NumBlocks = File.getBlockCount(); |
| 28 | Obj.Headers.SuperBlock.BlockMapAddr = File.getBlockMapIndex(); |
| 29 | Obj.Headers.BlockMapOffset = File.getBlockMapOffset(); |
| 30 | Obj.Headers.SuperBlock.BlockSize = File.getBlockSize(); |
Zachary Turner | 7120a47 | 2016-06-06 20:37:05 +0000 | [diff] [blame] | 31 | auto Blocks = File.getDirectoryBlockArray(); |
Zachary Turner | 1dc9fd3 | 2016-06-14 20:48:36 +0000 | [diff] [blame^] | 32 | Obj.Headers.DirectoryBlocks.assign(Blocks.begin(), Blocks.end()); |
| 33 | Obj.Headers.NumDirectoryBlocks = File.getNumDirectoryBlocks(); |
| 34 | Obj.Headers.SuperBlock.NumDirectoryBytes = File.getNumDirectoryBytes(); |
| 35 | Obj.Headers.NumStreams = File.getNumStreams(); |
| 36 | Obj.Headers.SuperBlock.Unknown0 = File.getUnknown0(); |
| 37 | Obj.Headers.SuperBlock.Unknown1 = File.getUnknown1(); |
| 38 | Obj.Headers.FileSize = File.getFileSize(); |
Zachary Turner | 7120a47 | 2016-06-06 20:37:05 +0000 | [diff] [blame] | 39 | |
| 40 | return Error::success(); |
| 41 | } |
| 42 | |
| 43 | Error YAMLOutputStyle::dumpStreamSummary() { |
| 44 | if (!opts::DumpStreamSummary) |
| 45 | return Error::success(); |
| 46 | |
Zachary Turner | 1dc9fd3 | 2016-06-14 20:48:36 +0000 | [diff] [blame^] | 47 | Obj.StreamSizes = File.getStreamSizes(); |
Zachary Turner | 7120a47 | 2016-06-06 20:37:05 +0000 | [diff] [blame] | 48 | return Error::success(); |
| 49 | } |
| 50 | |
| 51 | Error YAMLOutputStyle::dumpStreamBlocks() { |
| 52 | if (!opts::DumpStreamBlocks) |
| 53 | return Error::success(); |
| 54 | |
Zachary Turner | 1dc9fd3 | 2016-06-14 20:48:36 +0000 | [diff] [blame^] | 55 | auto StreamMap = File.getStreamMap(); |
| 56 | Obj.StreamMap.emplace(); |
| 57 | for (auto &Stream : StreamMap) { |
| 58 | pdb::yaml::StreamBlockList BlockList; |
| 59 | BlockList.Blocks = Stream; |
| 60 | Obj.StreamMap->push_back(BlockList); |
Zachary Turner | 25e8b05 | 2016-06-06 20:37:17 +0000 | [diff] [blame] | 61 | } |
Zachary Turner | 25e8b05 | 2016-06-06 20:37:17 +0000 | [diff] [blame] | 62 | |
Zachary Turner | 7120a47 | 2016-06-06 20:37:05 +0000 | [diff] [blame] | 63 | return Error::success(); |
| 64 | } |
| 65 | |
| 66 | Error YAMLOutputStyle::dumpStreamData() { |
| 67 | uint32_t StreamCount = File.getNumStreams(); |
| 68 | StringRef DumpStreamStr = opts::DumpStreamDataIdx; |
| 69 | uint32_t DumpStreamNum; |
| 70 | if (DumpStreamStr.getAsInteger(/*Radix=*/0U, DumpStreamNum) || |
| 71 | DumpStreamNum >= StreamCount) |
| 72 | return Error::success(); |
| 73 | |
| 74 | return Error::success(); |
| 75 | } |
| 76 | |
| 77 | Error YAMLOutputStyle::dumpInfoStream() { |
| 78 | if (!opts::DumpHeaders) |
| 79 | return Error::success(); |
| 80 | return Error::success(); |
| 81 | } |
| 82 | |
| 83 | Error YAMLOutputStyle::dumpNamedStream() { |
| 84 | if (opts::DumpStreamDataName.empty()) |
| 85 | return Error::success(); |
| 86 | |
| 87 | return Error::success(); |
| 88 | } |
| 89 | |
| 90 | Error YAMLOutputStyle::dumpTpiStream(uint32_t StreamIdx) { |
| 91 | return Error::success(); |
| 92 | } |
| 93 | |
| 94 | Error YAMLOutputStyle::dumpDbiStream() { return Error::success(); } |
| 95 | |
| 96 | Error YAMLOutputStyle::dumpSectionContribs() { |
| 97 | if (!opts::DumpSectionContribs) |
| 98 | return Error::success(); |
| 99 | |
| 100 | return Error::success(); |
| 101 | } |
| 102 | |
| 103 | Error YAMLOutputStyle::dumpSectionMap() { |
| 104 | if (!opts::DumpSectionMap) |
| 105 | return Error::success(); |
| 106 | |
| 107 | return Error::success(); |
| 108 | } |
| 109 | |
| 110 | Error YAMLOutputStyle::dumpPublicsStream() { |
| 111 | if (!opts::DumpPublics) |
| 112 | return Error::success(); |
| 113 | |
| 114 | return Error::success(); |
| 115 | } |
| 116 | |
| 117 | Error YAMLOutputStyle::dumpSectionHeaders() { |
| 118 | if (!opts::DumpSectionHeaders) |
| 119 | return Error::success(); |
| 120 | |
| 121 | return Error::success(); |
| 122 | } |
| 123 | |
| 124 | Error YAMLOutputStyle::dumpFpoStream() { |
| 125 | if (!opts::DumpFpo) |
| 126 | return Error::success(); |
| 127 | |
| 128 | return Error::success(); |
| 129 | } |
| 130 | |
| 131 | void YAMLOutputStyle::flush() { |
| 132 | Out << Obj; |
| 133 | outs().flush(); |
| 134 | } |