blob: cb2b7d6a1ed78f79ca2071456077cdc731e7db12 [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//
Zachary Turner6ac232c2017-03-13 23:28:25 +000010// Dumps debug information present in PDB files.
Zachary Turnerfcb14ad2015-01-27 20:46:21 +000011//
12//===----------------------------------------------------------------------===//
13
Zachary Turner9a818ad2015-02-22 22:03:38 +000014#include "llvm-pdbdump.h"
Zachary Turnerd50c0132017-02-01 18:30:22 +000015
16#include "Analyze.h"
Zachary Turner6ac232c2017-03-13 23:28:25 +000017#include "Diff.h"
Zachary Turnerd3117392016-06-03 19:28:33 +000018#include "LLVMOutputStyle.h"
Zachary Turner2d11c202015-02-27 09:15:59 +000019#include "LinePrinter.h"
Zachary Turnerd3117392016-06-03 19:28:33 +000020#include "OutputStyle.h"
Zachary Turnera9054dd2017-01-11 00:35:43 +000021#include "PrettyCompilandDumper.h"
22#include "PrettyExternalSymbolDumper.h"
23#include "PrettyFunctionDumper.h"
24#include "PrettyTypeDumper.h"
25#include "PrettyVariableDumper.h"
Zachary Turner7120a472016-06-06 20:37:05 +000026#include "YAMLOutputStyle.h"
Zachary Turner9a818ad2015-02-22 22:03:38 +000027
Zachary Turnerfcb14ad2015-01-27 20:46:21 +000028#include "llvm/ADT/ArrayRef.h"
David Majnemer6e081262015-10-15 01:27:19 +000029#include "llvm/ADT/BitVector.h"
30#include "llvm/ADT/DenseMap.h"
Zachary Turnerfcb14ad2015-01-27 20:46:21 +000031#include "llvm/ADT/StringExtras.h"
Zachary Turner8d7fa9b2015-02-10 22:47:14 +000032#include "llvm/Config/config.h"
Zachary Turnera3225b02016-07-29 20:56:36 +000033#include "llvm/DebugInfo/MSF/MSFBuilder.h"
Zachary Turner819e77d2016-05-06 20:51:57 +000034#include "llvm/DebugInfo/PDB/GenericError.h"
Zachary Turnera5549172015-02-10 22:43:25 +000035#include "llvm/DebugInfo/PDB/IPDBEnumChildren.h"
Zachary Turnera5549172015-02-10 22:43:25 +000036#include "llvm/DebugInfo/PDB/IPDBRawSymbol.h"
Chandler Carruth71f308a2015-02-13 09:09:03 +000037#include "llvm/DebugInfo/PDB/IPDBSession.h"
Adrian McCarthy6b6b8c42017-01-25 22:38:55 +000038#include "llvm/DebugInfo/PDB/Native/DbiStream.h"
39#include "llvm/DebugInfo/PDB/Native/DbiStreamBuilder.h"
40#include "llvm/DebugInfo/PDB/Native/InfoStream.h"
41#include "llvm/DebugInfo/PDB/Native/InfoStreamBuilder.h"
42#include "llvm/DebugInfo/PDB/Native/NativeSession.h"
43#include "llvm/DebugInfo/PDB/Native/PDBFile.h"
44#include "llvm/DebugInfo/PDB/Native/PDBFileBuilder.h"
45#include "llvm/DebugInfo/PDB/Native/RawConstants.h"
46#include "llvm/DebugInfo/PDB/Native/RawError.h"
47#include "llvm/DebugInfo/PDB/Native/StringTableBuilder.h"
48#include "llvm/DebugInfo/PDB/Native/TpiStream.h"
49#include "llvm/DebugInfo/PDB/Native/TpiStreamBuilder.h"
Chandler Carruth71f308a2015-02-13 09:09:03 +000050#include "llvm/DebugInfo/PDB/PDB.h"
Zachary Turnera5549172015-02-10 22:43:25 +000051#include "llvm/DebugInfo/PDB/PDBSymbolCompiland.h"
Zachary Turnerdb18f5c2015-02-27 09:15:18 +000052#include "llvm/DebugInfo/PDB/PDBSymbolData.h"
Chandler Carruth71f308a2015-02-13 09:09:03 +000053#include "llvm/DebugInfo/PDB/PDBSymbolExe.h"
Zachary Turnerdb18f5c2015-02-27 09:15:18 +000054#include "llvm/DebugInfo/PDB/PDBSymbolFunc.h"
55#include "llvm/DebugInfo/PDB/PDBSymbolThunk.h"
Zachary Turnerd9dc2822017-03-02 20:52:51 +000056#include "llvm/Support/BinaryByteStream.h"
Zachary Turner93839cb2016-06-02 05:07:49 +000057#include "llvm/Support/COM.h"
Zachary Turnerfcb14ad2015-01-27 20:46:21 +000058#include "llvm/Support/CommandLine.h"
59#include "llvm/Support/ConvertUTF.h"
Zachary Turner1dc9fd32016-06-14 20:48:36 +000060#include "llvm/Support/FileOutputBuffer.h"
Zachary Turner9a818ad2015-02-22 22:03:38 +000061#include "llvm/Support/FileSystem.h"
Zachary Turnerfcb14ad2015-01-27 20:46:21 +000062#include "llvm/Support/Format.h"
63#include "llvm/Support/ManagedStatic.h"
David Majnemer6e081262015-10-15 01:27:19 +000064#include "llvm/Support/MemoryBuffer.h"
Zachary Turnerfcb14ad2015-01-27 20:46:21 +000065#include "llvm/Support/PrettyStackTrace.h"
Chandler Carruth71f308a2015-02-13 09:09:03 +000066#include "llvm/Support/Process.h"
Zachary Turner72c5b642016-09-09 18:17:52 +000067#include "llvm/Support/Regex.h"
Reid Klecknerb0345262016-05-04 16:09:04 +000068#include "llvm/Support/ScopedPrinter.h"
Daniel Sandersd41718e2016-04-22 12:04:42 +000069#include "llvm/Support/Signals.h"
Zachary Turner0a43efe2016-04-25 17:38:08 +000070#include "llvm/Support/raw_ostream.h"
Zachary Turnerfcb14ad2015-01-27 20:46:21 +000071
Zachary Turnerfcb14ad2015-01-27 20:46:21 +000072using namespace llvm;
Zachary Turnera96cce62016-06-03 03:25:59 +000073using namespace llvm::codeview;
Zachary Turnerbac69d32016-07-22 19:56:05 +000074using namespace llvm::msf;
Zachary Turner2f09b502016-04-29 17:28:47 +000075using namespace llvm::pdb;
Zachary Turnerfcb14ad2015-01-27 20:46:21 +000076
77namespace opts {
Zachary Turnerc0acf682015-02-15 20:27:53 +000078
Zachary Turnera30bd1a2016-06-30 17:42:48 +000079cl::SubCommand RawSubcommand("raw", "Dump raw structure of the PDB file");
80cl::SubCommand
81 PrettySubcommand("pretty",
82 "Dump semantic information about types and symbols");
Zachary Turner6ac232c2017-03-13 23:28:25 +000083
84cl::SubCommand DiffSubcommand("diff", "Diff the contents of 2 PDB files");
85
Zachary Turnerab58ae82016-06-30 17:43:00 +000086cl::SubCommand
87 YamlToPdbSubcommand("yaml2pdb",
88 "Generate a PDB file from a YAML description");
Zachary Turnera30bd1a2016-06-30 17:42:48 +000089cl::SubCommand
90 PdbToYamlSubcommand("pdb2yaml",
91 "Generate a detailed YAML description of a PDB File");
Zachary Turnerfcb14ad2015-01-27 20:46:21 +000092
Zachary Turnerd50c0132017-02-01 18:30:22 +000093cl::SubCommand
94 AnalyzeSubcommand("analyze",
95 "Analyze various aspects of a PDB's structure");
96
Zachary Turner7797c722015-03-02 04:39:56 +000097cl::OptionCategory TypeCategory("Symbol Type Options");
98cl::OptionCategory FilterCategory("Filtering Options");
Zachary Turnere5cb2692015-05-01 20:24:26 +000099cl::OptionCategory OtherOptions("Other Options");
Zachary Turnera30bd1a2016-06-30 17:42:48 +0000100
101namespace pretty {
102cl::list<std::string> InputFilenames(cl::Positional,
103 cl::desc("<input PDB files>"),
104 cl::OneOrMore, cl::sub(PrettySubcommand));
Zachary Turner7797c722015-03-02 04:39:56 +0000105
106cl::opt<bool> Compilands("compilands", cl::desc("Display compilands"),
Zachary Turnera30bd1a2016-06-30 17:42:48 +0000107 cl::cat(TypeCategory), cl::sub(PrettySubcommand));
Zachary Turner7797c722015-03-02 04:39:56 +0000108cl::opt<bool> Symbols("symbols", cl::desc("Display symbols for each compiland"),
Zachary Turnera30bd1a2016-06-30 17:42:48 +0000109 cl::cat(TypeCategory), cl::sub(PrettySubcommand));
Zachary Turner7797c722015-03-02 04:39:56 +0000110cl::opt<bool> Globals("globals", cl::desc("Dump global symbols"),
Zachary Turnera30bd1a2016-06-30 17:42:48 +0000111 cl::cat(TypeCategory), cl::sub(PrettySubcommand));
Zachary Turnere5cb2692015-05-01 20:24:26 +0000112cl::opt<bool> Externals("externals", cl::desc("Dump external symbols"),
Zachary Turnera30bd1a2016-06-30 17:42:48 +0000113 cl::cat(TypeCategory), cl::sub(PrettySubcommand));
114cl::opt<bool> Types("types", cl::desc("Display types"), cl::cat(TypeCategory),
115 cl::sub(PrettySubcommand));
116cl::opt<bool> Lines("lines", cl::desc("Line tables"), cl::cat(TypeCategory),
117 cl::sub(PrettySubcommand));
Zachary Turner7797c722015-03-02 04:39:56 +0000118cl::opt<bool>
Zachary Turner7797c722015-03-02 04:39:56 +0000119 All("all", cl::desc("Implies all other options in 'Symbol Types' category"),
Zachary Turnera30bd1a2016-06-30 17:42:48 +0000120 cl::cat(TypeCategory), cl::sub(PrettySubcommand));
Zachary Turnerf5abda22015-03-01 06:49:49 +0000121
Zachary Turnere5cb2692015-05-01 20:24:26 +0000122cl::opt<uint64_t> LoadAddress(
123 "load-address",
124 cl::desc("Assume the module is loaded at the specified address"),
Zachary Turnera30bd1a2016-06-30 17:42:48 +0000125 cl::cat(OtherOptions), cl::sub(PrettySubcommand));
126cl::list<std::string> ExcludeTypes(
127 "exclude-types", cl::desc("Exclude types by regular expression"),
128 cl::ZeroOrMore, cl::cat(FilterCategory), cl::sub(PrettySubcommand));
129cl::list<std::string> ExcludeSymbols(
130 "exclude-symbols", cl::desc("Exclude symbols by regular expression"),
131 cl::ZeroOrMore, cl::cat(FilterCategory), cl::sub(PrettySubcommand));
132cl::list<std::string> ExcludeCompilands(
133 "exclude-compilands", cl::desc("Exclude compilands by regular expression"),
134 cl::ZeroOrMore, cl::cat(FilterCategory), cl::sub(PrettySubcommand));
Zachary Turner4dddcc62015-09-29 19:49:06 +0000135
136cl::list<std::string> IncludeTypes(
137 "include-types",
138 cl::desc("Include only types which match a regular expression"),
Zachary Turnera30bd1a2016-06-30 17:42:48 +0000139 cl::ZeroOrMore, cl::cat(FilterCategory), cl::sub(PrettySubcommand));
Zachary Turner4dddcc62015-09-29 19:49:06 +0000140cl::list<std::string> IncludeSymbols(
141 "include-symbols",
142 cl::desc("Include only symbols which match a regular expression"),
Zachary Turnera30bd1a2016-06-30 17:42:48 +0000143 cl::ZeroOrMore, cl::cat(FilterCategory), cl::sub(PrettySubcommand));
Zachary Turner4dddcc62015-09-29 19:49:06 +0000144cl::list<std::string> IncludeCompilands(
145 "include-compilands",
146 cl::desc("Include only compilands those which match a regular expression"),
Zachary Turnera30bd1a2016-06-30 17:42:48 +0000147 cl::ZeroOrMore, cl::cat(FilterCategory), cl::sub(PrettySubcommand));
Zachary Turner4dddcc62015-09-29 19:49:06 +0000148
Zachary Turner7797c722015-03-02 04:39:56 +0000149cl::opt<bool> ExcludeCompilerGenerated(
150 "no-compiler-generated",
151 cl::desc("Don't show compiler generated types and symbols"),
Zachary Turnera30bd1a2016-06-30 17:42:48 +0000152 cl::cat(FilterCategory), cl::sub(PrettySubcommand));
Zachary Turner7797c722015-03-02 04:39:56 +0000153cl::opt<bool>
154 ExcludeSystemLibraries("no-system-libs",
155 cl::desc("Don't show symbols from system libraries"),
Zachary Turnera30bd1a2016-06-30 17:42:48 +0000156 cl::cat(FilterCategory), cl::sub(PrettySubcommand));
Zachary Turner65323652015-03-04 06:09:53 +0000157cl::opt<bool> NoClassDefs("no-class-definitions",
158 cl::desc("Don't display full class definitions"),
Zachary Turnera30bd1a2016-06-30 17:42:48 +0000159 cl::cat(FilterCategory), cl::sub(PrettySubcommand));
Zachary Turner65323652015-03-04 06:09:53 +0000160cl::opt<bool> NoEnumDefs("no-enum-definitions",
161 cl::desc("Don't display full enum definitions"),
Zachary Turnera30bd1a2016-06-30 17:42:48 +0000162 cl::cat(FilterCategory), cl::sub(PrettySubcommand));
163}
164
Zachary Turner6ac232c2017-03-13 23:28:25 +0000165namespace diff {
166cl::opt<bool> Pedantic("pedantic",
167 cl::desc("Finds all differences (even structural ones "
168 "that produce otherwise identical PDBs)"),
169 cl::sub(DiffSubcommand));
170
171cl::list<std::string> InputFilenames(cl::Positional,
172 cl::desc("<first> <second>"),
173 cl::OneOrMore, cl::sub(DiffSubcommand));
174}
175
Zachary Turnera30bd1a2016-06-30 17:42:48 +0000176namespace raw {
177
178cl::OptionCategory MsfOptions("MSF Container Options");
179cl::OptionCategory TypeOptions("Type Record Options");
180cl::OptionCategory FileOptions("Module & File Options");
181cl::OptionCategory SymbolOptions("Symbol Options");
182cl::OptionCategory MiscOptions("Miscellaneous Options");
183
184// MSF OPTIONS
185cl::opt<bool> DumpHeaders("headers", cl::desc("dump PDB headers"),
186 cl::cat(MsfOptions), cl::sub(RawSubcommand));
187cl::opt<bool> DumpStreamBlocks("stream-blocks",
188 cl::desc("dump PDB stream blocks"),
189 cl::cat(MsfOptions), cl::sub(RawSubcommand));
190cl::opt<bool> DumpStreamSummary("stream-summary",
191 cl::desc("dump summary of the PDB streams"),
192 cl::cat(MsfOptions), cl::sub(RawSubcommand));
Zachary Turnerd3c7b8e2016-08-01 21:19:45 +0000193cl::opt<bool> DumpPageStats(
194 "page-stats",
195 cl::desc("dump allocation stats of the pages in the MSF file"),
196 cl::cat(MsfOptions), cl::sub(RawSubcommand));
Zachary Turner72c5b642016-09-09 18:17:52 +0000197cl::opt<std::string>
198 DumpBlockRangeOpt("block-data", cl::value_desc("start[-end]"),
199 cl::desc("Dump binary data from specified range."),
200 cl::cat(MsfOptions), cl::sub(RawSubcommand));
201llvm::Optional<BlockRange> DumpBlockRange;
202
203cl::list<uint32_t>
204 DumpStreamData("stream-data", cl::CommaSeparated, cl::ZeroOrMore,
205 cl::desc("Dump binary data from specified streams."),
206 cl::cat(MsfOptions), cl::sub(RawSubcommand));
Zachary Turnera30bd1a2016-06-30 17:42:48 +0000207
208// TYPE OPTIONS
209cl::opt<bool>
Zachary Turner44a643c2017-01-12 22:28:15 +0000210 CompactRecords("compact-records",
211 cl::desc("Dump type and symbol records with less detail"),
212 cl::cat(TypeOptions), cl::sub(RawSubcommand));
213
214cl::opt<bool>
Zachary Turnera30bd1a2016-06-30 17:42:48 +0000215 DumpTpiRecords("tpi-records",
216 cl::desc("dump CodeView type records from TPI stream"),
217 cl::cat(TypeOptions), cl::sub(RawSubcommand));
218cl::opt<bool> DumpTpiRecordBytes(
219 "tpi-record-bytes",
220 cl::desc("dump CodeView type record raw bytes from TPI stream"),
221 cl::cat(TypeOptions), cl::sub(RawSubcommand));
222cl::opt<bool> DumpTpiHash("tpi-hash", cl::desc("dump CodeView TPI hash stream"),
223 cl::cat(TypeOptions), cl::sub(RawSubcommand));
224cl::opt<bool>
225 DumpIpiRecords("ipi-records",
226 cl::desc("dump CodeView type records from IPI stream"),
227 cl::cat(TypeOptions), cl::sub(RawSubcommand));
228cl::opt<bool> DumpIpiRecordBytes(
229 "ipi-record-bytes",
230 cl::desc("dump CodeView type record raw bytes from IPI stream"),
231 cl::cat(TypeOptions), cl::sub(RawSubcommand));
232
233// MODULE & FILE OPTIONS
234cl::opt<bool> DumpModules("modules", cl::desc("dump compiland information"),
235 cl::cat(FileOptions), cl::sub(RawSubcommand));
236cl::opt<bool> DumpModuleFiles("module-files", cl::desc("dump file information"),
237 cl::cat(FileOptions), cl::sub(RawSubcommand));
238cl::opt<bool> DumpLineInfo("line-info",
Zachary Turnerab58ae82016-06-30 17:43:00 +0000239 cl::desc("dump file and line information"),
240 cl::cat(FileOptions), cl::sub(RawSubcommand));
Zachary Turnera30bd1a2016-06-30 17:42:48 +0000241
242// SYMBOL OPTIONS
Bob Haarman653baa22016-10-21 19:43:19 +0000243cl::opt<bool> DumpGlobals("globals", cl::desc("dump globals stream data"),
244 cl::cat(SymbolOptions), cl::sub(RawSubcommand));
Zachary Turnera30bd1a2016-06-30 17:42:48 +0000245cl::opt<bool> DumpModuleSyms("module-syms", cl::desc("dump module symbols"),
246 cl::cat(SymbolOptions), cl::sub(RawSubcommand));
247cl::opt<bool> DumpPublics("publics", cl::desc("dump Publics stream data"),
248 cl::cat(SymbolOptions), cl::sub(RawSubcommand));
249cl::opt<bool>
250 DumpSymRecordBytes("sym-record-bytes",
251 cl::desc("dump CodeView symbol record raw bytes"),
252 cl::cat(SymbolOptions), cl::sub(RawSubcommand));
253
254// MISCELLANEOUS OPTIONS
Zachary Turner760ad4d2017-01-20 22:42:09 +0000255cl::opt<bool> DumpStringTable("string-table", cl::desc("dump PDB String Table"),
256 cl::cat(MiscOptions), cl::sub(RawSubcommand));
257
Zachary Turnera30bd1a2016-06-30 17:42:48 +0000258cl::opt<bool> DumpSectionContribs("section-contribs",
259 cl::desc("dump section contributions"),
Zachary Turnerab58ae82016-06-30 17:43:00 +0000260 cl::cat(MiscOptions), cl::sub(RawSubcommand));
Zachary Turnera30bd1a2016-06-30 17:42:48 +0000261cl::opt<bool> DumpSectionMap("section-map", cl::desc("dump section map"),
262 cl::cat(MiscOptions), cl::sub(RawSubcommand));
263cl::opt<bool> DumpSectionHeaders("section-headers",
264 cl::desc("dump section headers"),
Zachary Turnerab58ae82016-06-30 17:43:00 +0000265 cl::cat(MiscOptions), cl::sub(RawSubcommand));
266cl::opt<bool> DumpFpo("fpo", cl::desc("dump FPO records"), cl::cat(MiscOptions),
267 cl::sub(RawSubcommand));
Zachary Turnera30bd1a2016-06-30 17:42:48 +0000268
Zachary Turnerab58ae82016-06-30 17:43:00 +0000269cl::opt<bool> RawAll("all", cl::desc("Implies most other options."),
270 cl::cat(MiscOptions), cl::sub(RawSubcommand));
Zachary Turnera30bd1a2016-06-30 17:42:48 +0000271
272cl::list<std::string> InputFilenames(cl::Positional,
273 cl::desc("<input PDB files>"),
274 cl::OneOrMore, cl::sub(RawSubcommand));
275}
276
277namespace yaml2pdb {
278cl::opt<std::string>
279 YamlPdbOutputFile("pdb", cl::desc("the name of the PDB file to write"),
280 cl::sub(YamlToPdbSubcommand));
281
282cl::list<std::string> InputFilename(cl::Positional,
283 cl::desc("<input YAML file>"), cl::Required,
284 cl::sub(YamlToPdbSubcommand));
285}
286
287namespace pdb2yaml {
Zachary Turnerf6b93822016-07-11 21:45:09 +0000288cl::opt<bool>
289 NoFileHeaders("no-file-headers",
290 cl::desc("Do not dump MSF file headers (you will not be able "
291 "to generate a fresh PDB from the resulting YAML)"),
292 cl::sub(PdbToYamlSubcommand), cl::init(false));
293
Zachary Turnerab58ae82016-06-30 17:43:00 +0000294cl::opt<bool> StreamMetadata(
295 "stream-metadata",
296 cl::desc("Dump the number of streams and each stream's size"),
Zachary Turnerf6b93822016-07-11 21:45:09 +0000297 cl::sub(PdbToYamlSubcommand), cl::init(false));
Zachary Turnerab58ae82016-06-30 17:43:00 +0000298cl::opt<bool> StreamDirectory(
299 "stream-directory",
300 cl::desc("Dump each stream's block map (implies -stream-metadata)"),
Zachary Turnerf6b93822016-07-11 21:45:09 +0000301 cl::sub(PdbToYamlSubcommand), cl::init(false));
Zachary Turnerfaa554b2016-07-15 22:16:56 +0000302cl::opt<bool> PdbStream("pdb-stream",
303 cl::desc("Dump the PDB Stream (Stream 1)"),
304 cl::sub(PdbToYamlSubcommand), cl::init(false));
Zachary Turner760ad4d2017-01-20 22:42:09 +0000305
306cl::opt<bool> StringTable("string-table", cl::desc("Dump the PDB String Table"),
307 cl::sub(PdbToYamlSubcommand), cl::init(false));
308
Zachary Turnerfaa554b2016-07-15 22:16:56 +0000309cl::opt<bool> DbiStream("dbi-stream",
310 cl::desc("Dump the DBI Stream (Stream 2)"),
311 cl::sub(PdbToYamlSubcommand), cl::init(false));
Zachary Turnerd218c262016-07-22 15:46:37 +0000312cl::opt<bool>
313 DbiModuleInfo("dbi-module-info",
314 cl::desc("Dump DBI Module Information (implies -dbi-stream)"),
315 cl::sub(PdbToYamlSubcommand), cl::init(false));
316
Zachary Turner3b147642016-10-08 01:12:01 +0000317cl::opt<bool> DbiModuleSyms(
318 "dbi-module-syms",
319 cl::desc("Dump DBI Module Information (implies -dbi-module-info)"),
320 cl::sub(PdbToYamlSubcommand), cl::init(false));
321
Zachary Turnerd218c262016-07-22 15:46:37 +0000322cl::opt<bool> DbiModuleSourceFileInfo(
323 "dbi-module-source-info",
324 cl::desc(
325 "Dump DBI Module Source File Information (implies -dbi-module-info"),
326 cl::sub(PdbToYamlSubcommand), cl::init(false));
Zachary Turnera30bd1a2016-06-30 17:42:48 +0000327
Zachary Turnerac5763e2016-08-18 16:49:29 +0000328cl::opt<bool> TpiStream("tpi-stream",
329 cl::desc("Dump the TPI Stream (Stream 3)"),
330 cl::sub(PdbToYamlSubcommand), cl::init(false));
331
Zachary Turnerde9ba152016-09-15 18:22:31 +0000332cl::opt<bool> IpiStream("ipi-stream",
333 cl::desc("Dump the IPI Stream (Stream 5)"),
334 cl::sub(PdbToYamlSubcommand), cl::init(false));
335
Zachary Turnera30bd1a2016-06-30 17:42:48 +0000336cl::list<std::string> InputFilename(cl::Positional,
337 cl::desc("<input PDB file>"), cl::Required,
338 cl::sub(PdbToYamlSubcommand));
339}
Zachary Turnerd50c0132017-02-01 18:30:22 +0000340
341namespace analyze {
342cl::opt<bool> StringTable("hash-collisions", cl::desc("Find hash collisions"),
343 cl::sub(AnalyzeSubcommand), cl::init(false));
344cl::list<std::string> InputFilename(cl::Positional,
345 cl::desc("<input PDB file>"), cl::Required,
346 cl::sub(AnalyzeSubcommand));
347}
Zachary Turner49693b42015-01-28 01:22:33 +0000348}
349
David Majnemerc165c882016-05-28 18:25:15 +0000350static ExitOnError ExitOnErr;
351
Zachary Turner1dc9fd32016-06-14 20:48:36 +0000352static void yamlToPdb(StringRef Path) {
Zachary Turnere109dc62016-07-22 19:56:26 +0000353 BumpPtrAllocator Allocator;
Zachary Turner1dc9fd32016-06-14 20:48:36 +0000354 ErrorOr<std::unique_ptr<MemoryBuffer>> ErrorOrBuffer =
355 MemoryBuffer::getFileOrSTDIN(Path, /*FileSize=*/-1,
356 /*RequiresNullTerminator=*/false);
357
358 if (ErrorOrBuffer.getError()) {
359 ExitOnErr(make_error<GenericError>(generic_error_code::invalid_path, Path));
360 }
361
362 std::unique_ptr<MemoryBuffer> &Buffer = ErrorOrBuffer.get();
363
364 llvm::yaml::Input In(Buffer->getBuffer());
Zachary Turnerc6d54da2016-09-09 17:46:17 +0000365 pdb::yaml::PdbObject YamlObj(Allocator);
Zachary Turner1dc9fd32016-06-14 20:48:36 +0000366 In >> YamlObj;
Zachary Turnerf6b93822016-07-11 21:45:09 +0000367 if (!YamlObj.Headers.hasValue())
368 ExitOnErr(make_error<GenericError>(generic_error_code::unspecified,
369 "Yaml does not contain MSF headers"));
Zachary Turner1dc9fd32016-06-14 20:48:36 +0000370
Zachary Turnere109dc62016-07-22 19:56:26 +0000371 PDBFileBuilder Builder(Allocator);
Zachary Turnerdbeaea72016-07-11 21:45:26 +0000372
Rui Ueyama5d6714e2016-09-30 20:52:12 +0000373 ExitOnErr(Builder.initialize(YamlObj.Headers->SuperBlock.BlockSize));
Zachary Turner620961d2016-09-14 23:00:02 +0000374 // Add each of the reserved streams. We ignore stream metadata in the
375 // yaml, because we will reconstruct our own view of the streams. For
376 // example, the YAML may say that there were 20 streams in the original
377 // PDB, but maybe we only dump a subset of those 20 streams, so we will
378 // have fewer, and the ones we do have may end up with different indices
379 // than the ones in the original PDB. So we just start with a clean slate.
380 for (uint32_t I = 0; I < kSpecialStreamCount; ++I)
381 ExitOnErr(Builder.getMsfBuilder().addStream(0));
Zachary Turner8848a7a2016-07-06 18:05:57 +0000382
Zachary Turner760ad4d2017-01-20 22:42:09 +0000383 if (YamlObj.StringTable.hasValue()) {
384 auto &Strings = Builder.getStringTableBuilder();
385 for (auto S : *YamlObj.StringTable)
386 Strings.insert(S);
387 }
388
Zachary Turner8848a7a2016-07-06 18:05:57 +0000389 if (YamlObj.PdbStream.hasValue()) {
Zachary Turnerdbeaea72016-07-11 21:45:26 +0000390 auto &InfoBuilder = Builder.getInfoBuilder();
391 InfoBuilder.setAge(YamlObj.PdbStream->Age);
392 InfoBuilder.setGuid(YamlObj.PdbStream->Guid);
393 InfoBuilder.setSignature(YamlObj.PdbStream->Signature);
394 InfoBuilder.setVersion(YamlObj.PdbStream->Version);
Zachary Turner1dc9fd32016-06-14 20:48:36 +0000395 }
396
Zachary Turnerdbeaea72016-07-11 21:45:26 +0000397 if (YamlObj.DbiStream.hasValue()) {
398 auto &DbiBuilder = Builder.getDbiBuilder();
399 DbiBuilder.setAge(YamlObj.DbiStream->Age);
400 DbiBuilder.setBuildNumber(YamlObj.DbiStream->BuildNumber);
401 DbiBuilder.setFlags(YamlObj.DbiStream->Flags);
402 DbiBuilder.setMachineType(YamlObj.DbiStream->MachineType);
403 DbiBuilder.setPdbDllRbld(YamlObj.DbiStream->PdbDllRbld);
404 DbiBuilder.setPdbDllVersion(YamlObj.DbiStream->PdbDllVersion);
405 DbiBuilder.setVersionHeader(YamlObj.DbiStream->VerHeader);
Zachary Turnerd218c262016-07-22 15:46:37 +0000406 for (const auto &MI : YamlObj.DbiStream->ModInfos) {
407 ExitOnErr(DbiBuilder.addModuleInfo(MI.Obj, MI.Mod));
408 for (auto S : MI.SourceFiles)
409 ExitOnErr(DbiBuilder.addModuleSourceFile(MI.Mod, S));
410 }
Zachary Turnerdbeaea72016-07-11 21:45:26 +0000411 }
412
Zachary Turnerc6d54da2016-09-09 17:46:17 +0000413 if (YamlObj.TpiStream.hasValue()) {
414 auto &TpiBuilder = Builder.getTpiBuilder();
415 TpiBuilder.setVersionHeader(YamlObj.TpiStream->Version);
416 for (const auto &R : YamlObj.TpiStream->Records)
417 TpiBuilder.addTypeRecord(R.Record);
418 }
419
Zachary Turnerde9ba152016-09-15 18:22:31 +0000420 if (YamlObj.IpiStream.hasValue()) {
421 auto &IpiBuilder = Builder.getIpiBuilder();
422 IpiBuilder.setVersionHeader(YamlObj.IpiStream->Version);
423 for (const auto &R : YamlObj.IpiStream->Records)
424 IpiBuilder.addTypeRecord(R.Record);
425 }
426
Rui Ueyamafc22cef2016-09-30 20:34:44 +0000427 ExitOnErr(Builder.commit(opts::yaml2pdb::YamlPdbOutputFile));
Zachary Turner1dc9fd32016-06-14 20:48:36 +0000428}
429
Zachary Turner6ac232c2017-03-13 23:28:25 +0000430static PDBFile &loadPDB(StringRef Path, std::unique_ptr<IPDBSession> &Session) {
Adrian McCarthy8f713192017-01-27 00:01:55 +0000431 ExitOnErr(loadDataForPDB(PDB_ReaderType::Native, Path, Session));
Zachary Turner8848a7a2016-07-06 18:05:57 +0000432
Zachary Turner6ac232c2017-03-13 23:28:25 +0000433 NativeSession *NS = static_cast<NativeSession *>(Session.get());
434 return NS->getPDBFile();
435}
436
437static void pdb2Yaml(StringRef Path) {
438 std::unique_ptr<IPDBSession> Session;
439 auto &File = loadPDB(Path, Session);
440
Zachary Turner8848a7a2016-07-06 18:05:57 +0000441 auto O = llvm::make_unique<YAMLOutputStyle>(File);
442 O = llvm::make_unique<YAMLOutputStyle>(File);
443
444 ExitOnErr(O->dump());
445}
446
Zachary Turnera30bd1a2016-06-30 17:42:48 +0000447static void dumpRaw(StringRef Path) {
David Majnemer1573b242016-04-28 23:47:27 +0000448 std::unique_ptr<IPDBSession> Session;
Zachary Turner6ac232c2017-03-13 23:28:25 +0000449 auto &File = loadPDB(Path, Session);
David Majnemer1573b242016-04-28 23:47:27 +0000450
Zachary Turner8848a7a2016-07-06 18:05:57 +0000451 auto O = llvm::make_unique<LLVMOutputStyle>(File);
Zachary Turnera30bd1a2016-06-30 17:42:48 +0000452
453 ExitOnErr(O->dump());
454}
455
Zachary Turnerd50c0132017-02-01 18:30:22 +0000456static void dumpAnalysis(StringRef Path) {
457 std::unique_ptr<IPDBSession> Session;
Zachary Turner6ac232c2017-03-13 23:28:25 +0000458 auto &File = loadPDB(Path, Session);
Zachary Turnerd50c0132017-02-01 18:30:22 +0000459 auto O = llvm::make_unique<AnalysisStyle>(File);
460
461 ExitOnErr(O->dump());
462}
463
Zachary Turner6ac232c2017-03-13 23:28:25 +0000464static void diff(StringRef Path1, StringRef Path2) {
465 std::unique_ptr<IPDBSession> Session1;
466 std::unique_ptr<IPDBSession> Session2;
467
468 auto &File1 = loadPDB(Path1, Session1);
469 auto &File2 = loadPDB(Path2, Session2);
470
471 auto O = llvm::make_unique<DiffStyle>(File1, File2);
472
473 ExitOnErr(O->dump());
474}
475
Zachary Turnera30bd1a2016-06-30 17:42:48 +0000476static void dumpPretty(StringRef Path) {
477 std::unique_ptr<IPDBSession> Session;
David Majnemer1573b242016-04-28 23:47:27 +0000478
David Majnemerc165c882016-05-28 18:25:15 +0000479 ExitOnErr(loadDataForPDB(PDB_ReaderType::DIA, Path, Session));
David Majnemer1573b242016-04-28 23:47:27 +0000480
Zachary Turnera30bd1a2016-06-30 17:42:48 +0000481 if (opts::pretty::LoadAddress)
482 Session->setLoadAddress(opts::pretty::LoadAddress);
Zachary Turner7058dfc2015-01-27 22:40:14 +0000483
Zachary Turner2d11c202015-02-27 09:15:59 +0000484 LinePrinter Printer(2, outs());
485
Zachary Turnera5549172015-02-10 22:43:25 +0000486 auto GlobalScope(Session->getGlobalScope());
Zachary Turner9a818ad2015-02-22 22:03:38 +0000487 std::string FileName(GlobalScope->getSymbolsFileName());
488
Zachary Turner2d11c202015-02-27 09:15:59 +0000489 WithColor(Printer, PDB_ColorItem::None).get() << "Summary for ";
490 WithColor(Printer, PDB_ColorItem::Path).get() << FileName;
491 Printer.Indent();
Zachary Turner9a818ad2015-02-22 22:03:38 +0000492 uint64_t FileSize = 0;
Zachary Turner9a818ad2015-02-22 22:03:38 +0000493
Zachary Turner2d11c202015-02-27 09:15:59 +0000494 Printer.NewLine();
495 WithColor(Printer, PDB_ColorItem::Identifier).get() << "Size";
David Majnemer6e081262015-10-15 01:27:19 +0000496 if (!sys::fs::file_size(FileName, FileSize)) {
Zachary Turner2d11c202015-02-27 09:15:59 +0000497 Printer << ": " << FileSize << " bytes";
498 } else {
499 Printer << ": (Unable to obtain file size)";
500 }
501
502 Printer.NewLine();
503 WithColor(Printer, PDB_ColorItem::Identifier).get() << "Guid";
504 Printer << ": " << GlobalScope->getGuid();
505
506 Printer.NewLine();
507 WithColor(Printer, PDB_ColorItem::Identifier).get() << "Age";
508 Printer << ": " << GlobalScope->getAge();
509
510 Printer.NewLine();
511 WithColor(Printer, PDB_ColorItem::Identifier).get() << "Attributes";
512 Printer << ": ";
Zachary Turner9a818ad2015-02-22 22:03:38 +0000513 if (GlobalScope->hasCTypes())
514 outs() << "HasCTypes ";
515 if (GlobalScope->hasPrivateSymbols())
516 outs() << "HasPrivateSymbols ";
Zachary Turner2d11c202015-02-27 09:15:59 +0000517 Printer.Unindent();
Zachary Turner9a818ad2015-02-22 22:03:38 +0000518
Zachary Turnera30bd1a2016-06-30 17:42:48 +0000519 if (opts::pretty::Compilands) {
Zachary Turner2d11c202015-02-27 09:15:59 +0000520 Printer.NewLine();
521 WithColor(Printer, PDB_ColorItem::SectionHeader).get()
522 << "---COMPILANDS---";
523 Printer.Indent();
Zachary Turnerc074de02015-02-12 21:09:24 +0000524 auto Compilands = GlobalScope->findAllChildren<PDBSymbolCompiland>();
Zachary Turner2d11c202015-02-27 09:15:59 +0000525 CompilandDumper Dumper(Printer);
Zachary Turnera99000d2016-03-08 21:42:24 +0000526 CompilandDumpFlags options = CompilandDumper::Flags::None;
Zachary Turnera30bd1a2016-06-30 17:42:48 +0000527 if (opts::pretty::Lines)
Zachary Turnera99000d2016-03-08 21:42:24 +0000528 options = options | CompilandDumper::Flags::Lines;
Zachary Turner9a818ad2015-02-22 22:03:38 +0000529 while (auto Compiland = Compilands->getNext())
Zachary Turnera99000d2016-03-08 21:42:24 +0000530 Dumper.start(*Compiland, options);
Zachary Turner2d11c202015-02-27 09:15:59 +0000531 Printer.Unindent();
Zachary Turnerdb18f5c2015-02-27 09:15:18 +0000532 }
533
Zachary Turnera30bd1a2016-06-30 17:42:48 +0000534 if (opts::pretty::Types) {
Zachary Turner2d11c202015-02-27 09:15:59 +0000535 Printer.NewLine();
536 WithColor(Printer, PDB_ColorItem::SectionHeader).get() << "---TYPES---";
537 Printer.Indent();
Zachary Turner65323652015-03-04 06:09:53 +0000538 TypeDumper Dumper(Printer);
Zachary Turnerb52d08d2015-03-01 06:51:29 +0000539 Dumper.start(*GlobalScope);
Zachary Turner2d11c202015-02-27 09:15:59 +0000540 Printer.Unindent();
Zachary Turnerdb18f5c2015-02-27 09:15:18 +0000541 }
542
Zachary Turnera30bd1a2016-06-30 17:42:48 +0000543 if (opts::pretty::Symbols) {
Zachary Turner2d11c202015-02-27 09:15:59 +0000544 Printer.NewLine();
545 WithColor(Printer, PDB_ColorItem::SectionHeader).get() << "---SYMBOLS---";
546 Printer.Indent();
Zachary Turnerdb18f5c2015-02-27 09:15:18 +0000547 auto Compilands = GlobalScope->findAllChildren<PDBSymbolCompiland>();
Zachary Turner2d11c202015-02-27 09:15:59 +0000548 CompilandDumper Dumper(Printer);
Zachary Turnerdb18f5c2015-02-27 09:15:18 +0000549 while (auto Compiland = Compilands->getNext())
Zachary Turnerb52d08d2015-03-01 06:51:29 +0000550 Dumper.start(*Compiland, true);
Zachary Turner2d11c202015-02-27 09:15:59 +0000551 Printer.Unindent();
Zachary Turnerdb18f5c2015-02-27 09:15:18 +0000552 }
553
Zachary Turnera30bd1a2016-06-30 17:42:48 +0000554 if (opts::pretty::Globals) {
Zachary Turner2d11c202015-02-27 09:15:59 +0000555 Printer.NewLine();
556 WithColor(Printer, PDB_ColorItem::SectionHeader).get() << "---GLOBALS---";
557 Printer.Indent();
Zachary Turnerdb18f5c2015-02-27 09:15:18 +0000558 {
Zachary Turner2d11c202015-02-27 09:15:59 +0000559 FunctionDumper Dumper(Printer);
Zachary Turnerdb18f5c2015-02-27 09:15:18 +0000560 auto Functions = GlobalScope->findAllChildren<PDBSymbolFunc>();
Zachary Turner2d11c202015-02-27 09:15:59 +0000561 while (auto Function = Functions->getNext()) {
562 Printer.NewLine();
Zachary Turnerb52d08d2015-03-01 06:51:29 +0000563 Dumper.start(*Function, FunctionDumper::PointerType::None);
Zachary Turner2d11c202015-02-27 09:15:59 +0000564 }
Zachary Turnerdb18f5c2015-02-27 09:15:18 +0000565 }
566 {
567 auto Vars = GlobalScope->findAllChildren<PDBSymbolData>();
Zachary Turner2d11c202015-02-27 09:15:59 +0000568 VariableDumper Dumper(Printer);
Zachary Turnerdb18f5c2015-02-27 09:15:18 +0000569 while (auto Var = Vars->getNext())
Zachary Turnerb52d08d2015-03-01 06:51:29 +0000570 Dumper.start(*Var);
Zachary Turnerdb18f5c2015-02-27 09:15:18 +0000571 }
572 {
573 auto Thunks = GlobalScope->findAllChildren<PDBSymbolThunk>();
Zachary Turner2d11c202015-02-27 09:15:59 +0000574 CompilandDumper Dumper(Printer);
Zachary Turnerdb18f5c2015-02-27 09:15:18 +0000575 while (auto Thunk = Thunks->getNext())
Zachary Turnerb52d08d2015-03-01 06:51:29 +0000576 Dumper.dump(*Thunk);
Zachary Turnerdb18f5c2015-02-27 09:15:18 +0000577 }
Zachary Turner2d11c202015-02-27 09:15:59 +0000578 Printer.Unindent();
Zachary Turner7058dfc2015-01-27 22:40:14 +0000579 }
Zachary Turnera30bd1a2016-06-30 17:42:48 +0000580 if (opts::pretty::Externals) {
Zachary Turnere5cb2692015-05-01 20:24:26 +0000581 Printer.NewLine();
582 WithColor(Printer, PDB_ColorItem::SectionHeader).get() << "---EXTERNALS---";
583 Printer.Indent();
584 ExternalSymbolDumper Dumper(Printer);
585 Dumper.start(*GlobalScope);
586 }
Zachary Turnera30bd1a2016-06-30 17:42:48 +0000587 if (opts::pretty::Lines) {
Zachary Turnera99000d2016-03-08 21:42:24 +0000588 Printer.NewLine();
589 }
Zachary Turnera5549172015-02-10 22:43:25 +0000590 outs().flush();
Zachary Turnerfcb14ad2015-01-27 20:46:21 +0000591}
592
593int main(int argc_, const char *argv_[]) {
594 // Print a stack trace if we signal out.
Richard Smith2ad6d482016-06-09 00:53:21 +0000595 sys::PrintStackTraceOnErrorSignal(argv_[0]);
Zachary Turnerfcb14ad2015-01-27 20:46:21 +0000596 PrettyStackTraceProgram X(argc_, argv_);
597
David Majnemerc165c882016-05-28 18:25:15 +0000598 ExitOnErr.setBanner("llvm-pdbdump: ");
599
Zachary Turnerfcb14ad2015-01-27 20:46:21 +0000600 SmallVector<const char *, 256> argv;
David Majnemer6e081262015-10-15 01:27:19 +0000601 SpecificBumpPtrAllocator<char> ArgAllocator;
David Majnemerc165c882016-05-28 18:25:15 +0000602 ExitOnErr(errorCodeToError(sys::Process::GetArgumentVector(
603 argv, makeArrayRef(argv_, argc_), ArgAllocator)));
Zachary Turnerfcb14ad2015-01-27 20:46:21 +0000604
605 llvm_shutdown_obj Y; // Call llvm_shutdown() on exit.
606
607 cl::ParseCommandLineOptions(argv.size(), argv.data(), "LLVM PDB Dumper\n");
Zachary Turner72c5b642016-09-09 18:17:52 +0000608 if (!opts::raw::DumpBlockRangeOpt.empty()) {
609 llvm::Regex R("^([0-9]+)(-([0-9]+))?$");
610 llvm::SmallVector<llvm::StringRef, 2> Matches;
611 if (!R.match(opts::raw::DumpBlockRangeOpt, &Matches)) {
612 errs() << "Argument '" << opts::raw::DumpBlockRangeOpt
613 << "' invalid format.\n";
614 errs().flush();
615 exit(1);
616 }
617 opts::raw::DumpBlockRange.emplace();
618 Matches[1].getAsInteger(10, opts::raw::DumpBlockRange->Min);
619 if (!Matches[3].empty()) {
620 opts::raw::DumpBlockRange->Max.emplace();
621 Matches[3].getAsInteger(10, *opts::raw::DumpBlockRange->Max);
622 }
623 }
Zachary Turnera99000d2016-03-08 21:42:24 +0000624
Zachary Turner44a643c2017-01-12 22:28:15 +0000625 if (opts::RawSubcommand) {
626 if (opts::raw::RawAll) {
627 opts::raw::DumpHeaders = true;
628 opts::raw::DumpModules = true;
629 opts::raw::DumpModuleFiles = true;
630 opts::raw::DumpModuleSyms = true;
631 opts::raw::DumpGlobals = true;
632 opts::raw::DumpPublics = true;
633 opts::raw::DumpSectionHeaders = true;
634 opts::raw::DumpStreamSummary = true;
635 opts::raw::DumpPageStats = true;
636 opts::raw::DumpStreamBlocks = true;
637 opts::raw::DumpTpiRecords = true;
638 opts::raw::DumpTpiHash = true;
639 opts::raw::DumpIpiRecords = true;
640 opts::raw::DumpSectionMap = true;
641 opts::raw::DumpSectionContribs = true;
642 opts::raw::DumpLineInfo = true;
643 opts::raw::DumpFpo = true;
Zachary Turner760ad4d2017-01-20 22:42:09 +0000644 opts::raw::DumpStringTable = true;
Zachary Turner44a643c2017-01-12 22:28:15 +0000645 }
646
647 if (opts::raw::CompactRecords &&
648 (opts::raw::DumpTpiRecordBytes || opts::raw::DumpIpiRecordBytes)) {
649 errs() << "-compact-records is incompatible with -tpi-record-bytes and "
650 "-ipi-record-bytes.\n";
651 exit(1);
652 }
Zachary Turner7797c722015-03-02 04:39:56 +0000653 }
Zachary Turnerfcb14ad2015-01-27 20:46:21 +0000654
Zachary Turner93839cb2016-06-02 05:07:49 +0000655 llvm::sys::InitializeCOMRAII COM(llvm::sys::COMThreadingMode::MultiThreaded);
Zachary Turnerfcb14ad2015-01-27 20:46:21 +0000656
Zachary Turnera30bd1a2016-06-30 17:42:48 +0000657 if (opts::PdbToYamlSubcommand) {
Zachary Turner8848a7a2016-07-06 18:05:57 +0000658 pdb2Yaml(opts::pdb2yaml::InputFilename.front());
Zachary Turnera30bd1a2016-06-30 17:42:48 +0000659 } else if (opts::YamlToPdbSubcommand) {
660 yamlToPdb(opts::yaml2pdb::InputFilename.front());
Zachary Turnerd50c0132017-02-01 18:30:22 +0000661 } else if (opts::AnalyzeSubcommand) {
662 dumpAnalysis(opts::analyze::InputFilename.front());
Zachary Turnera30bd1a2016-06-30 17:42:48 +0000663 } else if (opts::PrettySubcommand) {
664 if (opts::pretty::Lines)
665 opts::pretty::Compilands = true;
666
667 if (opts::pretty::All) {
668 opts::pretty::Compilands = true;
669 opts::pretty::Symbols = true;
670 opts::pretty::Globals = true;
671 opts::pretty::Types = true;
672 opts::pretty::Externals = true;
673 opts::pretty::Lines = true;
674 }
675
676 // When adding filters for excluded compilands and types, we need to
Zachary Turner72c5b642016-09-09 18:17:52 +0000677 // remember that these are regexes. So special characters such as * and \
678 // need to be escaped in the regex. In the case of a literal \, this means
679 // it needs to be escaped again in the C++. So matching a single \ in the
680 // input requires 4 \es in the C++.
Zachary Turnera30bd1a2016-06-30 17:42:48 +0000681 if (opts::pretty::ExcludeCompilerGenerated) {
682 opts::pretty::ExcludeTypes.push_back("__vc_attributes");
683 opts::pretty::ExcludeCompilands.push_back("\\* Linker \\*");
684 }
685 if (opts::pretty::ExcludeSystemLibraries) {
686 opts::pretty::ExcludeCompilands.push_back(
687 "f:\\\\binaries\\\\Intermediate\\\\vctools\\\\crt_bld");
688 opts::pretty::ExcludeCompilands.push_back("f:\\\\dd\\\\vctools\\\\crt");
689 opts::pretty::ExcludeCompilands.push_back(
690 "d:\\\\th.obj.x86fre\\\\minkernel");
691 }
692 std::for_each(opts::pretty::InputFilenames.begin(),
693 opts::pretty::InputFilenames.end(), dumpPretty);
694 } else if (opts::RawSubcommand) {
695 std::for_each(opts::raw::InputFilenames.begin(),
696 opts::raw::InputFilenames.end(), dumpRaw);
Zachary Turner6ac232c2017-03-13 23:28:25 +0000697 } else if (opts::DiffSubcommand) {
698 if (opts::diff::InputFilenames.size() != 2) {
699 errs() << "diff subcommand expects exactly 2 arguments.\n";
700 exit(1);
701 }
702 diff(opts::diff::InputFilenames[0], opts::diff::InputFilenames[1]);
Zachary Turner1dc9fd32016-06-14 20:48:36 +0000703 }
Zachary Turnerfcb14ad2015-01-27 20:46:21 +0000704
Zachary Turner819e77d2016-05-06 20:51:57 +0000705 outs().flush();
Zachary Turnerfcb14ad2015-01-27 20:46:21 +0000706 return 0;
707}