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