blob: 1eff23631929fac62d63c880a2f944ff7a992c59 [file] [log] [blame]
Zachary Turnerd3117392016-06-03 19:28:33 +00001//===- LLVMOutputStyle.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 "LLVMOutputStyle.h"
11
12#include "llvm-pdbdump.h"
13#include "llvm/DebugInfo/CodeView/EnumTables.h"
14#include "llvm/DebugInfo/CodeView/ModuleSubstreamVisitor.h"
15#include "llvm/DebugInfo/CodeView/SymbolDumper.h"
Zachary Turnera3225b02016-07-29 20:56:36 +000016#include "llvm/DebugInfo/MSF/MappedBlockStream.h"
17#include "llvm/DebugInfo/MSF/StreamReader.h"
Zachary Turnerd3117392016-06-03 19:28:33 +000018#include "llvm/DebugInfo/PDB/PDBExtras.h"
19#include "llvm/DebugInfo/PDB/Raw/DbiStream.h"
20#include "llvm/DebugInfo/PDB/Raw/EnumTables.h"
21#include "llvm/DebugInfo/PDB/Raw/ISectionContribVisitor.h"
22#include "llvm/DebugInfo/PDB/Raw/InfoStream.h"
23#include "llvm/DebugInfo/PDB/Raw/ModInfo.h"
24#include "llvm/DebugInfo/PDB/Raw/ModStream.h"
25#include "llvm/DebugInfo/PDB/Raw/PDBFile.h"
26#include "llvm/DebugInfo/PDB/Raw/PublicsStream.h"
27#include "llvm/DebugInfo/PDB/Raw/RawError.h"
28#include "llvm/DebugInfo/PDB/Raw/TpiStream.h"
29#include "llvm/Object/COFF.h"
30
31#include <unordered_map>
32
33using namespace llvm;
34using namespace llvm::codeview;
Zachary Turnerbac69d32016-07-22 19:56:05 +000035using namespace llvm::msf;
Zachary Turnerd3117392016-06-03 19:28:33 +000036using namespace llvm::pdb;
37
Zachary Turnerd3c7b8e2016-08-01 21:19:45 +000038namespace {
39struct PageStats {
40 explicit PageStats(const BitVector &FreePages)
41 : Upm(FreePages), ActualUsedPages(FreePages.size()),
42 MultiUsePages(FreePages.size()), UseAfterFreePages(FreePages.size()) {
43 const_cast<BitVector &>(Upm).flip();
44 // To calculate orphaned pages, we start with the set of pages that the
45 // MSF thinks are used. Each time we find one that actually *is* used,
46 // we unset it. Whichever bits remain set at the end are orphaned.
47 OrphanedPages = Upm;
48 }
49
50 // The inverse of the MSF File's copy of the Fpm. The basis for which we
51 // determine the allocation status of each page.
52 const BitVector Upm;
53
54 // Pages which are marked as used in the FPM and are used at least once.
55 BitVector ActualUsedPages;
56
57 // Pages which are marked as used in the FPM but are used more than once.
58 BitVector MultiUsePages;
59
60 // Pages which are marked as used in the FPM but are not used at all.
61 BitVector OrphanedPages;
62
63 // Pages which are marked free in the FPM but are used.
64 BitVector UseAfterFreePages;
65};
66}
67
68static void recordKnownUsedPage(PageStats &Stats, uint32_t UsedIndex) {
69 if (Stats.Upm.test(UsedIndex)) {
70 if (Stats.ActualUsedPages.test(UsedIndex))
71 Stats.MultiUsePages.set(UsedIndex);
72 Stats.ActualUsedPages.set(UsedIndex);
73 Stats.OrphanedPages.reset(UsedIndex);
74 } else {
75 // The MSF doesn't think this page is used, but it is.
76 Stats.UseAfterFreePages.set(UsedIndex);
77 }
78}
79
Zachary Turnerd3117392016-06-03 19:28:33 +000080static void printSectionOffset(llvm::raw_ostream &OS,
81 const SectionOffset &Off) {
82 OS << Off.Off << ", " << Off.Isect;
83}
84
85LLVMOutputStyle::LLVMOutputStyle(PDBFile &File)
Zachary Turner5e3e4bb2016-08-05 21:45:34 +000086 : File(File), P(outs()), Dumper(&P, false) {}
Zachary Turnerd3117392016-06-03 19:28:33 +000087
Zachary Turnera30bd1a2016-06-30 17:42:48 +000088Error LLVMOutputStyle::dump() {
89 if (auto EC = dumpFileHeaders())
90 return EC;
91
92 if (auto EC = dumpStreamSummary())
93 return EC;
94
Rui Ueyama7a5cdc62016-07-29 21:38:00 +000095 if (auto EC = dumpFreePageMap())
96 return EC;
97
Zachary Turnera30bd1a2016-06-30 17:42:48 +000098 if (auto EC = dumpStreamBlocks())
99 return EC;
100
101 if (auto EC = dumpStreamData())
102 return EC;
103
104 if (auto EC = dumpInfoStream())
105 return EC;
106
107 if (auto EC = dumpNamedStream())
108 return EC;
109
110 if (auto EC = dumpTpiStream(StreamTPI))
111 return EC;
112
113 if (auto EC = dumpTpiStream(StreamIPI))
114 return EC;
115
116 if (auto EC = dumpDbiStream())
117 return EC;
118
119 if (auto EC = dumpSectionContribs())
120 return EC;
121
122 if (auto EC = dumpSectionMap())
123 return EC;
124
125 if (auto EC = dumpPublicsStream())
126 return EC;
127
128 if (auto EC = dumpSectionHeaders())
129 return EC;
130
131 if (auto EC = dumpFpoStream())
132 return EC;
133
134 flush();
135
136 return Error::success();
137}
138
Zachary Turnerd3117392016-06-03 19:28:33 +0000139Error LLVMOutputStyle::dumpFileHeaders() {
Zachary Turnera30bd1a2016-06-30 17:42:48 +0000140 if (!opts::raw::DumpHeaders)
Zachary Turnerd3117392016-06-03 19:28:33 +0000141 return Error::success();
142
143 DictScope D(P, "FileHeaders");
144 P.printNumber("BlockSize", File.getBlockSize());
Zachary Turnerb927e022016-07-15 22:17:19 +0000145 P.printNumber("FreeBlockMap", File.getFreeBlockMapBlock());
Zachary Turnerd3117392016-06-03 19:28:33 +0000146 P.printNumber("NumBlocks", File.getBlockCount());
147 P.printNumber("NumDirectoryBytes", File.getNumDirectoryBytes());
148 P.printNumber("Unknown1", File.getUnknown1());
149 P.printNumber("BlockMapAddr", File.getBlockMapIndex());
150 P.printNumber("NumDirectoryBlocks", File.getNumDirectoryBlocks());
Zachary Turnerd3117392016-06-03 19:28:33 +0000151
152 // The directory is not contiguous. Instead, the block map contains a
153 // contiguous list of block numbers whose contents, when concatenated in
154 // order, make up the directory.
155 P.printList("DirectoryBlocks", File.getDirectoryBlockArray());
156 P.printNumber("NumStreams", File.getNumStreams());
157 return Error::success();
158}
159
160Error LLVMOutputStyle::dumpStreamSummary() {
Zachary Turnera30bd1a2016-06-30 17:42:48 +0000161 if (!opts::raw::DumpStreamSummary)
Zachary Turnerd3117392016-06-03 19:28:33 +0000162 return Error::success();
163
Reid Kleckner11582c52016-06-17 20:38:01 +0000164 // It's OK if we fail to load some of these streams, we still attempt to print
165 // what we can.
Zachary Turnera1657a92016-06-08 17:26:39 +0000166 auto Dbi = File.getPDBDbiStream();
Zachary Turnera1657a92016-06-08 17:26:39 +0000167 auto Tpi = File.getPDBTpiStream();
Zachary Turnera1657a92016-06-08 17:26:39 +0000168 auto Ipi = File.getPDBIpiStream();
Zachary Turnera1657a92016-06-08 17:26:39 +0000169 auto Info = File.getPDBInfoStream();
Zachary Turnerd3117392016-06-03 19:28:33 +0000170
171 ListScope L(P, "Streams");
172 uint32_t StreamCount = File.getNumStreams();
173 std::unordered_map<uint16_t, const ModuleInfoEx *> ModStreams;
174 std::unordered_map<uint16_t, std::string> NamedStreams;
175
Reid Kleckner11582c52016-06-17 20:38:01 +0000176 if (Dbi) {
177 for (auto &ModI : Dbi->modules()) {
178 uint16_t SN = ModI.Info.getModuleStreamIndex();
179 ModStreams[SN] = &ModI;
180 }
Zachary Turnerd3117392016-06-03 19:28:33 +0000181 }
Reid Kleckner11582c52016-06-17 20:38:01 +0000182 if (Info) {
183 for (auto &NSE : Info->named_streams()) {
184 NamedStreams[NSE.second] = NSE.first();
185 }
Zachary Turnerd3117392016-06-03 19:28:33 +0000186 }
187
188 for (uint16_t StreamIdx = 0; StreamIdx < StreamCount; ++StreamIdx) {
189 std::string Label("Stream ");
190 Label += to_string(StreamIdx);
191 std::string Value;
192 if (StreamIdx == OldMSFDirectory)
193 Value = "Old MSF Directory";
194 else if (StreamIdx == StreamPDB)
195 Value = "PDB Stream";
196 else if (StreamIdx == StreamDBI)
197 Value = "DBI Stream";
198 else if (StreamIdx == StreamTPI)
199 Value = "TPI Stream";
200 else if (StreamIdx == StreamIPI)
201 Value = "IPI Stream";
Reid Kleckner11582c52016-06-17 20:38:01 +0000202 else if (Dbi && StreamIdx == Dbi->getGlobalSymbolStreamIndex())
Zachary Turnerd3117392016-06-03 19:28:33 +0000203 Value = "Global Symbol Hash";
Reid Kleckner11582c52016-06-17 20:38:01 +0000204 else if (Dbi && StreamIdx == Dbi->getPublicSymbolStreamIndex())
Zachary Turnerd3117392016-06-03 19:28:33 +0000205 Value = "Public Symbol Hash";
Reid Kleckner11582c52016-06-17 20:38:01 +0000206 else if (Dbi && StreamIdx == Dbi->getSymRecordStreamIndex())
Zachary Turnerd3117392016-06-03 19:28:33 +0000207 Value = "Public Symbol Records";
Reid Kleckner11582c52016-06-17 20:38:01 +0000208 else if (Tpi && StreamIdx == Tpi->getTypeHashStreamIndex())
Zachary Turnerd3117392016-06-03 19:28:33 +0000209 Value = "TPI Hash";
Reid Kleckner11582c52016-06-17 20:38:01 +0000210 else if (Tpi && StreamIdx == Tpi->getTypeHashStreamAuxIndex())
Zachary Turnerd3117392016-06-03 19:28:33 +0000211 Value = "TPI Aux Hash";
Reid Kleckner11582c52016-06-17 20:38:01 +0000212 else if (Ipi && StreamIdx == Ipi->getTypeHashStreamIndex())
Zachary Turnerd3117392016-06-03 19:28:33 +0000213 Value = "IPI Hash";
Reid Kleckner11582c52016-06-17 20:38:01 +0000214 else if (Ipi && StreamIdx == Ipi->getTypeHashStreamAuxIndex())
Zachary Turnerd3117392016-06-03 19:28:33 +0000215 Value = "IPI Aux Hash";
Reid Kleckner11582c52016-06-17 20:38:01 +0000216 else if (Dbi &&
217 StreamIdx == Dbi->getDebugStreamIndex(DbgHeaderType::Exception))
Zachary Turnerd3117392016-06-03 19:28:33 +0000218 Value = "Exception Data";
Reid Kleckner11582c52016-06-17 20:38:01 +0000219 else if (Dbi && StreamIdx == Dbi->getDebugStreamIndex(DbgHeaderType::Fixup))
Zachary Turnerd3117392016-06-03 19:28:33 +0000220 Value = "Fixup Data";
Reid Kleckner11582c52016-06-17 20:38:01 +0000221 else if (Dbi && StreamIdx == Dbi->getDebugStreamIndex(DbgHeaderType::FPO))
Zachary Turnerd3117392016-06-03 19:28:33 +0000222 Value = "FPO Data";
Reid Kleckner11582c52016-06-17 20:38:01 +0000223 else if (Dbi &&
224 StreamIdx == Dbi->getDebugStreamIndex(DbgHeaderType::NewFPO))
Zachary Turnerd3117392016-06-03 19:28:33 +0000225 Value = "New FPO Data";
Reid Kleckner11582c52016-06-17 20:38:01 +0000226 else if (Dbi &&
227 StreamIdx == Dbi->getDebugStreamIndex(DbgHeaderType::OmapFromSrc))
Zachary Turnerd3117392016-06-03 19:28:33 +0000228 Value = "Omap From Source Data";
Reid Kleckner11582c52016-06-17 20:38:01 +0000229 else if (Dbi &&
230 StreamIdx == Dbi->getDebugStreamIndex(DbgHeaderType::OmapToSrc))
Zachary Turnerd3117392016-06-03 19:28:33 +0000231 Value = "Omap To Source Data";
Reid Kleckner11582c52016-06-17 20:38:01 +0000232 else if (Dbi && StreamIdx == Dbi->getDebugStreamIndex(DbgHeaderType::Pdata))
Zachary Turnerd3117392016-06-03 19:28:33 +0000233 Value = "Pdata";
Reid Kleckner11582c52016-06-17 20:38:01 +0000234 else if (Dbi &&
235 StreamIdx == Dbi->getDebugStreamIndex(DbgHeaderType::SectionHdr))
Zachary Turnerd3117392016-06-03 19:28:33 +0000236 Value = "Section Header Data";
Reid Kleckner11582c52016-06-17 20:38:01 +0000237 else if (Dbi &&
238 StreamIdx ==
239 Dbi->getDebugStreamIndex(DbgHeaderType::SectionHdrOrig))
Zachary Turnerd3117392016-06-03 19:28:33 +0000240 Value = "Section Header Original Data";
Reid Kleckner11582c52016-06-17 20:38:01 +0000241 else if (Dbi &&
242 StreamIdx == Dbi->getDebugStreamIndex(DbgHeaderType::TokenRidMap))
Zachary Turnerd3117392016-06-03 19:28:33 +0000243 Value = "Token Rid Data";
Reid Kleckner11582c52016-06-17 20:38:01 +0000244 else if (Dbi && StreamIdx == Dbi->getDebugStreamIndex(DbgHeaderType::Xdata))
Zachary Turnerd3117392016-06-03 19:28:33 +0000245 Value = "Xdata";
246 else {
247 auto ModIter = ModStreams.find(StreamIdx);
248 auto NSIter = NamedStreams.find(StreamIdx);
249 if (ModIter != ModStreams.end()) {
250 Value = "Module \"";
251 Value += ModIter->second->Info.getModuleName().str();
252 Value += "\"";
253 } else if (NSIter != NamedStreams.end()) {
254 Value = "Named Stream \"";
255 Value += NSIter->second;
256 Value += "\"";
257 } else {
258 Value = "???";
259 }
260 }
261 Value = "[" + Value + "]";
262 Value =
263 Value + " (" + to_string(File.getStreamByteSize(StreamIdx)) + " bytes)";
264
265 P.printString(Label, Value);
266 }
Reid Kleckner11582c52016-06-17 20:38:01 +0000267
268 // Consume errors from missing streams.
269 if (!Dbi)
270 consumeError(Dbi.takeError());
271 if (!Tpi)
272 consumeError(Tpi.takeError());
273 if (!Ipi)
274 consumeError(Ipi.takeError());
275 if (!Info)
276 consumeError(Info.takeError());
277
Zachary Turnerd3117392016-06-03 19:28:33 +0000278 P.flush();
279 return Error::success();
280}
281
Rui Ueyama7a5cdc62016-07-29 21:38:00 +0000282Error LLVMOutputStyle::dumpFreePageMap() {
Zachary Turnerd3c7b8e2016-08-01 21:19:45 +0000283 if (!opts::raw::DumpPageStats)
Rui Ueyama7a5cdc62016-07-29 21:38:00 +0000284 return Error::success();
Rui Ueyama7a5cdc62016-07-29 21:38:00 +0000285
Zachary Turnerd3c7b8e2016-08-01 21:19:45 +0000286 // Start with used pages instead of free pages because
Rui Ueyama7a5cdc62016-07-29 21:38:00 +0000287 // the number of free pages is far larger than used pages.
Zachary Turnerd3c7b8e2016-08-01 21:19:45 +0000288 BitVector FPM = File.getMsfLayout().FreePageMap;
289
290 PageStats PS(FPM);
291
292 recordKnownUsedPage(PS, 0); // MSF Super Block
293
Zachary Turner8cf51c32016-08-03 16:53:21 +0000294 uint32_t BlocksPerSection = msf::getFpmIntervalLength(File.getMsfLayout());
295 uint32_t NumSections = msf::getNumFpmIntervals(File.getMsfLayout());
Zachary Turnerd3c7b8e2016-08-01 21:19:45 +0000296 for (uint32_t I = 0; I < NumSections; ++I) {
297 uint32_t Fpm0 = 1 + BlocksPerSection * I;
298 // 2 Fpm blocks spaced at `getBlockSize()` block intervals
299 recordKnownUsedPage(PS, Fpm0);
300 recordKnownUsedPage(PS, Fpm0 + 1);
301 }
302
303 recordKnownUsedPage(PS, File.getBlockMapIndex()); // Stream Table
304
Rui Ueyama22e67382016-08-02 23:22:46 +0000305 for (auto DB : File.getDirectoryBlockArray())
Zachary Turnerd3c7b8e2016-08-01 21:19:45 +0000306 recordKnownUsedPage(PS, DB);
Rui Ueyama22e67382016-08-02 23:22:46 +0000307
308 // Record pages used by streams. Note that pages for stream 0
309 // are considered being unused because that's what MSVC tools do.
310 // Stream 0 doesn't contain actual data, so it makes some sense,
311 // though it's a bit confusing to us.
312 for (auto &SE : File.getStreamMap().drop_front(1))
313 for (auto &S : SE)
Zachary Turnerd3c7b8e2016-08-01 21:19:45 +0000314 recordKnownUsedPage(PS, S);
Zachary Turnerd3c7b8e2016-08-01 21:19:45 +0000315
316 dumpBitVector("Msf Free Pages", FPM);
317 dumpBitVector("Orphaned Pages", PS.OrphanedPages);
318 dumpBitVector("Multiply Used Pages", PS.MultiUsePages);
319 dumpBitVector("Use After Free Pages", PS.UseAfterFreePages);
Rui Ueyama7a5cdc62016-07-29 21:38:00 +0000320 return Error::success();
321}
322
Zachary Turnerd3c7b8e2016-08-01 21:19:45 +0000323void LLVMOutputStyle::dumpBitVector(StringRef Name, const BitVector &V) {
324 std::vector<uint32_t> Vec;
325 for (uint32_t I = 0, E = V.size(); I != E; ++I)
326 if (V[I])
327 Vec.push_back(I);
328 P.printList(Name, Vec);
329}
330
Zachary Turnerd3117392016-06-03 19:28:33 +0000331Error LLVMOutputStyle::dumpStreamBlocks() {
Zachary Turnera30bd1a2016-06-30 17:42:48 +0000332 if (!opts::raw::DumpStreamBlocks)
Zachary Turnerd3117392016-06-03 19:28:33 +0000333 return Error::success();
334
335 ListScope L(P, "StreamBlocks");
336 uint32_t StreamCount = File.getNumStreams();
337 for (uint32_t StreamIdx = 0; StreamIdx < StreamCount; ++StreamIdx) {
338 std::string Name("Stream ");
339 Name += to_string(StreamIdx);
340 auto StreamBlocks = File.getStreamBlockList(StreamIdx);
341 P.printList(Name, StreamBlocks);
342 }
343 return Error::success();
344}
345
346Error LLVMOutputStyle::dumpStreamData() {
347 uint32_t StreamCount = File.getNumStreams();
Zachary Turnera30bd1a2016-06-30 17:42:48 +0000348 StringRef DumpStreamStr = opts::raw::DumpStreamDataIdx;
Zachary Turnerd3117392016-06-03 19:28:33 +0000349 uint32_t DumpStreamNum;
Zachary Turnerd2b2bfe2016-06-08 00:25:08 +0000350 if (DumpStreamStr.getAsInteger(/*Radix=*/0U, DumpStreamNum))
Zachary Turnerd3117392016-06-03 19:28:33 +0000351 return Error::success();
352
Zachary Turnerd2b2bfe2016-06-08 00:25:08 +0000353 if (DumpStreamNum >= StreamCount)
354 return make_error<RawError>(raw_error_code::no_stream);
355
Zachary Turnerd66889c2016-07-28 19:12:28 +0000356 auto S = MappedBlockStream::createIndexedStream(
357 File.getMsfLayout(), File.getMsfBuffer(), DumpStreamNum);
358 StreamReader R(*S);
Zachary Turnerd3117392016-06-03 19:28:33 +0000359 while (R.bytesRemaining() > 0) {
360 ArrayRef<uint8_t> Data;
361 uint32_t BytesToReadInBlock = std::min(
362 R.bytesRemaining(), static_cast<uint32_t>(File.getBlockSize()));
363 if (auto EC = R.readBytes(Data, BytesToReadInBlock))
364 return EC;
365 P.printBinaryBlock(
366 "Data",
367 StringRef(reinterpret_cast<const char *>(Data.begin()), Data.size()));
368 }
369 return Error::success();
370}
371
372Error LLVMOutputStyle::dumpInfoStream() {
Zachary Turnera30bd1a2016-06-30 17:42:48 +0000373 if (!opts::raw::DumpHeaders)
Zachary Turnerd3117392016-06-03 19:28:33 +0000374 return Error::success();
Zachary Turnera1657a92016-06-08 17:26:39 +0000375 auto IS = File.getPDBInfoStream();
376 if (!IS)
377 return IS.takeError();
Zachary Turnerd3117392016-06-03 19:28:33 +0000378
379 DictScope D(P, "PDB Stream");
Zachary Turnera1657a92016-06-08 17:26:39 +0000380 P.printNumber("Version", IS->getVersion());
381 P.printHex("Signature", IS->getSignature());
382 P.printNumber("Age", IS->getAge());
383 P.printObject("Guid", IS->getGuid());
Zachary Turnerd3117392016-06-03 19:28:33 +0000384 return Error::success();
385}
386
387Error LLVMOutputStyle::dumpNamedStream() {
Zachary Turnera30bd1a2016-06-30 17:42:48 +0000388 if (opts::raw::DumpStreamDataName.empty())
Zachary Turnerd3117392016-06-03 19:28:33 +0000389 return Error::success();
390
Zachary Turnera1657a92016-06-08 17:26:39 +0000391 auto IS = File.getPDBInfoStream();
392 if (!IS)
393 return IS.takeError();
Zachary Turnerd3117392016-06-03 19:28:33 +0000394
Zachary Turnera30bd1a2016-06-30 17:42:48 +0000395 uint32_t NameStreamIndex =
396 IS->getNamedStreamIndex(opts::raw::DumpStreamDataName);
Zachary Turnerd2b2bfe2016-06-08 00:25:08 +0000397 if (NameStreamIndex == 0 || NameStreamIndex >= File.getNumStreams())
398 return make_error<RawError>(raw_error_code::no_stream);
Zachary Turnerd3117392016-06-03 19:28:33 +0000399
400 if (NameStreamIndex != 0) {
401 std::string Name("Stream '");
Zachary Turnera30bd1a2016-06-30 17:42:48 +0000402 Name += opts::raw::DumpStreamDataName;
Zachary Turnerd3117392016-06-03 19:28:33 +0000403 Name += "'";
404 DictScope D(P, Name);
405 P.printNumber("Index", NameStreamIndex);
406
Zachary Turnerd66889c2016-07-28 19:12:28 +0000407 auto NameStream = MappedBlockStream::createIndexedStream(
408 File.getMsfLayout(), File.getMsfBuffer(), NameStreamIndex);
409 StreamReader Reader(*NameStream);
Zachary Turnerd3117392016-06-03 19:28:33 +0000410
411 NameHashTable NameTable;
412 if (auto EC = NameTable.load(Reader))
413 return EC;
414
415 P.printHex("Signature", NameTable.getSignature());
416 P.printNumber("Version", NameTable.getHashVersion());
417 P.printNumber("Name Count", NameTable.getNameCount());
418 ListScope L(P, "Names");
419 for (uint32_t ID : NameTable.name_ids()) {
420 StringRef Str = NameTable.getStringForID(ID);
421 if (!Str.empty())
422 P.printString(to_string(ID), Str);
423 }
424 }
425 return Error::success();
426}
427
Rui Ueyamafd97bf12016-06-03 20:48:51 +0000428static void printTypeIndexOffset(raw_ostream &OS,
429 const TypeIndexOffset &TIOff) {
430 OS << "{" << TIOff.Type.getIndex() << ", " << TIOff.Offset << "}";
431}
432
433static void dumpTpiHash(ScopedPrinter &P, TpiStream &Tpi) {
Zachary Turnera30bd1a2016-06-30 17:42:48 +0000434 if (!opts::raw::DumpTpiHash)
Rui Ueyamafd97bf12016-06-03 20:48:51 +0000435 return;
436 DictScope DD(P, "Hash");
Rui Ueyamaf14a74c2016-06-07 23:53:43 +0000437 P.printNumber("Number of Hash Buckets", Tpi.NumHashBuckets());
Rui Ueyamad8339172016-06-07 23:44:27 +0000438 P.printNumber("Hash Key Size", Tpi.getHashKeySize());
Rui Ueyamafd97bf12016-06-03 20:48:51 +0000439 P.printList("Values", Tpi.getHashValues());
440 P.printList("Type Index Offsets", Tpi.getTypeIndexOffsets(),
441 printTypeIndexOffset);
442 P.printList("Hash Adjustments", Tpi.getHashAdjustments(),
443 printTypeIndexOffset);
444}
445
Zachary Turnerd3117392016-06-03 19:28:33 +0000446Error LLVMOutputStyle::dumpTpiStream(uint32_t StreamIdx) {
447 assert(StreamIdx == StreamTPI || StreamIdx == StreamIPI);
448
449 bool DumpRecordBytes = false;
450 bool DumpRecords = false;
451 StringRef Label;
452 StringRef VerLabel;
453 if (StreamIdx == StreamTPI) {
Zachary Turnera30bd1a2016-06-30 17:42:48 +0000454 DumpRecordBytes = opts::raw::DumpTpiRecordBytes;
455 DumpRecords = opts::raw::DumpTpiRecords;
Zachary Turnerd3117392016-06-03 19:28:33 +0000456 Label = "Type Info Stream (TPI)";
457 VerLabel = "TPI Version";
458 } else if (StreamIdx == StreamIPI) {
Zachary Turnera30bd1a2016-06-30 17:42:48 +0000459 DumpRecordBytes = opts::raw::DumpIpiRecordBytes;
460 DumpRecords = opts::raw::DumpIpiRecords;
Zachary Turnerd3117392016-06-03 19:28:33 +0000461 Label = "Type Info Stream (IPI)";
462 VerLabel = "IPI Version";
463 }
Zachary Turnera30bd1a2016-06-30 17:42:48 +0000464 if (!DumpRecordBytes && !DumpRecords && !opts::raw::DumpModuleSyms)
Zachary Turnerd3117392016-06-03 19:28:33 +0000465 return Error::success();
466
Zachary Turnera1657a92016-06-08 17:26:39 +0000467 auto Tpi = (StreamIdx == StreamTPI) ? File.getPDBTpiStream()
468 : File.getPDBIpiStream();
469 if (!Tpi)
470 return Tpi.takeError();
Zachary Turnerd3117392016-06-03 19:28:33 +0000471
472 if (DumpRecords || DumpRecordBytes) {
473 DictScope D(P, Label);
474
Zachary Turnera1657a92016-06-08 17:26:39 +0000475 P.printNumber(VerLabel, Tpi->getTpiVersion());
476 P.printNumber("Record count", Tpi->NumTypeRecords());
Zachary Turnerd3117392016-06-03 19:28:33 +0000477
478 ListScope L(P, "Records");
479
480 bool HadError = false;
Zachary Turnera1657a92016-06-08 17:26:39 +0000481 for (auto &Type : Tpi->types(&HadError)) {
Zachary Turnerd3117392016-06-03 19:28:33 +0000482 DictScope DD(P, "");
483
Zachary Turner01ee3dae2016-06-16 18:22:27 +0000484 if (DumpRecords) {
Zachary Turner5e3e4bb2016-08-05 21:45:34 +0000485 if (auto EC = Dumper.dump(Type))
Zachary Turner01ee3dae2016-06-16 18:22:27 +0000486 return EC;
487 }
Zachary Turnerd3117392016-06-03 19:28:33 +0000488
489 if (DumpRecordBytes)
490 P.printBinaryBlock("Bytes", Type.Data);
491 }
Zachary Turnera1657a92016-06-08 17:26:39 +0000492 dumpTpiHash(P, *Tpi);
Zachary Turnerd3117392016-06-03 19:28:33 +0000493 if (HadError)
494 return make_error<RawError>(raw_error_code::corrupt_file,
495 "TPI stream contained corrupt record");
Zachary Turnera30bd1a2016-06-30 17:42:48 +0000496 } else if (opts::raw::DumpModuleSyms) {
Zachary Turnerd3117392016-06-03 19:28:33 +0000497 // Even if the user doesn't want to dump type records, we still need to
498 // iterate them in order to build the list of types so that we can print
499 // them when dumping module symbols. So when they want to dump symbols
500 // but not types, use a null output stream.
Zachary Turner5e3e4bb2016-08-05 21:45:34 +0000501 ScopedPrinter *OldP = Dumper.getPrinter();
502 Dumper.setPrinter(nullptr);
Zachary Turnerd3117392016-06-03 19:28:33 +0000503
504 bool HadError = false;
Zachary Turner01ee3dae2016-06-16 18:22:27 +0000505 for (auto &Type : Tpi->types(&HadError)) {
Zachary Turner5e3e4bb2016-08-05 21:45:34 +0000506 if (auto EC = Dumper.dump(Type))
Zachary Turner01ee3dae2016-06-16 18:22:27 +0000507 return EC;
508 }
Zachary Turnerd3117392016-06-03 19:28:33 +0000509
Zachary Turner5e3e4bb2016-08-05 21:45:34 +0000510 Dumper.setPrinter(OldP);
Zachary Turnera1657a92016-06-08 17:26:39 +0000511 dumpTpiHash(P, *Tpi);
Zachary Turnerd3117392016-06-03 19:28:33 +0000512 if (HadError)
513 return make_error<RawError>(raw_error_code::corrupt_file,
514 "TPI stream contained corrupt record");
515 }
516 P.flush();
517 return Error::success();
518}
519
520Error LLVMOutputStyle::dumpDbiStream() {
Zachary Turnera30bd1a2016-06-30 17:42:48 +0000521 bool DumpModules = opts::raw::DumpModules || opts::raw::DumpModuleSyms ||
522 opts::raw::DumpModuleFiles || opts::raw::DumpLineInfo;
523 if (!opts::raw::DumpHeaders && !DumpModules)
Zachary Turnerd3117392016-06-03 19:28:33 +0000524 return Error::success();
525
Zachary Turnera1657a92016-06-08 17:26:39 +0000526 auto DS = File.getPDBDbiStream();
527 if (!DS)
528 return DS.takeError();
Zachary Turnerd3117392016-06-03 19:28:33 +0000529
530 DictScope D(P, "DBI Stream");
Zachary Turnera1657a92016-06-08 17:26:39 +0000531 P.printNumber("Dbi Version", DS->getDbiVersion());
532 P.printNumber("Age", DS->getAge());
533 P.printBoolean("Incremental Linking", DS->isIncrementallyLinked());
534 P.printBoolean("Has CTypes", DS->hasCTypes());
535 P.printBoolean("Is Stripped", DS->isStripped());
536 P.printObject("Machine Type", DS->getMachineType());
537 P.printNumber("Symbol Record Stream Index", DS->getSymRecordStreamIndex());
538 P.printNumber("Public Symbol Stream Index", DS->getPublicSymbolStreamIndex());
539 P.printNumber("Global Symbol Stream Index", DS->getGlobalSymbolStreamIndex());
Zachary Turnerd3117392016-06-03 19:28:33 +0000540
Zachary Turnera1657a92016-06-08 17:26:39 +0000541 uint16_t Major = DS->getBuildMajorVersion();
542 uint16_t Minor = DS->getBuildMinorVersion();
Zachary Turnerd3117392016-06-03 19:28:33 +0000543 P.printVersion("Toolchain Version", Major, Minor);
544
545 std::string DllName;
546 raw_string_ostream DllStream(DllName);
547 DllStream << "mspdb" << Major << Minor << ".dll version";
548 DllStream.flush();
Zachary Turnera1657a92016-06-08 17:26:39 +0000549 P.printVersion(DllName, Major, Minor, DS->getPdbDllVersion());
Zachary Turnerd3117392016-06-03 19:28:33 +0000550
551 if (DumpModules) {
552 ListScope L(P, "Modules");
Zachary Turnera1657a92016-06-08 17:26:39 +0000553 for (auto &Modi : DS->modules()) {
Zachary Turnerd3117392016-06-03 19:28:33 +0000554 DictScope DD(P);
555 P.printString("Name", Modi.Info.getModuleName().str());
556 P.printNumber("Debug Stream Index", Modi.Info.getModuleStreamIndex());
557 P.printString("Object File Name", Modi.Info.getObjFileName().str());
558 P.printNumber("Num Files", Modi.Info.getNumberOfFiles());
559 P.printNumber("Source File Name Idx", Modi.Info.getSourceFileNameIndex());
560 P.printNumber("Pdb File Name Idx", Modi.Info.getPdbFilePathNameIndex());
561 P.printNumber("Line Info Byte Size", Modi.Info.getLineInfoByteSize());
562 P.printNumber("C13 Line Info Byte Size",
563 Modi.Info.getC13LineInfoByteSize());
564 P.printNumber("Symbol Byte Size", Modi.Info.getSymbolDebugInfoByteSize());
565 P.printNumber("Type Server Index", Modi.Info.getTypeServerIndex());
566 P.printBoolean("Has EC Info", Modi.Info.hasECInfo());
Zachary Turnera30bd1a2016-06-30 17:42:48 +0000567 if (opts::raw::DumpModuleFiles) {
Zachary Turnerd3117392016-06-03 19:28:33 +0000568 std::string FileListName =
569 to_string(Modi.SourceFiles.size()) + " Contributing Source Files";
570 ListScope LL(P, FileListName);
571 for (auto File : Modi.SourceFiles)
572 P.printString(File.str());
573 }
574 bool HasModuleDI =
575 (Modi.Info.getModuleStreamIndex() < File.getNumStreams());
576 bool ShouldDumpSymbols =
Zachary Turnera30bd1a2016-06-30 17:42:48 +0000577 (opts::raw::DumpModuleSyms || opts::raw::DumpSymRecordBytes);
578 if (HasModuleDI && (ShouldDumpSymbols || opts::raw::DumpLineInfo)) {
Zachary Turnera1657a92016-06-08 17:26:39 +0000579 auto ModStreamData = MappedBlockStream::createIndexedStream(
Zachary Turnerd66889c2016-07-28 19:12:28 +0000580 File.getMsfLayout(), File.getMsfBuffer(),
581 Modi.Info.getModuleStreamIndex());
582
583 ModStream ModS(Modi.Info, std::move(ModStreamData));
Zachary Turnerd3117392016-06-03 19:28:33 +0000584 if (auto EC = ModS.reload())
585 return EC;
586
587 if (ShouldDumpSymbols) {
588 ListScope SS(P, "Symbols");
Zachary Turner5e3e4bb2016-08-05 21:45:34 +0000589 codeview::CVSymbolDumper SD(P, Dumper, nullptr, false);
Zachary Turnerd3117392016-06-03 19:28:33 +0000590 bool HadError = false;
591 for (const auto &S : ModS.symbols(&HadError)) {
592 DictScope DD(P, "");
593
Zachary Turnera30bd1a2016-06-30 17:42:48 +0000594 if (opts::raw::DumpModuleSyms)
Zachary Turnerd3117392016-06-03 19:28:33 +0000595 SD.dump(S);
Zachary Turnera30bd1a2016-06-30 17:42:48 +0000596 if (opts::raw::DumpSymRecordBytes)
Zachary Turnerd3117392016-06-03 19:28:33 +0000597 P.printBinaryBlock("Bytes", S.Data);
598 }
599 if (HadError)
600 return make_error<RawError>(
601 raw_error_code::corrupt_file,
602 "DBI stream contained corrupt symbol record");
603 }
Zachary Turnera30bd1a2016-06-30 17:42:48 +0000604 if (opts::raw::DumpLineInfo) {
Zachary Turnerd3117392016-06-03 19:28:33 +0000605 ListScope SS(P, "LineInfo");
606 bool HadError = false;
607 // Define a locally scoped visitor to print the different
608 // substream types types.
609 class RecordVisitor : public codeview::IModuleSubstreamVisitor {
610 public:
611 RecordVisitor(ScopedPrinter &P, PDBFile &F) : P(P), F(F) {}
612 Error visitUnknown(ModuleSubstreamKind Kind,
Zachary Turnerd66889c2016-07-28 19:12:28 +0000613 ReadableStreamRef Stream) override {
Zachary Turnerd3117392016-06-03 19:28:33 +0000614 DictScope DD(P, "Unknown");
615 ArrayRef<uint8_t> Data;
616 StreamReader R(Stream);
617 if (auto EC = R.readBytes(Data, R.bytesRemaining())) {
618 return make_error<RawError>(
619 raw_error_code::corrupt_file,
620 "DBI stream contained corrupt line info record");
621 }
622 P.printBinaryBlock("Data", Data);
623 return Error::success();
624 }
625 Error
Zachary Turnerd66889c2016-07-28 19:12:28 +0000626 visitFileChecksums(ReadableStreamRef Data,
Zachary Turnerd3117392016-06-03 19:28:33 +0000627 const FileChecksumArray &Checksums) override {
628 DictScope DD(P, "FileChecksums");
629 for (const auto &C : Checksums) {
630 DictScope DDD(P, "Checksum");
631 if (auto Result = getFileNameForOffset(C.FileNameOffset))
632 P.printString("FileName", Result.get());
633 else
634 return Result.takeError();
635 P.flush();
636 P.printEnum("Kind", uint8_t(C.Kind), getFileChecksumNames());
637 P.printBinaryBlock("Checksum", C.Checksum);
638 }
639 return Error::success();
640 }
641
Zachary Turnerd66889c2016-07-28 19:12:28 +0000642 Error visitLines(ReadableStreamRef Data,
643 const LineSubstreamHeader *Header,
Zachary Turnerd3117392016-06-03 19:28:33 +0000644 const LineInfoArray &Lines) override {
645 DictScope DD(P, "Lines");
646 for (const auto &L : Lines) {
647 if (auto Result = getFileNameForOffset2(L.NameIndex))
648 P.printString("FileName", Result.get());
649 else
650 return Result.takeError();
651 P.flush();
652 for (const auto &N : L.LineNumbers) {
653 DictScope DDD(P, "Line");
654 LineInfo LI(N.Flags);
655 P.printNumber("Offset", N.Offset);
656 if (LI.isAlwaysStepInto())
657 P.printString("StepInto", StringRef("Always"));
658 else if (LI.isNeverStepInto())
659 P.printString("StepInto", StringRef("Never"));
660 else
661 P.printNumber("LineNumberStart", LI.getStartLine());
662 P.printNumber("EndDelta", LI.getLineDelta());
663 P.printBoolean("IsStatement", LI.isStatement());
664 }
665 for (const auto &C : L.Columns) {
666 DictScope DDD(P, "Column");
667 P.printNumber("Start", C.StartColumn);
668 P.printNumber("End", C.EndColumn);
669 }
670 }
671 return Error::success();
672 }
673
674 private:
675 Expected<StringRef> getFileNameForOffset(uint32_t Offset) {
Zachary Turnera1657a92016-06-08 17:26:39 +0000676 auto ST = F.getStringTable();
677 if (!ST)
678 return ST.takeError();
679
680 return ST->getStringForID(Offset);
Zachary Turnerd3117392016-06-03 19:28:33 +0000681 }
682 Expected<StringRef> getFileNameForOffset2(uint32_t Offset) {
Zachary Turnera1657a92016-06-08 17:26:39 +0000683 auto DS = F.getPDBDbiStream();
684 if (!DS)
685 return DS.takeError();
686 return DS->getFileNameForIndex(Offset);
Zachary Turnerd3117392016-06-03 19:28:33 +0000687 }
688 ScopedPrinter &P;
689 PDBFile &F;
690 };
691
692 RecordVisitor V(P, File);
693 for (const auto &L : ModS.lines(&HadError)) {
694 if (auto EC = codeview::visitModuleSubstream(L, V))
695 return EC;
696 }
697 }
698 }
699 }
700 }
701 return Error::success();
702}
703
704Error LLVMOutputStyle::dumpSectionContribs() {
Zachary Turnera30bd1a2016-06-30 17:42:48 +0000705 if (!opts::raw::DumpSectionContribs)
Zachary Turnerd3117392016-06-03 19:28:33 +0000706 return Error::success();
707
Zachary Turnera1657a92016-06-08 17:26:39 +0000708 auto Dbi = File.getPDBDbiStream();
709 if (!Dbi)
710 return Dbi.takeError();
711
Zachary Turnerd3117392016-06-03 19:28:33 +0000712 ListScope L(P, "Section Contributions");
713 class Visitor : public ISectionContribVisitor {
714 public:
715 Visitor(ScopedPrinter &P, DbiStream &DS) : P(P), DS(DS) {}
716 void visit(const SectionContrib &SC) override {
717 DictScope D(P, "Contribution");
718 P.printNumber("ISect", SC.ISect);
719 P.printNumber("Off", SC.Off);
720 P.printNumber("Size", SC.Size);
721 P.printFlags("Characteristics", SC.Characteristics,
722 codeview::getImageSectionCharacteristicNames(),
723 COFF::SectionCharacteristics(0x00F00000));
724 {
725 DictScope DD(P, "Module");
726 P.printNumber("Index", SC.Imod);
727 auto M = DS.modules();
728 if (M.size() > SC.Imod) {
729 P.printString("Name", M[SC.Imod].Info.getModuleName());
730 }
731 }
732 P.printNumber("Data CRC", SC.DataCrc);
733 P.printNumber("Reloc CRC", SC.RelocCrc);
734 P.flush();
735 }
736 void visit(const SectionContrib2 &SC) override {
737 visit(SC.Base);
738 P.printNumber("ISect Coff", SC.ISectCoff);
739 P.flush();
740 }
741
742 private:
743 ScopedPrinter &P;
744 DbiStream &DS;
745 };
Zachary Turnera1657a92016-06-08 17:26:39 +0000746 Visitor V(P, *Dbi);
747 Dbi->visitSectionContributions(V);
Zachary Turnerd3117392016-06-03 19:28:33 +0000748 return Error::success();
749}
750
751Error LLVMOutputStyle::dumpSectionMap() {
Zachary Turnera30bd1a2016-06-30 17:42:48 +0000752 if (!opts::raw::DumpSectionMap)
Zachary Turnerd3117392016-06-03 19:28:33 +0000753 return Error::success();
754
Zachary Turnera1657a92016-06-08 17:26:39 +0000755 auto Dbi = File.getPDBDbiStream();
756 if (!Dbi)
757 return Dbi.takeError();
758
Zachary Turnerd3117392016-06-03 19:28:33 +0000759 ListScope L(P, "Section Map");
Zachary Turnera1657a92016-06-08 17:26:39 +0000760 for (auto &M : Dbi->getSectionMap()) {
Zachary Turnerd3117392016-06-03 19:28:33 +0000761 DictScope D(P, "Entry");
762 P.printFlags("Flags", M.Flags, getOMFSegMapDescFlagNames());
763 P.printNumber("Flags", M.Flags);
764 P.printNumber("Ovl", M.Ovl);
765 P.printNumber("Group", M.Group);
766 P.printNumber("Frame", M.Frame);
767 P.printNumber("SecName", M.SecName);
768 P.printNumber("ClassName", M.ClassName);
769 P.printNumber("Offset", M.Offset);
770 P.printNumber("SecByteLength", M.SecByteLength);
771 P.flush();
772 }
773 return Error::success();
774}
775
776Error LLVMOutputStyle::dumpPublicsStream() {
Zachary Turnera30bd1a2016-06-30 17:42:48 +0000777 if (!opts::raw::DumpPublics)
Zachary Turnerd3117392016-06-03 19:28:33 +0000778 return Error::success();
779
780 DictScope D(P, "Publics Stream");
Zachary Turnera1657a92016-06-08 17:26:39 +0000781 auto Publics = File.getPDBPublicsStream();
782 if (!Publics)
783 return Publics.takeError();
784
785 auto Dbi = File.getPDBDbiStream();
786 if (!Dbi)
787 return Dbi.takeError();
788
789 P.printNumber("Stream number", Dbi->getPublicSymbolStreamIndex());
790 P.printNumber("SymHash", Publics->getSymHash());
791 P.printNumber("AddrMap", Publics->getAddrMap());
792 P.printNumber("Number of buckets", Publics->getNumBuckets());
793 P.printList("Hash Buckets", Publics->getHashBuckets());
794 P.printList("Address Map", Publics->getAddressMap());
795 P.printList("Thunk Map", Publics->getThunkMap());
796 P.printList("Section Offsets", Publics->getSectionOffsets(),
Zachary Turnerd3117392016-06-03 19:28:33 +0000797 printSectionOffset);
798 ListScope L(P, "Symbols");
Zachary Turner5e3e4bb2016-08-05 21:45:34 +0000799 codeview::CVSymbolDumper SD(P, Dumper, nullptr, false);
Zachary Turnerd3117392016-06-03 19:28:33 +0000800 bool HadError = false;
Zachary Turnera1657a92016-06-08 17:26:39 +0000801 for (auto S : Publics->getSymbols(&HadError)) {
Zachary Turnerd3117392016-06-03 19:28:33 +0000802 DictScope DD(P, "");
803
804 SD.dump(S);
Zachary Turnera30bd1a2016-06-30 17:42:48 +0000805 if (opts::raw::DumpSymRecordBytes)
Zachary Turnerd3117392016-06-03 19:28:33 +0000806 P.printBinaryBlock("Bytes", S.Data);
807 }
808 if (HadError)
809 return make_error<RawError>(
810 raw_error_code::corrupt_file,
811 "Public symbol stream contained corrupt record");
812
813 return Error::success();
814}
815
816Error LLVMOutputStyle::dumpSectionHeaders() {
Zachary Turnera30bd1a2016-06-30 17:42:48 +0000817 if (!opts::raw::DumpSectionHeaders)
Zachary Turnerd3117392016-06-03 19:28:33 +0000818 return Error::success();
819
Zachary Turnera1657a92016-06-08 17:26:39 +0000820 auto Dbi = File.getPDBDbiStream();
821 if (!Dbi)
822 return Dbi.takeError();
Zachary Turnerd3117392016-06-03 19:28:33 +0000823
824 ListScope D(P, "Section Headers");
Zachary Turnera1657a92016-06-08 17:26:39 +0000825 for (const object::coff_section &Section : Dbi->getSectionHeaders()) {
Zachary Turnerd3117392016-06-03 19:28:33 +0000826 DictScope DD(P, "");
827
828 // If a name is 8 characters long, there is no NUL character at end.
829 StringRef Name(Section.Name, strnlen(Section.Name, sizeof(Section.Name)));
830 P.printString("Name", Name);
831 P.printNumber("Virtual Size", Section.VirtualSize);
832 P.printNumber("Virtual Address", Section.VirtualAddress);
833 P.printNumber("Size of Raw Data", Section.SizeOfRawData);
834 P.printNumber("File Pointer to Raw Data", Section.PointerToRawData);
835 P.printNumber("File Pointer to Relocations", Section.PointerToRelocations);
836 P.printNumber("File Pointer to Linenumbers", Section.PointerToLinenumbers);
837 P.printNumber("Number of Relocations", Section.NumberOfRelocations);
838 P.printNumber("Number of Linenumbers", Section.NumberOfLinenumbers);
Rui Ueyama2c5384a2016-06-06 21:34:55 +0000839 P.printFlags("Characteristics", Section.Characteristics,
840 getImageSectionCharacteristicNames());
Zachary Turnerd3117392016-06-03 19:28:33 +0000841 }
842 return Error::success();
843}
Rui Ueyamaef2b4882016-06-06 18:39:21 +0000844
845Error LLVMOutputStyle::dumpFpoStream() {
Zachary Turnera30bd1a2016-06-30 17:42:48 +0000846 if (!opts::raw::DumpFpo)
Rui Ueyamaef2b4882016-06-06 18:39:21 +0000847 return Error::success();
848
Zachary Turnera1657a92016-06-08 17:26:39 +0000849 auto Dbi = File.getPDBDbiStream();
850 if (!Dbi)
851 return Dbi.takeError();
Rui Ueyamaef2b4882016-06-06 18:39:21 +0000852
853 ListScope D(P, "New FPO");
Zachary Turnera1657a92016-06-08 17:26:39 +0000854 for (const object::FpoData &Fpo : Dbi->getFpoRecords()) {
Rui Ueyamaef2b4882016-06-06 18:39:21 +0000855 DictScope DD(P, "");
856 P.printNumber("Offset", Fpo.Offset);
857 P.printNumber("Size", Fpo.Size);
858 P.printNumber("Number of locals", Fpo.NumLocals);
859 P.printNumber("Number of params", Fpo.NumParams);
860 P.printNumber("Size of Prolog", Fpo.getPrologSize());
861 P.printNumber("Number of Saved Registers", Fpo.getNumSavedRegs());
862 P.printBoolean("Has SEH", Fpo.hasSEH());
863 P.printBoolean("Use BP", Fpo.useBP());
864 P.printNumber("Frame Pointer", Fpo.getFP());
865 }
866 return Error::success();
867}
Zachary Turnera30bd1a2016-06-30 17:42:48 +0000868
Zachary Turner7120a472016-06-06 20:37:05 +0000869void LLVMOutputStyle::flush() { P.flush(); }