1 //===- llvm-pdbutil.h ----------------------------------------- *- C++ --*-===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 9 #ifndef LLVM_TOOLS_LLVMPDBDUMP_LLVMPDBDUMP_H 10 #define LLVM_TOOLS_LLVMPDBDUMP_LLVMPDBDUMP_H 11 12 #include "llvm/ADT/DenseMap.h" 13 #include "llvm/ADT/Optional.h" 14 #include "llvm/ADT/PointerUnion.h" 15 #include "llvm/Support/CommandLine.h" 16 #include "llvm/Support/raw_ostream.h" 17 18 #include <memory> 19 #include <stdint.h> 20 21 namespace llvm { 22 namespace object { 23 class COFFObjectFile; 24 } 25 namespace pdb { 26 class PDBSymbolData; 27 class PDBSymbolFunc; 28 class PDBFile; 29 uint32_t getTypeLength(const PDBSymbolData &Symbol); 30 } 31 typedef llvm::PointerUnion<object::COFFObjectFile *, pdb::PDBFile *> 32 PdbOrCoffObj; 33 } 34 35 namespace opts { 36 37 enum class DumpLevel { None, Basic, Verbose }; 38 39 enum class ModuleSubsection { 40 Unknown, 41 Lines, 42 FileChecksums, 43 InlineeLines, 44 CrossScopeImports, 45 CrossScopeExports, 46 StringTable, 47 Symbols, 48 FrameData, 49 CoffSymbolRVAs, 50 All 51 }; 52 53 namespace pretty { 54 55 enum class ClassDefinitionFormat { None, Layout, All }; 56 enum class ClassSortMode { 57 None, 58 Name, 59 Size, 60 Padding, 61 PaddingPct, 62 PaddingImmediate, 63 PaddingPctImmediate 64 }; 65 66 enum class SymbolSortMode { None, Name, Size }; 67 68 enum class SymLevel { Functions, Data, Thunks, All }; 69 70 bool shouldDumpSymLevel(SymLevel Level); 71 bool compareFunctionSymbols( 72 const std::unique_ptr<llvm::pdb::PDBSymbolFunc> &F1, 73 const std::unique_ptr<llvm::pdb::PDBSymbolFunc> &F2); 74 bool compareDataSymbols(const std::unique_ptr<llvm::pdb::PDBSymbolData> &F1, 75 const std::unique_ptr<llvm::pdb::PDBSymbolData> &F2); 76 77 extern llvm::cl::list<std::string> WithName; 78 79 extern llvm::cl::opt<bool> Compilands; 80 extern llvm::cl::opt<bool> Symbols; 81 extern llvm::cl::opt<bool> Globals; 82 extern llvm::cl::opt<bool> Classes; 83 extern llvm::cl::opt<bool> Enums; 84 extern llvm::cl::opt<bool> Funcsigs; 85 extern llvm::cl::opt<bool> Arrays; 86 extern llvm::cl::opt<bool> Typedefs; 87 extern llvm::cl::opt<bool> Pointers; 88 extern llvm::cl::opt<bool> VTShapes; 89 extern llvm::cl::opt<bool> All; 90 extern llvm::cl::opt<bool> ExcludeCompilerGenerated; 91 92 extern llvm::cl::opt<bool> NoEnumDefs; 93 extern llvm::cl::list<std::string> ExcludeTypes; 94 extern llvm::cl::list<std::string> ExcludeSymbols; 95 extern llvm::cl::list<std::string> ExcludeCompilands; 96 extern llvm::cl::list<std::string> IncludeTypes; 97 extern llvm::cl::list<std::string> IncludeSymbols; 98 extern llvm::cl::list<std::string> IncludeCompilands; 99 extern llvm::cl::opt<SymbolSortMode> SymbolOrder; 100 extern llvm::cl::opt<ClassSortMode> ClassOrder; 101 extern llvm::cl::opt<uint32_t> SizeThreshold; 102 extern llvm::cl::opt<uint32_t> PaddingThreshold; 103 extern llvm::cl::opt<uint32_t> ImmediatePaddingThreshold; 104 extern llvm::cl::opt<ClassDefinitionFormat> ClassFormat; 105 extern llvm::cl::opt<uint32_t> ClassRecursionDepth; 106 } 107 108 namespace bytes { 109 struct NumberRange { 110 uint64_t Min; 111 llvm::Optional<uint64_t> Max; 112 }; 113 114 extern llvm::Optional<NumberRange> DumpBlockRange; 115 extern llvm::Optional<NumberRange> DumpByteRange; 116 extern llvm::cl::list<std::string> DumpStreamData; 117 extern llvm::cl::opt<bool> NameMap; 118 extern llvm::cl::opt<bool> Fpm; 119 120 extern llvm::cl::opt<bool> SectionContributions; 121 extern llvm::cl::opt<bool> SectionMap; 122 extern llvm::cl::opt<bool> ModuleInfos; 123 extern llvm::cl::opt<bool> FileInfo; 124 extern llvm::cl::opt<bool> TypeServerMap; 125 extern llvm::cl::opt<bool> ECData; 126 127 extern llvm::cl::list<uint32_t> TypeIndex; 128 extern llvm::cl::list<uint32_t> IdIndex; 129 130 extern llvm::cl::opt<uint32_t> ModuleIndex; 131 extern llvm::cl::opt<bool> ModuleSyms; 132 extern llvm::cl::opt<bool> ModuleC11; 133 extern llvm::cl::opt<bool> ModuleC13; 134 extern llvm::cl::opt<bool> SplitChunks; 135 } // namespace bytes 136 137 namespace dump { 138 139 extern llvm::cl::opt<bool> DumpSummary; 140 extern llvm::cl::opt<bool> DumpFpm; 141 extern llvm::cl::opt<bool> DumpStreams; 142 extern llvm::cl::opt<bool> DumpSymbolStats; 143 extern llvm::cl::opt<bool> DumpTypeStats; 144 extern llvm::cl::opt<bool> DumpIDStats; 145 extern llvm::cl::opt<bool> DumpUdtStats; 146 extern llvm::cl::opt<bool> DumpStreamBlocks; 147 148 extern llvm::cl::opt<bool> DumpLines; 149 extern llvm::cl::opt<bool> DumpInlineeLines; 150 extern llvm::cl::opt<bool> DumpXmi; 151 extern llvm::cl::opt<bool> DumpXme; 152 extern llvm::cl::opt<bool> DumpNamedStreams; 153 extern llvm::cl::opt<bool> DumpStringTable; 154 extern llvm::cl::opt<bool> DumpStringTableDetails; 155 extern llvm::cl::opt<bool> DumpTypes; 156 extern llvm::cl::opt<bool> DumpTypeData; 157 extern llvm::cl::opt<bool> DumpTypeExtras; 158 extern llvm::cl::list<uint32_t> DumpTypeIndex; 159 extern llvm::cl::opt<bool> DumpTypeDependents; 160 extern llvm::cl::opt<bool> DumpTypeRefStats; 161 extern llvm::cl::opt<bool> DumpSectionHeaders; 162 163 extern llvm::cl::opt<bool> DumpIds; 164 extern llvm::cl::opt<bool> DumpIdData; 165 extern llvm::cl::opt<bool> DumpIdExtras; 166 extern llvm::cl::list<uint32_t> DumpIdIndex; 167 extern llvm::cl::opt<uint32_t> DumpModi; 168 extern llvm::cl::opt<bool> JustMyCode; 169 extern llvm::cl::opt<bool> DontResolveForwardRefs; 170 extern llvm::cl::opt<bool> DumpSymbols; 171 extern llvm::cl::opt<bool> DumpSymRecordBytes; 172 extern llvm::cl::opt<bool> DumpGSIRecords; 173 extern llvm::cl::opt<bool> DumpGlobals; 174 extern llvm::cl::list<std::string> DumpGlobalNames; 175 extern llvm::cl::opt<bool> DumpGlobalExtras; 176 extern llvm::cl::opt<bool> DumpPublics; 177 extern llvm::cl::opt<bool> DumpPublicExtras; 178 extern llvm::cl::opt<bool> DumpSectionContribs; 179 extern llvm::cl::opt<bool> DumpSectionMap; 180 extern llvm::cl::opt<bool> DumpModules; 181 extern llvm::cl::opt<bool> DumpModuleFiles; 182 extern llvm::cl::opt<bool> DumpFpo; 183 extern llvm::cl::opt<bool> RawAll; 184 } 185 186 namespace pdb2yaml { 187 extern llvm::cl::opt<bool> All; 188 extern llvm::cl::opt<bool> NoFileHeaders; 189 extern llvm::cl::opt<bool> Minimal; 190 extern llvm::cl::opt<bool> StreamMetadata; 191 extern llvm::cl::opt<bool> StreamDirectory; 192 extern llvm::cl::opt<bool> StringTable; 193 extern llvm::cl::opt<bool> PdbStream; 194 extern llvm::cl::opt<bool> DbiStream; 195 extern llvm::cl::opt<bool> TpiStream; 196 extern llvm::cl::opt<bool> IpiStream; 197 extern llvm::cl::opt<bool> PublicsStream; 198 extern llvm::cl::list<std::string> InputFilename; 199 extern llvm::cl::opt<bool> DumpModules; 200 extern llvm::cl::opt<bool> DumpModuleFiles; 201 extern llvm::cl::list<ModuleSubsection> DumpModuleSubsections; 202 extern llvm::cl::opt<bool> DumpModuleSyms; 203 } // namespace pdb2yaml 204 205 namespace explain { 206 enum class InputFileType { PDBFile, PDBStream, DBIStream, Names, ModuleStream }; 207 208 extern llvm::cl::list<std::string> InputFilename; 209 extern llvm::cl::list<uint64_t> Offsets; 210 extern llvm::cl::opt<InputFileType> InputType; 211 } // namespace explain 212 213 namespace exportstream { 214 extern llvm::cl::opt<std::string> OutputFile; 215 extern llvm::cl::opt<std::string> Stream; 216 extern llvm::cl::opt<bool> ForceName; 217 } // namespace exportstream 218 } 219 220 #endif 221