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