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/PointerUnion.h" 14 #include "llvm/DebugInfo/PDB/Native/LinePrinter.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 extern FilterOptions Filters; 54 55 namespace pretty { 56 57 enum class ClassDefinitionFormat { None, Layout, All }; 58 enum class ClassSortMode { 59 None, 60 Name, 61 Size, 62 Padding, 63 PaddingPct, 64 PaddingImmediate, 65 PaddingPctImmediate 66 }; 67 68 enum class SymbolSortMode { None, Name, Size }; 69 70 enum class SymLevel { Functions, Data, Thunks, All }; 71 72 bool shouldDumpSymLevel(SymLevel Level); 73 bool compareFunctionSymbols( 74 const std::unique_ptr<llvm::pdb::PDBSymbolFunc> &F1, 75 const std::unique_ptr<llvm::pdb::PDBSymbolFunc> &F2); 76 bool compareDataSymbols(const std::unique_ptr<llvm::pdb::PDBSymbolData> &F1, 77 const std::unique_ptr<llvm::pdb::PDBSymbolData> &F2); 78 79 extern llvm::cl::list<std::string> WithName; 80 81 extern llvm::cl::opt<bool> Compilands; 82 extern llvm::cl::opt<bool> Symbols; 83 extern llvm::cl::opt<bool> Globals; 84 extern llvm::cl::opt<bool> Classes; 85 extern llvm::cl::opt<bool> Enums; 86 extern llvm::cl::opt<bool> Funcsigs; 87 extern llvm::cl::opt<bool> Arrays; 88 extern llvm::cl::opt<bool> Typedefs; 89 extern llvm::cl::opt<bool> Pointers; 90 extern llvm::cl::opt<bool> VTShapes; 91 extern llvm::cl::opt<bool> All; 92 extern llvm::cl::opt<bool> ExcludeCompilerGenerated; 93 94 extern llvm::cl::opt<bool> NoEnumDefs; 95 extern llvm::cl::list<std::string> ExcludeTypes; 96 extern llvm::cl::list<std::string> ExcludeSymbols; 97 extern llvm::cl::list<std::string> ExcludeCompilands; 98 extern llvm::cl::list<std::string> IncludeTypes; 99 extern llvm::cl::list<std::string> IncludeSymbols; 100 extern llvm::cl::list<std::string> IncludeCompilands; 101 extern llvm::cl::opt<SymbolSortMode> SymbolOrder; 102 extern llvm::cl::opt<ClassSortMode> ClassOrder; 103 extern llvm::cl::opt<uint32_t> SizeThreshold; 104 extern llvm::cl::opt<uint32_t> PaddingThreshold; 105 extern llvm::cl::opt<uint32_t> ImmediatePaddingThreshold; 106 extern llvm::cl::opt<ClassDefinitionFormat> ClassFormat; 107 extern llvm::cl::opt<uint32_t> ClassRecursionDepth; 108 } 109 110 namespace bytes { 111 struct NumberRange { 112 uint64_t Min; 113 std::optional<uint64_t> Max; 114 }; 115 116 extern std::optional<NumberRange> DumpBlockRange; 117 extern std::optional<NumberRange> DumpByteRange; 118 extern llvm::cl::list<std::string> DumpStreamData; 119 extern llvm::cl::opt<bool> NameMap; 120 extern llvm::cl::opt<bool> Fpm; 121 122 extern llvm::cl::opt<bool> SectionContributions; 123 extern llvm::cl::opt<bool> SectionMap; 124 extern llvm::cl::opt<bool> ModuleInfos; 125 extern llvm::cl::opt<bool> FileInfo; 126 extern llvm::cl::opt<bool> TypeServerMap; 127 extern llvm::cl::opt<bool> ECData; 128 129 extern llvm::cl::list<uint32_t> TypeIndex; 130 extern llvm::cl::list<uint32_t> IdIndex; 131 132 extern llvm::cl::opt<uint32_t> ModuleIndex; 133 extern llvm::cl::opt<bool> ModuleSyms; 134 extern llvm::cl::opt<bool> ModuleC11; 135 extern llvm::cl::opt<bool> ModuleC13; 136 extern llvm::cl::opt<bool> SplitChunks; 137 } // namespace bytes 138 139 namespace dump { 140 141 extern llvm::cl::opt<bool> DumpSummary; 142 extern llvm::cl::opt<bool> DumpFpm; 143 extern llvm::cl::opt<bool> DumpStreams; 144 extern llvm::cl::opt<bool> DumpSymbolStats; 145 extern llvm::cl::opt<bool> DumpTypeStats; 146 extern llvm::cl::opt<bool> DumpIDStats; 147 extern llvm::cl::opt<bool> DumpUdtStats; 148 extern llvm::cl::opt<bool> DumpStreamBlocks; 149 150 extern llvm::cl::opt<bool> DumpLines; 151 extern llvm::cl::opt<bool> DumpInlineeLines; 152 extern llvm::cl::opt<bool> DumpXmi; 153 extern llvm::cl::opt<bool> DumpXme; 154 extern llvm::cl::opt<bool> DumpNamedStreams; 155 extern llvm::cl::opt<bool> DumpStringTable; 156 extern llvm::cl::opt<bool> DumpStringTableDetails; 157 extern llvm::cl::opt<bool> DumpTypes; 158 extern llvm::cl::opt<bool> DumpTypeData; 159 extern llvm::cl::opt<bool> DumpTypeExtras; 160 extern llvm::cl::list<uint32_t> DumpTypeIndex; 161 extern llvm::cl::opt<bool> DumpTypeDependents; 162 extern llvm::cl::opt<bool> DumpTypeRefStats; 163 extern llvm::cl::opt<bool> DumpSectionHeaders; 164 165 extern llvm::cl::opt<bool> DumpIds; 166 extern llvm::cl::opt<bool> DumpIdData; 167 extern llvm::cl::opt<bool> DumpIdExtras; 168 extern llvm::cl::list<uint32_t> DumpIdIndex; 169 extern llvm::cl::opt<uint32_t> DumpModi; 170 extern llvm::cl::opt<bool> JustMyCode; 171 extern llvm::cl::opt<bool> DontResolveForwardRefs; 172 extern llvm::cl::opt<bool> DumpSymbols; 173 extern llvm::cl::opt<bool> DumpSymRecordBytes; 174 extern llvm::cl::opt<bool> DumpGSIRecords; 175 extern llvm::cl::opt<bool> DumpGlobals; 176 extern llvm::cl::list<std::string> DumpGlobalNames; 177 extern llvm::cl::opt<bool> DumpGlobalExtras; 178 extern llvm::cl::opt<bool> DumpPublics; 179 extern llvm::cl::opt<bool> DumpPublicExtras; 180 extern llvm::cl::opt<bool> DumpSectionContribs; 181 extern llvm::cl::opt<bool> DumpSectionMap; 182 extern llvm::cl::opt<bool> DumpModules; 183 extern llvm::cl::opt<bool> DumpModuleFiles; 184 extern llvm::cl::opt<bool> DumpFpo; 185 extern llvm::cl::opt<bool> RawAll; 186 } 187 188 namespace pdb2yaml { 189 extern llvm::cl::opt<bool> All; 190 extern llvm::cl::opt<bool> NoFileHeaders; 191 extern llvm::cl::opt<bool> Minimal; 192 extern llvm::cl::opt<bool> StreamMetadata; 193 extern llvm::cl::opt<bool> StreamDirectory; 194 extern llvm::cl::opt<bool> StringTable; 195 extern llvm::cl::opt<bool> PdbStream; 196 extern llvm::cl::opt<bool> DbiStream; 197 extern llvm::cl::opt<bool> TpiStream; 198 extern llvm::cl::opt<bool> IpiStream; 199 extern llvm::cl::opt<bool> PublicsStream; 200 extern llvm::cl::list<std::string> InputFilename; 201 extern llvm::cl::opt<bool> DumpModules; 202 extern llvm::cl::opt<bool> DumpModuleFiles; 203 extern llvm::cl::list<ModuleSubsection> DumpModuleSubsections; 204 extern llvm::cl::opt<bool> DumpModuleSyms; 205 } // namespace pdb2yaml 206 207 namespace explain { 208 enum class InputFileType { PDBFile, PDBStream, DBIStream, Names, ModuleStream }; 209 210 extern llvm::cl::list<std::string> InputFilename; 211 extern llvm::cl::list<uint64_t> Offsets; 212 extern llvm::cl::opt<InputFileType> InputType; 213 } // namespace explain 214 215 namespace exportstream { 216 extern llvm::cl::opt<std::string> OutputFile; 217 extern llvm::cl::opt<std::string> Stream; 218 extern llvm::cl::opt<bool> ForceName; 219 } // namespace exportstream 220 } 221 222 #endif 223