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 | |
Zachary Turner | 8c099fe | 2017-05-30 16:36:15 +0000 | [diff] [blame] | 15 | #include "llvm/DebugInfo/CodeView/DebugChecksumsSubsection.h" |
| 16 | #include "llvm/DebugInfo/CodeView/DebugInlineeLinesSubsection.h" |
| 17 | #include "llvm/DebugInfo/CodeView/DebugLinesSubsection.h" |
| 18 | #include "llvm/DebugInfo/CodeView/DebugSubsection.h" |
Zachary Turner | 8c099fe | 2017-05-30 16:36:15 +0000 | [diff] [blame] | 19 | #include "llvm/DebugInfo/CodeView/DebugUnknownSubsection.h" |
Zachary Turner | ee3b9c2 | 2017-04-25 20:22:02 +0000 | [diff] [blame] | 20 | #include "llvm/DebugInfo/CodeView/Line.h" |
Zachary Turner | 3b14764 | 2016-10-08 01:12:01 +0000 | [diff] [blame] | 21 | #include "llvm/DebugInfo/MSF/MappedBlockStream.h" |
Adrian McCarthy | 6b6b8c4 | 2017-01-25 22:38:55 +0000 | [diff] [blame] | 22 | #include "llvm/DebugInfo/PDB/Native/DbiStream.h" |
| 23 | #include "llvm/DebugInfo/PDB/Native/InfoStream.h" |
Zachary Turner | 67c5601 | 2017-04-27 16:11:19 +0000 | [diff] [blame] | 24 | #include "llvm/DebugInfo/PDB/Native/ModuleDebugStream.h" |
Adrian McCarthy | 6b6b8c4 | 2017-01-25 22:38:55 +0000 | [diff] [blame] | 25 | #include "llvm/DebugInfo/PDB/Native/PDBFile.h" |
| 26 | #include "llvm/DebugInfo/PDB/Native/RawConstants.h" |
Zachary Turner | 5b6e4e0 | 2017-04-29 01:13:21 +0000 | [diff] [blame] | 27 | #include "llvm/DebugInfo/PDB/Native/RawError.h" |
Adrian McCarthy | 6b6b8c4 | 2017-01-25 22:38:55 +0000 | [diff] [blame] | 28 | #include "llvm/DebugInfo/PDB/Native/TpiStream.h" |
Zachary Turner | 7120a47 | 2016-06-06 20:37:05 +0000 | [diff] [blame] | 29 | |
| 30 | using namespace llvm; |
Zachary Turner | c37cb0c | 2017-04-27 16:12:16 +0000 | [diff] [blame] | 31 | using namespace llvm::codeview; |
Zachary Turner | 7120a47 | 2016-06-06 20:37:05 +0000 | [diff] [blame] | 32 | using namespace llvm::pdb; |
| 33 | |
Zachary Turner | c6d54da | 2016-09-09 17:46:17 +0000 | [diff] [blame] | 34 | YAMLOutputStyle::YAMLOutputStyle(PDBFile &File) |
Zachary Turner | ea4e607 | 2017-03-15 22:18:53 +0000 | [diff] [blame] | 35 | : File(File), Out(outs()), Obj(File.getAllocator()) { |
| 36 | Out.setWriteDefaultValues(!opts::pdb2yaml::Minimal); |
| 37 | } |
Zachary Turner | 7120a47 | 2016-06-06 20:37:05 +0000 | [diff] [blame] | 38 | |
Zachary Turner | a30bd1a | 2016-06-30 17:42:48 +0000 | [diff] [blame] | 39 | Error YAMLOutputStyle::dump() { |
Zachary Turner | faa554b | 2016-07-15 22:16:56 +0000 | [diff] [blame] | 40 | if (opts::pdb2yaml::StreamDirectory) |
Zachary Turner | 8848a7a | 2016-07-06 18:05:57 +0000 | [diff] [blame] | 41 | opts::pdb2yaml::StreamMetadata = true; |
Zachary Turner | 5b6e4e0 | 2017-04-29 01:13:21 +0000 | [diff] [blame] | 42 | |
Zachary Turner | a30bd1a | 2016-06-30 17:42:48 +0000 | [diff] [blame] | 43 | if (auto EC = dumpFileHeaders()) |
| 44 | return EC; |
Zachary Turner | 7120a47 | 2016-06-06 20:37:05 +0000 | [diff] [blame] | 45 | |
Zachary Turner | a30bd1a | 2016-06-30 17:42:48 +0000 | [diff] [blame] | 46 | if (auto EC = dumpStreamMetadata()) |
| 47 | return EC; |
| 48 | |
| 49 | if (auto EC = dumpStreamDirectory()) |
| 50 | return EC; |
| 51 | |
Zachary Turner | 760ad4d | 2017-01-20 22:42:09 +0000 | [diff] [blame] | 52 | if (auto EC = dumpStringTable()) |
| 53 | return EC; |
| 54 | |
Zachary Turner | 8848a7a | 2016-07-06 18:05:57 +0000 | [diff] [blame] | 55 | if (auto EC = dumpPDBStream()) |
| 56 | return EC; |
| 57 | |
Zachary Turner | dbeaea7 | 2016-07-11 21:45:26 +0000 | [diff] [blame] | 58 | if (auto EC = dumpDbiStream()) |
| 59 | return EC; |
| 60 | |
Zachary Turner | ac5763e | 2016-08-18 16:49:29 +0000 | [diff] [blame] | 61 | if (auto EC = dumpTpiStream()) |
| 62 | return EC; |
| 63 | |
Zachary Turner | de9ba15 | 2016-09-15 18:22:31 +0000 | [diff] [blame] | 64 | if (auto EC = dumpIpiStream()) |
| 65 | return EC; |
| 66 | |
Zachary Turner | a30bd1a | 2016-06-30 17:42:48 +0000 | [diff] [blame] | 67 | flush(); |
| 68 | return Error::success(); |
| 69 | } |
| 70 | |
Zachary Turner | ee3b9c2 | 2017-04-25 20:22:02 +0000 | [diff] [blame] | 71 | |
Zachary Turner | a30bd1a | 2016-06-30 17:42:48 +0000 | [diff] [blame] | 72 | Error YAMLOutputStyle::dumpFileHeaders() { |
Zachary Turner | f6b9382 | 2016-07-11 21:45:09 +0000 | [diff] [blame] | 73 | if (opts::pdb2yaml::NoFileHeaders) |
| 74 | return Error::success(); |
| 75 | |
Zachary Turner | a3225b0 | 2016-07-29 20:56:36 +0000 | [diff] [blame] | 76 | yaml::MSFHeaders Headers; |
Zachary Turner | f6b9382 | 2016-07-11 21:45:09 +0000 | [diff] [blame] | 77 | Obj.Headers.emplace(); |
| 78 | Obj.Headers->SuperBlock.NumBlocks = File.getBlockCount(); |
| 79 | Obj.Headers->SuperBlock.BlockMapAddr = File.getBlockMapIndex(); |
Zachary Turner | f6b9382 | 2016-07-11 21:45:09 +0000 | [diff] [blame] | 80 | Obj.Headers->SuperBlock.BlockSize = File.getBlockSize(); |
Zachary Turner | 7120a47 | 2016-06-06 20:37:05 +0000 | [diff] [blame] | 81 | auto Blocks = File.getDirectoryBlockArray(); |
Zachary Turner | f6b9382 | 2016-07-11 21:45:09 +0000 | [diff] [blame] | 82 | Obj.Headers->DirectoryBlocks.assign(Blocks.begin(), Blocks.end()); |
| 83 | Obj.Headers->NumDirectoryBlocks = File.getNumDirectoryBlocks(); |
| 84 | Obj.Headers->SuperBlock.NumDirectoryBytes = File.getNumDirectoryBytes(); |
| 85 | Obj.Headers->NumStreams = |
Zachary Turner | ab58ae8 | 2016-06-30 17:43:00 +0000 | [diff] [blame] | 86 | opts::pdb2yaml::StreamMetadata ? File.getNumStreams() : 0; |
Zachary Turner | b927e02 | 2016-07-15 22:17:19 +0000 | [diff] [blame] | 87 | Obj.Headers->SuperBlock.FreeBlockMapBlock = File.getFreeBlockMapBlock(); |
Zachary Turner | f6b9382 | 2016-07-11 21:45:09 +0000 | [diff] [blame] | 88 | Obj.Headers->SuperBlock.Unknown1 = File.getUnknown1(); |
| 89 | Obj.Headers->FileSize = File.getFileSize(); |
Zachary Turner | 7120a47 | 2016-06-06 20:37:05 +0000 | [diff] [blame] | 90 | |
| 91 | return Error::success(); |
| 92 | } |
| 93 | |
Zachary Turner | 760ad4d | 2017-01-20 22:42:09 +0000 | [diff] [blame] | 94 | Error YAMLOutputStyle::dumpStringTable() { |
Zachary Turner | 3eedd16 | 2017-06-08 23:39:33 +0000 | [diff] [blame] | 95 | bool RequiresStringTable = opts::shared::DumpModuleFiles || |
| 96 | !opts::shared::DumpModuleSubsections.empty(); |
Zachary Turner | 92dcdda | 2017-06-02 19:49:14 +0000 | [diff] [blame] | 97 | bool RequestedStringTable = opts::pdb2yaml::StringTable; |
| 98 | if (!RequiresStringTable && !RequestedStringTable) |
Zachary Turner | 760ad4d | 2017-01-20 22:42:09 +0000 | [diff] [blame] | 99 | return Error::success(); |
| 100 | |
Zachary Turner | 760ad4d | 2017-01-20 22:42:09 +0000 | [diff] [blame] | 101 | auto ExpectedST = File.getStringTable(); |
| 102 | if (!ExpectedST) |
| 103 | return ExpectedST.takeError(); |
| 104 | |
Zachary Turner | 92dcdda | 2017-06-02 19:49:14 +0000 | [diff] [blame] | 105 | Obj.StringTable.emplace(); |
Zachary Turner | 760ad4d | 2017-01-20 22:42:09 +0000 | [diff] [blame] | 106 | const auto &ST = ExpectedST.get(); |
| 107 | for (auto ID : ST.name_ids()) { |
Zachary Turner | 2d5c2cd | 2017-05-03 17:11:11 +0000 | [diff] [blame] | 108 | auto S = ST.getStringForID(ID); |
| 109 | if (!S) |
| 110 | return S.takeError(); |
| 111 | if (S->empty()) |
| 112 | continue; |
| 113 | Obj.StringTable->push_back(*S); |
Zachary Turner | 760ad4d | 2017-01-20 22:42:09 +0000 | [diff] [blame] | 114 | } |
| 115 | return Error::success(); |
| 116 | } |
| 117 | |
Zachary Turner | a30bd1a | 2016-06-30 17:42:48 +0000 | [diff] [blame] | 118 | Error YAMLOutputStyle::dumpStreamMetadata() { |
| 119 | if (!opts::pdb2yaml::StreamMetadata) |
Zachary Turner | 7120a47 | 2016-06-06 20:37:05 +0000 | [diff] [blame] | 120 | return Error::success(); |
| 121 | |
Zachary Turner | faa554b | 2016-07-15 22:16:56 +0000 | [diff] [blame] | 122 | Obj.StreamSizes.emplace(); |
| 123 | Obj.StreamSizes->assign(File.getStreamSizes().begin(), |
| 124 | File.getStreamSizes().end()); |
Zachary Turner | 7120a47 | 2016-06-06 20:37:05 +0000 | [diff] [blame] | 125 | return Error::success(); |
| 126 | } |
| 127 | |
Zachary Turner | a30bd1a | 2016-06-30 17:42:48 +0000 | [diff] [blame] | 128 | Error YAMLOutputStyle::dumpStreamDirectory() { |
| 129 | if (!opts::pdb2yaml::StreamDirectory) |
Zachary Turner | 7120a47 | 2016-06-06 20:37:05 +0000 | [diff] [blame] | 130 | return Error::success(); |
| 131 | |
Zachary Turner | 1dc9fd3 | 2016-06-14 20:48:36 +0000 | [diff] [blame] | 132 | auto StreamMap = File.getStreamMap(); |
| 133 | Obj.StreamMap.emplace(); |
| 134 | for (auto &Stream : StreamMap) { |
| 135 | pdb::yaml::StreamBlockList BlockList; |
Zachary Turner | faa554b | 2016-07-15 22:16:56 +0000 | [diff] [blame] | 136 | BlockList.Blocks.assign(Stream.begin(), Stream.end()); |
Zachary Turner | 1dc9fd3 | 2016-06-14 20:48:36 +0000 | [diff] [blame] | 137 | Obj.StreamMap->push_back(BlockList); |
Zachary Turner | 25e8b05 | 2016-06-06 20:37:17 +0000 | [diff] [blame] | 138 | } |
Zachary Turner | 25e8b05 | 2016-06-06 20:37:17 +0000 | [diff] [blame] | 139 | |
Zachary Turner | 7120a47 | 2016-06-06 20:37:05 +0000 | [diff] [blame] | 140 | return Error::success(); |
| 141 | } |
| 142 | |
Zachary Turner | 8848a7a | 2016-07-06 18:05:57 +0000 | [diff] [blame] | 143 | Error YAMLOutputStyle::dumpPDBStream() { |
| 144 | if (!opts::pdb2yaml::PdbStream) |
| 145 | return Error::success(); |
| 146 | |
| 147 | auto IS = File.getPDBInfoStream(); |
| 148 | if (!IS) |
| 149 | return IS.takeError(); |
| 150 | |
| 151 | auto &InfoS = IS.get(); |
| 152 | Obj.PdbStream.emplace(); |
| 153 | Obj.PdbStream->Age = InfoS.getAge(); |
| 154 | Obj.PdbStream->Guid = InfoS.getGuid(); |
| 155 | Obj.PdbStream->Signature = InfoS.getSignature(); |
| 156 | Obj.PdbStream->Version = InfoS.getVersion(); |
Zachary Turner | 05d5e61 | 2017-03-16 20:19:11 +0000 | [diff] [blame] | 157 | Obj.PdbStream->Features = InfoS.getFeatureSignatures(); |
Zachary Turner | 8848a7a | 2016-07-06 18:05:57 +0000 | [diff] [blame] | 158 | |
| 159 | return Error::success(); |
| 160 | } |
| 161 | |
Zachary Turner | 3eedd16 | 2017-06-08 23:39:33 +0000 | [diff] [blame] | 162 | static opts::ModuleSubsection convertSubsectionKind(DebugSubsectionKind K) { |
| 163 | switch (K) { |
| 164 | case DebugSubsectionKind::CrossScopeExports: |
| 165 | return opts::ModuleSubsection::CrossScopeExports; |
| 166 | case DebugSubsectionKind::CrossScopeImports: |
| 167 | return opts::ModuleSubsection::CrossScopeImports; |
| 168 | case DebugSubsectionKind::FileChecksums: |
| 169 | return opts::ModuleSubsection::FileChecksums; |
| 170 | case DebugSubsectionKind::InlineeLines: |
| 171 | return opts::ModuleSubsection::InlineeLines; |
| 172 | case DebugSubsectionKind::Lines: |
| 173 | return opts::ModuleSubsection::Lines; |
Zachary Turner | deb3913 | 2017-06-09 00:28:08 +0000 | [diff] [blame^] | 174 | case DebugSubsectionKind::Symbols: |
| 175 | return opts::ModuleSubsection::Symbols; |
| 176 | case DebugSubsectionKind::StringTable: |
| 177 | return opts::ModuleSubsection::StringTable; |
| 178 | case DebugSubsectionKind::FrameData: |
| 179 | return opts::ModuleSubsection::FrameData; |
Zachary Turner | 3eedd16 | 2017-06-08 23:39:33 +0000 | [diff] [blame] | 180 | default: |
| 181 | return opts::ModuleSubsection::Unknown; |
| 182 | } |
| 183 | llvm_unreachable("Unreachable!"); |
| 184 | } |
| 185 | |
Zachary Turner | dbeaea7 | 2016-07-11 21:45:26 +0000 | [diff] [blame] | 186 | Error YAMLOutputStyle::dumpDbiStream() { |
| 187 | if (!opts::pdb2yaml::DbiStream) |
| 188 | return Error::success(); |
| 189 | |
| 190 | auto DbiS = File.getPDBDbiStream(); |
| 191 | if (!DbiS) |
| 192 | return DbiS.takeError(); |
| 193 | |
| 194 | auto &DS = DbiS.get(); |
| 195 | Obj.DbiStream.emplace(); |
| 196 | Obj.DbiStream->Age = DS.getAge(); |
| 197 | Obj.DbiStream->BuildNumber = DS.getBuildNumber(); |
| 198 | Obj.DbiStream->Flags = DS.getFlags(); |
| 199 | Obj.DbiStream->MachineType = DS.getMachineType(); |
| 200 | Obj.DbiStream->PdbDllRbld = DS.getPdbDllRbld(); |
| 201 | Obj.DbiStream->PdbDllVersion = DS.getPdbDllVersion(); |
| 202 | Obj.DbiStream->VerHeader = DS.getDbiVersion(); |
Zachary Turner | 3eedd16 | 2017-06-08 23:39:33 +0000 | [diff] [blame] | 203 | if (opts::shared::DumpModules) { |
Zachary Turner | 1eb9a02 | 2017-05-04 23:53:29 +0000 | [diff] [blame] | 204 | const auto &Modules = DS.modules(); |
| 205 | for (uint32_t I = 0; I < Modules.getModuleCount(); ++I) { |
| 206 | DbiModuleDescriptor MI = Modules.getModuleDescriptor(I); |
| 207 | |
Zachary Turner | 5b6e4e0 | 2017-04-29 01:13:21 +0000 | [diff] [blame] | 208 | Obj.DbiStream->ModInfos.emplace_back(); |
| 209 | yaml::PdbDbiModuleInfo &DMI = Obj.DbiStream->ModInfos.back(); |
| 210 | |
Zachary Turner | 1eb9a02 | 2017-05-04 23:53:29 +0000 | [diff] [blame] | 211 | DMI.Mod = MI.getModuleName(); |
| 212 | DMI.Obj = MI.getObjFileName(); |
Zachary Turner | 3eedd16 | 2017-06-08 23:39:33 +0000 | [diff] [blame] | 213 | if (opts::shared::DumpModuleFiles) { |
Zachary Turner | 1eb9a02 | 2017-05-04 23:53:29 +0000 | [diff] [blame] | 214 | auto Files = Modules.source_files(I); |
| 215 | DMI.SourceFiles.assign(Files.begin(), Files.end()); |
| 216 | } |
Zachary Turner | 3b14764 | 2016-10-08 01:12:01 +0000 | [diff] [blame] | 217 | |
Zachary Turner | 1eb9a02 | 2017-05-04 23:53:29 +0000 | [diff] [blame] | 218 | uint16_t ModiStream = MI.getModuleStreamIndex(); |
Zachary Turner | 5b6e4e0 | 2017-04-29 01:13:21 +0000 | [diff] [blame] | 219 | if (ModiStream == kInvalidStreamIndex) |
| 220 | continue; |
| 221 | |
Zachary Turner | ee3b9c2 | 2017-04-25 20:22:02 +0000 | [diff] [blame] | 222 | auto ModStreamData = msf::MappedBlockStream::createIndexedStream( |
Zachary Turner | 5b74ff3 | 2017-06-03 00:33:35 +0000 | [diff] [blame] | 223 | File.getMsfLayout(), File.getMsfBuffer(), ModiStream, |
| 224 | File.getAllocator()); |
Zachary Turner | ee3b9c2 | 2017-04-25 20:22:02 +0000 | [diff] [blame] | 225 | |
Zachary Turner | 1eb9a02 | 2017-05-04 23:53:29 +0000 | [diff] [blame] | 226 | pdb::ModuleDebugStreamRef ModS(MI, std::move(ModStreamData)); |
Zachary Turner | ee3b9c2 | 2017-04-25 20:22:02 +0000 | [diff] [blame] | 227 | if (auto EC = ModS.reload()) |
| 228 | return EC; |
| 229 | |
Zachary Turner | 92dcdda | 2017-06-02 19:49:14 +0000 | [diff] [blame] | 230 | auto ExpectedST = File.getStringTable(); |
| 231 | if (!ExpectedST) |
| 232 | return ExpectedST.takeError(); |
Zachary Turner | 3eedd16 | 2017-06-08 23:39:33 +0000 | [diff] [blame] | 233 | if (!opts::shared::DumpModuleSubsections.empty() && |
Zachary Turner | 92dcdda | 2017-06-02 19:49:14 +0000 | [diff] [blame] | 234 | ModS.hasDebugSubsections()) { |
| 235 | auto ExpectedChecksums = ModS.findChecksumsSubsection(); |
| 236 | if (!ExpectedChecksums) |
| 237 | return ExpectedChecksums.takeError(); |
| 238 | |
| 239 | for (const auto &SS : ModS.subsections()) { |
Zachary Turner | 3eedd16 | 2017-06-08 23:39:33 +0000 | [diff] [blame] | 240 | opts::ModuleSubsection OptionKind = convertSubsectionKind(SS.kind()); |
| 241 | if (!opts::checkModuleSubsection(OptionKind)) |
| 242 | continue; |
| 243 | |
Zachary Turner | 92dcdda | 2017-06-02 19:49:14 +0000 | [diff] [blame] | 244 | auto Converted = |
| 245 | CodeViewYAML::YAMLDebugSubsection::fromCodeViewSubection( |
| 246 | ExpectedST->getStringTable(), *ExpectedChecksums, SS); |
| 247 | if (!Converted) |
| 248 | return Converted.takeError(); |
| 249 | DMI.Subsections.push_back(*Converted); |
| 250 | } |
Zachary Turner | ee3b9c2 | 2017-04-25 20:22:02 +0000 | [diff] [blame] | 251 | } |
| 252 | |
Zachary Turner | 3eedd16 | 2017-06-08 23:39:33 +0000 | [diff] [blame] | 253 | if (opts::shared::DumpModuleSyms) { |
Zachary Turner | 3b14764 | 2016-10-08 01:12:01 +0000 | [diff] [blame] | 254 | DMI.Modi.emplace(); |
Zachary Turner | 3b14764 | 2016-10-08 01:12:01 +0000 | [diff] [blame] | 255 | |
| 256 | DMI.Modi->Signature = ModS.signature(); |
| 257 | bool HadError = false; |
| 258 | for (auto &Sym : ModS.symbols(&HadError)) { |
Zachary Turner | 1e4d369 | 2017-05-30 23:50:44 +0000 | [diff] [blame] | 259 | auto ES = CodeViewYAML::SymbolRecord::fromCodeViewSymbol(Sym); |
| 260 | if (!ES) |
| 261 | return ES.takeError(); |
| 262 | |
| 263 | DMI.Modi->Symbols.push_back(*ES); |
Zachary Turner | 3b14764 | 2016-10-08 01:12:01 +0000 | [diff] [blame] | 264 | } |
| 265 | } |
Zachary Turner | d218c26 | 2016-07-22 15:46:37 +0000 | [diff] [blame] | 266 | } |
| 267 | } |
Zachary Turner | dbeaea7 | 2016-07-11 21:45:26 +0000 | [diff] [blame] | 268 | return Error::success(); |
| 269 | } |
| 270 | |
Zachary Turner | ac5763e | 2016-08-18 16:49:29 +0000 | [diff] [blame] | 271 | Error YAMLOutputStyle::dumpTpiStream() { |
| 272 | if (!opts::pdb2yaml::TpiStream) |
| 273 | return Error::success(); |
| 274 | |
| 275 | auto TpiS = File.getPDBTpiStream(); |
| 276 | if (!TpiS) |
| 277 | return TpiS.takeError(); |
| 278 | |
| 279 | auto &TS = TpiS.get(); |
| 280 | Obj.TpiStream.emplace(); |
| 281 | Obj.TpiStream->Version = TS.getTpiVersion(); |
| 282 | for (auto &Record : TS.types(nullptr)) { |
Zachary Turner | d427383 | 2017-05-30 21:53:05 +0000 | [diff] [blame] | 283 | auto ExpectedRecord = CodeViewYAML::LeafRecord::fromCodeViewRecord(Record); |
| 284 | if (!ExpectedRecord) |
| 285 | return ExpectedRecord.takeError(); |
| 286 | Obj.TpiStream->Records.push_back(*ExpectedRecord); |
Zachary Turner | ac5763e | 2016-08-18 16:49:29 +0000 | [diff] [blame] | 287 | } |
| 288 | |
| 289 | return Error::success(); |
| 290 | } |
| 291 | |
Zachary Turner | de9ba15 | 2016-09-15 18:22:31 +0000 | [diff] [blame] | 292 | Error YAMLOutputStyle::dumpIpiStream() { |
| 293 | if (!opts::pdb2yaml::IpiStream) |
| 294 | return Error::success(); |
| 295 | |
| 296 | auto IpiS = File.getPDBIpiStream(); |
| 297 | if (!IpiS) |
| 298 | return IpiS.takeError(); |
| 299 | |
| 300 | auto &IS = IpiS.get(); |
| 301 | Obj.IpiStream.emplace(); |
| 302 | Obj.IpiStream->Version = IS.getTpiVersion(); |
| 303 | for (auto &Record : IS.types(nullptr)) { |
Zachary Turner | d427383 | 2017-05-30 21:53:05 +0000 | [diff] [blame] | 304 | auto ExpectedRecord = CodeViewYAML::LeafRecord::fromCodeViewRecord(Record); |
| 305 | if (!ExpectedRecord) |
| 306 | return ExpectedRecord.takeError(); |
| 307 | |
| 308 | Obj.IpiStream->Records.push_back(*ExpectedRecord); |
Zachary Turner | de9ba15 | 2016-09-15 18:22:31 +0000 | [diff] [blame] | 309 | } |
| 310 | |
| 311 | return Error::success(); |
| 312 | } |
| 313 | |
Zachary Turner | 7120a47 | 2016-06-06 20:37:05 +0000 | [diff] [blame] | 314 | void YAMLOutputStyle::flush() { |
| 315 | Out << Obj; |
| 316 | outs().flush(); |
| 317 | } |