#include "llvm-pdbutil.h"
#include "BytesOutputStyle.h"
#include "DumpOutputStyle.h"
#include "ExplainOutputStyle.h"
#include "OutputStyle.h"
#include "PrettyClassDefinitionDumper.h"
#include "PrettyCompilandDumper.h"
#include "PrettyEnumDumper.h"
#include "PrettyExternalSymbolDumper.h"
#include "PrettyFunctionDumper.h"
#include "PrettyTypeDumper.h"
#include "PrettyTypedefDumper.h"
#include "PrettyVariableDumper.h"
#include "YAMLOutputStyle.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/BinaryFormat/Magic.h"
#include "llvm/Config/config.h"
#include "llvm/DebugInfo/CodeView/AppendingTypeTableBuilder.h"
#include "llvm/DebugInfo/CodeView/DebugChecksumsSubsection.h"
#include "llvm/DebugInfo/CodeView/DebugInlineeLinesSubsection.h"
#include "llvm/DebugInfo/CodeView/DebugLinesSubsection.h"
#include "llvm/DebugInfo/CodeView/LazyRandomTypeCollection.h"
#include "llvm/DebugInfo/CodeView/MergingTypeTableBuilder.h"
#include "llvm/DebugInfo/CodeView/StringsAndChecksums.h"
#include "llvm/DebugInfo/CodeView/TypeStreamMerger.h"
#include "llvm/DebugInfo/MSF/MSFBuilder.h"
#include "llvm/DebugInfo/MSF/MappedBlockStream.h"
#include "llvm/DebugInfo/PDB/ConcreteSymbolEnumerator.h"
#include "llvm/DebugInfo/PDB/IPDBEnumChildren.h"
#include "llvm/DebugInfo/PDB/IPDBInjectedSource.h"
#include "llvm/DebugInfo/PDB/IPDBLineNumber.h"
#include "llvm/DebugInfo/PDB/IPDBRawSymbol.h"
#include "llvm/DebugInfo/PDB/IPDBSession.h"
#include "llvm/DebugInfo/PDB/Native/DbiModuleDescriptorBuilder.h"
#include "llvm/DebugInfo/PDB/Native/DbiStreamBuilder.h"
#include "llvm/DebugInfo/PDB/Native/InfoStream.h"
#include "llvm/DebugInfo/PDB/Native/InfoStreamBuilder.h"
#include "llvm/DebugInfo/PDB/Native/InputFile.h"
#include "llvm/DebugInfo/PDB/Native/NativeSession.h"
#include "llvm/DebugInfo/PDB/Native/PDBFile.h"
#include "llvm/DebugInfo/PDB/Native/PDBFileBuilder.h"
#include "llvm/DebugInfo/PDB/Native/PDBStringTableBuilder.h"
#include "llvm/DebugInfo/PDB/Native/RawConstants.h"
#include "llvm/DebugInfo/PDB/Native/RawError.h"
#include "llvm/DebugInfo/PDB/Native/TpiStream.h"
#include "llvm/DebugInfo/PDB/Native/TpiStreamBuilder.h"
#include "llvm/DebugInfo/PDB/PDB.h"
#include "llvm/DebugInfo/PDB/PDBSymbolCompiland.h"
#include "llvm/DebugInfo/PDB/PDBSymbolData.h"
#include "llvm/DebugInfo/PDB/PDBSymbolExe.h"
#include "llvm/DebugInfo/PDB/PDBSymbolFunc.h"
#include "llvm/DebugInfo/PDB/PDBSymbolPublicSymbol.h"
#include "llvm/DebugInfo/PDB/PDBSymbolThunk.h"
#include "llvm/DebugInfo/PDB/PDBSymbolTypeBuiltin.h"
#include "llvm/DebugInfo/PDB/PDBSymbolTypeEnum.h"
#include "llvm/DebugInfo/PDB/PDBSymbolTypeFunctionArg.h"
#include "llvm/DebugInfo/PDB/PDBSymbolTypeFunctionSig.h"
#include "llvm/DebugInfo/PDB/PDBSymbolTypeTypedef.h"
#include "llvm/DebugInfo/PDB/PDBSymbolTypeUDT.h"
#include "llvm/Support/BinaryByteStream.h"
#include "llvm/Support/COM.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/ConvertUTF.h"
#include "llvm/Support/FileOutputBuffer.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/Format.h"
#include "llvm/Support/InitLLVM.h"
#include "llvm/Support/LineIterator.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/PrettyStackTrace.h"
#include "llvm/Support/Process.h"
#include "llvm/Support/Regex.h"
#include "llvm/Support/ScopedPrinter.h"
#include "llvm/Support/Signals.h"
#include "llvm/Support/raw_ostream.h"
usingnamespacellvm;
usingnamespacellvm::codeview;
usingnamespacellvm::msf;
usingnamespacellvm::pdb;
namespace opts {
cl::SubCommand DumpSubcommand("dump", "Dump MSF and CodeView debug info");
cl::SubCommand BytesSubcommand("bytes", "Dump raw bytes from the PDB file");
cl::SubCommand DiaDumpSubcommand("diadump",
"Dump debug information using a DIA-like API");
cl::SubCommand
PrettySubcommand("pretty",
"Dump semantic information about types and symbols");
cl::SubCommand
YamlToPdbSubcommand("yaml2pdb",
"Generate a PDB file from a YAML description");
cl::SubCommand
PdbToYamlSubcommand("pdb2yaml",
"Generate a detailed YAML description of a PDB File");
cl::SubCommand MergeSubcommand("merge",
"Merge multiple PDBs into a single PDB");
cl::SubCommand ExplainSubcommand("explain",
"Explain the meaning of a file offset");
cl::SubCommand ExportSubcommand("export",
"Write binary data from a stream to a file");
cl::OptionCategory TypeCategory("Symbol Type Options");
cl::OptionCategory FilterCategory("Filtering and Sorting Options");
cl::OptionCategory OtherOptions("Other Options");
cl::ValuesClass ChunkValues = …;
namespace diadump {
cl::list<std::string> InputFilenames(cl::Positional,
cl::desc("<input PDB files>"),
cl::OneOrMore, cl::sub(DiaDumpSubcommand));
cl::opt<bool> Native("native", cl::desc("Use native PDB reader instead of DIA"),
cl::sub(DiaDumpSubcommand));
static cl::opt<bool>
ShowClassHierarchy("hierarchy", cl::desc("Show lexical and class parents"),
cl::sub(DiaDumpSubcommand));
static cl::opt<bool> NoSymIndexIds(
"no-ids",
cl::desc("Don't show any SymIndexId fields (overrides -hierarchy)"),
cl::sub(DiaDumpSubcommand));
static cl::opt<bool>
Recurse("recurse",
cl::desc("When dumping a SymIndexId, dump the full details of the "
"corresponding record"),
cl::sub(DiaDumpSubcommand));
static cl::opt<bool> Enums("enums", cl::desc("Dump enum types"),
cl::sub(DiaDumpSubcommand));
static cl::opt<bool> Pointers("pointers", cl::desc("Dump enum types"),
cl::sub(DiaDumpSubcommand));
static cl::opt<bool> UDTs("udts", cl::desc("Dump udt types"),
cl::sub(DiaDumpSubcommand));
static cl::opt<bool> Compilands("compilands",
cl::desc("Dump compiland information"),
cl::sub(DiaDumpSubcommand));
static cl::opt<bool> Funcsigs("funcsigs",
cl::desc("Dump function signature information"),
cl::sub(DiaDumpSubcommand));
static cl::opt<bool> Arrays("arrays", cl::desc("Dump array types"),
cl::sub(DiaDumpSubcommand));
static cl::opt<bool> VTShapes("vtshapes", cl::desc("Dump virtual table shapes"),
cl::sub(DiaDumpSubcommand));
static cl::opt<bool> Typedefs("typedefs", cl::desc("Dump typedefs"),
cl::sub(DiaDumpSubcommand));
}
FilterOptions Filters;
namespace pretty {
cl::list<std::string> InputFilenames(cl::Positional,
cl::desc("<input PDB files>"),
cl::OneOrMore, cl::sub(PrettySubcommand));
cl::opt<bool> InjectedSources("injected-sources",
cl::desc("Display injected sources"),
cl::cat(OtherOptions), cl::sub(PrettySubcommand));
cl::opt<bool> ShowInjectedSourceContent(
"injected-source-content",
cl::desc("When displaying an injected source, display the file content"),
cl::cat(OtherOptions), cl::sub(PrettySubcommand));
cl::list<std::string> WithName(
"with-name",
cl::desc("Display any symbol or type with the specified exact name"),
cl::cat(TypeCategory), cl::sub(PrettySubcommand));
cl::opt<bool> Compilands("compilands", cl::desc("Display compilands"),
cl::cat(TypeCategory), cl::sub(PrettySubcommand));
cl::opt<bool> Symbols("module-syms",
cl::desc("Display symbols for each compiland"),
cl::cat(TypeCategory), cl::sub(PrettySubcommand));
cl::opt<bool> Globals("globals", cl::desc("Dump global symbols"),
cl::cat(TypeCategory), cl::sub(PrettySubcommand));
cl::opt<bool> Externals("externals", cl::desc("Dump external symbols"),
cl::cat(TypeCategory), cl::sub(PrettySubcommand));
cl::list<SymLevel> SymTypes(
"sym-types", cl::desc("Type of symbols to dump (default all)"),
cl::cat(TypeCategory), cl::sub(PrettySubcommand),
cl::values(
clEnumValN(SymLevel::Thunks, "thunks", "Display thunk symbols"),
clEnumValN(SymLevel::Data, "data", "Display data symbols"),
clEnumValN(SymLevel::Functions, "funcs", "Display function symbols"),
clEnumValN(SymLevel::All, "all", "Display all symbols (default)")));
cl::opt<bool>
Types("types",
cl::desc("Display all types (implies -classes, -enums, -typedefs)"),
cl::cat(TypeCategory), cl::sub(PrettySubcommand));
cl::opt<bool> Classes("classes", cl::desc("Display class types"),
cl::cat(TypeCategory), cl::sub(PrettySubcommand));
cl::opt<bool> Enums("enums", cl::desc("Display enum types"),
cl::cat(TypeCategory), cl::sub(PrettySubcommand));
cl::opt<bool> Typedefs("typedefs", cl::desc("Display typedef types"),
cl::cat(TypeCategory), cl::sub(PrettySubcommand));
cl::opt<bool> Funcsigs("funcsigs", cl::desc("Display function signatures"),
cl::cat(TypeCategory), cl::sub(PrettySubcommand));
cl::opt<bool> Pointers("pointers", cl::desc("Display pointer types"),
cl::cat(TypeCategory), cl::sub(PrettySubcommand));
cl::opt<bool> Arrays("arrays", cl::desc("Display arrays"),
cl::cat(TypeCategory), cl::sub(PrettySubcommand));
cl::opt<bool> VTShapes("vtshapes", cl::desc("Display vftable shapes"),
cl::cat(TypeCategory), cl::sub(PrettySubcommand));
cl::opt<SymbolSortMode> SymbolOrder(
"symbol-order", cl::desc("symbol sort order"),
cl::init(SymbolSortMode::None),
cl::values(clEnumValN(SymbolSortMode::None, "none",
"Undefined / no particular sort order"),
clEnumValN(SymbolSortMode::Name, "name", "Sort symbols by name"),
clEnumValN(SymbolSortMode::Size, "size",
"Sort symbols by size")),
cl::cat(TypeCategory), cl::sub(PrettySubcommand));
cl::opt<ClassSortMode> ClassOrder(
"class-order", cl::desc("Class sort order"), cl::init(ClassSortMode::None),
cl::values(
clEnumValN(ClassSortMode::None, "none",
"Undefined / no particular sort order"),
clEnumValN(ClassSortMode::Name, "name", "Sort classes by name"),
clEnumValN(ClassSortMode::Size, "size", "Sort classes by size"),
clEnumValN(ClassSortMode::Padding, "padding",
"Sort classes by amount of padding"),
clEnumValN(ClassSortMode::PaddingPct, "padding-pct",
"Sort classes by percentage of space consumed by padding"),
clEnumValN(ClassSortMode::PaddingImmediate, "padding-imm",
"Sort classes by amount of immediate padding"),
clEnumValN(ClassSortMode::PaddingPctImmediate, "padding-pct-imm",
"Sort classes by percentage of space consumed by immediate "
"padding")),
cl::cat(TypeCategory), cl::sub(PrettySubcommand));
cl::opt<ClassDefinitionFormat> ClassFormat(
"class-definitions", cl::desc("Class definition format"),
cl::init(ClassDefinitionFormat::All),
cl::values(
clEnumValN(ClassDefinitionFormat::All, "all",
"Display all class members including data, constants, "
"typedefs, functions, etc"),
clEnumValN(ClassDefinitionFormat::Layout, "layout",
"Only display members that contribute to class size."),
clEnumValN(ClassDefinitionFormat::None, "none",
"Don't display class definitions")),
cl::cat(TypeCategory), cl::sub(PrettySubcommand));
cl::opt<uint32_t> ClassRecursionDepth(
"class-recurse-depth", cl::desc("Class recursion depth (0=no limit)"),
cl::init(0), cl::cat(TypeCategory), cl::sub(PrettySubcommand));
cl::opt<bool> Lines("lines", cl::desc("Line tables"), cl::cat(TypeCategory),
cl::sub(PrettySubcommand));
cl::opt<bool>
All("all", cl::desc("Implies all other options in 'Symbol Types' category"),
cl::cat(TypeCategory), cl::sub(PrettySubcommand));
cl::opt<uint64_t> LoadAddress(
"load-address",
cl::desc("Assume the module is loaded at the specified address"),
cl::cat(OtherOptions), cl::sub(PrettySubcommand));
cl::opt<bool> Native("native", cl::desc("Use native PDB reader instead of DIA"),
cl::cat(OtherOptions), cl::sub(PrettySubcommand));
cl::opt<cl::boolOrDefault>
ColorOutput("color-output",
cl::desc("Override use of color (default = isatty)"),
cl::cat(OtherOptions), cl::sub(PrettySubcommand));
cl::list<std::string>
ExcludeTypes("exclude-types",
cl::desc("Exclude types by regular expression"),
cl::cat(FilterCategory), cl::sub(PrettySubcommand));
cl::list<std::string>
ExcludeSymbols("exclude-symbols",
cl::desc("Exclude symbols by regular expression"),
cl::cat(FilterCategory), cl::sub(PrettySubcommand));
cl::list<std::string>
ExcludeCompilands("exclude-compilands",
cl::desc("Exclude compilands by regular expression"),
cl::cat(FilterCategory), cl::sub(PrettySubcommand));
cl::list<std::string> IncludeTypes(
"include-types",
cl::desc("Include only types which match a regular expression"),
cl::cat(FilterCategory), cl::sub(PrettySubcommand));
cl::list<std::string> IncludeSymbols(
"include-symbols",
cl::desc("Include only symbols which match a regular expression"),
cl::cat(FilterCategory), cl::sub(PrettySubcommand));
cl::list<std::string> IncludeCompilands(
"include-compilands",
cl::desc("Include only compilands those which match a regular expression"),
cl::cat(FilterCategory), cl::sub(PrettySubcommand));
cl::opt<uint32_t> SizeThreshold(
"min-type-size", cl::desc("Displays only those types which are greater "
"than or equal to the specified size."),
cl::init(0), cl::cat(FilterCategory), cl::sub(PrettySubcommand));
cl::opt<uint32_t> PaddingThreshold(
"min-class-padding", cl::desc("Displays only those classes which have at "
"least the specified amount of padding."),
cl::init(0), cl::cat(FilterCategory), cl::sub(PrettySubcommand));
cl::opt<uint32_t> ImmediatePaddingThreshold(
"min-class-padding-imm",
cl::desc("Displays only those classes which have at least the specified "
"amount of immediate padding, ignoring padding internal to bases "
"and aggregates."),
cl::init(0), cl::cat(FilterCategory), cl::sub(PrettySubcommand));
cl::opt<bool> ExcludeCompilerGenerated(
"no-compiler-generated",
cl::desc("Don't show compiler generated types and symbols"),
cl::cat(FilterCategory), cl::sub(PrettySubcommand));
cl::opt<bool>
ExcludeSystemLibraries("no-system-libs",
cl::desc("Don't show symbols from system libraries"),
cl::cat(FilterCategory), cl::sub(PrettySubcommand));
cl::opt<bool> NoEnumDefs("no-enum-definitions",
cl::desc("Don't display full enum definitions"),
cl::cat(FilterCategory), cl::sub(PrettySubcommand));
}
cl::OptionCategory FileOptions("Module & File Options");
namespace bytes {
cl::OptionCategory MsfBytes("MSF File Options");
cl::OptionCategory DbiBytes("Dbi Stream Options");
cl::OptionCategory PdbBytes("PDB Stream Options");
cl::OptionCategory Types("Type Options");
cl::OptionCategory ModuleCategory("Module Options");
std::optional<NumberRange> DumpBlockRange;
std::optional<NumberRange> DumpByteRange;
cl::opt<std::string> DumpBlockRangeOpt(
"block-range", cl::value_desc("start[-end]"),
cl::desc("Dump binary data from specified range of blocks."),
cl::sub(BytesSubcommand), cl::cat(MsfBytes));
cl::opt<std::string>
DumpByteRangeOpt("byte-range", cl::value_desc("start[-end]"),
cl::desc("Dump binary data from specified range of bytes"),
cl::sub(BytesSubcommand), cl::cat(MsfBytes));
cl::list<std::string>
DumpStreamData("stream-data", cl::CommaSeparated,
cl::desc("Dump binary data from specified streams. Format "
"is SN[:Start][@Size]"),
cl::sub(BytesSubcommand), cl::cat(MsfBytes));
cl::opt<bool> NameMap("name-map", cl::desc("Dump bytes of PDB Name Map"),
cl::sub(BytesSubcommand), cl::cat(PdbBytes));
cl::opt<bool> Fpm("fpm", cl::desc("Dump free page map"),
cl::sub(BytesSubcommand), cl::cat(MsfBytes));
cl::opt<bool> SectionContributions("sc", cl::desc("Dump section contributions"),
cl::sub(BytesSubcommand), cl::cat(DbiBytes));
cl::opt<bool> SectionMap("sm", cl::desc("Dump section map"),
cl::sub(BytesSubcommand), cl::cat(DbiBytes));
cl::opt<bool> ModuleInfos("modi", cl::desc("Dump module info"),
cl::sub(BytesSubcommand), cl::cat(DbiBytes));
cl::opt<bool> FileInfo("files", cl::desc("Dump source file info"),
cl::sub(BytesSubcommand), cl::cat(DbiBytes));
cl::opt<bool> TypeServerMap("type-server", cl::desc("Dump type server map"),
cl::sub(BytesSubcommand), cl::cat(DbiBytes));
cl::opt<bool> ECData("ec", cl::desc("Dump edit and continue map"),
cl::sub(BytesSubcommand), cl::cat(DbiBytes));
cl::list<uint32_t> TypeIndex(
"type", cl::desc("Dump the type record with the given type index"),
cl::CommaSeparated, cl::sub(BytesSubcommand), cl::cat(TypeCategory));
cl::list<uint32_t>
IdIndex("id", cl::desc("Dump the id record with the given type index"),
cl::CommaSeparated, cl::sub(BytesSubcommand),
cl::cat(TypeCategory));
cl::opt<uint32_t> ModuleIndex(
"mod",
cl::desc(
"Limit options in the Modules category to the specified module index"),
cl::Optional, cl::sub(BytesSubcommand), cl::cat(ModuleCategory));
cl::opt<bool> ModuleSyms("syms", cl::desc("Dump symbol record substream"),
cl::sub(BytesSubcommand), cl::cat(ModuleCategory));
cl::opt<bool> ModuleC11("c11-chunks", cl::Hidden,
cl::desc("Dump C11 CodeView debug chunks"),
cl::sub(BytesSubcommand), cl::cat(ModuleCategory));
cl::opt<bool> ModuleC13("chunks",
cl::desc("Dump C13 CodeView debug chunk subsection"),
cl::sub(BytesSubcommand), cl::cat(ModuleCategory));
cl::opt<bool> SplitChunks(
"split-chunks",
cl::desc(
"When dumping debug chunks, show a different section for each chunk"),
cl::sub(BytesSubcommand), cl::cat(ModuleCategory));
cl::list<std::string> InputFilenames(cl::Positional,
cl::desc("<input PDB files>"),
cl::OneOrMore, cl::sub(BytesSubcommand));
}
namespace dump {
cl::OptionCategory MsfOptions("MSF Container Options");
cl::OptionCategory TypeOptions("Type Record Options");
cl::OptionCategory SymbolOptions("Symbol Options");
cl::OptionCategory MiscOptions("Miscellaneous Options");
cl::opt<bool> DumpSummary("summary", cl::desc("dump file summary"),
cl::cat(MsfOptions), cl::sub(DumpSubcommand));
cl::opt<bool> DumpStreams("streams",
cl::desc("dump summary of the PDB streams"),
cl::cat(MsfOptions), cl::sub(DumpSubcommand));
cl::opt<bool> DumpStreamBlocks(
"stream-blocks",
cl::desc("Add block information to the output of -streams"),
cl::cat(MsfOptions), cl::sub(DumpSubcommand));
cl::opt<bool> DumpSymbolStats(
"sym-stats",
cl::desc("Dump a detailed breakdown of symbol usage/size for each module"),
cl::cat(MsfOptions), cl::sub(DumpSubcommand));
cl::opt<bool> DumpTypeStats(
"type-stats",
cl::desc("Dump a detailed breakdown of type usage/size"),
cl::cat(MsfOptions), cl::sub(DumpSubcommand));
cl::opt<bool> DumpIDStats(
"id-stats",
cl::desc("Dump a detailed breakdown of IPI types usage/size"),
cl::cat(MsfOptions), cl::sub(DumpSubcommand));
cl::opt<bool> DumpUdtStats(
"udt-stats",
cl::desc("Dump a detailed breakdown of S_UDT record usage / stats"),
cl::cat(MsfOptions), cl::sub(DumpSubcommand));
cl::opt<bool> DumpTypes("types",
cl::desc("dump CodeView type records from TPI stream"),
cl::cat(TypeOptions), cl::sub(DumpSubcommand));
cl::opt<bool> DumpTypeData(
"type-data",
cl::desc("dump CodeView type record raw bytes from TPI stream"),
cl::cat(TypeOptions), cl::sub(DumpSubcommand));
cl::opt<bool>
DumpTypeRefStats("type-ref-stats",
cl::desc("dump statistics on the number and size of types "
"transitively referenced by symbol records"),
cl::cat(TypeOptions), cl::sub(DumpSubcommand));
cl::opt<bool> DumpTypeExtras("type-extras",
cl::desc("dump type hashes and index offsets"),
cl::cat(TypeOptions), cl::sub(DumpSubcommand));
cl::opt<bool> DontResolveForwardRefs(
"dont-resolve-forward-refs",
cl::desc("When dumping type records for classes, unions, enums, and "
"structs, don't try to resolve forward references"),
cl::cat(TypeOptions), cl::sub(DumpSubcommand));
cl::list<uint32_t> DumpTypeIndex(
"type-index", cl::CommaSeparated,
cl::desc("only dump types with the specified hexadecimal type index"),
cl::cat(TypeOptions), cl::sub(DumpSubcommand));
cl::opt<bool> DumpIds("ids",
cl::desc("dump CodeView type records from IPI stream"),
cl::cat(TypeOptions), cl::sub(DumpSubcommand));
cl::opt<bool>
DumpIdData("id-data",
cl::desc("dump CodeView type record raw bytes from IPI stream"),
cl::cat(TypeOptions), cl::sub(DumpSubcommand));
cl::opt<bool> DumpIdExtras("id-extras",
cl::desc("dump id hashes and index offsets"),
cl::cat(TypeOptions), cl::sub(DumpSubcommand));
cl::list<uint32_t> DumpIdIndex(
"id-index", cl::CommaSeparated,
cl::desc("only dump ids with the specified hexadecimal type index"),
cl::cat(TypeOptions), cl::sub(DumpSubcommand));
cl::opt<bool> DumpTypeDependents(
"dependents",
cl::desc("In conjunection with -type-index and -id-index, dumps the entire "
"dependency graph for the specified index instead of "
"just the single record with the specified index"),
cl::cat(TypeOptions), cl::sub(DumpSubcommand));
cl::opt<bool> DumpGlobals("globals", cl::desc("dump Globals symbol records"),
cl::cat(SymbolOptions), cl::sub(DumpSubcommand));
cl::opt<bool> DumpGlobalExtras("global-extras", cl::desc("dump Globals hashes"),
cl::cat(SymbolOptions), cl::sub(DumpSubcommand));
cl::list<std::string> DumpGlobalNames(
"global-name",
cl::desc(
"With -globals, only dump globals whose name matches the given value"),
cl::cat(SymbolOptions), cl::sub(DumpSubcommand));
cl::opt<bool> DumpPublics("publics", cl::desc("dump Publics stream data"),
cl::cat(SymbolOptions), cl::sub(DumpSubcommand));
cl::opt<bool> DumpPublicExtras("public-extras",
cl::desc("dump Publics hashes and address maps"),
cl::cat(SymbolOptions), cl::sub(DumpSubcommand));
cl::opt<bool>
DumpGSIRecords("gsi-records",
cl::desc("dump public / global common record stream"),
cl::cat(SymbolOptions), cl::sub(DumpSubcommand));
cl::opt<bool> DumpSymbols("symbols", cl::desc("dump module symbols"),
cl::cat(SymbolOptions), cl::sub(DumpSubcommand));
cl::opt<bool>
DumpSymRecordBytes("sym-data",
cl::desc("dump CodeView symbol record raw bytes"),
cl::cat(SymbolOptions), cl::sub(DumpSubcommand));
cl::opt<bool> DumpFpo("fpo", cl::desc("dump FPO records"),
cl::cat(SymbolOptions), cl::sub(DumpSubcommand));
cl::opt<uint32_t> DumpSymbolOffset(
"symbol-offset", cl::Optional,
cl::desc("only dump symbol record with the specified symbol offset"),
cl::cat(SymbolOptions), cl::sub(DumpSubcommand));
cl::opt<bool> DumpParents("show-parents",
cl::desc("dump the symbols record's all parents."),
cl::cat(SymbolOptions), cl::sub(DumpSubcommand));
cl::opt<uint32_t>
DumpParentDepth("parent-recurse-depth", cl::Optional, cl::init(-1U),
cl::desc("only recurse to a depth of N when displaying "
"parents of a symbol record."),
cl::cat(SymbolOptions), cl::sub(DumpSubcommand));
cl::opt<bool> DumpChildren("show-children",
cl::desc("dump the symbols record's all children."),
cl::cat(SymbolOptions), cl::sub(DumpSubcommand));
cl::opt<uint32_t>
DumpChildrenDepth("children-recurse-depth", cl::Optional, cl::init(-1U),
cl::desc("only recurse to a depth of N when displaying "
"children of a symbol record."),
cl::cat(SymbolOptions), cl::sub(DumpSubcommand));
cl::opt<bool> DumpModules("modules", cl::desc("dump compiland information"),
cl::cat(FileOptions), cl::sub(DumpSubcommand));
cl::opt<bool> DumpModuleFiles(
"files",
cl::desc("Dump the source files that contribute to each module's."),
cl::cat(FileOptions), cl::sub(DumpSubcommand));
cl::opt<bool> DumpLines(
"l",
cl::desc("dump source file/line information (DEBUG_S_LINES subsection)"),
cl::cat(FileOptions), cl::sub(DumpSubcommand));
cl::opt<bool> DumpInlineeLines(
"il",
cl::desc("dump inlinee line information (DEBUG_S_INLINEELINES subsection)"),
cl::cat(FileOptions), cl::sub(DumpSubcommand));
cl::opt<bool> DumpXmi(
"xmi",
cl::desc(
"dump cross module imports (DEBUG_S_CROSSSCOPEIMPORTS subsection)"),
cl::cat(FileOptions), cl::sub(DumpSubcommand));
cl::opt<bool> DumpXme(
"xme",
cl::desc(
"dump cross module exports (DEBUG_S_CROSSSCOPEEXPORTS subsection)"),
cl::cat(FileOptions), cl::sub(DumpSubcommand));
cl::opt<uint32_t> DumpModi("modi", cl::Optional,
cl::desc("For all options that iterate over "
"modules, limit to the specified module"),
cl::cat(FileOptions), cl::sub(DumpSubcommand));
cl::opt<bool> JustMyCode("jmc", cl::Optional,
cl::desc("For all options that iterate over modules, "
"ignore modules from system libraries"),
cl::cat(FileOptions), cl::sub(DumpSubcommand));
cl::opt<bool> DumpNamedStreams("named-streams",
cl::desc("dump PDB named stream table"),
cl::cat(MiscOptions), cl::sub(DumpSubcommand));
cl::opt<bool> DumpStringTable("string-table", cl::desc("dump PDB String Table"),
cl::cat(MiscOptions), cl::sub(DumpSubcommand));
cl::opt<bool> DumpStringTableDetails("string-table-details",
cl::desc("dump PDB String Table Details"),
cl::cat(MiscOptions),
cl::sub(DumpSubcommand));
cl::opt<bool> DumpSectionContribs("section-contribs",
cl::desc("dump section contributions"),
cl::cat(MiscOptions),
cl::sub(DumpSubcommand));
cl::opt<bool> DumpSectionMap("section-map", cl::desc("dump section map"),
cl::cat(MiscOptions), cl::sub(DumpSubcommand));
cl::opt<bool> DumpSectionHeaders("section-headers",
cl::desc("Dump image section headers"),
cl::cat(MiscOptions), cl::sub(DumpSubcommand));
cl::opt<bool> RawAll("all", cl::desc("Implies most other options."),
cl::cat(MiscOptions), cl::sub(DumpSubcommand));
cl::list<std::string> InputFilenames(cl::Positional,
cl::desc("<input PDB files>"),
cl::OneOrMore, cl::sub(DumpSubcommand));
}
namespace yaml2pdb {
cl::opt<std::string>
YamlPdbOutputFile("pdb", cl::desc("the name of the PDB file to write"),
cl::sub(YamlToPdbSubcommand));
cl::opt<std::string> InputFilename(cl::Positional,
cl::desc("<input YAML file>"), cl::Required,
cl::sub(YamlToPdbSubcommand));
}
namespace pdb2yaml {
cl::opt<bool> All("all",
cl::desc("Dump everything we know how to dump."),
cl::sub(PdbToYamlSubcommand), cl::init(false));
cl::opt<bool> NoFileHeaders("no-file-headers",
cl::desc("Do not dump MSF file headers"),
cl::sub(PdbToYamlSubcommand), cl::init(false));
cl::opt<bool> Minimal("minimal",
cl::desc("Don't write fields with default values"),
cl::sub(PdbToYamlSubcommand), cl::init(false));
cl::opt<bool> StreamMetadata(
"stream-metadata",
cl::desc("Dump the number of streams and each stream's size"),
cl::sub(PdbToYamlSubcommand), cl::init(false));
cl::opt<bool> StreamDirectory(
"stream-directory",
cl::desc("Dump each stream's block map (implies -stream-metadata)"),
cl::sub(PdbToYamlSubcommand), cl::init(false));
cl::opt<bool> PdbStream("pdb-stream",
cl::desc("Dump the PDB Stream (Stream 1)"),
cl::sub(PdbToYamlSubcommand), cl::init(false));
cl::opt<bool> StringTable("string-table", cl::desc("Dump the PDB String Table"),
cl::sub(PdbToYamlSubcommand), cl::init(false));
cl::opt<bool> DbiStream("dbi-stream",
cl::desc("Dump the DBI Stream Headers (Stream 2)"),
cl::sub(PdbToYamlSubcommand), cl::init(false));
cl::opt<bool> TpiStream("tpi-stream",
cl::desc("Dump the TPI Stream (Stream 3)"),
cl::sub(PdbToYamlSubcommand), cl::init(false));
cl::opt<bool> IpiStream("ipi-stream",
cl::desc("Dump the IPI Stream (Stream 5)"),
cl::sub(PdbToYamlSubcommand), cl::init(false));
cl::opt<bool> PublicsStream("publics-stream",
cl::desc("Dump the Publics Stream"),
cl::sub(PdbToYamlSubcommand), cl::init(false));
cl::opt<bool> DumpModules("modules", cl::desc("dump compiland information"),
cl::cat(FileOptions), cl::sub(PdbToYamlSubcommand));
cl::opt<bool> DumpModuleFiles("module-files", cl::desc("dump file information"),
cl::cat(FileOptions),
cl::sub(PdbToYamlSubcommand));
cl::list<ModuleSubsection> DumpModuleSubsections(
"subsections", cl::CommaSeparated,
cl::desc("dump subsections from each module's debug stream"), ChunkValues,
cl::cat(FileOptions), cl::sub(PdbToYamlSubcommand));
cl::opt<bool> DumpModuleSyms("module-syms", cl::desc("dump module symbols"),
cl::cat(FileOptions),
cl::sub(PdbToYamlSubcommand));
cl::list<std::string> InputFilename(cl::Positional,
cl::desc("<input PDB file>"), cl::Required,
cl::sub(PdbToYamlSubcommand));
}
namespace merge {
cl::list<std::string> InputFilenames(cl::Positional,
cl::desc("<input PDB files>"),
cl::OneOrMore, cl::sub(MergeSubcommand));
cl::opt<std::string>
PdbOutputFile("pdb", cl::desc("the name of the PDB file to write"),
cl::sub(MergeSubcommand));
}
namespace explain {
cl::list<std::string> InputFilename(cl::Positional,
cl::desc("<input PDB file>"), cl::Required,
cl::sub(ExplainSubcommand));
cl::list<uint64_t> Offsets("offset", cl::desc("The file offset to explain"),
cl::sub(ExplainSubcommand), cl::OneOrMore);
cl::opt<InputFileType> InputType(
"input-type", cl::desc("Specify how to interpret the input file"),
cl::init(InputFileType::PDBFile), cl::Optional, cl::sub(ExplainSubcommand),
cl::values(clEnumValN(InputFileType::PDBFile, "pdb-file",
"Treat input as a PDB file (default)"),
clEnumValN(InputFileType::PDBStream, "pdb-stream",
"Treat input as raw contents of PDB stream"),
clEnumValN(InputFileType::DBIStream, "dbi-stream",
"Treat input as raw contents of DBI stream"),
clEnumValN(InputFileType::Names, "names-stream",
"Treat input as raw contents of /names named stream"),
clEnumValN(InputFileType::ModuleStream, "mod-stream",
"Treat input as raw contents of a module stream")));
}
namespace exportstream {
cl::list<std::string> InputFilename(cl::Positional,
cl::desc("<input PDB file>"), cl::Required,
cl::sub(ExportSubcommand));
cl::opt<std::string> OutputFile("out",
cl::desc("The file to write the stream to"),
cl::Required, cl::sub(ExportSubcommand));
cl::opt<std::string>
Stream("stream", cl::Required,
cl::desc("The index or name of the stream whose contents to export"),
cl::sub(ExportSubcommand));
cl::opt<bool> ForceName("name",
cl::desc("Force the interpretation of -stream as a "
"string, even if it is a valid integer"),
cl::sub(ExportSubcommand), cl::Optional,
cl::init(false));
}
}
static ExitOnError ExitOnErr;
static void yamlToPdb(StringRef Path) { … }
static PDBFile &loadPDB(StringRef Path, std::unique_ptr<IPDBSession> &Session) { … }
static void pdb2Yaml(StringRef Path) { … }
static void dumpRaw(StringRef Path) { … }
static void dumpBytes(StringRef Path) { … }
bool opts::pretty::shouldDumpSymLevel(SymLevel Search) { … }
uint32_t llvm::pdb::getTypeLength(const PDBSymbolData &Symbol) { … }
bool opts::pretty::compareFunctionSymbols(
const std::unique_ptr<PDBSymbolFunc> &F1,
const std::unique_ptr<PDBSymbolFunc> &F2) { … }
bool opts::pretty::compareDataSymbols(
const std::unique_ptr<PDBSymbolData> &F1,
const std::unique_ptr<PDBSymbolData> &F2) { … }
static std::string stringOr(std::string Str, std::string IfEmpty) { … }
static void dumpInjectedSources(LinePrinter &Printer, IPDBSession &Session) { … }
template <typename OuterT, typename ChildT>
void diaDumpChildren(PDBSymbol &Outer, PdbSymbolIdField Ids,
PdbSymbolIdField Recurse) { … }
static void dumpDia(StringRef Path) { … }
static void dumpPretty(StringRef Path) { … }
static void mergePdbs() { … }
static void explain() { … }
static void exportStream() { … }
static bool parseRange(StringRef Str,
std::optional<opts::bytes::NumberRange> &Parsed) { … }
static void simplifyChunkList(llvm::cl::list<opts::ModuleSubsection> &Chunks) { … }
int main(int Argc, const char **Argv) { … }