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> DumpUdtStats; 145 extern llvm::cl::opt<bool> DumpStreamBlocks; 146 147 extern llvm::cl::opt<bool> DumpLines; 148 extern llvm::cl::opt<bool> DumpInlineeLines; 149 extern llvm::cl::opt<bool> DumpXmi; 150 extern llvm::cl::opt<bool> DumpXme; 151 extern llvm::cl::opt<bool> DumpNamedStreams; 152 extern llvm::cl::opt<bool> DumpStringTable; 153 extern llvm::cl::opt<bool> DumpStringTableDetails; 154 extern llvm::cl::opt<bool> DumpTypes; 155 extern llvm::cl::opt<bool> DumpTypeData; 156 extern llvm::cl::opt<bool> DumpTypeExtras; 157 extern llvm::cl::list<uint32_t> DumpTypeIndex; 158 extern llvm::cl::opt<bool> DumpTypeDependents; 159 extern llvm::cl::opt<bool> DumpTypeRefStats; 160 extern llvm::cl::opt<bool> DumpSectionHeaders; 161 162 extern llvm::cl::opt<bool> DumpIds; 163 extern llvm::cl::opt<bool> DumpIdData; 164 extern llvm::cl::opt<bool> DumpIdExtras; 165 extern llvm::cl::list<uint32_t> DumpIdIndex; 166 extern llvm::cl::opt<uint32_t> DumpModi; 167 extern llvm::cl::opt<bool> JustMyCode; 168 extern llvm::cl::opt<bool> DontResolveForwardRefs; 169 extern llvm::cl::opt<bool> DumpSymbols; 170 extern llvm::cl::opt<bool> DumpSymRecordBytes; 171 extern llvm::cl::opt<bool> DumpGSIRecords; 172 extern llvm::cl::opt<bool> DumpGlobals; 173 extern llvm::cl::list<std::string> DumpGlobalNames; 174 extern llvm::cl::opt<bool> DumpGlobalExtras; 175 extern llvm::cl::opt<bool> DumpPublics; 176 extern llvm::cl::opt<bool> DumpPublicExtras; 177 extern llvm::cl::opt<bool> DumpSectionContribs; 178 extern llvm::cl::opt<bool> DumpSectionMap; 179 extern llvm::cl::opt<bool> DumpModules; 180 extern llvm::cl::opt<bool> DumpModuleFiles; 181 extern llvm::cl::opt<bool> DumpFpo; 182 extern llvm::cl::opt<bool> RawAll; 183 } 184 185 namespace pdb2yaml { 186 extern llvm::cl::opt<bool> All; 187 extern llvm::cl::opt<bool> NoFileHeaders; 188 extern llvm::cl::opt<bool> Minimal; 189 extern llvm::cl::opt<bool> StreamMetadata; 190 extern llvm::cl::opt<bool> StreamDirectory; 191 extern llvm::cl::opt<bool> StringTable; 192 extern llvm::cl::opt<bool> PdbStream; 193 extern llvm::cl::opt<bool> DbiStream; 194 extern llvm::cl::opt<bool> TpiStream; 195 extern llvm::cl::opt<bool> IpiStream; 196 extern llvm::cl::opt<bool> PublicsStream; 197 extern llvm::cl::list<std::string> InputFilename; 198 extern llvm::cl::opt<bool> DumpModules; 199 extern llvm::cl::opt<bool> DumpModuleFiles; 200 extern llvm::cl::list<ModuleSubsection> DumpModuleSubsections; 201 extern llvm::cl::opt<bool> DumpModuleSyms; 202 } // namespace pdb2yaml 203 204 namespace explain { 205 enum class InputFileType { PDBFile, PDBStream, DBIStream, Names, ModuleStream }; 206 207 extern llvm::cl::list<std::string> InputFilename; 208 extern llvm::cl::list<uint64_t> Offsets; 209 extern llvm::cl::opt<InputFileType> InputType; 210 } // namespace explain 211 212 namespace exportstream { 213 extern llvm::cl::opt<std::string> OutputFile; 214 extern llvm::cl::opt<std::string> Stream; 215 extern llvm::cl::opt<bool> ForceName; 216 } // namespace exportstream 217 } 218 219 #endif 220