blob: 0946873536fbe0b6b05aa911de119a56451d897e [file] [log] [blame]
Zachary Turnerfcb14ad2015-01-27 20:46:21 +00001//===- llvm-pdbdump.cpp - Dump debug info from a PDB file -------*- 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// Dumps debug information present in PDB files. This utility makes use of
11// the Microsoft Windows SDK, so will not compile or run on non-Windows
12// platforms.
13//
14//===----------------------------------------------------------------------===//
15
Zachary Turner9a818ad2015-02-22 22:03:38 +000016#include "llvm-pdbdump.h"
17#include "CompilandDumper.h"
Zachary Turnere5cb2692015-05-01 20:24:26 +000018#include "ExternalSymbolDumper.h"
Zachary Turnerdb18f5c2015-02-27 09:15:18 +000019#include "FunctionDumper.h"
Zachary Turner2d11c202015-02-27 09:15:59 +000020#include "LinePrinter.h"
Zachary Turner9a818ad2015-02-22 22:03:38 +000021#include "TypeDumper.h"
Zachary Turnerdb18f5c2015-02-27 09:15:18 +000022#include "VariableDumper.h"
Zachary Turner9a818ad2015-02-22 22:03:38 +000023
Zachary Turnerfcb14ad2015-01-27 20:46:21 +000024#include "llvm/ADT/ArrayRef.h"
David Majnemer6e081262015-10-15 01:27:19 +000025#include "llvm/ADT/BitVector.h"
26#include "llvm/ADT/DenseMap.h"
Zachary Turnerfcb14ad2015-01-27 20:46:21 +000027#include "llvm/ADT/StringExtras.h"
Zachary Turner8d7fa9b2015-02-10 22:47:14 +000028#include "llvm/Config/config.h"
Zachary Turnercac29ae2016-05-24 17:30:25 +000029#include "llvm/DebugInfo/CodeView/SymbolDumper.h"
Zachary Turner5a1b5ef2016-05-06 22:15:42 +000030#include "llvm/DebugInfo/CodeView/TypeDumper.h"
Zachary Turner819e77d2016-05-06 20:51:57 +000031#include "llvm/DebugInfo/PDB/GenericError.h"
Zachary Turnera5549172015-02-10 22:43:25 +000032#include "llvm/DebugInfo/PDB/IPDBEnumChildren.h"
Zachary Turnera5549172015-02-10 22:43:25 +000033#include "llvm/DebugInfo/PDB/IPDBRawSymbol.h"
Chandler Carruth71f308a2015-02-13 09:09:03 +000034#include "llvm/DebugInfo/PDB/IPDBSession.h"
35#include "llvm/DebugInfo/PDB/PDB.h"
Zachary Turnera5549172015-02-10 22:43:25 +000036#include "llvm/DebugInfo/PDB/PDBSymbolCompiland.h"
Zachary Turnerdb18f5c2015-02-27 09:15:18 +000037#include "llvm/DebugInfo/PDB/PDBSymbolData.h"
Chandler Carruth71f308a2015-02-13 09:09:03 +000038#include "llvm/DebugInfo/PDB/PDBSymbolExe.h"
Zachary Turnerdb18f5c2015-02-27 09:15:18 +000039#include "llvm/DebugInfo/PDB/PDBSymbolFunc.h"
40#include "llvm/DebugInfo/PDB/PDBSymbolThunk.h"
Zachary Turner2f09b502016-04-29 17:28:47 +000041#include "llvm/DebugInfo/PDB/Raw/DbiStream.h"
42#include "llvm/DebugInfo/PDB/Raw/InfoStream.h"
Zachary Turner6ba65de2016-04-29 17:22:58 +000043#include "llvm/DebugInfo/PDB/Raw/MappedBlockStream.h"
Zachary Turner1822af542016-04-27 23:41:42 +000044#include "llvm/DebugInfo/PDB/Raw/ModInfo.h"
Zachary Turner06c2b4b2016-05-09 17:45:21 +000045#include "llvm/DebugInfo/PDB/Raw/ModStream.h"
Zachary Turner0eace0b2016-05-02 18:09:14 +000046#include "llvm/DebugInfo/PDB/Raw/NameHashTable.h"
Zachary Turner0a43efe2016-04-25 17:38:08 +000047#include "llvm/DebugInfo/PDB/Raw/PDBFile.h"
Rui Ueyama1f6b6e22016-05-13 21:21:53 +000048#include "llvm/DebugInfo/PDB/Raw/PublicsStream.h"
Reid Klecknerce5196e2016-05-12 23:26:23 +000049#include "llvm/DebugInfo/PDB/Raw/RawError.h"
Zachary Turner0a43efe2016-04-25 17:38:08 +000050#include "llvm/DebugInfo/PDB/Raw/RawSession.h"
Zachary Turner6ba65de2016-04-29 17:22:58 +000051#include "llvm/DebugInfo/PDB/Raw/StreamReader.h"
Zachary Turnerf5c59652016-05-03 00:28:21 +000052#include "llvm/DebugInfo/PDB/Raw/TpiStream.h"
Zachary Turnerfcb14ad2015-01-27 20:46:21 +000053#include "llvm/Support/CommandLine.h"
54#include "llvm/Support/ConvertUTF.h"
Zachary Turner9a818ad2015-02-22 22:03:38 +000055#include "llvm/Support/FileSystem.h"
Zachary Turnerfcb14ad2015-01-27 20:46:21 +000056#include "llvm/Support/Format.h"
57#include "llvm/Support/ManagedStatic.h"
David Majnemer6e081262015-10-15 01:27:19 +000058#include "llvm/Support/MemoryBuffer.h"
Zachary Turnerfcb14ad2015-01-27 20:46:21 +000059#include "llvm/Support/PrettyStackTrace.h"
Chandler Carruth71f308a2015-02-13 09:09:03 +000060#include "llvm/Support/Process.h"
Reid Klecknerb0345262016-05-04 16:09:04 +000061#include "llvm/Support/ScopedPrinter.h"
Daniel Sandersd41718e2016-04-22 12:04:42 +000062#include "llvm/Support/Signals.h"
Zachary Turner0a43efe2016-04-25 17:38:08 +000063#include "llvm/Support/raw_ostream.h"
Zachary Turnerfcb14ad2015-01-27 20:46:21 +000064
Zachary Turner8d7fa9b2015-02-10 22:47:14 +000065#if defined(HAVE_DIA_SDK)
Benjamin Kramer4b4a9362015-10-15 09:38:45 +000066#ifndef NOMINMAX
67#define NOMINMAX
68#endif
Zachary Turnera5549172015-02-10 22:43:25 +000069#include <Windows.h>
Zachary Turner8d7fa9b2015-02-10 22:47:14 +000070#endif
Zachary Turnerfcb14ad2015-01-27 20:46:21 +000071
72using namespace llvm;
Zachary Turner2f09b502016-04-29 17:28:47 +000073using namespace llvm::pdb;
Zachary Turnerfcb14ad2015-01-27 20:46:21 +000074
75namespace opts {
Zachary Turnerc0acf682015-02-15 20:27:53 +000076
77enum class PDB_DumpType { ByType, ByObjFile, Both };
78
Zachary Turnerfcb14ad2015-01-27 20:46:21 +000079cl::list<std::string> InputFilenames(cl::Positional,
80 cl::desc("<input PDB files>"),
81 cl::OneOrMore);
82
Zachary Turner7797c722015-03-02 04:39:56 +000083cl::OptionCategory TypeCategory("Symbol Type Options");
84cl::OptionCategory FilterCategory("Filtering Options");
Zachary Turnere5cb2692015-05-01 20:24:26 +000085cl::OptionCategory OtherOptions("Other Options");
Zachary Turner06c2b4b2016-05-09 17:45:21 +000086cl::OptionCategory NativeOtions("Native Options");
Zachary Turner7797c722015-03-02 04:39:56 +000087
88cl::opt<bool> Compilands("compilands", cl::desc("Display compilands"),
89 cl::cat(TypeCategory));
90cl::opt<bool> Symbols("symbols", cl::desc("Display symbols for each compiland"),
91 cl::cat(TypeCategory));
92cl::opt<bool> Globals("globals", cl::desc("Dump global symbols"),
93 cl::cat(TypeCategory));
Zachary Turnere5cb2692015-05-01 20:24:26 +000094cl::opt<bool> Externals("externals", cl::desc("Dump external symbols"),
95 cl::cat(TypeCategory));
Zachary Turner7797c722015-03-02 04:39:56 +000096cl::opt<bool> Types("types", cl::desc("Display types"), cl::cat(TypeCategory));
Zachary Turnera99000d2016-03-08 21:42:24 +000097cl::opt<bool> Lines("lines", cl::desc("Line tables"), cl::cat(TypeCategory));
Zachary Turner7797c722015-03-02 04:39:56 +000098cl::opt<bool>
Zachary Turner7797c722015-03-02 04:39:56 +000099 All("all", cl::desc("Implies all other options in 'Symbol Types' category"),
100 cl::cat(TypeCategory));
Zachary Turnerf5abda22015-03-01 06:49:49 +0000101
Zachary Turnere5cb2692015-05-01 20:24:26 +0000102cl::opt<uint64_t> LoadAddress(
103 "load-address",
104 cl::desc("Assume the module is loaded at the specified address"),
105 cl::cat(OtherOptions));
106
Zachary Turner96e60f72016-05-24 20:31:48 +0000107cl::opt<bool> DumpHeaders("raw-headers", cl::desc("dump PDB headers"),
Zachary Turner06c2b4b2016-05-09 17:45:21 +0000108 cl::cat(NativeOtions));
Zachary Turner96e60f72016-05-24 20:31:48 +0000109cl::opt<bool> DumpStreamSizes("raw-stream-sizes",
David Majnemer6e081262015-10-15 01:27:19 +0000110 cl::desc("dump PDB stream sizes"),
Zachary Turner06c2b4b2016-05-09 17:45:21 +0000111 cl::cat(NativeOtions));
Zachary Turner96e60f72016-05-24 20:31:48 +0000112cl::opt<bool> DumpStreamBlocks("raw-stream-blocks",
David Majnemer6e081262015-10-15 01:27:19 +0000113 cl::desc("dump PDB stream blocks"),
Zachary Turner06c2b4b2016-05-09 17:45:21 +0000114 cl::cat(NativeOtions));
Zachary Turner96e60f72016-05-24 20:31:48 +0000115cl::opt<bool> DumpTpiRecords("raw-tpi-records",
Zachary Turner5a1b5ef2016-05-06 22:15:42 +0000116 cl::desc("dump CodeView type records"),
Zachary Turner06c2b4b2016-05-09 17:45:21 +0000117 cl::cat(NativeOtions));
Reid Klecknerb0345262016-05-04 16:09:04 +0000118cl::opt<bool>
Zachary Turner96e60f72016-05-24 20:31:48 +0000119 DumpTpiRecordBytes("raw-tpi-record-bytes",
Reid Klecknerb0345262016-05-04 16:09:04 +0000120 cl::desc("dump CodeView type record raw bytes"),
Zachary Turner06c2b4b2016-05-09 17:45:21 +0000121 cl::cat(NativeOtions));
Zachary Turner96e60f72016-05-24 20:31:48 +0000122cl::opt<std::string> DumpStreamDataIdx("raw-stream",
123 cl::desc("dump stream data"),
124 cl::cat(NativeOtions));
125cl::opt<std::string> DumpStreamDataName("raw-stream-name",
126 cl::desc("dump stream data"),
127 cl::cat(NativeOtions));
128cl::opt<bool> DumpModules("raw-modules", cl::desc("dump compiland information"),
129 cl::cat(NativeOtions));
130cl::opt<bool> DumpModuleFiles("raw-module-files",
131 cl::desc("dump file information"),
132 cl::cat(NativeOtions));
133cl::opt<bool> DumpModuleSyms("raw-module-syms", cl::desc("dump module symbols"),
Zachary Turner06c2b4b2016-05-09 17:45:21 +0000134 cl::cat(NativeOtions));
Zachary Turner96e60f72016-05-24 20:31:48 +0000135cl::opt<bool> DumpPublics("raw-publics", cl::desc("dump Publics stream data"),
Rui Ueyama1f6b6e22016-05-13 21:21:53 +0000136 cl::cat(NativeOtions));
Zachary Turnercac29ae2016-05-24 17:30:25 +0000137cl::opt<bool>
Zachary Turner96e60f72016-05-24 20:31:48 +0000138 DumpSymRecordBytes("raw-sym-record-bytes",
Zachary Turnercac29ae2016-05-24 17:30:25 +0000139 cl::desc("dump CodeView symbol record raw bytes"),
140 cl::cat(NativeOtions));
David Majnemer6e081262015-10-15 01:27:19 +0000141
Zachary Turnerf5abda22015-03-01 06:49:49 +0000142cl::list<std::string>
143 ExcludeTypes("exclude-types",
144 cl::desc("Exclude types by regular expression"),
Zachary Turner7797c722015-03-02 04:39:56 +0000145 cl::ZeroOrMore, cl::cat(FilterCategory));
Zachary Turnerf5abda22015-03-01 06:49:49 +0000146cl::list<std::string>
147 ExcludeSymbols("exclude-symbols",
148 cl::desc("Exclude symbols by regular expression"),
Zachary Turner7797c722015-03-02 04:39:56 +0000149 cl::ZeroOrMore, cl::cat(FilterCategory));
Zachary Turnerf5abda22015-03-01 06:49:49 +0000150cl::list<std::string>
151 ExcludeCompilands("exclude-compilands",
152 cl::desc("Exclude compilands by regular expression"),
Zachary Turner7797c722015-03-02 04:39:56 +0000153 cl::ZeroOrMore, cl::cat(FilterCategory));
Zachary Turner4dddcc62015-09-29 19:49:06 +0000154
155cl::list<std::string> IncludeTypes(
156 "include-types",
157 cl::desc("Include only types which match a regular expression"),
158 cl::ZeroOrMore, cl::cat(FilterCategory));
159cl::list<std::string> IncludeSymbols(
160 "include-symbols",
161 cl::desc("Include only symbols which match a regular expression"),
162 cl::ZeroOrMore, cl::cat(FilterCategory));
163cl::list<std::string> IncludeCompilands(
164 "include-compilands",
165 cl::desc("Include only compilands those which match a regular expression"),
166 cl::ZeroOrMore, cl::cat(FilterCategory));
167
Zachary Turner7797c722015-03-02 04:39:56 +0000168cl::opt<bool> ExcludeCompilerGenerated(
169 "no-compiler-generated",
170 cl::desc("Don't show compiler generated types and symbols"),
171 cl::cat(FilterCategory));
172cl::opt<bool>
173 ExcludeSystemLibraries("no-system-libs",
174 cl::desc("Don't show symbols from system libraries"),
175 cl::cat(FilterCategory));
Zachary Turner65323652015-03-04 06:09:53 +0000176cl::opt<bool> NoClassDefs("no-class-definitions",
177 cl::desc("Don't display full class definitions"),
178 cl::cat(FilterCategory));
179cl::opt<bool> NoEnumDefs("no-enum-definitions",
180 cl::desc("Don't display full enum definitions"),
181 cl::cat(FilterCategory));
Zachary Turner49693b42015-01-28 01:22:33 +0000182}
183
Zachary Turner819e77d2016-05-06 20:51:57 +0000184static Error dumpFileHeaders(ScopedPrinter &P, PDBFile &File) {
Reid Klecknerb0345262016-05-04 16:09:04 +0000185 if (!opts::DumpHeaders)
Zachary Turner819e77d2016-05-06 20:51:57 +0000186 return Error::success();
187
Reid Klecknerb0345262016-05-04 16:09:04 +0000188 DictScope D(P, "FileHeaders");
189 P.printNumber("BlockSize", File.getBlockSize());
190 P.printNumber("Unknown0", File.getUnknown0());
191 P.printNumber("NumBlocks", File.getBlockCount());
192 P.printNumber("NumDirectoryBytes", File.getNumDirectoryBytes());
193 P.printNumber("Unknown1", File.getUnknown1());
194 P.printNumber("BlockMapAddr", File.getBlockMapIndex());
195 P.printNumber("NumDirectoryBlocks", File.getNumDirectoryBlocks());
196 P.printNumber("BlockMapOffset", File.getBlockMapOffset());
Zachary Turnercdd313c2016-05-04 15:05:12 +0000197
Chad Rosier20dbbf32016-05-04 15:25:06 +0000198 // The directory is not contiguous. Instead, the block map contains a
199 // contiguous list of block numbers whose contents, when concatenated in
200 // order, make up the directory.
Reid Klecknerb0345262016-05-04 16:09:04 +0000201 P.printList("DirectoryBlocks", File.getDirectoryBlockArray());
202 P.printNumber("NumStreams", File.getNumStreams());
Zachary Turner819e77d2016-05-06 20:51:57 +0000203 return Error::success();
Reid Klecknerb0345262016-05-04 16:09:04 +0000204}
Zachary Turnercdd313c2016-05-04 15:05:12 +0000205
Zachary Turner819e77d2016-05-06 20:51:57 +0000206static Error dumpStreamSizes(ScopedPrinter &P, PDBFile &File) {
Reid Klecknerb0345262016-05-04 16:09:04 +0000207 if (!opts::DumpStreamSizes)
Zachary Turner819e77d2016-05-06 20:51:57 +0000208 return Error::success();
Zachary Turnercdd313c2016-05-04 15:05:12 +0000209
Reid Klecknerb0345262016-05-04 16:09:04 +0000210 ListScope L(P, "StreamSizes");
Chad Rosier20dbbf32016-05-04 15:25:06 +0000211 uint32_t StreamCount = File.getNumStreams();
Reid Klecknerb0345262016-05-04 16:09:04 +0000212 for (uint32_t StreamIdx = 0; StreamIdx < StreamCount; ++StreamIdx) {
213 std::string Name("Stream ");
214 Name += to_string(StreamIdx);
215 P.printNumber(Name, File.getStreamByteSize(StreamIdx));
Chad Rosier20dbbf32016-05-04 15:25:06 +0000216 }
Zachary Turner819e77d2016-05-06 20:51:57 +0000217 return Error::success();
Reid Klecknerb0345262016-05-04 16:09:04 +0000218}
Zachary Turnercdd313c2016-05-04 15:05:12 +0000219
Zachary Turner819e77d2016-05-06 20:51:57 +0000220static Error dumpStreamBlocks(ScopedPrinter &P, PDBFile &File) {
Reid Klecknerb0345262016-05-04 16:09:04 +0000221 if (!opts::DumpStreamBlocks)
Zachary Turner819e77d2016-05-06 20:51:57 +0000222 return Error::success();
Reid Klecknerb0345262016-05-04 16:09:04 +0000223
224 ListScope L(P, "StreamBlocks");
225 uint32_t StreamCount = File.getNumStreams();
226 for (uint32_t StreamIdx = 0; StreamIdx < StreamCount; ++StreamIdx) {
227 std::string Name("Stream ");
228 Name += to_string(StreamIdx);
229 auto StreamBlocks = File.getStreamBlockList(StreamIdx);
230 P.printList(Name, StreamBlocks);
Chad Rosier20dbbf32016-05-04 15:25:06 +0000231 }
Zachary Turner819e77d2016-05-06 20:51:57 +0000232 return Error::success();
Reid Klecknerb0345262016-05-04 16:09:04 +0000233}
Zachary Turnercdd313c2016-05-04 15:05:12 +0000234
Zachary Turner819e77d2016-05-06 20:51:57 +0000235static Error dumpStreamData(ScopedPrinter &P, PDBFile &File) {
Reid Klecknerb0345262016-05-04 16:09:04 +0000236 uint32_t StreamCount = File.getNumStreams();
Zachary Turner96e60f72016-05-24 20:31:48 +0000237 StringRef DumpStreamStr = opts::DumpStreamDataIdx;
Chad Rosier20dbbf32016-05-04 15:25:06 +0000238 uint32_t DumpStreamNum;
Reid Klecknerb0345262016-05-04 16:09:04 +0000239 if (DumpStreamStr.getAsInteger(/*Radix=*/0U, DumpStreamNum) ||
240 DumpStreamNum >= StreamCount)
Zachary Turner819e77d2016-05-06 20:51:57 +0000241 return Error::success();
Chad Rosier20dbbf32016-05-04 15:25:06 +0000242
Zachary Turner96e60f72016-05-24 20:31:48 +0000243 MappedBlockStream S(DumpStreamNum, File);
244 StreamReader R(S);
245 while (R.bytesRemaining() > 0) {
246 ArrayRef<uint8_t> Data;
Reid Klecknerb0345262016-05-04 16:09:04 +0000247 uint32_t BytesToReadInBlock = std::min(
Zachary Turner96e60f72016-05-24 20:31:48 +0000248 R.bytesRemaining(), static_cast<uint32_t>(File.getBlockSize()));
249 if (auto EC = R.getArrayRef(Data, BytesToReadInBlock))
250 return EC;
251 outs() << StringRef(reinterpret_cast<const char *>(Data.begin()),
252 Data.size());
Chad Rosier20dbbf32016-05-04 15:25:06 +0000253 }
Zachary Turner819e77d2016-05-06 20:51:57 +0000254 return Error::success();
Reid Klecknerb0345262016-05-04 16:09:04 +0000255}
Chad Rosier20dbbf32016-05-04 15:25:06 +0000256
Zachary Turner819e77d2016-05-06 20:51:57 +0000257static Error dumpInfoStream(ScopedPrinter &P, PDBFile &File) {
258 auto InfoS = File.getPDBInfoStream();
259 if (auto EC = InfoS.takeError())
260 return EC;
261
262 InfoStream &IS = InfoS.get();
Chad Rosier20dbbf32016-05-04 15:25:06 +0000263
Reid Klecknerb0345262016-05-04 16:09:04 +0000264 DictScope D(P, "PDB Stream");
265 P.printNumber("Version", IS.getVersion());
266 P.printHex("Signature", IS.getSignature());
267 P.printNumber("Age", IS.getAge());
268 P.printObject("Guid", IS.getGuid());
Zachary Turner819e77d2016-05-06 20:51:57 +0000269 return Error::success();
Reid Klecknerb0345262016-05-04 16:09:04 +0000270}
271
Zachary Turner96e60f72016-05-24 20:31:48 +0000272static Error dumpNamedStream(ScopedPrinter &P, PDBFile &File) {
273 if (opts::DumpStreamDataName.empty())
274 return Error::success();
275
Zachary Turner819e77d2016-05-06 20:51:57 +0000276 auto InfoS = File.getPDBInfoStream();
277 if (auto EC = InfoS.takeError())
278 return EC;
279 InfoStream &IS = InfoS.get();
280
Zachary Turner96e60f72016-05-24 20:31:48 +0000281 uint32_t NameStreamIndex = IS.getNamedStreamIndex(opts::DumpStreamDataName);
Reid Klecknerb0345262016-05-04 16:09:04 +0000282
Chad Rosier20dbbf32016-05-04 15:25:06 +0000283 if (NameStreamIndex != 0) {
Reid Klecknerb0345262016-05-04 16:09:04 +0000284 std::string Name("Stream '");
Zachary Turner96e60f72016-05-24 20:31:48 +0000285 Name += opts::DumpStreamDataName;
Reid Klecknerb0345262016-05-04 16:09:04 +0000286 Name += "'";
287 DictScope D(P, Name);
288 P.printNumber("Index", NameStreamIndex);
289
Chad Rosier20dbbf32016-05-04 15:25:06 +0000290 MappedBlockStream NameStream(NameStreamIndex, File);
291 StreamReader Reader(NameStream);
292
Chad Rosier20dbbf32016-05-04 15:25:06 +0000293 NameHashTable NameTable;
Zachary Turner819e77d2016-05-06 20:51:57 +0000294 if (auto EC = NameTable.load(Reader))
295 return EC;
296
Reid Klecknerb0345262016-05-04 16:09:04 +0000297 P.printHex("Signature", NameTable.getSignature());
298 P.printNumber("Version", NameTable.getHashVersion());
299 P.printNumber("Name Count", NameTable.getNameCount());
300 ListScope L(P, "Names");
Chad Rosier20dbbf32016-05-04 15:25:06 +0000301 for (uint32_t ID : NameTable.name_ids()) {
Reid Klecknerb0345262016-05-04 16:09:04 +0000302 StringRef Str = NameTable.getStringForID(ID);
303 if (!Str.empty())
304 P.printString(Str);
Chad Rosier20dbbf32016-05-04 15:25:06 +0000305 }
306 }
Zachary Turner819e77d2016-05-06 20:51:57 +0000307 return Error::success();
Reid Klecknerb0345262016-05-04 16:09:04 +0000308}
Chad Rosier20dbbf32016-05-04 15:25:06 +0000309
Zachary Turnercac29ae2016-05-24 17:30:25 +0000310static Error dumpDbiStream(ScopedPrinter &P, PDBFile &File,
311 codeview::CVTypeDumper &TD) {
Zachary Turner819e77d2016-05-06 20:51:57 +0000312 auto DbiS = File.getPDBDbiStream();
313 if (auto EC = DbiS.takeError())
314 return EC;
315 DbiStream &DS = DbiS.get();
Reid Klecknerb0345262016-05-04 16:09:04 +0000316
317 DictScope D(P, "DBI Stream");
318 P.printNumber("Dbi Version", DS.getDbiVersion());
319 P.printNumber("Age", DS.getAge());
320 P.printBoolean("Incremental Linking", DS.isIncrementallyLinked());
321 P.printBoolean("Has CTypes", DS.hasCTypes());
322 P.printBoolean("Is Stripped", DS.isStripped());
323 P.printObject("Machine Type", DS.getMachineType());
Rui Ueyama0376b1a2016-05-19 18:05:58 +0000324 P.printNumber("Symbol Record Stream Index", DS.getSymRecordStreamIndex());
Zachary Turner96e60f72016-05-24 20:31:48 +0000325 P.printNumber("Public Symbol Stream Index", DS.getPublicSymbolStreamIndex());
326 P.printNumber("Global Symbol Stream Index", DS.getGlobalSymbolStreamIndex());
Chad Rosier20dbbf32016-05-04 15:25:06 +0000327
328 uint16_t Major = DS.getBuildMajorVersion();
329 uint16_t Minor = DS.getBuildMinorVersion();
Reid Klecknerb0345262016-05-04 16:09:04 +0000330 P.printVersion("Toolchain Version", Major, Minor);
Chad Rosier20dbbf32016-05-04 15:25:06 +0000331
Reid Klecknerb0345262016-05-04 16:09:04 +0000332 std::string DllName;
333 raw_string_ostream DllStream(DllName);
334 DllStream << "mspdb" << Major << Minor << ".dll version";
335 DllStream.flush();
336 P.printVersion(DllName, Major, Minor, DS.getPdbDllVersion());
337
Zachary Turner96e60f72016-05-24 20:31:48 +0000338 if (opts::DumpModules || opts::DumpModuleSyms || opts::DumpModuleFiles) {
339 ListScope L(P, "Modules");
340 for (auto &Modi : DS.modules()) {
341 DictScope DD(P);
342 P.printString("Name", Modi.Info.getModuleName());
343 P.printNumber("Debug Stream Index", Modi.Info.getModuleStreamIndex());
344 P.printString("Object File Name", Modi.Info.getObjFileName());
345 P.printNumber("Num Files", Modi.Info.getNumberOfFiles());
346 P.printNumber("Source File Name Idx", Modi.Info.getSourceFileNameIndex());
347 P.printNumber("Pdb File Name Idx", Modi.Info.getPdbFilePathNameIndex());
348 P.printNumber("Line Info Byte Size", Modi.Info.getLineInfoByteSize());
349 P.printNumber("C13 Line Info Byte Size",
350 Modi.Info.getC13LineInfoByteSize());
351 P.printNumber("Symbol Byte Size", Modi.Info.getSymbolDebugInfoByteSize());
352 P.printNumber("Type Server Index", Modi.Info.getTypeServerIndex());
353 P.printBoolean("Has EC Info", Modi.Info.hasECInfo());
354 if (opts::DumpModuleFiles) {
355 std::string FileListName =
356 to_string(Modi.SourceFiles.size()) + " Contributing Source Files";
357 ListScope LL(P, FileListName);
358 for (auto File : Modi.SourceFiles)
359 P.printString(File);
360 }
361 bool HasModuleDI =
362 (Modi.Info.getModuleStreamIndex() < File.getNumStreams());
363 bool ShouldDumpSymbols =
364 (opts::DumpModuleSyms || opts::DumpSymRecordBytes);
365 if (HasModuleDI && ShouldDumpSymbols) {
366 ListScope SS(P, "Symbols");
367 ModStream ModS(File, Modi.Info);
368 if (auto EC = ModS.reload())
369 return EC;
Zachary Turner06c2b4b2016-05-09 17:45:21 +0000370
Zachary Turner96e60f72016-05-24 20:31:48 +0000371 codeview::CVSymbolDumper SD(P, TD, nullptr, false);
372 for (auto &S : ModS.symbols()) {
373 DictScope DD(P, "");
Zachary Turnercac29ae2016-05-24 17:30:25 +0000374
Zachary Turner96e60f72016-05-24 20:31:48 +0000375 if (opts::DumpModuleSyms)
376 SD.dump(S);
377 if (opts::DumpSymRecordBytes)
378 P.printBinaryBlock("Bytes", S.Data);
379 }
Zachary Turner06c2b4b2016-05-09 17:45:21 +0000380 }
381 }
Chad Rosier20dbbf32016-05-04 15:25:06 +0000382 }
Zachary Turner819e77d2016-05-06 20:51:57 +0000383 return Error::success();
Reid Klecknerb0345262016-05-04 16:09:04 +0000384}
385
Zachary Turnercac29ae2016-05-24 17:30:25 +0000386static Error dumpTpiStream(ScopedPrinter &P, PDBFile &File,
387 codeview::CVTypeDumper &TD) {
Reid Klecknerb0345262016-05-04 16:09:04 +0000388
Zachary Turner5a1b5ef2016-05-06 22:15:42 +0000389 if (opts::DumpTpiRecordBytes || opts::DumpTpiRecords) {
Zachary Turnercac29ae2016-05-24 17:30:25 +0000390 DictScope D(P, "Type Info Stream");
391
392 auto TpiS = File.getPDBTpiStream();
393 if (auto EC = TpiS.takeError())
394 return EC;
395 TpiStream &Tpi = TpiS.get();
396
397 P.printNumber("TPI Version", Tpi.getTpiVersion());
398 P.printNumber("Record count", Tpi.NumTypeRecords());
399
Zachary Turner5a1b5ef2016-05-06 22:15:42 +0000400 ListScope L(P, "Records");
Reid Klecknerb0345262016-05-04 16:09:04 +0000401
Reid Klecknerce5196e2016-05-12 23:26:23 +0000402 bool HadError = false;
403 for (auto &Type : Tpi.types(&HadError)) {
Zachary Turner5a1b5ef2016-05-06 22:15:42 +0000404 DictScope DD(P, "");
405
406 if (opts::DumpTpiRecords)
407 TD.dump(Type);
408
409 if (opts::DumpTpiRecordBytes)
Zachary Turner9073ed62016-05-09 17:44:58 +0000410 P.printBinaryBlock("Bytes", Type.Data);
Zachary Turner5a1b5ef2016-05-06 22:15:42 +0000411 }
Reid Klecknerce5196e2016-05-12 23:26:23 +0000412 if (HadError)
413 return make_error<RawError>(raw_error_code::corrupt_file,
414 "TPI stream contained corrupt record");
Zachary Turnercac29ae2016-05-24 17:30:25 +0000415 } else if (opts::DumpModuleSyms) {
416 // Even if the user doesn't want to dump type records, we still need to
417 // iterate them in order to build the list of types so that we can print
418 // them when dumping module symbols. So when they want to dump symbols
419 // but not types, use a null output stream.
420 ScopedPrinter *OldP = TD.getPrinter();
421 TD.setPrinter(nullptr);
422 auto TpiS = File.getPDBTpiStream();
423 if (auto EC = TpiS.takeError())
424 return EC;
425 TpiStream &Tpi = TpiS.get();
426 bool HadError = false;
427 for (auto &Type : Tpi.types(&HadError))
428 TD.dump(Type);
429
430 TD.setPrinter(OldP);
431 if (HadError)
432 return make_error<RawError>(raw_error_code::corrupt_file,
433 "TPI stream contained corrupt record");
Chad Rosier20dbbf32016-05-04 15:25:06 +0000434 }
Zachary Turnercac29ae2016-05-24 17:30:25 +0000435
Zachary Turner819e77d2016-05-06 20:51:57 +0000436 return Error::success();
Zachary Turnercdd313c2016-05-04 15:05:12 +0000437}
438
Zachary Turner9e33e6f2016-05-24 18:55:14 +0000439static Error dumpPublicsStream(ScopedPrinter &P, PDBFile &File,
440 codeview::CVTypeDumper &TD) {
Rui Ueyama1f6b6e22016-05-13 21:21:53 +0000441 if (!opts::DumpPublics)
442 return Error::success();
443
444 DictScope D(P, "Publics Stream");
445 auto PublicsS = File.getPDBPublicsStream();
446 if (auto EC = PublicsS.takeError())
447 return EC;
448 PublicsStream &Publics = PublicsS.get();
449 P.printNumber("Stream number", Publics.getStreamNum());
450 P.printNumber("SymHash", Publics.getSymHash());
451 P.printNumber("AddrMap", Publics.getAddrMap());
452 P.printNumber("Number of buckets", Publics.getNumBuckets());
Rui Ueyama8dc18c52016-05-17 23:07:48 +0000453 P.printList("Hash Buckets", Publics.getHashBuckets());
454 P.printList("Address Map", Publics.getAddressMap());
455 P.printList("Thunk Map", Publics.getThunkMap());
Rui Ueyama350b2982016-05-18 16:24:16 +0000456 P.printList("Section Offsets", Publics.getSectionOffsets());
Zachary Turner9e33e6f2016-05-24 18:55:14 +0000457 ListScope L(P, "Symbols");
458 codeview::CVSymbolDumper SD(P, TD, nullptr, false);
459 for (auto S : Publics.getSymbols()) {
460 DictScope DD(P, "");
461
462 SD.dump(S);
463 if (opts::DumpSymRecordBytes)
464 P.printBinaryBlock("Bytes", S.Data);
465 }
Rui Ueyama1f6b6e22016-05-13 21:21:53 +0000466 return Error::success();
467}
468
Zachary Turner819e77d2016-05-06 20:51:57 +0000469static Error dumpStructure(RawSession &RS) {
Reid Klecknerb0345262016-05-04 16:09:04 +0000470 PDBFile &File = RS.getPDBFile();
471 ScopedPrinter P(outs());
472
Zachary Turner819e77d2016-05-06 20:51:57 +0000473 if (auto EC = dumpFileHeaders(P, File))
474 return EC;
Reid Klecknerb0345262016-05-04 16:09:04 +0000475
Zachary Turner819e77d2016-05-06 20:51:57 +0000476 if (auto EC = dumpStreamSizes(P, File))
477 return EC;
Reid Klecknerb0345262016-05-04 16:09:04 +0000478
Zachary Turner819e77d2016-05-06 20:51:57 +0000479 if (auto EC = dumpStreamBlocks(P, File))
480 return EC;
Reid Klecknerb0345262016-05-04 16:09:04 +0000481
Zachary Turner819e77d2016-05-06 20:51:57 +0000482 if (auto EC = dumpStreamData(P, File))
483 return EC;
Reid Klecknerb0345262016-05-04 16:09:04 +0000484
Zachary Turner819e77d2016-05-06 20:51:57 +0000485 if (auto EC = dumpInfoStream(P, File))
486 return EC;
Reid Klecknerb0345262016-05-04 16:09:04 +0000487
Zachary Turner96e60f72016-05-24 20:31:48 +0000488 if (auto EC = dumpNamedStream(P, File))
Zachary Turner819e77d2016-05-06 20:51:57 +0000489 return EC;
Reid Klecknerb0345262016-05-04 16:09:04 +0000490
Zachary Turnercac29ae2016-05-24 17:30:25 +0000491 codeview::CVTypeDumper TD(P, false);
492 if (auto EC = dumpTpiStream(P, File, TD))
Zachary Turner819e77d2016-05-06 20:51:57 +0000493 return EC;
Reid Klecknerb0345262016-05-04 16:09:04 +0000494
Zachary Turnercac29ae2016-05-24 17:30:25 +0000495 if (auto EC = dumpDbiStream(P, File, TD))
Zachary Turner819e77d2016-05-06 20:51:57 +0000496 return EC;
Rui Ueyama1f6b6e22016-05-13 21:21:53 +0000497
Zachary Turner9e33e6f2016-05-24 18:55:14 +0000498 if (auto EC = dumpPublicsStream(P, File, TD))
Rui Ueyama1f6b6e22016-05-13 21:21:53 +0000499 return EC;
Zachary Turner96e60f72016-05-24 20:31:48 +0000500 return Error::success();
501}
502
503bool isRawDumpEnabled() {
504 if (opts::DumpHeaders)
505 return true;
506 if (opts::DumpModules)
507 return true;
508 if (opts::DumpModuleFiles)
509 return true;
510 if (opts::DumpModuleSyms)
511 return true;
512 if (!opts::DumpStreamDataIdx.empty())
513 return true;
514 if (!opts::DumpStreamDataName.empty())
515 return true;
516 if (opts::DumpPublics)
517 return true;
518 if (opts::DumpStreamBlocks)
519 return true;
520 if (opts::DumpStreamSizes)
521 return true;
522 if (opts::DumpSymRecordBytes)
523 return true;
524 if (opts::DumpTpiRecordBytes)
525 return true;
526 if (opts::DumpTpiRecords)
527 return true;
528 return false;
David Majnemer1573b242016-04-28 23:47:27 +0000529}
530
531static void dumpInput(StringRef Path) {
532 std::unique_ptr<IPDBSession> Session;
Zachary Turner96e60f72016-05-24 20:31:48 +0000533 if (isRawDumpEnabled()) {
Zachary Turner819e77d2016-05-06 20:51:57 +0000534 auto E = loadDataForPDB(PDB_ReaderType::Raw, Path, Session);
535 if (!E) {
David Majnemer1573b242016-04-28 23:47:27 +0000536 RawSession *RS = static_cast<RawSession *>(Session.get());
Zachary Turner819e77d2016-05-06 20:51:57 +0000537 E = dumpStructure(*RS);
David Majnemer1573b242016-04-28 23:47:27 +0000538 }
539
Zachary Turner819e77d2016-05-06 20:51:57 +0000540 if (E)
541 logAllUnhandledErrors(std::move(E), outs(), "");
542
David Majnemer1573b242016-04-28 23:47:27 +0000543 return;
544 }
545
Zachary Turner819e77d2016-05-06 20:51:57 +0000546 Error E = loadDataForPDB(PDB_ReaderType::DIA, Path, Session);
547 if (E) {
548 logAllUnhandledErrors(std::move(E), outs(), "");
David Majnemer1573b242016-04-28 23:47:27 +0000549 return;
550 }
551
Zachary Turnere5cb2692015-05-01 20:24:26 +0000552 if (opts::LoadAddress)
553 Session->setLoadAddress(opts::LoadAddress);
Zachary Turner7058dfc2015-01-27 22:40:14 +0000554
Zachary Turner2d11c202015-02-27 09:15:59 +0000555 LinePrinter Printer(2, outs());
556
Zachary Turnera5549172015-02-10 22:43:25 +0000557 auto GlobalScope(Session->getGlobalScope());
Zachary Turner9a818ad2015-02-22 22:03:38 +0000558 std::string FileName(GlobalScope->getSymbolsFileName());
559
Zachary Turner2d11c202015-02-27 09:15:59 +0000560 WithColor(Printer, PDB_ColorItem::None).get() << "Summary for ";
561 WithColor(Printer, PDB_ColorItem::Path).get() << FileName;
562 Printer.Indent();
Zachary Turner9a818ad2015-02-22 22:03:38 +0000563 uint64_t FileSize = 0;
Zachary Turner9a818ad2015-02-22 22:03:38 +0000564
Zachary Turner2d11c202015-02-27 09:15:59 +0000565 Printer.NewLine();
566 WithColor(Printer, PDB_ColorItem::Identifier).get() << "Size";
David Majnemer6e081262015-10-15 01:27:19 +0000567 if (!sys::fs::file_size(FileName, FileSize)) {
Zachary Turner2d11c202015-02-27 09:15:59 +0000568 Printer << ": " << FileSize << " bytes";
569 } else {
570 Printer << ": (Unable to obtain file size)";
571 }
572
573 Printer.NewLine();
574 WithColor(Printer, PDB_ColorItem::Identifier).get() << "Guid";
575 Printer << ": " << GlobalScope->getGuid();
576
577 Printer.NewLine();
578 WithColor(Printer, PDB_ColorItem::Identifier).get() << "Age";
579 Printer << ": " << GlobalScope->getAge();
580
581 Printer.NewLine();
582 WithColor(Printer, PDB_ColorItem::Identifier).get() << "Attributes";
583 Printer << ": ";
Zachary Turner9a818ad2015-02-22 22:03:38 +0000584 if (GlobalScope->hasCTypes())
585 outs() << "HasCTypes ";
586 if (GlobalScope->hasPrivateSymbols())
587 outs() << "HasPrivateSymbols ";
Zachary Turner2d11c202015-02-27 09:15:59 +0000588 Printer.Unindent();
Zachary Turner9a818ad2015-02-22 22:03:38 +0000589
Zachary Turnerdb18f5c2015-02-27 09:15:18 +0000590 if (opts::Compilands) {
Zachary Turner2d11c202015-02-27 09:15:59 +0000591 Printer.NewLine();
592 WithColor(Printer, PDB_ColorItem::SectionHeader).get()
593 << "---COMPILANDS---";
594 Printer.Indent();
Zachary Turnerc074de02015-02-12 21:09:24 +0000595 auto Compilands = GlobalScope->findAllChildren<PDBSymbolCompiland>();
Zachary Turner2d11c202015-02-27 09:15:59 +0000596 CompilandDumper Dumper(Printer);
Zachary Turnera99000d2016-03-08 21:42:24 +0000597 CompilandDumpFlags options = CompilandDumper::Flags::None;
598 if (opts::Lines)
599 options = options | CompilandDumper::Flags::Lines;
Zachary Turner9a818ad2015-02-22 22:03:38 +0000600 while (auto Compiland = Compilands->getNext())
Zachary Turnera99000d2016-03-08 21:42:24 +0000601 Dumper.start(*Compiland, options);
Zachary Turner2d11c202015-02-27 09:15:59 +0000602 Printer.Unindent();
Zachary Turnerdb18f5c2015-02-27 09:15:18 +0000603 }
604
605 if (opts::Types) {
Zachary Turner2d11c202015-02-27 09:15:59 +0000606 Printer.NewLine();
607 WithColor(Printer, PDB_ColorItem::SectionHeader).get() << "---TYPES---";
608 Printer.Indent();
Zachary Turner65323652015-03-04 06:09:53 +0000609 TypeDumper Dumper(Printer);
Zachary Turnerb52d08d2015-03-01 06:51:29 +0000610 Dumper.start(*GlobalScope);
Zachary Turner2d11c202015-02-27 09:15:59 +0000611 Printer.Unindent();
Zachary Turnerdb18f5c2015-02-27 09:15:18 +0000612 }
613
614 if (opts::Symbols) {
Zachary Turner2d11c202015-02-27 09:15:59 +0000615 Printer.NewLine();
616 WithColor(Printer, PDB_ColorItem::SectionHeader).get() << "---SYMBOLS---";
617 Printer.Indent();
Zachary Turnerdb18f5c2015-02-27 09:15:18 +0000618 auto Compilands = GlobalScope->findAllChildren<PDBSymbolCompiland>();
Zachary Turner2d11c202015-02-27 09:15:59 +0000619 CompilandDumper Dumper(Printer);
Zachary Turnerdb18f5c2015-02-27 09:15:18 +0000620 while (auto Compiland = Compilands->getNext())
Zachary Turnerb52d08d2015-03-01 06:51:29 +0000621 Dumper.start(*Compiland, true);
Zachary Turner2d11c202015-02-27 09:15:59 +0000622 Printer.Unindent();
Zachary Turnerdb18f5c2015-02-27 09:15:18 +0000623 }
624
625 if (opts::Globals) {
Zachary Turner2d11c202015-02-27 09:15:59 +0000626 Printer.NewLine();
627 WithColor(Printer, PDB_ColorItem::SectionHeader).get() << "---GLOBALS---";
628 Printer.Indent();
Zachary Turnerdb18f5c2015-02-27 09:15:18 +0000629 {
Zachary Turner2d11c202015-02-27 09:15:59 +0000630 FunctionDumper Dumper(Printer);
Zachary Turnerdb18f5c2015-02-27 09:15:18 +0000631 auto Functions = GlobalScope->findAllChildren<PDBSymbolFunc>();
Zachary Turner2d11c202015-02-27 09:15:59 +0000632 while (auto Function = Functions->getNext()) {
633 Printer.NewLine();
Zachary Turnerb52d08d2015-03-01 06:51:29 +0000634 Dumper.start(*Function, FunctionDumper::PointerType::None);
Zachary Turner2d11c202015-02-27 09:15:59 +0000635 }
Zachary Turnerdb18f5c2015-02-27 09:15:18 +0000636 }
637 {
638 auto Vars = GlobalScope->findAllChildren<PDBSymbolData>();
Zachary Turner2d11c202015-02-27 09:15:59 +0000639 VariableDumper Dumper(Printer);
Zachary Turnerdb18f5c2015-02-27 09:15:18 +0000640 while (auto Var = Vars->getNext())
Zachary Turnerb52d08d2015-03-01 06:51:29 +0000641 Dumper.start(*Var);
Zachary Turnerdb18f5c2015-02-27 09:15:18 +0000642 }
643 {
644 auto Thunks = GlobalScope->findAllChildren<PDBSymbolThunk>();
Zachary Turner2d11c202015-02-27 09:15:59 +0000645 CompilandDumper Dumper(Printer);
Zachary Turnerdb18f5c2015-02-27 09:15:18 +0000646 while (auto Thunk = Thunks->getNext())
Zachary Turnerb52d08d2015-03-01 06:51:29 +0000647 Dumper.dump(*Thunk);
Zachary Turnerdb18f5c2015-02-27 09:15:18 +0000648 }
Zachary Turner2d11c202015-02-27 09:15:59 +0000649 Printer.Unindent();
Zachary Turner7058dfc2015-01-27 22:40:14 +0000650 }
Zachary Turnere5cb2692015-05-01 20:24:26 +0000651 if (opts::Externals) {
652 Printer.NewLine();
653 WithColor(Printer, PDB_ColorItem::SectionHeader).get() << "---EXTERNALS---";
654 Printer.Indent();
655 ExternalSymbolDumper Dumper(Printer);
656 Dumper.start(*GlobalScope);
657 }
Zachary Turnera99000d2016-03-08 21:42:24 +0000658 if (opts::Lines) {
659 Printer.NewLine();
660 }
Zachary Turnera5549172015-02-10 22:43:25 +0000661 outs().flush();
Zachary Turnerfcb14ad2015-01-27 20:46:21 +0000662}
663
664int main(int argc_, const char *argv_[]) {
665 // Print a stack trace if we signal out.
666 sys::PrintStackTraceOnErrorSignal();
667 PrettyStackTraceProgram X(argc_, argv_);
668
669 SmallVector<const char *, 256> argv;
David Majnemer6e081262015-10-15 01:27:19 +0000670 SpecificBumpPtrAllocator<char> ArgAllocator;
671 std::error_code EC = sys::Process::GetArgumentVector(
672 argv, makeArrayRef(argv_, argc_), ArgAllocator);
Zachary Turnerfcb14ad2015-01-27 20:46:21 +0000673 if (EC) {
David Majnemer6e081262015-10-15 01:27:19 +0000674 errs() << "error: couldn't get arguments: " << EC.message() << '\n';
Zachary Turnerfcb14ad2015-01-27 20:46:21 +0000675 return 1;
676 }
677
678 llvm_shutdown_obj Y; // Call llvm_shutdown() on exit.
679
680 cl::ParseCommandLineOptions(argv.size(), argv.data(), "LLVM PDB Dumper\n");
Zachary Turnera99000d2016-03-08 21:42:24 +0000681 if (opts::Lines)
682 opts::Compilands = true;
683
Zachary Turner7797c722015-03-02 04:39:56 +0000684 if (opts::All) {
685 opts::Compilands = true;
686 opts::Symbols = true;
687 opts::Globals = true;
688 opts::Types = true;
Zachary Turnere5cb2692015-05-01 20:24:26 +0000689 opts::Externals = true;
Zachary Turnera99000d2016-03-08 21:42:24 +0000690 opts::Lines = true;
Zachary Turner7797c722015-03-02 04:39:56 +0000691 }
Zachary Turnera99000d2016-03-08 21:42:24 +0000692
693 // When adding filters for excluded compilands and types, we need to remember
694 // that these are regexes. So special characters such as * and \ need to be
695 // escaped in the regex. In the case of a literal \, this means it needs to
696 // be escaped again in the C++. So matching a single \ in the input requires
697 // 4 \es in the C++.
Zachary Turner7797c722015-03-02 04:39:56 +0000698 if (opts::ExcludeCompilerGenerated) {
699 opts::ExcludeTypes.push_back("__vc_attributes");
Zachary Turnera99000d2016-03-08 21:42:24 +0000700 opts::ExcludeCompilands.push_back("\\* Linker \\*");
Zachary Turner7797c722015-03-02 04:39:56 +0000701 }
702 if (opts::ExcludeSystemLibraries) {
703 opts::ExcludeCompilands.push_back(
Zachary Turnera99000d2016-03-08 21:42:24 +0000704 "f:\\\\binaries\\\\Intermediate\\\\vctools\\\\crt_bld");
705 opts::ExcludeCompilands.push_back("f:\\\\dd\\\\vctools\\\\crt");
706 opts::ExcludeCompilands.push_back("d:\\\\th.obj.x86fre\\\\minkernel");
Zachary Turner7797c722015-03-02 04:39:56 +0000707 }
Zachary Turnerfcb14ad2015-01-27 20:46:21 +0000708
Zachary Turner8d7fa9b2015-02-10 22:47:14 +0000709#if defined(HAVE_DIA_SDK)
Zachary Turnerfcb14ad2015-01-27 20:46:21 +0000710 CoInitializeEx(nullptr, COINIT_MULTITHREADED);
Zachary Turner8d7fa9b2015-02-10 22:47:14 +0000711#endif
Zachary Turnerfcb14ad2015-01-27 20:46:21 +0000712
713 std::for_each(opts::InputFilenames.begin(), opts::InputFilenames.end(),
714 dumpInput);
715
Zachary Turner8d7fa9b2015-02-10 22:47:14 +0000716#if defined(HAVE_DIA_SDK)
Zachary Turnerfcb14ad2015-01-27 20:46:21 +0000717 CoUninitialize();
Zachary Turner8d7fa9b2015-02-10 22:47:14 +0000718#endif
Zachary Turner819e77d2016-05-06 20:51:57 +0000719 outs().flush();
Zachary Turnerfcb14ad2015-01-27 20:46:21 +0000720 return 0;
721}