llvm.org GIT mirror llvm / eb6ab04
[CodeView/PDB] Rename a bunch of files. We were starting to get some name clashes between llvm-pdbdump and the common CodeView framework, so I took this opportunity to rename a bunch of files to more accurately describe their usage. This also helps in llvm-pdbdump to distinguish between different files and whether they are used for pretty dump mode or raw dump mode. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@291627 91177308-0d34-0410-b5e6-96231b3b80d8 Zachary Turner 2 years ago
49 changed file(s) with 2230 addition(s) and 2232 deletion(s). Raw diff Collapse all Expand all
0 //===-- CVTypeDumper.h - CodeView type info dumper --------------*- C++ -*-===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8
9 #ifndef LLVM_DEBUGINFO_CODEVIEW_CVTYPEDUMPER_H
10 #define LLVM_DEBUGINFO_CODEVIEW_CVTYPEDUMPER_H
11
12 #include "llvm/ADT/ArrayRef.h"
13 #include "llvm/ADT/StringSet.h"
14 #include "llvm/DebugInfo/CodeView/TypeDatabase.h"
15 #include "llvm/DebugInfo/CodeView/TypeIndex.h"
16 #include "llvm/DebugInfo/CodeView/TypeRecord.h"
17 #include "llvm/DebugInfo/CodeView/TypeVisitorCallbacks.h"
18
19 namespace llvm {
20 class ScopedPrinter;
21
22 namespace codeview {
23
24 /// Dumper for CodeView type streams found in COFF object files and PDB files.
25 class CVTypeDumper : public TypeVisitorCallbacks {
26 public:
27 CVTypeDumper(ScopedPrinter *W, bool PrintRecordBytes)
28 : W(W), PrintRecordBytes(PrintRecordBytes) {}
29
30 void printTypeIndex(StringRef FieldName, TypeIndex TI);
31
32 /// Dumps one type record. Returns false if there was a type parsing error,
33 /// and true otherwise. This should be called in order, since the dumper
34 /// maintains state about previous records which are necessary for cross
35 /// type references.
36 Error dump(const CVRecord &Record);
37
38 /// Dumps the type records in Types. Returns false if there was a type stream
39 /// parse error, and true otherwise.
40 Error dump(const CVTypeArray &Types);
41
42 /// Dumps the type records in Data. Returns false if there was a type stream
43 /// parse error, and true otherwise. Use this method instead of the
44 /// CVTypeArray overload when type records are laid out contiguously in
45 /// memory.
46 Error dump(ArrayRef Data);
47
48 void setPrinter(ScopedPrinter *P);
49 ScopedPrinter *getPrinter() { return W; }
50
51 /// Action to take on unknown types. By default, they are ignored.
52 Error visitUnknownType(CVType &Record) override;
53 Error visitUnknownMember(CVMemberRecord &Record) override;
54
55 /// Paired begin/end actions for all types. Receives all record data,
56 /// including the fixed-length record prefix.
57 Error visitTypeBegin(CVType &Record) override;
58 Error visitTypeEnd(CVType &Record) override;
59 Error visitMemberBegin(CVMemberRecord &Record) override;
60 Error visitMemberEnd(CVMemberRecord &Record) override;
61
62 #define TYPE_RECORD(EnumName, EnumVal, Name) \
63 Error visitKnownRecord(CVType &CVR, Name##Record &Record) override;
64 #define MEMBER_RECORD(EnumName, EnumVal, Name) \
65 Error visitKnownMember(CVMemberRecord &CVR, Name##Record &Record) override;
66 #define TYPE_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName)
67 #define MEMBER_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName)
68 #include "TypeRecords.def"
69
70 private:
71 void printMemberAttributes(MemberAttributes Attrs);
72 void printMemberAttributes(MemberAccess Access, MethodKind Kind,
73 MethodOptions Options);
74
75 ScopedPrinter *W;
76
77 bool IsInFieldList = false;
78 bool PrintRecordBytes = false;
79
80 TypeDatabase TypeDB;
81 };
82
83 } // end namespace codeview
84 } // end namespace llvm
85
86 #endif // LLVM_DEBUGINFO_CODEVIEW_TYPEDUMPER_H
+0
-87
include/llvm/DebugInfo/CodeView/TypeDumper.h less more
None //===-- TypeDumper.h - CodeView type info dumper ----------------*- C++ -*-===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8
9 #ifndef LLVM_DEBUGINFO_CODEVIEW_TYPEDUMPER_H
10 #define LLVM_DEBUGINFO_CODEVIEW_TYPEDUMPER_H
11
12 #include "llvm/ADT/ArrayRef.h"
13 #include "llvm/ADT/StringSet.h"
14 #include "llvm/DebugInfo/CodeView/TypeDatabase.h"
15 #include "llvm/DebugInfo/CodeView/TypeIndex.h"
16 #include "llvm/DebugInfo/CodeView/TypeRecord.h"
17 #include "llvm/DebugInfo/CodeView/TypeVisitorCallbacks.h"
18
19 namespace llvm {
20 class ScopedPrinter;
21
22 namespace codeview {
23
24 /// Dumper for CodeView type streams found in COFF object files and PDB files.
25 class CVTypeDumper : public TypeVisitorCallbacks {
26 public:
27 CVTypeDumper(ScopedPrinter *W, bool PrintRecordBytes)
28 : W(W), PrintRecordBytes(PrintRecordBytes) {}
29
30 void printTypeIndex(StringRef FieldName, TypeIndex TI);
31
32 /// Dumps one type record. Returns false if there was a type parsing error,
33 /// and true otherwise. This should be called in order, since the dumper
34 /// maintains state about previous records which are necessary for cross
35 /// type references.
36 Error dump(const CVRecord &Record);
37
38 /// Dumps the type records in Types. Returns false if there was a type stream
39 /// parse error, and true otherwise.
40 Error dump(const CVTypeArray &Types);
41
42 /// Dumps the type records in Data. Returns false if there was a type stream
43 /// parse error, and true otherwise. Use this method instead of the
44 /// CVTypeArray overload when type records are laid out contiguously in
45 /// memory.
46 Error dump(ArrayRef Data);
47
48 void setPrinter(ScopedPrinter *P);
49 ScopedPrinter *getPrinter() { return W; }
50
51 /// Action to take on unknown types. By default, they are ignored.
52 Error visitUnknownType(CVType &Record) override;
53 Error visitUnknownMember(CVMemberRecord &Record) override;
54
55 /// Paired begin/end actions for all types. Receives all record data,
56 /// including the fixed-length record prefix.
57 Error visitTypeBegin(CVType &Record) override;
58 Error visitTypeEnd(CVType &Record) override;
59 Error visitMemberBegin(CVMemberRecord &Record) override;
60 Error visitMemberEnd(CVMemberRecord &Record) override;
61
62 #define TYPE_RECORD(EnumName, EnumVal, Name) \
63 Error visitKnownRecord(CVType &CVR, Name##Record &Record) override;
64 #define MEMBER_RECORD(EnumName, EnumVal, Name) \
65 Error visitKnownMember(CVMemberRecord &CVR, Name##Record &Record) override;
66 #define TYPE_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName)
67 #define MEMBER_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName)
68 #include "TypeRecords.def"
69
70 private:
71 void printMemberAttributes(MemberAttributes Attrs);
72 void printMemberAttributes(MemberAccess Access, MethodKind Kind,
73 MethodOptions Options);
74
75 ScopedPrinter *W;
76
77 bool IsInFieldList = false;
78 bool PrintRecordBytes = false;
79
80 TypeDatabase TypeDB;
81 };
82
83 } // end namespace codeview
84 } // end namespace llvm
85
86 #endif // LLVM_DEBUGINFO_CODEVIEW_TYPEDUMPER_H
1212
1313 #include "CodeViewDebug.h"
1414 #include "llvm/ADT/TinyPtrVector.h"
15 #include "llvm/DebugInfo/CodeView/CVTypeDumper.h"
1516 #include "llvm/DebugInfo/CodeView/CVTypeVisitor.h"
1617 #include "llvm/DebugInfo/CodeView/CodeView.h"
1718 #include "llvm/DebugInfo/CodeView/Line.h"
1819 #include "llvm/DebugInfo/CodeView/SymbolRecord.h"
1920 #include "llvm/DebugInfo/CodeView/TypeDatabase.h"
20 #include "llvm/DebugInfo/CodeView/TypeDumper.h"
2121 #include "llvm/DebugInfo/CodeView/TypeIndex.h"
2222 #include "llvm/DebugInfo/CodeView/TypeRecord.h"
2323 #include "llvm/DebugInfo/CodeView/TypeVisitorCallbacks.h"
11 CodeViewError.cpp
22 CodeViewRecordIO.cpp
33 CVSymbolVisitor.cpp
4 CVTypeDumper.cpp
45 CVTypeVisitor.cpp
56 EnumTables.cpp
67 Line.cpp
1112 SymbolDumper.cpp
1213 TypeDatabase.cpp
1314 TypeDatabaseVisitor.cpp
14 TypeDumper.cpp
1515 TypeRecord.cpp
1616 TypeRecordMapping.cpp
1717 TypeSerializer.cpp
0 //===-- CVTypeDumper.cpp - CodeView type info dumper ------------*- C++ -*-===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8
9 #include "llvm/DebugInfo/CodeView/CVTypeDumper.h"
10 #include "llvm/ADT/SmallString.h"
11 #include "llvm/DebugInfo/CodeView/CVTypeVisitor.h"
12 #include "llvm/DebugInfo/CodeView/TypeDatabase.h"
13 #include "llvm/DebugInfo/CodeView/TypeDatabaseVisitor.h"
14 #include "llvm/DebugInfo/CodeView/TypeDeserializer.h"
15 #include "llvm/DebugInfo/CodeView/TypeIndex.h"
16 #include "llvm/DebugInfo/CodeView/TypeRecord.h"
17 #include "llvm/DebugInfo/CodeView/TypeVisitorCallbackPipeline.h"
18 #include "llvm/DebugInfo/MSF/ByteStream.h"
19 #include "llvm/Support/ScopedPrinter.h"
20
21 using namespace llvm;
22 using namespace llvm::codeview;
23
24 static const EnumEntry LeafTypeNames[] = {
25 #define CV_TYPE(enum, val) {#enum, enum},
26 #include "llvm/DebugInfo/CodeView/TypeRecords.def"
27 };
28
29 #define ENUM_ENTRY(enum_class, enum) \
30 { #enum, std::underlying_type < enum_class > ::type(enum_class::enum) }
31
32 static const EnumEntry ClassOptionNames[] = {
33 ENUM_ENTRY(ClassOptions, Packed),
34 ENUM_ENTRY(ClassOptions, HasConstructorOrDestructor),
35 ENUM_ENTRY(ClassOptions, HasOverloadedOperator),
36 ENUM_ENTRY(ClassOptions, Nested),
37 ENUM_ENTRY(ClassOptions, ContainsNestedClass),
38 ENUM_ENTRY(ClassOptions, HasOverloadedAssignmentOperator),
39 ENUM_ENTRY(ClassOptions, HasConversionOperator),
40 ENUM_ENTRY(ClassOptions, ForwardReference),
41 ENUM_ENTRY(ClassOptions, Scoped),
42 ENUM_ENTRY(ClassOptions, HasUniqueName),
43 ENUM_ENTRY(ClassOptions, Sealed),
44 ENUM_ENTRY(ClassOptions, Intrinsic),
45 };
46
47 static const EnumEntry MemberAccessNames[] = {
48 ENUM_ENTRY(MemberAccess, None), ENUM_ENTRY(MemberAccess, Private),
49 ENUM_ENTRY(MemberAccess, Protected), ENUM_ENTRY(MemberAccess, Public),
50 };
51
52 static const EnumEntry MethodOptionNames[] = {
53 ENUM_ENTRY(MethodOptions, Pseudo),
54 ENUM_ENTRY(MethodOptions, NoInherit),
55 ENUM_ENTRY(MethodOptions, NoConstruct),
56 ENUM_ENTRY(MethodOptions, CompilerGenerated),
57 ENUM_ENTRY(MethodOptions, Sealed),
58 };
59
60 static const EnumEntry MemberKindNames[] = {
61 ENUM_ENTRY(MethodKind, Vanilla),
62 ENUM_ENTRY(MethodKind, Virtual),
63 ENUM_ENTRY(MethodKind, Static),
64 ENUM_ENTRY(MethodKind, Friend),
65 ENUM_ENTRY(MethodKind, IntroducingVirtual),
66 ENUM_ENTRY(MethodKind, PureVirtual),
67 ENUM_ENTRY(MethodKind, PureIntroducingVirtual),
68 };
69
70 static const EnumEntry PtrKindNames[] = {
71 ENUM_ENTRY(PointerKind, Near16),
72 ENUM_ENTRY(PointerKind, Far16),
73 ENUM_ENTRY(PointerKind, Huge16),
74 ENUM_ENTRY(PointerKind, BasedOnSegment),
75 ENUM_ENTRY(PointerKind, BasedOnValue),
76 ENUM_ENTRY(PointerKind, BasedOnSegmentValue),
77 ENUM_ENTRY(PointerKind, BasedOnAddress),
78 ENUM_ENTRY(PointerKind, BasedOnSegmentAddress),
79 ENUM_ENTRY(PointerKind, BasedOnType),
80 ENUM_ENTRY(PointerKind, BasedOnSelf),
81 ENUM_ENTRY(PointerKind, Near32),
82 ENUM_ENTRY(PointerKind, Far32),
83 ENUM_ENTRY(PointerKind, Near64),
84 };
85
86 static const EnumEntry PtrModeNames[] = {
87 ENUM_ENTRY(PointerMode, Pointer),
88 ENUM_ENTRY(PointerMode, LValueReference),
89 ENUM_ENTRY(PointerMode, PointerToDataMember),
90 ENUM_ENTRY(PointerMode, PointerToMemberFunction),
91 ENUM_ENTRY(PointerMode, RValueReference),
92 };
93
94 static const EnumEntry PtrMemberRepNames[] = {
95 ENUM_ENTRY(PointerToMemberRepresentation, Unknown),
96 ENUM_ENTRY(PointerToMemberRepresentation, SingleInheritanceData),
97 ENUM_ENTRY(PointerToMemberRepresentation, MultipleInheritanceData),
98 ENUM_ENTRY(PointerToMemberRepresentation, VirtualInheritanceData),
99 ENUM_ENTRY(PointerToMemberRepresentation, GeneralData),
100 ENUM_ENTRY(PointerToMemberRepresentation, SingleInheritanceFunction),
101 ENUM_ENTRY(PointerToMemberRepresentation, MultipleInheritanceFunction),
102 ENUM_ENTRY(PointerToMemberRepresentation, VirtualInheritanceFunction),
103 ENUM_ENTRY(PointerToMemberRepresentation, GeneralFunction),
104 };
105
106 static const EnumEntry TypeModifierNames[] = {
107 ENUM_ENTRY(ModifierOptions, Const), ENUM_ENTRY(ModifierOptions, Volatile),
108 ENUM_ENTRY(ModifierOptions, Unaligned),
109 };
110
111 static const EnumEntry CallingConventions[] = {
112 ENUM_ENTRY(CallingConvention, NearC),
113 ENUM_ENTRY(CallingConvention, FarC),
114 ENUM_ENTRY(CallingConvention, NearPascal),
115 ENUM_ENTRY(CallingConvention, FarPascal),
116 ENUM_ENTRY(CallingConvention, NearFast),
117 ENUM_ENTRY(CallingConvention, FarFast),
118 ENUM_ENTRY(CallingConvention, NearStdCall),
119 ENUM_ENTRY(CallingConvention, FarStdCall),
120 ENUM_ENTRY(CallingConvention, NearSysCall),
121 ENUM_ENTRY(CallingConvention, FarSysCall),
122 ENUM_ENTRY(CallingConvention, ThisCall),
123 ENUM_ENTRY(CallingConvention, MipsCall),
124 ENUM_ENTRY(CallingConvention, Generic),
125 ENUM_ENTRY(CallingConvention, AlphaCall),
126 ENUM_ENTRY(CallingConvention, PpcCall),
127 ENUM_ENTRY(CallingConvention, SHCall),
128 ENUM_ENTRY(CallingConvention, ArmCall),
129 ENUM_ENTRY(CallingConvention, AM33Call),
130 ENUM_ENTRY(CallingConvention, TriCall),
131 ENUM_ENTRY(CallingConvention, SH5Call),
132 ENUM_ENTRY(CallingConvention, M32RCall),
133 ENUM_ENTRY(CallingConvention, ClrCall),
134 ENUM_ENTRY(CallingConvention, Inline),
135 ENUM_ENTRY(CallingConvention, NearVector),
136 };
137
138 static const EnumEntry FunctionOptionEnum[] = {
139 ENUM_ENTRY(FunctionOptions, CxxReturnUdt),
140 ENUM_ENTRY(FunctionOptions, Constructor),
141 ENUM_ENTRY(FunctionOptions, ConstructorWithVirtualBases),
142 };
143
144 #undef ENUM_ENTRY
145
146 static StringRef getLeafTypeName(TypeLeafKind LT) {
147 switch (LT) {
148 #define TYPE_RECORD(ename, value, name) \
149 case ename: \
150 return #name;
151 #include "llvm/DebugInfo/CodeView/TypeRecords.def"
152 default:
153 break;
154 }
155 return "UnknownLeaf";
156 }
157
158 Error CVTypeDumper::visitTypeBegin(CVType &Record) {
159 W->startLine() << getLeafTypeName(Record.Type);
160 W->getOStream() << " (" << HexNumber(TypeDB.getNextTypeIndex().getIndex())
161 << ")";
162 W->getOStream() << " {\n";
163 W->indent();
164 W->printEnum("TypeLeafKind", unsigned(Record.Type),
165 makeArrayRef(LeafTypeNames));
166 return Error::success();
167 }
168
169 Error CVTypeDumper::visitTypeEnd(CVType &Record) {
170 if (PrintRecordBytes)
171 W->printBinaryBlock("LeafData", getBytesAsCharacters(Record.content()));
172
173 W->unindent();
174 W->startLine() << "}\n";
175 return Error::success();
176 }
177
178 Error CVTypeDumper::visitMemberBegin(CVMemberRecord &Record) {
179 W->startLine() << getLeafTypeName(Record.Kind);
180 W->getOStream() << " {\n";
181 W->indent();
182 W->printEnum("TypeLeafKind", unsigned(Record.Kind),
183 makeArrayRef(LeafTypeNames));
184 return Error::success();
185 }
186
187 Error CVTypeDumper::visitMemberEnd(CVMemberRecord &Record) {
188 if (PrintRecordBytes)
189 W->printBinaryBlock("LeafData", getBytesAsCharacters(Record.Data));
190
191 W->unindent();
192 W->startLine() << "}\n";
193 return Error::success();
194 }
195
196 Error CVTypeDumper::visitKnownRecord(CVType &CVR, FieldListRecord &FieldList) {
197 CVTypeVisitor Visitor(*this);
198 if (auto EC = Visitor.visitFieldListMemberStream(FieldList.Data))
199 return EC;
200
201 return Error::success();
202 }
203
204 Error CVTypeDumper::visitKnownRecord(CVType &CVR, StringIdRecord &String) {
205 printTypeIndex("Id", String.getId());
206 W->printString("StringData", String.getString());
207 return Error::success();
208 }
209
210 Error CVTypeDumper::visitKnownRecord(CVType &CVR, ArgListRecord &Args) {
211 auto Indices = Args.getIndices();
212 uint32_t Size = Indices.size();
213 W->printNumber("NumArgs", Size);
214 ListScope Arguments(*W, "Arguments");
215 for (uint32_t I = 0; I < Size; ++I) {
216 printTypeIndex("ArgType", Indices[I]);
217 }
218 return Error::success();
219 }
220
221 Error CVTypeDumper::visitKnownRecord(CVType &CVR, ClassRecord &Class) {
222 uint16_t Props = static_cast(Class.getOptions());
223 W->printNumber("MemberCount", Class.getMemberCount());
224 W->printFlags("Properties", Props, makeArrayRef(ClassOptionNames));
225 printTypeIndex("FieldList", Class.getFieldList());
226 printTypeIndex("DerivedFrom", Class.getDerivationList());
227 printTypeIndex("VShape", Class.getVTableShape());
228 W->printNumber("SizeOf", Class.getSize());
229 W->printString("Name", Class.getName());
230 if (Props & uint16_t(ClassOptions::HasUniqueName))
231 W->printString("LinkageName", Class.getUniqueName());
232 return Error::success();
233 }
234
235 Error CVTypeDumper::visitKnownRecord(CVType &CVR, UnionRecord &Union) {
236 uint16_t Props = static_cast(Union.getOptions());
237 W->printNumber("MemberCount", Union.getMemberCount());
238 W->printFlags("Properties", Props, makeArrayRef(ClassOptionNames));
239 printTypeIndex("FieldList", Union.getFieldList());
240 W->printNumber("SizeOf", Union.getSize());
241 W->printString("Name", Union.getName());
242 if (Props & uint16_t(ClassOptions::HasUniqueName))
243 W->printString("LinkageName", Union.getUniqueName());
244 return Error::success();
245 }
246
247 Error CVTypeDumper::visitKnownRecord(CVType &CVR, EnumRecord &Enum) {
248 uint16_t Props = static_cast(Enum.getOptions());
249 W->printNumber("NumEnumerators", Enum.getMemberCount());
250 W->printFlags("Properties", uint16_t(Enum.getOptions()),
251 makeArrayRef(ClassOptionNames));
252 printTypeIndex("UnderlyingType", Enum.getUnderlyingType());
253 printTypeIndex("FieldListType", Enum.getFieldList());
254 W->printString("Name", Enum.getName());
255 if (Props & uint16_t(ClassOptions::HasUniqueName))
256 W->printString("LinkageName", Enum.getUniqueName());
257 return Error::success();
258 }
259
260 Error CVTypeDumper::visitKnownRecord(CVType &CVR, ArrayRecord &AT) {
261 printTypeIndex("ElementType", AT.getElementType());
262 printTypeIndex("IndexType", AT.getIndexType());
263 W->printNumber("SizeOf", AT.getSize());
264 W->printString("Name", AT.getName());
265 return Error::success();
266 }
267
268 Error CVTypeDumper::visitKnownRecord(CVType &CVR, VFTableRecord &VFT) {
269 printTypeIndex("CompleteClass", VFT.getCompleteClass());
270 printTypeIndex("OverriddenVFTable", VFT.getOverriddenVTable());
271 W->printHex("VFPtrOffset", VFT.getVFPtrOffset());
272 W->printString("VFTableName", VFT.getName());
273 for (auto N : VFT.getMethodNames())
274 W->printString("MethodName", N);
275 return Error::success();
276 }
277
278 Error CVTypeDumper::visitKnownRecord(CVType &CVR, MemberFuncIdRecord &Id) {
279 printTypeIndex("ClassType", Id.getClassType());
280 printTypeIndex("FunctionType", Id.getFunctionType());
281 W->printString("Name", Id.getName());
282 return Error::success();
283 }
284
285 Error CVTypeDumper::visitKnownRecord(CVType &CVR, ProcedureRecord &Proc) {
286 printTypeIndex("ReturnType", Proc.getReturnType());
287 W->printEnum("CallingConvention", uint8_t(Proc.getCallConv()),
288 makeArrayRef(CallingConventions));
289 W->printFlags("FunctionOptions", uint8_t(Proc.getOptions()),
290 makeArrayRef(FunctionOptionEnum));
291 W->printNumber("NumParameters", Proc.getParameterCount());
292 printTypeIndex("ArgListType", Proc.getArgumentList());
293 return Error::success();
294 }
295
296 Error CVTypeDumper::visitKnownRecord(CVType &CVR, MemberFunctionRecord &MF) {
297 printTypeIndex("ReturnType", MF.getReturnType());
298 printTypeIndex("ClassType", MF.getClassType());
299 printTypeIndex("ThisType", MF.getThisType());
300 W->printEnum("CallingConvention", uint8_t(MF.getCallConv()),
301 makeArrayRef(CallingConventions));
302 W->printFlags("FunctionOptions", uint8_t(MF.getOptions()),
303 makeArrayRef(FunctionOptionEnum));
304 W->printNumber("NumParameters", MF.getParameterCount());
305 printTypeIndex("ArgListType", MF.getArgumentList());
306 W->printNumber("ThisAdjustment", MF.getThisPointerAdjustment());
307 return Error::success();
308 }
309
310 Error CVTypeDumper::visitKnownRecord(CVType &CVR,
311 MethodOverloadListRecord &MethodList) {
312 for (auto &M : MethodList.getMethods()) {
313 ListScope S(*W, "Method");
314 printMemberAttributes(M.getAccess(), M.getMethodKind(), M.getOptions());
315 printTypeIndex("Type", M.getType());
316 if (M.isIntroducingVirtual())
317 W->printHex("VFTableOffset", M.getVFTableOffset());
318 }
319 return Error::success();
320 }
321
322 Error CVTypeDumper::visitKnownRecord(CVType &CVR, FuncIdRecord &Func) {
323 printTypeIndex("ParentScope", Func.getParentScope());
324 printTypeIndex("FunctionType", Func.getFunctionType());
325 W->printString("Name", Func.getName());
326 return Error::success();
327 }
328
329 Error CVTypeDumper::visitKnownRecord(CVType &CVR, TypeServer2Record &TS) {
330 W->printBinary("Signature", TS.getGuid());
331 W->printNumber("Age", TS.getAge());
332 W->printString("Name", TS.getName());
333 return Error::success();
334 }
335
336 Error CVTypeDumper::visitKnownRecord(CVType &CVR, PointerRecord &Ptr) {
337 printTypeIndex("PointeeType", Ptr.getReferentType());
338 W->printHex("PointerAttributes", uint32_t(Ptr.getOptions()));
339 W->printEnum("PtrType", unsigned(Ptr.getPointerKind()),
340 makeArrayRef(PtrKindNames));
341 W->printEnum("PtrMode", unsigned(Ptr.getMode()), makeArrayRef(PtrModeNames));
342
343 W->printNumber("IsFlat", Ptr.isFlat());
344 W->printNumber("IsConst", Ptr.isConst());
345 W->printNumber("IsVolatile", Ptr.isVolatile());
346 W->printNumber("IsUnaligned", Ptr.isUnaligned());
347 W->printNumber("SizeOf", Ptr.getSize());
348
349 if (Ptr.isPointerToMember()) {
350 const MemberPointerInfo &MI = Ptr.getMemberInfo();
351
352 printTypeIndex("ClassType", MI.getContainingType());
353 W->printEnum("Representation", uint16_t(MI.getRepresentation()),
354 makeArrayRef(PtrMemberRepNames));
355 }
356
357 return Error::success();
358 }
359
360 Error CVTypeDumper::visitKnownRecord(CVType &CVR, ModifierRecord &Mod) {
361 uint16_t Mods = static_cast(Mod.getModifiers());
362 printTypeIndex("ModifiedType", Mod.getModifiedType());
363 W->printFlags("Modifiers", Mods, makeArrayRef(TypeModifierNames));
364
365 return Error::success();
366 }
367
368 Error CVTypeDumper::visitKnownRecord(CVType &CVR, BitFieldRecord &BitField) {
369 printTypeIndex("Type", BitField.getType());
370 W->printNumber("BitSize", BitField.getBitSize());
371 W->printNumber("BitOffset", BitField.getBitOffset());
372 return Error::success();
373 }
374
375 Error CVTypeDumper::visitKnownRecord(CVType &CVR, VFTableShapeRecord &Shape) {
376 W->printNumber("VFEntryCount", Shape.getEntryCount());
377 return Error::success();
378 }
379
380 Error CVTypeDumper::visitKnownRecord(CVType &CVR, UdtSourceLineRecord &Line) {
381 printTypeIndex("UDT", Line.getUDT());
382 printTypeIndex("SourceFile", Line.getSourceFile());
383 W->printNumber("LineNumber", Line.getLineNumber());
384 return Error::success();
385 }
386
387 Error CVTypeDumper::visitKnownRecord(CVType &CVR,
388 UdtModSourceLineRecord &Line) {
389 printTypeIndex("UDT", Line.getUDT());
390 printTypeIndex("SourceFile", Line.getSourceFile());
391 W->printNumber("LineNumber", Line.getLineNumber());
392 W->printNumber("Module", Line.getModule());
393 return Error::success();
394 }
395
396 Error CVTypeDumper::visitKnownRecord(CVType &CVR, BuildInfoRecord &Args) {
397 W->printNumber("NumArgs", static_cast(Args.getArgs().size()));
398
399 ListScope Arguments(*W, "Arguments");
400 for (auto Arg : Args.getArgs()) {
401 printTypeIndex("ArgType", Arg);
402 }
403 return Error::success();
404 }
405
406 void CVTypeDumper::printMemberAttributes(MemberAttributes Attrs) {
407 return printMemberAttributes(Attrs.getAccess(), Attrs.getMethodKind(),
408 Attrs.getFlags());
409 }
410
411 void CVTypeDumper::printMemberAttributes(MemberAccess Access, MethodKind Kind,
412 MethodOptions Options) {
413 W->printEnum("AccessSpecifier", uint8_t(Access),
414 makeArrayRef(MemberAccessNames));
415 // Data members will be vanilla. Don't try to print a method kind for them.
416 if (Kind != MethodKind::Vanilla)
417 W->printEnum("MethodKind", unsigned(Kind), makeArrayRef(MemberKindNames));
418 if (Options != MethodOptions::None) {
419 W->printFlags("MethodOptions", unsigned(Options),
420 makeArrayRef(MethodOptionNames));
421 }
422 }
423
424 Error CVTypeDumper::visitUnknownMember(CVMemberRecord &Record) {
425 W->printHex("UnknownMember", unsigned(Record.Kind));
426 return Error::success();
427 }
428
429 Error CVTypeDumper::visitUnknownType(CVType &Record) {
430 W->printEnum("Kind", uint16_t(Record.kind()), makeArrayRef(LeafTypeNames));
431 W->printNumber("Length", uint32_t(Record.content().size()));
432 return Error::success();
433 }
434
435 Error CVTypeDumper::visitKnownMember(CVMemberRecord &CVR,
436 NestedTypeRecord &Nested) {
437 printTypeIndex("Type", Nested.getNestedType());
438 W->printString("Name", Nested.getName());
439 return Error::success();
440 }
441
442 Error CVTypeDumper::visitKnownMember(CVMemberRecord &CVR,
443 OneMethodRecord &Method) {
444 MethodKind K = Method.getMethodKind();
445 printMemberAttributes(Method.getAccess(), K, Method.getOptions());
446 printTypeIndex("Type", Method.getType());
447 // If virtual, then read the vftable offset.
448 if (Method.isIntroducingVirtual())
449 W->printHex("VFTableOffset", Method.getVFTableOffset());
450 W->printString("Name", Method.getName());
451 return Error::success();
452 }
453
454 Error CVTypeDumper::visitKnownMember(CVMemberRecord &CVR,
455 OverloadedMethodRecord &Method) {
456 W->printHex("MethodCount", Method.getNumOverloads());
457 printTypeIndex("MethodListIndex", Method.getMethodList());
458 W->printString("Name", Method.getName());
459 return Error::success();
460 }
461
462 Error CVTypeDumper::visitKnownMember(CVMemberRecord &CVR,
463 DataMemberRecord &Field) {
464 printMemberAttributes(Field.getAccess(), MethodKind::Vanilla,
465 MethodOptions::None);
466 printTypeIndex("Type", Field.getType());
467 W->printHex("FieldOffset", Field.getFieldOffset());
468 W->printString("Name", Field.getName());
469 return Error::success();
470 }
471
472 Error CVTypeDumper::visitKnownMember(CVMemberRecord &CVR,
473 StaticDataMemberRecord &Field) {
474 printMemberAttributes(Field.getAccess(), MethodKind::Vanilla,
475 MethodOptions::None);
476 printTypeIndex("Type", Field.getType());
477 W->printString("Name", Field.getName());
478 return Error::success();
479 }
480
481 Error CVTypeDumper::visitKnownMember(CVMemberRecord &CVR,
482 VFPtrRecord &VFTable) {
483 printTypeIndex("Type", VFTable.getType());
484 return Error::success();
485 }
486
487 Error CVTypeDumper::visitKnownMember(CVMemberRecord &CVR,
488 EnumeratorRecord &Enum) {
489 printMemberAttributes(Enum.getAccess(), MethodKind::Vanilla,
490 MethodOptions::None);
491 W->printNumber("EnumValue", Enum.getValue());
492 W->printString("Name", Enum.getName());
493 return Error::success();
494 }
495
496 Error CVTypeDumper::visitKnownMember(CVMemberRecord &CVR,
497 BaseClassRecord &Base) {
498 printMemberAttributes(Base.getAccess(), MethodKind::Vanilla,
499 MethodOptions::None);
500 printTypeIndex("BaseType", Base.getBaseType());
501 W->printHex("BaseOffset", Base.getBaseOffset());
502 return Error::success();
503 }
504
505 Error CVTypeDumper::visitKnownMember(CVMemberRecord &CVR,
506 VirtualBaseClassRecord &Base) {
507 printMemberAttributes(Base.getAccess(), MethodKind::Vanilla,
508 MethodOptions::None);
509 printTypeIndex("BaseType", Base.getBaseType());
510 printTypeIndex("VBPtrType", Base.getVBPtrType());
511 W->printHex("VBPtrOffset", Base.getVBPtrOffset());
512 W->printHex("VBTableIndex", Base.getVTableIndex());
513 return Error::success();
514 }
515
516 Error CVTypeDumper::visitKnownMember(CVMemberRecord &CVR,
517 ListContinuationRecord &Cont) {
518 printTypeIndex("ContinuationIndex", Cont.getContinuationIndex());
519 return Error::success();
520 }
521
522 void CVTypeDumper::printTypeIndex(StringRef FieldName, TypeIndex TI) {
523 StringRef TypeName;
524 if (!TI.isNoneType())
525 TypeName = TypeDB.getTypeName(TI);
526 if (!TypeName.empty())
527 W->printHex(FieldName, TypeName, TI.getIndex());
528 else
529 W->printHex(FieldName, TI.getIndex());
530 }
531
532 Error CVTypeDumper::dump(const CVType &Record) {
533 assert(W && "printer should not be null");
534 TypeDatabaseVisitor DBV(TypeDB);
535 TypeDeserializer Deserializer;
536 TypeVisitorCallbackPipeline Pipeline;
537 Pipeline.addCallbackToPipeline(Deserializer);
538 Pipeline.addCallbackToPipeline(DBV);
539 Pipeline.addCallbackToPipeline(*this);
540
541 CVTypeVisitor Visitor(Pipeline);
542
543 CVType RecordCopy = Record;
544 if (auto EC = Visitor.visitTypeRecord(RecordCopy))
545 return EC;
546 return Error::success();
547 }
548
549 Error CVTypeDumper::dump(const CVTypeArray &Types) {
550 assert(W && "printer should not be null");
551 TypeDatabaseVisitor DBV(TypeDB);
552 TypeDeserializer Deserializer;
553 TypeVisitorCallbackPipeline Pipeline;
554 Pipeline.addCallbackToPipeline(Deserializer);
555 Pipeline.addCallbackToPipeline(DBV);
556 Pipeline.addCallbackToPipeline(*this);
557
558 CVTypeVisitor Visitor(Pipeline);
559
560 if (auto EC = Visitor.visitTypeStream(Types))
561 return EC;
562 return Error::success();
563 }
564
565 Error CVTypeDumper::dump(ArrayRef Data) {
566 msf::ByteStream Stream(Data);
567 CVTypeArray Types;
568 msf::StreamReader Reader(Stream);
569 if (auto EC = Reader.readArray(Types, Reader.getLength()))
570 return EC;
571
572 return dump(Types);
573 }
574
575 void CVTypeDumper::setPrinter(ScopedPrinter *P) {
576 static ScopedPrinter NullP(llvm::nulls());
577 W = P ? P : &NullP;
578 }
1010 #include "llvm/ADT/DenseMap.h"
1111 #include "llvm/ADT/SmallString.h"
1212 #include "llvm/DebugInfo/CodeView/CVSymbolVisitor.h"
13 #include "llvm/DebugInfo/CodeView/CVTypeDumper.h"
1314 #include "llvm/DebugInfo/CodeView/EnumTables.h"
1415 #include "llvm/DebugInfo/CodeView/SymbolDeserializer.h"
1516 #include "llvm/DebugInfo/CodeView/SymbolDumpDelegate.h"
1617 #include "llvm/DebugInfo/CodeView/SymbolRecord.h"
1718 #include "llvm/DebugInfo/CodeView/SymbolVisitorCallbackPipeline.h"
1819 #include "llvm/DebugInfo/CodeView/SymbolVisitorCallbacks.h"
19 #include "llvm/DebugInfo/CodeView/TypeDumper.h"
2020 #include "llvm/DebugInfo/CodeView/TypeIndex.h"
2121 #include "llvm/Support/Error.h"
2222 #include "llvm/Support/ScopedPrinter.h"
+0
-582
lib/DebugInfo/CodeView/TypeDumper.cpp less more
None //===-- TypeDumper.cpp - CodeView type info dumper --------------*- C++ -*-===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8
9 #include "llvm/DebugInfo/CodeView/TypeDumper.h"
10 #include "llvm/ADT/SmallString.h"
11 #include "llvm/DebugInfo/CodeView/CVTypeVisitor.h"
12 #include "llvm/DebugInfo/CodeView/TypeDatabase.h"
13 #include "llvm/DebugInfo/CodeView/TypeDatabaseVisitor.h"
14 #include "llvm/DebugInfo/CodeView/TypeDeserializer.h"
15 #include "llvm/DebugInfo/CodeView/TypeIndex.h"
16 #include "llvm/DebugInfo/CodeView/TypeRecord.h"
17 #include "llvm/DebugInfo/CodeView/TypeVisitorCallbackPipeline.h"
18 #include "llvm/DebugInfo/MSF/ByteStream.h"
19 #include "llvm/Support/ScopedPrinter.h"
20
21 using namespace llvm;
22 using namespace llvm::codeview;
23
24 static const EnumEntry LeafTypeNames[] = {
25 #define CV_TYPE(enum, val) {#enum, enum},
26 #include "llvm/DebugInfo/CodeView/TypeRecords.def"
27 };
28
29 #define ENUM_ENTRY(enum_class, enum) \
30 { #enum, std::underlying_type < enum_class > ::type(enum_class::enum) }
31
32 static const EnumEntry ClassOptionNames[] = {
33 ENUM_ENTRY(ClassOptions, Packed),
34 ENUM_ENTRY(ClassOptions, HasConstructorOrDestructor),
35 ENUM_ENTRY(ClassOptions, HasOverloadedOperator),
36 ENUM_ENTRY(ClassOptions, Nested),
37 ENUM_ENTRY(ClassOptions, ContainsNestedClass),
38 ENUM_ENTRY(ClassOptions, HasOverloadedAssignmentOperator),
39 ENUM_ENTRY(ClassOptions, HasConversionOperator),
40 ENUM_ENTRY(ClassOptions, ForwardReference),
41 ENUM_ENTRY(ClassOptions, Scoped),
42 ENUM_ENTRY(ClassOptions, HasUniqueName),
43 ENUM_ENTRY(ClassOptions, Sealed),
44 ENUM_ENTRY(ClassOptions, Intrinsic),
45 };
46
47 static const EnumEntry MemberAccessNames[] = {
48 ENUM_ENTRY(MemberAccess, None),
49 ENUM_ENTRY(MemberAccess, Private),
50 ENUM_ENTRY(MemberAccess, Protected),
51 ENUM_ENTRY(MemberAccess, Public),
52 };
53
54 static const EnumEntry MethodOptionNames[] = {
55 ENUM_ENTRY(MethodOptions, Pseudo),
56 ENUM_ENTRY(MethodOptions, NoInherit),
57 ENUM_ENTRY(MethodOptions, NoConstruct),
58 ENUM_ENTRY(MethodOptions, CompilerGenerated),
59 ENUM_ENTRY(MethodOptions, Sealed),
60 };
61
62 static const EnumEntry MemberKindNames[] = {
63 ENUM_ENTRY(MethodKind, Vanilla),
64 ENUM_ENTRY(MethodKind, Virtual),
65 ENUM_ENTRY(MethodKind, Static),
66 ENUM_ENTRY(MethodKind, Friend),
67 ENUM_ENTRY(MethodKind, IntroducingVirtual),
68 ENUM_ENTRY(MethodKind, PureVirtual),
69 ENUM_ENTRY(MethodKind, PureIntroducingVirtual),
70 };
71
72 static const EnumEntry PtrKindNames[] = {
73 ENUM_ENTRY(PointerKind, Near16),
74 ENUM_ENTRY(PointerKind, Far16),
75 ENUM_ENTRY(PointerKind, Huge16),
76 ENUM_ENTRY(PointerKind, BasedOnSegment),
77 ENUM_ENTRY(PointerKind, BasedOnValue),
78 ENUM_ENTRY(PointerKind, BasedOnSegmentValue),
79 ENUM_ENTRY(PointerKind, BasedOnAddress),
80 ENUM_ENTRY(PointerKind, BasedOnSegmentAddress),
81 ENUM_ENTRY(PointerKind, BasedOnType),
82 ENUM_ENTRY(PointerKind, BasedOnSelf),
83 ENUM_ENTRY(PointerKind, Near32),
84 ENUM_ENTRY(PointerKind, Far32),
85 ENUM_ENTRY(PointerKind, Near64),
86 };
87
88 static const EnumEntry PtrModeNames[] = {
89 ENUM_ENTRY(PointerMode, Pointer),
90 ENUM_ENTRY(PointerMode, LValueReference),
91 ENUM_ENTRY(PointerMode, PointerToDataMember),
92 ENUM_ENTRY(PointerMode, PointerToMemberFunction),
93 ENUM_ENTRY(PointerMode, RValueReference),
94 };
95
96 static const EnumEntry PtrMemberRepNames[] = {
97 ENUM_ENTRY(PointerToMemberRepresentation, Unknown),
98 ENUM_ENTRY(PointerToMemberRepresentation, SingleInheritanceData),
99 ENUM_ENTRY(PointerToMemberRepresentation, MultipleInheritanceData),
100 ENUM_ENTRY(PointerToMemberRepresentation, VirtualInheritanceData),
101 ENUM_ENTRY(PointerToMemberRepresentation, GeneralData),
102 ENUM_ENTRY(PointerToMemberRepresentation, SingleInheritanceFunction),
103 ENUM_ENTRY(PointerToMemberRepresentation, MultipleInheritanceFunction),
104 ENUM_ENTRY(PointerToMemberRepresentation, VirtualInheritanceFunction),
105 ENUM_ENTRY(PointerToMemberRepresentation, GeneralFunction),
106 };
107
108 static const EnumEntry TypeModifierNames[] = {
109 ENUM_ENTRY(ModifierOptions, Const),
110 ENUM_ENTRY(ModifierOptions, Volatile),
111 ENUM_ENTRY(ModifierOptions, Unaligned),
112 };
113
114 static const EnumEntry CallingConventions[] = {
115 ENUM_ENTRY(CallingConvention, NearC),
116 ENUM_ENTRY(CallingConvention, FarC),
117 ENUM_ENTRY(CallingConvention, NearPascal),
118 ENUM_ENTRY(CallingConvention, FarPascal),
119 ENUM_ENTRY(CallingConvention, NearFast),
120 ENUM_ENTRY(CallingConvention, FarFast),
121 ENUM_ENTRY(CallingConvention, NearStdCall),
122 ENUM_ENTRY(CallingConvention, FarStdCall),
123 ENUM_ENTRY(CallingConvention, NearSysCall),
124 ENUM_ENTRY(CallingConvention, FarSysCall),
125 ENUM_ENTRY(CallingConvention, ThisCall),
126 ENUM_ENTRY(CallingConvention, MipsCall),
127 ENUM_ENTRY(CallingConvention, Generic),
128 ENUM_ENTRY(CallingConvention, AlphaCall),
129 ENUM_ENTRY(CallingConvention, PpcCall),
130 ENUM_ENTRY(CallingConvention, SHCall),
131 ENUM_ENTRY(CallingConvention, ArmCall),
132 ENUM_ENTRY(CallingConvention, AM33Call),
133 ENUM_ENTRY(CallingConvention, TriCall),
134 ENUM_ENTRY(CallingConvention, SH5Call),
135 ENUM_ENTRY(CallingConvention, M32RCall),
136 ENUM_ENTRY(CallingConvention, ClrCall),
137 ENUM_ENTRY(CallingConvention, Inline),
138 ENUM_ENTRY(CallingConvention, NearVector),
139 };
140
141 static const EnumEntry FunctionOptionEnum[] = {
142 ENUM_ENTRY(FunctionOptions, CxxReturnUdt),
143 ENUM_ENTRY(FunctionOptions, Constructor),
144 ENUM_ENTRY(FunctionOptions, ConstructorWithVirtualBases),
145 };
146
147 #undef ENUM_ENTRY
148
149 static StringRef getLeafTypeName(TypeLeafKind LT) {
150 switch (LT) {
151 #define TYPE_RECORD(ename, value, name) \
152 case ename: \
153 return #name;
154 #include "llvm/DebugInfo/CodeView/TypeRecords.def"
155 default:
156 break;
157 }
158 return "UnknownLeaf";
159 }
160
161 Error CVTypeDumper::visitTypeBegin(CVType &Record) {
162 W->startLine() << getLeafTypeName(Record.Type);
163 W->getOStream() << " (" << HexNumber(TypeDB.getNextTypeIndex().getIndex())
164 << ")";
165 W->getOStream() << " {\n";
166 W->indent();
167 W->printEnum("TypeLeafKind", unsigned(Record.Type),
168 makeArrayRef(LeafTypeNames));
169 return Error::success();
170 }
171
172 Error CVTypeDumper::visitTypeEnd(CVType &Record) {
173 if (PrintRecordBytes)
174 W->printBinaryBlock("LeafData", getBytesAsCharacters(Record.content()));
175
176 W->unindent();
177 W->startLine() << "}\n";
178 return Error::success();
179 }
180
181 Error CVTypeDumper::visitMemberBegin(CVMemberRecord &Record) {
182 W->startLine() << getLeafTypeName(Record.Kind);
183 W->getOStream() << " {\n";
184 W->indent();
185 W->printEnum("TypeLeafKind", unsigned(Record.Kind),
186 makeArrayRef(LeafTypeNames));
187 return Error::success();
188 }
189
190 Error CVTypeDumper::visitMemberEnd(CVMemberRecord &Record) {
191 if (PrintRecordBytes)
192 W->printBinaryBlock("LeafData", getBytesAsCharacters(Record.Data));
193
194 W->unindent();
195 W->startLine() << "}\n";
196 return Error::success();
197 }
198
199 Error CVTypeDumper::visitKnownRecord(CVType &CVR, FieldListRecord &FieldList) {
200 CVTypeVisitor Visitor(*this);
201 if (auto EC = Visitor.visitFieldListMemberStream(FieldList.Data))
202 return EC;
203
204 return Error::success();
205 }
206
207 Error CVTypeDumper::visitKnownRecord(CVType &CVR, StringIdRecord &String) {
208 printTypeIndex("Id", String.getId());
209 W->printString("StringData", String.getString());
210 return Error::success();
211 }
212
213 Error CVTypeDumper::visitKnownRecord(CVType &CVR, ArgListRecord &Args) {
214 auto Indices = Args.getIndices();
215 uint32_t Size = Indices.size();
216 W->printNumber("NumArgs", Size);
217 ListScope Arguments(*W, "Arguments");
218 for (uint32_t I = 0; I < Size; ++I) {
219 printTypeIndex("ArgType", Indices[I]);
220 }
221 return Error::success();
222 }
223
224 Error CVTypeDumper::visitKnownRecord(CVType &CVR, ClassRecord &Class) {
225 uint16_t Props = static_cast(Class.getOptions());
226 W->printNumber("MemberCount", Class.getMemberCount());
227 W->printFlags("Properties", Props, makeArrayRef(ClassOptionNames));
228 printTypeIndex("FieldList", Class.getFieldList());
229 printTypeIndex("DerivedFrom", Class.getDerivationList());
230 printTypeIndex("VShape", Class.getVTableShape());
231 W->printNumber("SizeOf", Class.getSize());
232 W->printString("Name", Class.getName());
233 if (Props & uint16_t(ClassOptions::HasUniqueName))
234 W->printString("LinkageName", Class.getUniqueName());
235 return Error::success();
236 }
237
238 Error CVTypeDumper::visitKnownRecord(CVType &CVR, UnionRecord &Union) {
239 uint16_t Props = static_cast(Union.getOptions());
240 W->printNumber("MemberCount", Union.getMemberCount());
241 W->printFlags("Properties", Props, makeArrayRef(ClassOptionNames));
242 printTypeIndex("FieldList", Union.getFieldList());
243 W->printNumber("SizeOf", Union.getSize());
244 W->printString("Name", Union.getName());
245 if (Props & uint16_t(ClassOptions::HasUniqueName))
246 W->printString("LinkageName", Union.getUniqueName());
247 return Error::success();
248 }
249
250 Error CVTypeDumper::visitKnownRecord(CVType &CVR, EnumRecord &Enum) {
251 uint16_t Props = static_cast(Enum.getOptions());
252 W->printNumber("NumEnumerators", Enum.getMemberCount());
253 W->printFlags("Properties", uint16_t(Enum.getOptions()),
254 makeArrayRef(ClassOptionNames));
255 printTypeIndex("UnderlyingType", Enum.getUnderlyingType());
256 printTypeIndex("FieldListType", Enum.getFieldList());
257 W->printString("Name", Enum.getName());
258 if (Props & uint16_t(ClassOptions::HasUniqueName))
259 W->printString("LinkageName", Enum.getUniqueName());
260 return Error::success();
261 }
262
263 Error CVTypeDumper::visitKnownRecord(CVType &CVR, ArrayRecord &AT) {
264 printTypeIndex("ElementType", AT.getElementType());
265 printTypeIndex("IndexType", AT.getIndexType());
266 W->printNumber("SizeOf", AT.getSize());
267 W->printString("Name", AT.getName());
268 return Error::success();
269 }
270
271 Error CVTypeDumper::visitKnownRecord(CVType &CVR, VFTableRecord &VFT) {
272 printTypeIndex("CompleteClass", VFT.getCompleteClass());
273 printTypeIndex("OverriddenVFTable", VFT.getOverriddenVTable());
274 W->printHex("VFPtrOffset", VFT.getVFPtrOffset());
275 W->printString("VFTableName", VFT.getName());
276 for (auto N : VFT.getMethodNames())
277 W->printString("MethodName", N);
278 return Error::success();
279 }
280
281 Error CVTypeDumper::visitKnownRecord(CVType &CVR, MemberFuncIdRecord &Id) {
282 printTypeIndex("ClassType", Id.getClassType());
283 printTypeIndex("FunctionType", Id.getFunctionType());
284 W->printString("Name", Id.getName());
285 return Error::success();
286 }
287
288 Error CVTypeDumper::visitKnownRecord(CVType &CVR, ProcedureRecord &Proc) {
289 printTypeIndex("ReturnType", Proc.getReturnType());
290 W->printEnum("CallingConvention", uint8_t(Proc.getCallConv()),
291 makeArrayRef(CallingConventions));
292 W->printFlags("FunctionOptions", uint8_t(Proc.getOptions()),
293 makeArrayRef(FunctionOptionEnum));
294 W->printNumber("NumParameters", Proc.getParameterCount());
295 printTypeIndex("ArgListType", Proc.getArgumentList());
296 return Error::success();
297 }
298
299 Error CVTypeDumper::visitKnownRecord(CVType &CVR, MemberFunctionRecord &MF) {
300 printTypeIndex("ReturnType", MF.getReturnType());
301 printTypeIndex("ClassType", MF.getClassType());
302 printTypeIndex("ThisType", MF.getThisType());
303 W->printEnum("CallingConvention", uint8_t(MF.getCallConv()),
304 makeArrayRef(CallingConventions));
305 W->printFlags("FunctionOptions", uint8_t(MF.getOptions()),
306 makeArrayRef(FunctionOptionEnum));
307 W->printNumber("NumParameters", MF.getParameterCount());
308 printTypeIndex("ArgListType", MF.getArgumentList());
309 W->printNumber("ThisAdjustment", MF.getThisPointerAdjustment());
310 return Error::success();
311 }
312
313 Error CVTypeDumper::visitKnownRecord(CVType &CVR,
314 MethodOverloadListRecord &MethodList) {
315 for (auto &M : MethodList.getMethods()) {
316 ListScope S(*W, "Method");
317 printMemberAttributes(M.getAccess(), M.getMethodKind(), M.getOptions());
318 printTypeIndex("Type", M.getType());
319 if (M.isIntroducingVirtual())
320 W->printHex("VFTableOffset", M.getVFTableOffset());
321 }
322 return Error::success();
323 }
324
325 Error CVTypeDumper::visitKnownRecord(CVType &CVR, FuncIdRecord &Func) {
326 printTypeIndex("ParentScope", Func.getParentScope());
327 printTypeIndex("FunctionType", Func.getFunctionType());
328 W->printString("Name", Func.getName());
329 return Error::success();
330 }
331
332 Error CVTypeDumper::visitKnownRecord(CVType &CVR, TypeServer2Record &TS) {
333 W->printBinary("Signature", TS.getGuid());
334 W->printNumber("Age", TS.getAge());
335 W->printString("Name", TS.getName());
336 return Error::success();
337 }
338
339 Error CVTypeDumper::visitKnownRecord(CVType &CVR, PointerRecord &Ptr) {
340 printTypeIndex("PointeeType", Ptr.getReferentType());
341 W->printHex("PointerAttributes", uint32_t(Ptr.getOptions()));
342 W->printEnum("PtrType", unsigned(Ptr.getPointerKind()),
343 makeArrayRef(PtrKindNames));
344 W->printEnum("PtrMode", unsigned(Ptr.getMode()), makeArrayRef(PtrModeNames));
345
346 W->printNumber("IsFlat", Ptr.isFlat());
347 W->printNumber("IsConst", Ptr.isConst());
348 W->printNumber("IsVolatile", Ptr.isVolatile());
349 W->printNumber("IsUnaligned", Ptr.isUnaligned());
350 W->printNumber("SizeOf", Ptr.getSize());
351
352 if (Ptr.isPointerToMember()) {
353 const MemberPointerInfo &MI = Ptr.getMemberInfo();
354
355 printTypeIndex("ClassType", MI.getContainingType());
356 W->printEnum("Representation", uint16_t(MI.getRepresentation()),
357 makeArrayRef(PtrMemberRepNames));
358 }
359
360 return Error::success();
361 }
362
363 Error CVTypeDumper::visitKnownRecord(CVType &CVR, ModifierRecord &Mod) {
364 uint16_t Mods = static_cast(Mod.getModifiers());
365 printTypeIndex("ModifiedType", Mod.getModifiedType());
366 W->printFlags("Modifiers", Mods, makeArrayRef(TypeModifierNames));
367
368 return Error::success();
369 }
370
371 Error CVTypeDumper::visitKnownRecord(CVType &CVR, BitFieldRecord &BitField) {
372 printTypeIndex("Type", BitField.getType());
373 W->printNumber("BitSize", BitField.getBitSize());
374 W->printNumber("BitOffset", BitField.getBitOffset());
375 return Error::success();
376 }
377
378 Error CVTypeDumper::visitKnownRecord(CVType &CVR, VFTableShapeRecord &Shape) {
379 W->printNumber("VFEntryCount", Shape.getEntryCount());
380 return Error::success();
381 }
382
383 Error CVTypeDumper::visitKnownRecord(CVType &CVR, UdtSourceLineRecord &Line) {
384 printTypeIndex("UDT", Line.getUDT());
385 printTypeIndex("SourceFile", Line.getSourceFile());
386 W->printNumber("LineNumber", Line.getLineNumber());
387 return Error::success();
388 }
389
390 Error CVTypeDumper::visitKnownRecord(CVType &CVR,
391 UdtModSourceLineRecord &Line) {
392 printTypeIndex("UDT", Line.getUDT());
393 printTypeIndex("SourceFile", Line.getSourceFile());
394 W->printNumber("LineNumber", Line.getLineNumber());
395 W->printNumber("Module", Line.getModule());
396 return Error::success();
397 }
398
399 Error CVTypeDumper::visitKnownRecord(CVType &CVR, BuildInfoRecord &Args) {
400 W->printNumber("NumArgs", static_cast(Args.getArgs().size()));
401
402 ListScope Arguments(*W, "Arguments");
403 for (auto Arg : Args.getArgs()) {
404 printTypeIndex("ArgType", Arg);
405 }
406 return Error::success();
407 }
408
409 void CVTypeDumper::printMemberAttributes(MemberAttributes Attrs) {
410 return printMemberAttributes(Attrs.getAccess(), Attrs.getMethodKind(),
411 Attrs.getFlags());
412 }
413
414 void CVTypeDumper::printMemberAttributes(MemberAccess Access, MethodKind Kind,
415 MethodOptions Options) {
416 W->printEnum("AccessSpecifier", uint8_t(Access),
417 makeArrayRef(MemberAccessNames));
418 // Data members will be vanilla. Don't try to print a method kind for them.
419 if (Kind != MethodKind::Vanilla)
420 W->printEnum("MethodKind", unsigned(Kind), makeArrayRef(MemberKindNames));
421 if (Options != MethodOptions::None) {
422 W->printFlags("MethodOptions", unsigned(Options),
423 makeArrayRef(MethodOptionNames));
424 }
425 }
426
427 Error CVTypeDumper::visitUnknownMember(CVMemberRecord &Record) {
428 W->printHex("UnknownMember", unsigned(Record.Kind));
429 return Error::success();
430 }
431
432 Error CVTypeDumper::visitUnknownType(CVType &Record) {
433 W->printEnum("Kind", uint16_t(Record.kind()), makeArrayRef(LeafTypeNames));
434 W->printNumber("Length", uint32_t(Record.content().size()));
435 return Error::success();
436 }
437
438 Error CVTypeDumper::visitKnownMember(CVMemberRecord &CVR,
439 NestedTypeRecord &Nested) {
440 printTypeIndex("Type", Nested.getNestedType());
441 W->printString("Name", Nested.getName());
442 return Error::success();
443 }
444
445 Error CVTypeDumper::visitKnownMember(CVMemberRecord &CVR,
446 OneMethodRecord &Method) {
447 MethodKind K = Method.getMethodKind();
448 printMemberAttributes(Method.getAccess(), K, Method.getOptions());
449 printTypeIndex("Type", Method.getType());
450 // If virtual, then read the vftable offset.
451 if (Method.isIntroducingVirtual())
452 W->printHex("VFTableOffset", Method.getVFTableOffset());
453 W->printString("Name", Method.getName());
454 return Error::success();
455 }
456
457 Error CVTypeDumper::visitKnownMember(CVMemberRecord &CVR,
458 OverloadedMethodRecord &Method) {
459 W->printHex("MethodCount", Method.getNumOverloads());
460 printTypeIndex("MethodListIndex", Method.getMethodList());
461 W->printString("Name", Method.getName());
462 return Error::success();
463 }
464
465 Error CVTypeDumper::visitKnownMember(CVMemberRecord &CVR,
466 DataMemberRecord &Field) {
467 printMemberAttributes(Field.getAccess(), MethodKind::Vanilla,
468 MethodOptions::None);
469 printTypeIndex("Type", Field.getType());
470 W->printHex("FieldOffset", Field.getFieldOffset());
471 W->printString("Name", Field.getName());
472 return Error::success();
473 }
474
475 Error CVTypeDumper::visitKnownMember(CVMemberRecord &CVR,
476 StaticDataMemberRecord &Field) {
477 printMemberAttributes(Field.getAccess(), MethodKind::Vanilla,
478 MethodOptions::None);
479 printTypeIndex("Type", Field.getType());
480 W->printString("Name", Field.getName());
481 return Error::success();
482 }
483
484 Error CVTypeDumper::visitKnownMember(CVMemberRecord &CVR,
485 VFPtrRecord &VFTable) {
486 printTypeIndex("Type", VFTable.getType());
487 return Error::success();
488 }
489
490 Error CVTypeDumper::visitKnownMember(CVMemberRecord &CVR,
491 EnumeratorRecord &Enum) {
492 printMemberAttributes(Enum.getAccess(), MethodKind::Vanilla,
493 MethodOptions::None);
494 W->printNumber("EnumValue", Enum.getValue());
495 W->printString("Name", Enum.getName());
496 return Error::success();
497 }
498
499 Error CVTypeDumper::visitKnownMember(CVMemberRecord &CVR,
500 BaseClassRecord &Base) {
501 printMemberAttributes(Base.getAccess(), MethodKind::Vanilla,
502 MethodOptions::None);
503 printTypeIndex("BaseType", Base.getBaseType());
504 W->printHex("BaseOffset", Base.getBaseOffset());
505 return Error::success();
506 }
507
508 Error CVTypeDumper::visitKnownMember(CVMemberRecord &CVR,
509 VirtualBaseClassRecord &Base) {
510 printMemberAttributes(Base.getAccess(), MethodKind::Vanilla,
511 MethodOptions::None);
512 printTypeIndex("BaseType", Base.getBaseType());
513 printTypeIndex("VBPtrType", Base.getVBPtrType());
514 W->printHex("VBPtrOffset", Base.getVBPtrOffset());
515 W->printHex("VBTableIndex", Base.getVTableIndex());
516 return Error::success();
517 }
518
519 Error CVTypeDumper::visitKnownMember(CVMemberRecord &CVR,
520 ListContinuationRecord &Cont) {
521 printTypeIndex("ContinuationIndex", Cont.getContinuationIndex());
522 return Error::success();
523 }
524
525 void CVTypeDumper::printTypeIndex(StringRef FieldName, TypeIndex TI) {
526 StringRef TypeName;
527 if (!TI.isNoneType())
528 TypeName = TypeDB.getTypeName(TI);
529 if (!TypeName.empty())
530 W->printHex(FieldName, TypeName, TI.getIndex());
531 else
532 W->printHex(FieldName, TI.getIndex());
533 }
534
535 Error CVTypeDumper::dump(const CVType &Record) {
536 assert(W && "printer should not be null");
537 TypeDatabaseVisitor DBV(TypeDB);
538 TypeDeserializer Deserializer;
539 TypeVisitorCallbackPipeline Pipeline;
540 Pipeline.addCallbackToPipeline(Deserializer);
541 Pipeline.addCallbackToPipeline(DBV);
542 Pipeline.addCallbackToPipeline(*this);
543
544 CVTypeVisitor Visitor(Pipeline);
545
546 CVType RecordCopy = Record;
547 if (auto EC = Visitor.visitTypeRecord(RecordCopy))
548 return EC;
549 return Error::success();
550 }
551
552 Error CVTypeDumper::dump(const CVTypeArray &Types) {
553 assert(W && "printer should not be null");
554 TypeDatabaseVisitor DBV(TypeDB);
555 TypeDeserializer Deserializer;
556 TypeVisitorCallbackPipeline Pipeline;
557 Pipeline.addCallbackToPipeline(Deserializer);
558 Pipeline.addCallbackToPipeline(DBV);
559 Pipeline.addCallbackToPipeline(*this);
560
561 CVTypeVisitor Visitor(Pipeline);
562
563 if (auto EC = Visitor.visitTypeStream(Types))
564 return EC;
565 return Error::success();
566 }
567
568 Error CVTypeDumper::dump(ArrayRef Data) {
569 msf::ByteStream Stream(Data);
570 CVTypeArray Types;
571 msf::StreamReader Reader(Stream);
572 if (auto EC = Reader.readArray(Types, Reader.getLength()))
573 return EC;
574
575 return dump(Types);
576 }
577
578 void CVTypeDumper::setPrinter(ScopedPrinter *P) {
579 static ScopedPrinter NullP(llvm::nulls());
580 W = P ? P : &NullP;
581 }
+0
-90
tools/llvm-pdbdump/BuiltinDumper.cpp less more
None //===- BuiltinDumper.cpp ---------------------------------------- *- C++ *-===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8
9 #include "BuiltinDumper.h"
10 #include "LinePrinter.h"
11 #include "llvm-pdbdump.h"
12
13 #include "llvm/DebugInfo/PDB/PDBSymbolTypeBuiltin.h"
14
15 using namespace llvm;
16 using namespace llvm::pdb;
17
18 BuiltinDumper::BuiltinDumper(LinePrinter &P)
19 : PDBSymDumper(false), Printer(P) {}
20
21 void BuiltinDumper::start(const PDBSymbolTypeBuiltin &Symbol) {
22 WithColor(Printer, PDB_ColorItem::Type).get() << getTypeName(Symbol);
23 }
24
25 StringRef BuiltinDumper::getTypeName(const PDBSymbolTypeBuiltin &Symbol) {
26 PDB_BuiltinType Type = Symbol.getBuiltinType();
27 switch (Type) {
28 case PDB_BuiltinType::Float:
29 if (Symbol.getLength() == 4)
30 return "float";
31 return "double";
32 case PDB_BuiltinType::UInt:
33 switch (Symbol.getLength()) {
34 case 8:
35 return "unsigned __int64";
36 case 4:
37 return "unsigned int";
38 case 2:
39 return "unsigned short";
40 case 1:
41 return "unsigned char";
42 default:
43 return "unsigned";
44 }
45 case PDB_BuiltinType::Int:
46 switch (Symbol.getLength()) {
47 case 8:
48 return "__int64";
49 case 4:
50 return "int";
51 case 2:
52 return "short";
53 case 1:
54 return "char";
55 default:
56 return "int";
57 }
58 case PDB_BuiltinType::Char:
59 return "char";
60 case PDB_BuiltinType::WCharT:
61 return "wchar_t";
62 case PDB_BuiltinType::Void:
63 return "void";
64 case PDB_BuiltinType::Long:
65 return "long";
66 case PDB_BuiltinType::ULong:
67 return "unsigned long";
68 case PDB_BuiltinType::Bool:
69 return "bool";
70 case PDB_BuiltinType::Currency:
71 return "CURRENCY";
72 case PDB_BuiltinType::Date:
73 return "DATE";
74 case PDB_BuiltinType::Variant:
75 return "VARIANT";
76 case PDB_BuiltinType::Complex:
77 return "complex";
78 case PDB_BuiltinType::Bitfield:
79 return "bitfield";
80 case PDB_BuiltinType::BSTR:
81 return "BSTR";
82 case PDB_BuiltinType::HResult:
83 return "HRESULT";
84 case PDB_BuiltinType::BCD:
85 return "HRESULT";
86 default:
87 return "void";
88 }
89 }
+0
-35
tools/llvm-pdbdump/BuiltinDumper.h less more
None //===- BuiltinDumper.h ---------------------------------------- *- C++ --*-===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8
9 #ifndef LLVM_TOOLS_LLVMPDBDUMP_BUILTINDUMPER_H
10 #define LLVM_TOOLS_LLVMPDBDUMP_BUILTINDUMPER_H
11
12 #include "llvm/ADT/StringRef.h"
13 #include "llvm/DebugInfo/PDB/PDBSymDumper.h"
14
15 namespace llvm {
16 namespace pdb {
17
18 class LinePrinter;
19
20 class BuiltinDumper : public PDBSymDumper {
21 public:
22 BuiltinDumper(LinePrinter &P);
23
24 void start(const PDBSymbolTypeBuiltin &Symbol);
25
26 private:
27 StringRef getTypeName(const PDBSymbolTypeBuiltin &Symbol);
28
29 LinePrinter &Printer;
30 };
31 }
32 }
33
34 #endif
77
88 add_llvm_tool(llvm-pdbdump
99 llvm-pdbdump.cpp
10 BuiltinDumper.cpp
11 ClassDefinitionDumper.cpp
1210 YamlSymbolDumper.cpp
1311 YamlTypeDumper.cpp
14 CompilandDumper.cpp
15 EnumDumper.cpp
16 ExternalSymbolDumper.cpp
17 FunctionDumper.cpp
1812 LinePrinter.cpp
1913 LLVMOutputStyle.cpp
2014 PdbYaml.cpp
21 TypeDumper.cpp
22 TypedefDumper.cpp
23 VariableDumper.cpp
15 PrettyBuiltinDumper.cpp
16 PrettyClassDefinitionDumper.cpp
17 PrettyCompilandDumper.cpp
18 PrettyEnumDumper.cpp
19 PrettyExternalSymbolDumper.cpp
20 PrettyFunctionDumper.cpp
21 PrettyTypeDumper.cpp
22 PrettyTypedefDumper.cpp
23 PrettyVariableDumper.cpp
2424 YAMLOutputStyle.cpp
2525 )
2626
+0
-191
tools/llvm-pdbdump/ClassDefinitionDumper.cpp less more
None //===- ClassDefinitionDumper.cpp --------------------------------*- C++ -*-===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8
9 #include "ClassDefinitionDumper.h"
10 #include "EnumDumper.h"
11 #include "FunctionDumper.h"
12 #include "LinePrinter.h"
13 #include "llvm-pdbdump.h"
14 #include "TypedefDumper.h"
15 #include "VariableDumper.h"
16
17 #include "llvm/DebugInfo/PDB/IPDBSession.h"
18 #include "llvm/DebugInfo/PDB/PDBExtras.h"
19 #include "llvm/DebugInfo/PDB/PDBSymbolData.h"
20 #include "llvm/DebugInfo/PDB/PDBSymbolFunc.h"
21 #include "llvm/DebugInfo/PDB/PDBSymbolTypeBaseClass.h"
22 #include "llvm/DebugInfo/PDB/PDBSymbolTypeEnum.h"
23 #include "llvm/DebugInfo/PDB/PDBSymbolTypePointer.h"
24 #include "llvm/DebugInfo/PDB/PDBSymbolTypeTypedef.h"
25 #include "llvm/DebugInfo/PDB/PDBSymbolTypeUDT.h"
26 #include "llvm/DebugInfo/PDB/PDBSymbolTypeVTable.h"
27 #include "llvm/Support/Format.h"
28
29 using namespace llvm;
30 using namespace llvm::pdb;
31
32 ClassDefinitionDumper::ClassDefinitionDumper(LinePrinter &P)
33 : PDBSymDumper(true), Printer(P) {}
34
35 void ClassDefinitionDumper::start(const PDBSymbolTypeUDT &Class) {
36 std::string Name = Class.getName();
37 WithColor(Printer, PDB_ColorItem::Keyword).get() << Class.getUdtKind() << " ";
38 WithColor(Printer, PDB_ColorItem::Type).get() << Class.getName();
39
40 auto Bases = Class.findAllChildren();
41 if (Bases->getChildCount() > 0) {
42 Printer.Indent();
43 Printer.NewLine();
44 Printer << ":";
45 uint32_t BaseIndex = 0;
46 while (auto Base = Bases->getNext()) {
47 Printer << " ";
48 WithColor(Printer, PDB_ColorItem::Keyword).get() << Base->getAccess();
49 if (Base->isVirtualBaseClass())
50 WithColor(Printer, PDB_ColorItem::Keyword).get() << " virtual";
51 WithColor(Printer, PDB_ColorItem::Type).get() << " " << Base->getName();
52 if (++BaseIndex < Bases->getChildCount()) {
53 Printer.NewLine();
54 Printer << ",";
55 }
56 }
57 Printer.Unindent();
58 }
59
60 Printer << " {";
61 auto Children = Class.findAllChildren();
62 if (Children->getChildCount() == 0) {
63 Printer << "}";
64 return;
65 }
66
67 // Try to dump symbols organized by member access level. Public members
68 // first, then protected, then private. This might be slow, so it's worth
69 // reconsidering the value of this if performance of large PDBs is a problem.
70 // NOTE: Access level of nested types is not recorded in the PDB, so we have
71 // a special case for them.
72 SymbolGroupByAccess Groups;
73 Groups.insert(std::make_pair(0, SymbolGroup()));
74 Groups.insert(std::make_pair((int)PDB_MemberAccess::Private, SymbolGroup()));
75 Groups.insert(
76 std::make_pair((int)PDB_MemberAccess::Protected, SymbolGroup()));
77 Groups.insert(std::make_pair((int)PDB_MemberAccess::Public, SymbolGroup()));
78
79 while (auto Child = Children->getNext()) {
80 PDB_MemberAccess Access = Child->getRawSymbol().getAccess();
81 if (isa(*Child))
82 continue;
83
84 auto &AccessGroup = Groups.find((int)Access)->second;
85
86 if (auto Func = dyn_cast(Child.get())) {
87 if (Func->isCompilerGenerated() && opts::pretty::ExcludeCompilerGenerated)
88 continue;
89 if (Func->getLength() == 0 && !Func->isPureVirtual() &&
90 !Func->isIntroVirtualFunction())
91 continue;
92 Child.release();
93 AccessGroup.Functions.push_back(std::unique_ptr(Func));
94 } else if (auto Data = dyn_cast(Child.get())) {
95 Child.release();
96 AccessGroup.Data.push_back(std::unique_ptr(Data));
97 } else {
98 AccessGroup.Unknown.push_back(std::move(Child));
99 }
100 }
101
102 int Count = 0;
103 Count += dumpAccessGroup((PDB_MemberAccess)0, Groups[0]);
104 Count += dumpAccessGroup(PDB_MemberAccess::Public,
105 Groups[(int)PDB_MemberAccess::Public]);
106 Count += dumpAccessGroup(PDB_MemberAccess::Protected,
107 Groups[(int)PDB_MemberAccess::Protected]);
108 Count += dumpAccessGroup(PDB_MemberAccess::Private,
109 Groups[(int)PDB_MemberAccess::Private]);
110 if (Count > 0)
111 Printer.NewLine();
112 Printer << "}";
113 }
114
115 int ClassDefinitionDumper::dumpAccessGroup(PDB_MemberAccess Access,
116 const SymbolGroup &Group) {
117 if (Group.Functions.empty() && Group.Data.empty() && Group.Unknown.empty())
118 return 0;
119
120 int Count = 0;
121 if (Access == PDB_MemberAccess::Private) {
122 Printer.NewLine();
123 WithColor(Printer, PDB_ColorItem::Keyword).get() << "private";
124 Printer << ":";
125 } else if (Access == PDB_MemberAccess::Protected) {
126 Printer.NewLine();
127 WithColor(Printer, PDB_ColorItem::Keyword).get() << "protected";
128 Printer << ":";
129 } else if (Access == PDB_MemberAccess::Public) {
130 Printer.NewLine();
131 WithColor(Printer, PDB_ColorItem::Keyword).get() << "public";
132 Printer << ":";
133 }
134 Printer.Indent();
135 for (auto iter = Group.Functions.begin(), end = Group.Functions.end();
136 iter != end; ++iter) {
137 ++Count;
138 (*iter)->dump(*this);
139 }
140 for (auto iter = Group.Data.begin(), end = Group.Data.end(); iter != end;
141 ++iter) {
142 ++Count;
143 (*iter)->dump(*this);
144 }
145 for (auto iter = Group.Unknown.begin(), end = Group.Unknown.end();
146 iter != end; ++iter) {
147 ++Count;
148 (*iter)->dump(*this);
149 }
150 Printer.Unindent();
151 return Count;
152 }
153
154 void ClassDefinitionDumper::dump(const PDBSymbolTypeBaseClass &Symbol) {}
155
156 void ClassDefinitionDumper::dump(const PDBSymbolData &Symbol) {
157 VariableDumper Dumper(Printer);
158 Dumper.start(Symbol);
159 }
160
161 void ClassDefinitionDumper::dump(const PDBSymbolFunc &Symbol) {
162 if (Printer.IsSymbolExcluded(Symbol.getName()))
163 return;
164
165 Printer.NewLine();
166 FunctionDumper Dumper(Printer);
167 Dumper.start(Symbol, FunctionDumper::PointerType::None);
168 }
169
170 void ClassDefinitionDumper::dump(const PDBSymbolTypeVTable &Symbol) {}
171
172 void ClassDefinitionDumper::dump(const PDBSymbolTypeEnum &Symbol) {
173 if (Printer.IsTypeExcluded(Symbol.getName()))
174 return;
175
176 Printer.NewLine();
177 EnumDumper Dumper(Printer);
178 Dumper.start(Symbol);
179 }
180
181 void ClassDefinitionDumper::dump(const PDBSymbolTypeTypedef &Symbol) {
182 if (Printer.IsTypeExcluded(Symbol.getName()))
183 return;
184
185 Printer.NewLine();
186 TypedefDumper Dumper(Printer);
187 Dumper.start(Symbol);
188 }
189
190 void ClassDefinitionDumper::dump(const PDBSymbolTypeUDT &Symbol) {}
+0
-63
tools/llvm-pdbdump/ClassDefinitionDumper.h less more
None //===- ClassDefinitionDumper.h - --------------------------------*- C++ -*-===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8
9 #ifndef LLVM_TOOLS_LLVMPDBDUMP_CLASSDEFINITIONDUMPER_H
10 #define LLVM_TOOLS_LLVMPDBDUMP_CLASSDEFINITIONDUMPER_H
11
12 #include "llvm/DebugInfo/PDB/PDBSymDumper.h"
13 #include "llvm/DebugInfo/PDB/PDBSymbolFunc.h"
14 #include "llvm/DebugInfo/PDB/PDBSymbolData.h"
15
16 #include
17 #include
18 #include
19
20 namespace llvm {
21 namespace pdb {
22
23 class LinePrinter;
24
25 class ClassDefinitionDumper : public PDBSymDumper {
26 public:
27 ClassDefinitionDumper(LinePrinter &P);
28
29 void start(const PDBSymbolTypeUDT &Exe);
30
31 void dump(const PDBSymbolTypeBaseClass &Symbol) override;
32 void dump(const PDBSymbolData &Symbol) override;
33 void dump(const PDBSymbolTypeEnum &Symbol) override;
34 void dump(const PDBSymbolFunc &Symbol) override;
35 void dump(const PDBSymbolTypeTypedef &Symbol) override;
36 void dump(const PDBSymbolTypeUDT &Symbol) override;
37 void dump(const PDBSymbolTypeVTable &Symbol) override;
38
39 private:
40 LinePrinter &Printer;
41
42 struct SymbolGroup {
43 SymbolGroup() {}
44 SymbolGroup(SymbolGroup &&Other) {
45 Functions = std::move(Other.Functions);
46 Data = std::move(Other.Data);
47 Unknown = std::move(Other.Unknown);
48 }
49
50 std::list> Functions;
51 std::list> Data;
52 std::list> Unknown;
53 SymbolGroup(const SymbolGroup &other) = delete;
54 SymbolGroup &operator=(const SymbolGroup &other) = delete;
55 };
56 typedef std::unordered_map SymbolGroupByAccess;
57
58 int dumpAccessGroup(PDB_MemberAccess Access, const SymbolGroup &Group);
59 };
60 }
61 }
62 #endif
+0
-195
tools/llvm-pdbdump/CompilandDumper.cpp less more
None //===- CompilandDumper.cpp - llvm-pdbdump compiland symbol dumper *- C++ *-===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8
9 #include "CompilandDumper.h"
10 #include "LinePrinter.h"
11 #include "llvm-pdbdump.h"
12
13 #include "llvm/DebugInfo/PDB/IPDBEnumChildren.h"
14 #include "llvm/DebugInfo/PDB/IPDBLineNumber.h"
15 #include "llvm/DebugInfo/PDB/IPDBSession.h"
16 #include "llvm/DebugInfo/PDB/IPDBSourceFile.h"
17 #include "llvm/DebugInfo/PDB/PDBExtras.h"
18 #include "llvm/DebugInfo/PDB/PDBSymbol.h"
19 #include "llvm/DebugInfo/PDB/PDBSymbolCompiland.h"
20 #include "llvm/DebugInfo/PDB/PDBSymbolData.h"
21 #include "llvm/DebugInfo/PDB/PDBSymbolFunc.h"
22 #include "llvm/DebugInfo/PDB/PDBSymbolFuncDebugEnd.h"
23 #include "llvm/DebugInfo/PDB/PDBSymbolFuncDebugStart.h"
24 #include "llvm/DebugInfo/PDB/PDBSymbolLabel.h"
25 #include "llvm/DebugInfo/PDB/PDBSymbolThunk.h"
26 #include "llvm/DebugInfo/PDB/PDBSymbolTypeFunctionSig.h"
27 #include "llvm/DebugInfo/PDB/PDBSymbolUnknown.h"
28 #include "llvm/Support/Format.h"
29 #include "llvm/Support/Path.h"
30 #include "llvm/Support/raw_ostream.h"
31
32 #include "FunctionDumper.h"
33
34 #include
35
36 using namespace llvm;
37 using namespace llvm::pdb;
38
39 CompilandDumper::CompilandDumper(LinePrinter &P)
40 : PDBSymDumper(true), Printer(P) {}
41
42 void CompilandDumper::dump(const PDBSymbolCompilandDetails &Symbol) {}
43
44 void CompilandDumper::dump(const PDBSymbolCompilandEnv &Symbol) {}
45
46 void CompilandDumper::start(const PDBSymbolCompiland &Symbol,
47 CompilandDumpFlags opts) {
48 std::string FullName = Symbol.getName();
49 if (Printer.IsCompilandExcluded(FullName))
50 return;
51
52 Printer.NewLine();
53 WithColor(Printer, PDB_ColorItem::Path).get() << FullName;
54
55 if (opts & Flags::Lines) {
56 const IPDBSession &Session = Symbol.getSession();
57 auto Files = Session.getSourceFilesForCompiland(Symbol);
58 Printer.Indent();
59 while (auto File = Files->getNext()) {
60 Printer.NewLine();
61 WithColor(Printer, PDB_ColorItem::Path).get() << File->getFileName();
62
63 auto Lines = Session.findLineNumbers(Symbol, *File);
64 Printer.Indent();
65 while (auto Line = Lines->getNext()) {
66 Printer.NewLine();
67 uint32_t LineStart = Line->getLineNumber();
68 uint32_t LineEnd = Line->getLineNumberEnd();
69
70 Printer << "Line ";
71 PDB_ColorItem StatementColor = Line->isStatement()
72 ? PDB_ColorItem::Keyword
73 : PDB_ColorItem::LiteralValue;
74 WithColor(Printer, StatementColor).get() << LineStart;
75 if (LineStart != LineEnd)
76 WithColor(Printer, StatementColor).get() << " - " << LineEnd;
77
78 uint32_t ColumnStart = Line->getColumnNumber();
79 uint32_t ColumnEnd = Line->getColumnNumberEnd();
80 if (ColumnStart != 0 || ColumnEnd != 0) {
81 Printer << ", Column: ";
82 WithColor(Printer, StatementColor).get() << ColumnStart;
83 if (ColumnEnd != ColumnStart)
84 WithColor(Printer, StatementColor).get() << " - " << ColumnEnd;
85 }
86
87 Printer << ", Address: ";
88 if (Line->getLength() > 0) {
89 uint64_t AddrStart = Line->getVirtualAddress();
90 uint64_t AddrEnd = AddrStart + Line->getLength() - 1;
91 WithColor(Printer, PDB_ColorItem::Address).get()
92 << "[" << format_hex(AddrStart, 10) << " - "
93 << format_hex(AddrEnd, 10) << "]";
94 Printer << " (" << Line->getLength() << " bytes)";
95 } else {
96 uint64_t AddrStart = Line->getVirtualAddress();
97 WithColor(Printer, PDB_ColorItem::Address).get()
98 << "[" << format_hex(AddrStart, 10) << "] ";
99 Printer << "(0 bytes)";
100 }
101 }
102 Printer.Unindent();
103 }
104 Printer.Unindent();
105 }
106
107 if (opts & Flags::Children) {
108 auto ChildrenEnum = Symbol.findAllChildren();
109 Printer.Indent();
110 while (auto Child = ChildrenEnum->getNext())
111 Child->dump(*this);
112 Printer.Unindent();
113 }
114 }
115
116 void CompilandDumper::dump(const PDBSymbolData &Symbol) {
117 if (Printer.IsSymbolExcluded(Symbol.getName()))
118 return;
119
120 Printer.NewLine();
121
122 switch (auto LocType = Symbol.getLocationType()) {
123 case PDB_LocType::Static:
124 Printer << "data: ";
125 WithColor(Printer, PDB_ColorItem::Address).get()
126 << "[" << format_hex(Symbol.getVirtualAddress(), 10) << "]";
127 break;
128 case PDB_LocType::Constant:
129 Printer << "constant: ";
130 WithColor(Printer, PDB_ColorItem::LiteralValue).get()
131 << "[" << Symbol.getValue() << "]";
132 break;
133 default:
134 Printer << "data(unexpected type=" << LocType << ")";
135 }
136
137 Printer << " ";
138 WithColor(Printer, PDB_ColorItem::Identifier).get() << Symbol.getName();
139 }
140
141 void CompilandDumper::dump(const PDBSymbolFunc &Symbol) {
142 if (Symbol.getLength() == 0)
143 return;
144 if (Printer.IsSymbolExcluded(Symbol.getName()))
145 return;
146
147 Printer.NewLine();
148 FunctionDumper Dumper(Printer);
149 Dumper.start(Symbol, FunctionDumper::PointerType::None);
150 }
151
152 void CompilandDumper::dump(const PDBSymbolLabel &Symbol) {
153 if (Printer.IsSymbolExcluded(Symbol.getName()))
154 return;
155
156 Printer.NewLine();
157 Printer << "label ";
158 WithColor(Printer, PDB_ColorItem::Address).get()
159 << "[" << format_hex(Symbol.getVirtualAddress(), 10) << "] ";
160 WithColor(Printer, PDB_ColorItem::Identifier).get() << Symbol.getName();
161 }
162
163 void CompilandDumper::dump(const PDBSymbolThunk &Symbol) {
164 if (Printer.IsSymbolExcluded(Symbol.getName()))
165 return;
166
167 Printer.NewLine();
168 Printer << "thunk ";
169 codeview::ThunkOrdinal Ordinal = Symbol.getThunkOrdinal();
170 uint64_t VA = Symbol.getVirtualAddress();
171 if (Ordinal == codeview::ThunkOrdinal::TrampIncremental) {
172 uint64_t Target = Symbol.getTargetVirtualAddress();
173 WithColor(Printer, PDB_ColorItem::Address).get() << format_hex(VA, 10);
174 Printer << " -> ";
175 WithColor(Printer, PDB_ColorItem::Address).get() << format_hex(Target, 10);
176 } else {
177 WithColor(Printer, PDB_ColorItem::Address).get()
178 << "[" << format_hex(VA, 10) << " - "
179 << format_hex(VA + Symbol.getLength(), 10) << "]";
180 }
181 Printer << " (";
182 WithColor(Printer, PDB_ColorItem::Register).get() << Ordinal;
183 Printer << ") ";
184 std::string Name = Symbol.getName();
185 if (!Name.empty())
186 WithColor(Printer, PDB_ColorItem::Identifier).get() << Name;
187 }
188
189 void CompilandDumper::dump(const PDBSymbolTypeTypedef &Symbol) {}
190
191 void CompilandDumper::dump(const PDBSymbolUnknown &Symbol) {
192 Printer.NewLine();
193 Printer << "unknown (" << Symbol.getSymTag() << ")";
194 }
+0
-44
tools/llvm-pdbdump/CompilandDumper.h less more
None //===- CompilandDumper.h - llvm-pdbdump compiland symbol dumper *- C++ --*-===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8
9 #ifndef LLVM_TOOLS_LLVMPDBDUMP_COMPILANDDUMPER_H
10 #define LLVM_TOOLS_LLVMPDBDUMP_COMPILANDDUMPER_H
11
12 #include "llvm/DebugInfo/PDB/PDBSymDumper.h"
13
14 namespace llvm {
15 namespace pdb {
16
17 class LinePrinter;
18
19 typedef int CompilandDumpFlags;
20 class CompilandDumper : public PDBSymDumper {
21 public:
22 enum Flags { None = 0x0, Children = 0x1, Symbols = 0x2, Lines = 0x4 };
23
24 CompilandDumper(LinePrinter &P);
25
26 void start(const PDBSymbolCompiland &Symbol, CompilandDumpFlags flags);
27
28 void dump(const PDBSymbolCompilandDetails &Symbol) override;
29 void dump(const PDBSymbolCompilandEnv &Symbol) override;
30 void dump(const PDBSymbolData &Symbol) override;
31 void dump(const PDBSymbolFunc &Symbol) override;
32 void dump(const PDBSymbolLabel &Symbol) override;
33 void dump(const PDBSymbolThunk &Symbol) override;
34 void dump(const PDBSymbolTypeTypedef &Symbol) override;
35 void dump(const PDBSymbolUnknown &Symbol) override;
36
37 private:
38 LinePrinter &Printer;
39 };
40 }
41 }
42
43 #endif
+0
-53
tools/llvm-pdbdump/EnumDumper.cpp less more
None //===- EnumDumper.cpp -------------------------------------------*- C++ -*-===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8
9 #include "EnumDumper.h"
10
11 #include "BuiltinDumper.h"
12 #include "LinePrinter.h"
13 #include "llvm-pdbdump.h"
14
15 #include "llvm/DebugInfo/PDB/PDBSymbolData.h"
16 #include "llvm/DebugInfo/PDB/PDBSymbolTypeBuiltin.h"
17 #include "llvm/DebugInfo/PDB/PDBSymbolTypeEnum.h"
18
19 using namespace llvm;
20 using namespace llvm::pdb;
21
22 EnumDumper::EnumDumper(LinePrinter &P) : PDBSymDumper(true), Printer(P) {}
23
24 void EnumDumper::start(const PDBSymbolTypeEnum &Symbol) {
25 WithColor(Printer, PDB_ColorItem::Keyword).get() << "enum ";
26 WithColor(Printer, PDB_ColorItem::Type).get() << Symbol.getName();
27 if (!opts::pretty::NoEnumDefs) {
28 auto BuiltinType = Symbol.getUnderlyingType();
29 if (BuiltinType->getBuiltinType() != PDB_BuiltinType::Int ||
30 BuiltinType->getLength() != 4) {
31 Printer << " : ";
32 BuiltinDumper Dumper(Printer);
33 Dumper.start(*BuiltinType);
34 }
35 Printer << " {";
36 Printer.Indent();
37 auto EnumValues = Symbol.findAllChildren();
38 while (auto EnumValue = EnumValues->getNext()) {
39 if (EnumValue->getDataKind() != PDB_DataKind::Constant)
40 continue;
41 Printer.NewLine();
42 WithColor(Printer, PDB_ColorItem::Identifier).get()
43 << EnumValue->getName();
44 Printer << " = ";
45 WithColor(Printer, PDB_ColorItem::LiteralValue).get()
46 << EnumValue->getValue();
47 }
48 Printer.Unindent();
49 Printer.NewLine();
50 Printer << "}";
51 }
52 }
+0
-31
tools/llvm-pdbdump/EnumDumper.h less more
None //===- EnumDumper.h - -------------------------------------------*- C++ -*-===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8
9 #ifndef LLVM_TOOLS_LLVMPDBDUMP_ENUMDUMPER_H
10 #define LLVM_TOOLS_LLVMPDBDUMP_ENUMDUMPER_H
11
12 #include "llvm/DebugInfo/PDB/PDBSymDumper.h"
13
14 namespace llvm {
15 namespace pdb {
16
17 class LinePrinter;
18
19 class EnumDumper : public PDBSymDumper {
20 public:
21 EnumDumper(LinePrinter &P);
22
23 void start(const PDBSymbolTypeEnum &Symbol);
24
25 private:
26 LinePrinter &Printer;
27 };
28 }
29 }
30 #endif
+0
-41
tools/llvm-pdbdump/ExternalSymbolDumper.cpp less more
None //===- ExternalSymbolDumper.cpp -------------------------------- *- C++ *-===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8
9 #include "ExternalSymbolDumper.h"
10 #include "LinePrinter.h"
11
12 #include "llvm/DebugInfo/PDB/PDBSymbolExe.h"
13 #include "llvm/DebugInfo/PDB/PDBSymbolPublicSymbol.h"
14 #include "llvm/Support/Format.h"
15
16 using namespace llvm;
17 using namespace llvm::pdb;
18
19 ExternalSymbolDumper::ExternalSymbolDumper(LinePrinter &P)
20 : PDBSymDumper(true), Printer(P) {}
21
22 void ExternalSymbolDumper::start(const PDBSymbolExe &Symbol) {
23 auto Vars = Symbol.findAllChildren();
24 while (auto Var = Vars->getNext())
25 Var->dump(*this);
26 }
27
28 void ExternalSymbolDumper::dump(const PDBSymbolPublicSymbol &Symbol) {
29 std::string LinkageName = Symbol.getName();
30 if (Printer.IsSymbolExcluded(LinkageName))
31 return;
32
33 Printer.NewLine();
34 uint64_t Addr = Symbol.getVirtualAddress();
35
36 Printer << "[";
37 WithColor(Printer, PDB_ColorItem::Address).get() << format_hex(Addr, 10);
38 Printer << "] ";
39 WithColor(Printer, PDB_ColorItem::Identifier).get() << LinkageName;
40 }
+0
-34
tools/llvm-pdbdump/ExternalSymbolDumper.h less more
None //===- ExternalSymbolDumper.h --------------------------------- *- C++ --*-===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8
9 #ifndef LLVM_TOOLS_LLVMPDBDUMP_EXTERNALSYMBOLDUMPER_H
10 #define LLVM_TOOLS_LLVMPDBDUMP_EXTERNALSYMBOLDUMPER_H
11
12 #include "llvm/DebugInfo/PDB/PDBSymDumper.h"
13
14 namespace llvm {
15 namespace pdb {
16
17 class LinePrinter;
18
19 class ExternalSymbolDumper : public PDBSymDumper {
20 public:
21 ExternalSymbolDumper(LinePrinter &P);
22
23 void start(const PDBSymbolExe &Symbol);
24
25 void dump(const PDBSymbolPublicSymbol &Symbol) override;
26
27 private:
28 LinePrinter &Printer;
29 };
30 }
31 }
32
33 #endif
+0
-257
tools/llvm-pdbdump/FunctionDumper.cpp less more
None //===- FunctionDumper.cpp ------------------------------------ *- C++ *-===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8
9 #include "FunctionDumper.h"
10 #include "BuiltinDumper.h"
11 #include "LinePrinter.h"
12 #include "llvm-pdbdump.h"
13
14 #include "llvm/DebugInfo/PDB/IPDBSession.h"
15 #include "llvm/DebugInfo/PDB/PDBExtras.h"
16 #include "llvm/DebugInfo/PDB/PDBSymbolData.h"
17 #include "llvm/DebugInfo/PDB/PDBSymbolFunc.h"
18 #include "llvm/DebugInfo/PDB/PDBSymbolFuncDebugEnd.h"
19 #include "llvm/DebugInfo/PDB/PDBSymbolFuncDebugStart.h"
20 #include "llvm/DebugInfo/PDB/PDBSymbolTypeArray.h"
21 #include "llvm/DebugInfo/PDB/PDBSymbolTypeEnum.h"
22 #include "llvm/DebugInfo/PDB/PDBSymbolTypeFunctionArg.h"
23 #include "llvm/DebugInfo/PDB/PDBSymbolTypeFunctionSig.h"
24 #include "llvm/DebugInfo/PDB/PDBSymbolTypePointer.h"
25 #include "llvm/DebugInfo/PDB/PDBSymbolTypeTypedef.h"
26 #include "llvm/DebugInfo/PDB/PDBSymbolTypeUDT.h"
27 #include "llvm/Support/Format.h"
28
29 using namespace llvm;
30 using namespace llvm::codeview;
31 using namespace llvm::pdb;
32
33 namespace {
34 template
35 void dumpClassParentWithScopeOperator(const T &Symbol, LinePrinter &Printer,
36 FunctionDumper &Dumper) {
37 uint32_t ClassParentId = Symbol.getClassParentId();
38 auto ClassParent =
39 Symbol.getSession().template getConcreteSymbolById(
40 ClassParentId);
41 if (!ClassParent)
42 return;
43
44 WithColor(Printer, PDB_ColorItem::Type).get() << ClassParent->getName();
45 Printer << "::";
46 }
47 }
48
49 FunctionDumper::FunctionDumper(LinePrinter &P)
50 : PDBSymDumper(true), Printer(P) {}
51
52 void FunctionDumper::start(const PDBSymbolTypeFunctionSig &Symbol,
53 const char *Name, PointerType Pointer) {
54 auto ReturnType = Symbol.getReturnType();
55 ReturnType->dump(*this);
56 Printer << " ";
57 uint32_t ClassParentId = Symbol.getClassParentId();
58 auto ClassParent =
59 Symbol.getSession().getConcreteSymbolById(
60 ClassParentId);
61
62 PDB_CallingConv CC = Symbol.getCallingConvention();
63 bool ShouldDumpCallingConvention = true;
64 if ((ClassParent && CC == CallingConvention::ThisCall) ||
65 (!ClassParent && CC == CallingConvention::NearStdCall)) {
66 ShouldDumpCallingConvention = false;
67 }
68
69 if (Pointer == PointerType::None) {
70 if (ShouldDumpCallingConvention)
71 WithColor(Printer, PDB_ColorItem::Keyword).get() << CC << " ";
72 if (ClassParent) {
73 Printer << "(";
74 WithColor(Printer, PDB_ColorItem::Identifier).get()
75 << ClassParent->getName();
76 Printer << "::)";
77 }
78 } else {
79 Printer << "(";
80 if (ShouldDumpCallingConvention)
81 WithColor(Printer, PDB_ColorItem::Keyword).get() << CC << " ";
82 if (ClassParent) {
83 WithColor(Printer, PDB_ColorItem::Identifier).get()
84 << ClassParent->getName();
85 Printer << "::";
86 }
87 if (Pointer == PointerType::Reference)
88 Printer << "&";
89 else
90 Printer << "*";
91 if (Name)
92 WithColor(Printer, PDB_ColorItem::Identifier).get() << Name;
93 Printer << ")";
94 }
95
96 Printer << "(";
97 if (auto ChildEnum = Symbol.getArguments()) {
98 uint32_t Index = 0;
99 while (auto Arg = ChildEnum->getNext()) {
100 Arg->dump(*this);
101 if (++Index < ChildEnum->getChildCount())
102 Printer << ", ";
103 }
104 }
105 Printer << ")";
106
107 if (Symbol.isConstType())
108 WithColor(Printer, PDB_ColorItem::Keyword).get() << " const";
109 if (Symbol.isVolatileType())
110 WithColor(Printer, PDB_ColorItem::Keyword).get() << " volatile";
111 }
112
113 void FunctionDumper::start(const PDBSymbolFunc &Symbol, PointerType Pointer) {
114 uint64_t FuncStart = Symbol.getVirtualAddress();
115 uint64_t FuncEnd = FuncStart + Symbol.getLength();
116
117 Printer << "func [";
118 WithColor(Printer, PDB_ColorItem::Address).get() << format_hex(FuncStart, 10);
119 if (auto DebugStart = Symbol.findOneChild()) {
120 uint64_t Prologue = DebugStart->getVirtualAddress() - FuncStart;
121 WithColor(Printer, PDB_ColorItem::Offset).get() << "+" << Prologue;
122 }
123 Printer << " - ";
124 WithColor(Printer, PDB_ColorItem::Address).get() << format_hex(FuncEnd, 10);
125 if (auto DebugEnd = Symbol.findOneChild()) {
126 uint64_t Epilogue = FuncEnd - DebugEnd->getVirtualAddress();
127 WithColor(Printer, PDB_ColorItem::Offset).get() << "-" << Epilogue;
128 }
129 Printer << "] (";
130
131 if (Symbol.hasFramePointer()) {
132 WithColor(Printer, PDB_ColorItem::Register).get()
133 << Symbol.getLocalBasePointerRegisterId();
134 } else {
135 WithColor(Printer, PDB_ColorItem::Register).get() << "FPO";
136 }
137 Printer << ") ";
138
139 if (Symbol.isVirtual() || Symbol.isPureVirtual())
140 WithColor(Printer, PDB_ColorItem::Keyword).get() << "virtual ";
141
142 auto Signature = Symbol.getSignature();
143 if (!Signature) {
144 WithColor(Printer, PDB_ColorItem::Identifier).get() << Symbol.getName();
145 if (Pointer == PointerType::Pointer)
146 Printer << "*";
147 else if (Pointer == FunctionDumper::PointerType::Reference)
148 Printer << "&";
149 return;
150 }
151
152 auto ReturnType = Signature->getReturnType();
153 ReturnType->dump(*this);
154 Printer << " ";
155
156 auto ClassParent = Symbol.getClassParent();
157 CallingConvention CC = Signature->getCallingConvention();
158 if (Pointer != FunctionDumper::PointerType::None)
159 Printer << "(";
160
161 if ((ClassParent && CC != CallingConvention::ThisCall) ||
162 (!ClassParent && CC != CallingConvention::NearStdCall)) {
163 WithColor(Printer, PDB_ColorItem::Keyword).get()
164 << Signature->getCallingConvention() << " ";
165 }
166 WithColor(Printer, PDB_ColorItem::Identifier).get() << Symbol.getName();
167 if (Pointer != FunctionDumper::PointerType::None) {
168 if (Pointer == PointerType::Pointer)
169 Printer << "*";
170 else if (Pointer == FunctionDumper::PointerType::Reference)
171 Printer << "&";
172 Printer << ")";
173 }
174
175 Printer << "(";
176 if (auto Arguments = Symbol.getArguments()) {
177 uint32_t Index = 0;
178 while (auto Arg = Arguments->getNext()) {
179 auto ArgType = Arg->getType();
180 ArgType->dump(*this);
181 WithColor(Printer, PDB_ColorItem::Identifier).get() << " "
182 << Arg->getName();
183 if (++Index < Arguments->getChildCount())
184 Printer << ", ";
185 }
186 }
187 Printer << ")";
188 if (Symbol.isConstType())
189 WithColor(Printer, PDB_ColorItem::Keyword).get() << " const";
190 if (Symbol.isVolatileType())
191 WithColor(Printer, PDB_ColorItem::Keyword).get() << " volatile";
192 if (Symbol.isPureVirtual())
193 Printer << " = 0";
194 }
195
196 void FunctionDumper::dump(const PDBSymbolTypeArray &Symbol) {
197 uint32_t ElementTypeId = Symbol.getTypeId();
198 auto ElementType = Symbol.getSession().getSymbolById(ElementTypeId);
199 if (!ElementType)
200 return;
201
202 ElementType->dump(*this);
203 Printer << "[";
204 WithColor(Printer, PDB_ColorItem::LiteralValue).get() << Symbol.getLength();
205 Printer << "]";
206 }
207
208 void FunctionDumper::dump(const PDBSymbolTypeBuiltin &Symbol) {
209 BuiltinDumper Dumper(Printer);
210 Dumper.start(Symbol);
211 }
212
213 void FunctionDumper::dump(const PDBSymbolTypeEnum &Symbol) {
214 dumpClassParentWithScopeOperator(Symbol, Printer, *this);
215 WithColor(Printer, PDB_ColorItem::Type).get() << Symbol.getName();
216 }
217
218 void FunctionDumper::dump(const PDBSymbolTypeFunctionArg &Symbol) {
219 // PDBSymbolTypeFunctionArg is just a shim over the real argument. Just drill
220 // through to the real thing and dump it.
221 uint32_t TypeId = Symbol.getTypeId();
222 auto Type = Symbol.getSession().getSymbolById(TypeId);
223 if (!Type)
224 return;
225 Type->dump(*this);
226 }
227
228 void FunctionDumper::dump(const PDBSymbolTypeTypedef &Symbol) {
229 dumpClassParentWithScopeOperator(Symbol, Printer, *this);
230 WithColor(Printer, PDB_ColorItem::Type).get() << Symbol.getName();
231 }
232
233 void FunctionDumper::dump(const PDBSymbolTypePointer &Symbol) {
234 uint32_t PointeeId = Symbol.getTypeId();
235 auto PointeeType = Symbol.getSession().getSymbolById(PointeeId);
236 if (!PointeeType)
237 return;
238
239 if (auto FuncSig = dyn_cast(PointeeType.get())) {
240 FunctionDumper NestedDumper(Printer);
241 PointerType Pointer =
242 Symbol.isReference() ? PointerType::Reference : PointerType::Pointer;
243 NestedDumper.start(*FuncSig, nullptr, Pointer);
244 } else {
245 if (Symbol.isConstType())
246 WithColor(Printer, PDB_ColorItem::Keyword).get() << "const ";
247 if (Symbol.isVolatileType())
248 WithColor(Printer, PDB_ColorItem::Keyword).get() << "volatile ";
249 PointeeType->dump(*this);
250 Printer << (Symbol.isReference() ? "&" : "*");
251 }
252 }
253
254 void FunctionDumper::dump(const PDBSymbolTypeUDT &Symbol) {
255 WithColor(Printer, PDB_ColorItem::Type).get() << Symbol.getName();
256 }
+0
-43
tools/llvm-pdbdump/FunctionDumper.h less more
None //===- FunctionDumper.h --------------------------------------- *- C++ --*-===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8
9 #ifndef LLVM_TOOLS_LLVMPDBDUMP_FUNCTIONDUMPER_H
10 #define LLVM_TOOLS_LLVMPDBDUMP_FUNCTIONDUMPER_H
11
12 #include "llvm/DebugInfo/PDB/PDBSymDumper.h"
13
14 namespace llvm {
15 namespace pdb {
16 class LinePrinter;
17
18 class FunctionDumper : public PDBSymDumper {
19 public:
20 FunctionDumper(LinePrinter &P);
21
22 enum class PointerType { None, Pointer, Reference };
23
24 void start(const PDBSymbolTypeFunctionSig &Symbol, const char *Name,
25 PointerType Pointer);
26 void start(const PDBSymbolFunc &Symbol, PointerType Pointer);
27
28 void dump(const PDBSymbolTypeArray &Symbol) override;
29 void dump(const PDBSymbolTypeBuiltin &Symbol) override;
30 void dump(const PDBSymbolTypeEnum &Symbol) override;
31 void dump(const PDBSymbolTypeFunctionArg &Symbol) override;
32 void dump(const PDBSymbolTypePointer &Symbol) override;
33 void dump(const PDBSymbolTypeTypedef &Symbol) override;
34 void dump(const PDBSymbolTypeUDT &Symbol) override;
35
36 private:
37 LinePrinter &Printer;
38 };
39 }
40 }
41
42 #endif
1111
1212 #include "OutputStyle.h"
1313
14 #include "llvm/DebugInfo/CodeView/TypeDumper.h"
14 #include "llvm/DebugInfo/CodeView/CVTypeDumper.h"
1515 #include "llvm/Support/ScopedPrinter.h"
1616
1717 namespace llvm {
0 //===- PrettyBuiltinDumper.cpp ---------------------------------- *- C++ *-===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8
9 #include "PrettyBuiltinDumper.h"
10 #include "LinePrinter.h"
11 #include "llvm-pdbdump.h"
12
13 #include "llvm/DebugInfo/PDB/PDBSymbolTypeBuiltin.h"
14
15 using namespace llvm;
16 using namespace llvm::pdb;
17
18 BuiltinDumper::BuiltinDumper(LinePrinter &P)
19 : PDBSymDumper(false), Printer(P) {}
20
21 void BuiltinDumper::start(const PDBSymbolTypeBuiltin &Symbol) {
22 WithColor(Printer, PDB_ColorItem::Type).get() << getTypeName(Symbol);
23 }
24
25 StringRef BuiltinDumper::getTypeName(const PDBSymbolTypeBuiltin &Symbol) {
26 PDB_BuiltinType Type = Symbol.getBuiltinType();
27 switch (Type) {
28 case PDB_BuiltinType::Float:
29 if (Symbol.getLength() == 4)
30 return "float";
31 return "double";
32 case PDB_BuiltinType::UInt:
33 switch (Symbol.getLength()) {
34 case 8:
35 return "unsigned __int64";
36 case 4:
37 return "unsigned int";
38 case 2:
39 return "unsigned short";
40 case 1:
41 return "unsigned char";
42 default:
43 return "unsigned";
44 }
45 case PDB_BuiltinType::Int:
46 switch (Symbol.getLength()) {
47 case 8:
48 return "__int64";
49 case 4:
50 return "int";
51 case 2:
52 return "short";
53 case 1:
54 return "char";
55 default:
56 return "int";
57 }
58 case PDB_BuiltinType::Char:
59 return "char";
60 case PDB_BuiltinType::WCharT:
61 return "wchar_t";
62 case PDB_BuiltinType::Void:
63 return "void";
64 case PDB_BuiltinType::Long:
65 return "long";
66 case PDB_BuiltinType::ULong:
67 return "unsigned long";
68 case PDB_BuiltinType::Bool:
69 return "bool";
70 case PDB_BuiltinType::Currency:
71 return "CURRENCY";
72 case PDB_BuiltinType::Date:
73 return "DATE";
74 case PDB_BuiltinType::Variant:
75 return "VARIANT";
76 case PDB_BuiltinType::Complex:
77 return "complex";
78 case PDB_BuiltinType::Bitfield:
79 return "bitfield";
80 case PDB_BuiltinType::BSTR:
81 return "BSTR";
82 case PDB_BuiltinType::HResult:
83 return "HRESULT";
84 case PDB_BuiltinType::BCD:
85 return "HRESULT";
86 default:
87 return "void";
88 }
89 }
0 //===- PrettyBuiltinDumper.h ---------------------------------- *- C++ --*-===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8
9 #ifndef LLVM_TOOLS_LLVMPDBDUMP_PRETTYBUILTINDUMPER_H
10 #define LLVM_TOOLS_LLVMPDBDUMP_PRETTYBUILTINDUMPER_H
11
12 #include "llvm/ADT/StringRef.h"
13 #include "llvm/DebugInfo/PDB/PDBSymDumper.h"
14
15 namespace llvm {
16 namespace pdb {
17
18 class LinePrinter;
19
20 class BuiltinDumper : public PDBSymDumper {
21 public:
22 BuiltinDumper(LinePrinter &P);
23
24 void start(const PDBSymbolTypeBuiltin &Symbol);
25
26 private:
27 StringRef getTypeName(const PDBSymbolTypeBuiltin &Symbol);
28
29 LinePrinter &Printer;
30 };
31 }
32 }
33
34 #endif
0 //===- PrettyClassDefinitionDumper.cpp --------------------------*- C++ -*-===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8
9 #include "PrettyClassDefinitionDumper.h"
10
11 #include "LinePrinter.h"
12 #include "PrettyEnumDumper.h"
13 #include "PrettyFunctionDumper.h"
14 #include "PrettyTypedefDumper.h"
15 #include "PrettyVariableDumper.h"
16 #include "llvm-pdbdump.h"
17
18 #include "llvm/DebugInfo/PDB/IPDBSession.h"
19 #include "llvm/DebugInfo/PDB/PDBExtras.h"
20 #include "llvm/DebugInfo/PDB/PDBSymbolData.h"
21 #include "llvm/DebugInfo/PDB/PDBSymbolFunc.h"
22 #include "llvm/DebugInfo/PDB/PDBSymbolTypeBaseClass.h"
23 #include "llvm/DebugInfo/PDB/PDBSymbolTypeEnum.h"
24 #include "llvm/DebugInfo/PDB/PDBSymbolTypePointer.h"
25 #include "llvm/DebugInfo/PDB/PDBSymbolTypeTypedef.h"
26 #include "llvm/DebugInfo/PDB/PDBSymbolTypeUDT.h"
27 #include "llvm/DebugInfo/PDB/PDBSymbolTypeVTable.h"
28 #include "llvm/Support/Format.h"
29
30 using namespace llvm;
31 using namespace llvm::pdb;
32
33 ClassDefinitionDumper::ClassDefinitionDumper(LinePrinter &P)
34 : PDBSymDumper(true), Printer(P) {}
35
36 void ClassDefinitionDumper::start(const PDBSymbolTypeUDT &Class) {
37 std::string Name = Class.getName();
38 WithColor(Printer, PDB_ColorItem::Keyword).get() << Class.getUdtKind() << " ";
39 WithColor(Printer, PDB_ColorItem::Type).get() << Class.getName();
40
41 auto Bases = Class.findAllChildren();
42 if (Bases->getChildCount() > 0) {
43 Printer.Indent();
44 Printer.NewLine();
45 Printer << ":";
46 uint32_t BaseIndex = 0;
47 while (auto Base = Bases->getNext()) {
48 Printer << " ";
49 WithColor(Printer, PDB_ColorItem::Keyword).get() << Base->getAccess();
50 if (Base->isVirtualBaseClass())
51 WithColor(Printer, PDB_ColorItem::Keyword).get() << " virtual";
52 WithColor(Printer, PDB_ColorItem::Type).get() << " " << Base->getName();
53 if (++BaseIndex < Bases->getChildCount()) {
54 Printer.NewLine();
55 Printer << ",";
56 }
57 }
58 Printer.Unindent();
59 }
60
61 Printer << " {";
62 auto Children = Class.findAllChildren();
63 if (Children->getChildCount() == 0) {
64 Printer << "}";
65 return;
66 }
67
68 // Try to dump symbols organized by member access level. Public members
69 // first, then protected, then private. This might be slow, so it's worth
70 // reconsidering the value of this if performance of large PDBs is a problem.
71 // NOTE: Access level of nested types is not recorded in the PDB, so we have
72 // a special case for them.
73 SymbolGroupByAccess Groups;
74 Groups.insert(std::make_pair(0, SymbolGroup()));
75 Groups.insert(std::make_pair((int)PDB_MemberAccess::Private, SymbolGroup()));
76 Groups.insert(
77 std::make_pair((int)PDB_MemberAccess::Protected, SymbolGroup()));
78 Groups.insert(std::make_pair((int)PDB_MemberAccess::Public, SymbolGroup()));
79
80 while (auto Child = Children->getNext()) {
81 PDB_MemberAccess Access = Child->getRawSymbol().getAccess();
82 if (isa(*Child))
83 continue;
84
85 auto &AccessGroup = Groups.find((int)Access)->second;
86
87 if (auto Func = dyn_cast(Child.get())) {
88 if (Func->isCompilerGenerated() && opts::pretty::ExcludeCompilerGenerated)
89 continue;
90 if (Func->getLength() == 0 && !Func->isPureVirtual() &&
91 !Func->isIntroVirtualFunction())
92 continue;
93 Child.release();
94 AccessGroup.Functions.push_back(std::unique_ptr(Func));
95 } else if (auto Data = dyn_cast(Child.get())) {
96 Child.release();
97 AccessGroup.Data.push_back(std::unique_ptr(Data));
98 } else {
99 AccessGroup.Unknown.push_back(std::move(Child));
100 }
101 }
102
103 int Count = 0;
104 Count += dumpAccessGroup((PDB_MemberAccess)0, Groups[0]);
105 Count += dumpAccessGroup(PDB_MemberAccess::Public,
106 Groups[(int)PDB_MemberAccess::Public]);
107 Count += dumpAccessGroup(PDB_MemberAccess::Protected,
108 Groups[(int)PDB_MemberAccess::Protected]);
109 Count += dumpAccessGroup(PDB_MemberAccess::Private,
110 Groups[(int)PDB_MemberAccess::Private]);
111 if (Count > 0)
112 Printer.NewLine();
113 Printer << "}";
114 }
115
116 int ClassDefinitionDumper::dumpAccessGroup(PDB_MemberAccess Access,
117 const SymbolGroup &Group) {
118 if (Group.Functions.empty() && Group.Data.empty() && Group.Unknown.empty())
119 return 0;
120
121 int Count = 0;
122 if (Access == PDB_MemberAccess::Private) {
123 Printer.NewLine();
124 WithColor(Printer, PDB_ColorItem::Keyword).get() << "private";
125 Printer << ":";
126 } else if (Access == PDB_MemberAccess::Protected) {
127 Printer.NewLine();
128 WithColor(Printer, PDB_ColorItem::Keyword).get() << "protected";
129 Printer << ":";
130 } else if (Access == PDB_MemberAccess::Public) {
131 Printer.NewLine();
132 WithColor(Printer, PDB_ColorItem::Keyword).get() << "public";
133 Printer << ":";
134 }
135 Printer.Indent();
136 for (auto iter = Group.Functions.begin(), end = Group.Functions.end();
137 iter != end; ++iter) {
138 ++Count;
139 (*iter)->dump(*this);
140 }
141 for (auto iter = Group.Data.begin(), end = Group.Data.end(); iter != end;
142 ++iter) {
143 ++Count;
144 (*iter)->dump(*this);
145 }
146 for (auto iter = Group.Unknown.begin(), end = Group.Unknown.end();
147 iter != end; ++iter) {
148 ++Count;
149 (*iter)->dump(*this);
150 }
151 Printer.Unindent();
152 return Count;
153 }
154
155 void ClassDefinitionDumper::dump(const PDBSymbolTypeBaseClass &Symbol) {}
156
157 void ClassDefinitionDumper::dump(const PDBSymbolData &Symbol) {
158 VariableDumper Dumper(Printer);
159 Dumper.start(Symbol);
160 }
161
162 void ClassDefinitionDumper::dump(const PDBSymbolFunc &Symbol) {
163 if (Printer.IsSymbolExcluded(Symbol.getName()))
164 return;
165
166 Printer.NewLine();
167 FunctionDumper Dumper(Printer);
168 Dumper.start(Symbol, FunctionDumper::PointerType::None);
169 }
170
171 void ClassDefinitionDumper::dump(const PDBSymbolTypeVTable &Symbol) {}
172
173 void ClassDefinitionDumper::dump(const PDBSymbolTypeEnum &Symbol) {
174 if (Printer.IsTypeExcluded(Symbol.getName()))
175 return;
176
177 Printer.NewLine();
178 EnumDumper Dumper(Printer);
179 Dumper.start(Symbol);
180 }
181
182 void ClassDefinitionDumper::dump(const PDBSymbolTypeTypedef &Symbol) {
183 if (Printer.IsTypeExcluded(Symbol.getName()))
184 return;
185
186 Printer.NewLine();
187 TypedefDumper Dumper(Printer);
188 Dumper.start(Symbol);
189 }
190
191 void ClassDefinitionDumper::dump(const PDBSymbolTypeUDT &Symbol) {}
0 //===- PrettyClassDefinitionDumper.h ----------------------------*- C++ -*-===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8
9 #ifndef LLVM_TOOLS_LLVMPDBDUMP_PRETTYCLASSDEFINITIONDUMPER_H
10 #define LLVM_TOOLS_LLVMPDBDUMP_PRETTYCLASSDEFINITIONDUMPER_H
11
12 #include "llvm/DebugInfo/PDB/PDBSymDumper.h"
13 #include "llvm/DebugInfo/PDB/PDBSymbolData.h"
14 #include "llvm/DebugInfo/PDB/PDBSymbolFunc.h"
15
16 #include
17 #include
18 #include
19
20 namespace llvm {
21 namespace pdb {
22
23 class LinePrinter;
24
25 class ClassDefinitionDumper : public PDBSymDumper {
26 public:
27 ClassDefinitionDumper(LinePrinter &P);
28
29 void start(const PDBSymbolTypeUDT &Exe);
30
31 void dump(const PDBSymbolTypeBaseClass &Symbol) override;
32 void dump(const PDBSymbolData &Symbol) override;
33 void dump(const PDBSymbolTypeEnum &Symbol) override;
34 void dump(const PDBSymbolFunc &Symbol) override;
35 void dump(const PDBSymbolTypeTypedef &Symbol) override;
36 void dump(const PDBSymbolTypeUDT &Symbol) override;
37 void dump(const PDBSymbolTypeVTable &Symbol) override;
38
39 private:
40 LinePrinter &Printer;
41
42 struct SymbolGroup {
43 SymbolGroup() {}
44 SymbolGroup(SymbolGroup &&Other) {
45 Functions = std::move(Other.Functions);
46 Data = std::move(Other.Data);
47 Unknown = std::move(Other.Unknown);
48 }
49
50 std::list> Functions;
51 std::list> Data;
52 std::list> Unknown;
53 SymbolGroup(const SymbolGroup &other) = delete;
54 SymbolGroup &operator=(const SymbolGroup &other) = delete;
55 };
56 typedef std::unordered_map SymbolGroupByAccess;
57
58 int dumpAccessGroup(PDB_MemberAccess Access, const SymbolGroup &Group);
59 };
60 }
61 }
62 #endif
0 //===- PrettyCompilandDumper.cpp - llvm-pdbdump compiland dumper -*- C++ *-===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8
9 #include "PrettyCompilandDumper.h"
10
11 #include "LinePrinter.h"
12 #include "PrettyFunctionDumper.h"
13 #include "llvm-pdbdump.h"
14
15 #include "llvm/DebugInfo/PDB/IPDBEnumChildren.h"
16 #include "llvm/DebugInfo/PDB/IPDBLineNumber.h"
17 #include "llvm/DebugInfo/PDB/IPDBSession.h"
18 #include "llvm/DebugInfo/PDB/IPDBSourceFile.h"
19 #include "llvm/DebugInfo/PDB/PDBExtras.h"
20 #include "llvm/DebugInfo/PDB/PDBSymbol.h"
21 #include "llvm/DebugInfo/PDB/PDBSymbolCompiland.h"
22 #include "llvm/DebugInfo/PDB/PDBSymbolData.h"
23 #include "llvm/DebugInfo/PDB/PDBSymbolFunc.h"
24 #include "llvm/DebugInfo/PDB/PDBSymbolFuncDebugEnd.h"
25 #include "llvm/DebugInfo/PDB/PDBSymbolFuncDebugStart.h"
26 #include "llvm/DebugInfo/PDB/PDBSymbolLabel.h"
27 #include "llvm/DebugInfo/PDB/PDBSymbolThunk.h"
28 #include "llvm/DebugInfo/PDB/PDBSymbolTypeFunctionSig.h"
29 #include "llvm/DebugInfo/PDB/PDBSymbolUnknown.h"
30 #include "llvm/Support/Format.h"
31 #include "llvm/Support/Path.h"
32 #include "llvm/Support/raw_ostream.h"
33
34 #include
35
36 using namespace llvm;
37 using namespace llvm::pdb;
38
39 CompilandDumper::CompilandDumper(LinePrinter &P)
40 : PDBSymDumper(true), Printer(P) {}
41
42 void CompilandDumper::dump(const PDBSymbolCompilandDetails &Symbol) {}
43
44 void CompilandDumper::dump(const PDBSymbolCompilandEnv &Symbol) {}
45
46 void CompilandDumper::start(const PDBSymbolCompiland &Symbol,
47 CompilandDumpFlags opts) {
48 std::string FullName = Symbol.getName();
49 if (Printer.IsCompilandExcluded(FullName))
50 return;
51
52 Printer.NewLine();
53 WithColor(Printer, PDB_ColorItem::Path).get() << FullName;
54
55 if (opts & Flags::Lines) {
56 const IPDBSession &Session = Symbol.getSession();
57 auto Files = Session.getSourceFilesForCompiland(Symbol);
58 Printer.Indent();
59 while (auto File = Files->getNext()) {
60 Printer.NewLine();
61 WithColor(Printer, PDB_ColorItem::Path).get() << File->getFileName();
62
63 auto Lines = Session.findLineNumbers(Symbol, *File);
64 Printer.Indent();
65 while (auto Line = Lines->getNext()) {
66 Printer.NewLine();
67 uint32_t LineStart = Line->getLineNumber();
68 uint32_t LineEnd = Line->getLineNumberEnd();
69
70 Printer << "Line ";
71 PDB_ColorItem StatementColor = Line->isStatement()
72 ? PDB_ColorItem::Keyword
73 : PDB_ColorItem::LiteralValue;
74 WithColor(Printer, StatementColor).get() << LineStart;
75 if (LineStart != LineEnd)
76 WithColor(Printer, StatementColor).get() << " - " << LineEnd;
77
78 uint32_t ColumnStart = Line->getColumnNumber();
79 uint32_t ColumnEnd = Line->getColumnNumberEnd();
80 if (ColumnStart != 0 || ColumnEnd != 0) {
81 Printer << ", Column: ";
82 WithColor(Printer, StatementColor).get() << ColumnStart;
83 if (ColumnEnd != ColumnStart)
84 WithColor(Printer, StatementColor).get() << " - " << ColumnEnd;
85 }
86
87 Printer << ", Address: ";
88 if (Line->getLength() > 0) {
89 uint64_t AddrStart = Line->getVirtualAddress();
90 uint64_t AddrEnd = AddrStart + Line->getLength() - 1;
91 WithColor(Printer, PDB_ColorItem::Address).get()
92 << "[" << format_hex(AddrStart, 10) << " - "
93 << format_hex(AddrEnd, 10) << "]";
94 Printer << " (" << Line->getLength() << " bytes)";
95 } else {
96 uint64_t AddrStart = Line->getVirtualAddress();
97 WithColor(Printer, PDB_ColorItem::Address).get()
98 << "[" << format_hex(AddrStart, 10) << "] ";
99 Printer << "(0 bytes)";
100 }
101 }
102 Printer.Unindent();
103 }
104 Printer.Unindent();
105 }
106
107 if (opts & Flags::Children) {
108 auto ChildrenEnum = Symbol.findAllChildren();
109 Printer.Indent();
110 while (auto Child = ChildrenEnum->getNext())
111 Child->dump(*this);
112 Printer.Unindent();
113 }
114 }
115
116 void CompilandDumper::dump(const PDBSymbolData &Symbol) {
117 if (Printer.IsSymbolExcluded(Symbol.getName()))
118 return;
119
120 Printer.NewLine();
121
122 switch (auto LocType = Symbol.getLocationType()) {
123 case PDB_LocType::Static:
124 Printer << "data: ";
125 WithColor(Printer, PDB_ColorItem::Address).get()
126 << "[" << format_hex(Symbol.getVirtualAddress(), 10) << "]";
127 break;
128 case PDB_LocType::Constant:
129 Printer << "constant: ";
130 WithColor(Printer, PDB_ColorItem::LiteralValue).get()
131 << "[" << Symbol.getValue() << "]";
132 break;
133 default:
134 Printer << "data(unexpected type=" << LocType << ")";
135 }
136
137 Printer << " ";
138 WithColor(Printer, PDB_ColorItem::Identifier).get() << Symbol.getName();
139 }
140
141 void CompilandDumper::dump(const PDBSymbolFunc &Symbol) {
142 if (Symbol.getLength() == 0)
143 return;
144 if (Printer.IsSymbolExcluded(Symbol.getName()))
145 return;
146
147 Printer.NewLine();
148 FunctionDumper Dumper(Printer);
149 Dumper.start(Symbol, FunctionDumper::PointerType::None);
150 }
151
152 void CompilandDumper::dump(const PDBSymbolLabel &Symbol) {
153 if (Printer.IsSymbolExcluded(Symbol.getName()))
154 return;
155
156 Printer.NewLine();
157 Printer << "label ";
158 WithColor(Printer, PDB_ColorItem::Address).get()
159 << "[" << format_hex(Symbol.getVirtualAddress(), 10) << "] ";
160 WithColor(Printer, PDB_ColorItem::Identifier).get() << Symbol.getName();
161 }
162
163 void CompilandDumper::dump(const PDBSymbolThunk &Symbol) {
164 if (Printer.IsSymbolExcluded(Symbol.getName()))
165 return;
166
167 Printer.NewLine();
168 Printer << "thunk ";
169 codeview::ThunkOrdinal Ordinal = Symbol.getThunkOrdinal();
170 uint64_t VA = Symbol.getVirtualAddress();
171 if (Ordinal == codeview::ThunkOrdinal::TrampIncremental) {
172 uint64_t Target = Symbol.getTargetVirtualAddress();
173 WithColor(Printer, PDB_ColorItem::Address).get() << format_hex(VA, 10);
174 Printer << " -> ";
175 WithColor(Printer, PDB_ColorItem::Address).get() << format_hex(Target, 10);
176 } else {
177 WithColor(Printer, PDB_ColorItem::Address).get()
178 << "[" << format_hex(VA, 10) << " - "
179 << format_hex(VA + Symbol.getLength(), 10) << "]";
180 }
181 Printer << " (";
182 WithColor(Printer, PDB_ColorItem::Register).get() << Ordinal;
183 Printer << ") ";
184 std::string Name = Symbol.getName();
185 if (!Name.empty())
186 WithColor(Printer, PDB_ColorItem::Identifier).get() << Name;
187 }
188
189 void CompilandDumper::dump(const PDBSymbolTypeTypedef &Symbol) {}
190
191 void CompilandDumper::dump(const PDBSymbolUnknown &Symbol) {
192 Printer.NewLine();
193 Printer << "unknown (" << Symbol.getSymTag() << ")";
194 }
0 //===- PrettyCompilandDumper.h - llvm-pdbdump compiland dumper -*- C++ --*-===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8
9 #ifndef LLVM_TOOLS_LLVMPDBDUMP_PRETTYCOMPILANDDUMPER_H
10 #define LLVM_TOOLS_LLVMPDBDUMP_PRETTYCOMPILANDDUMPER_H
11
12 #include "llvm/DebugInfo/PDB/PDBSymDumper.h"
13
14 namespace llvm {
15 namespace pdb {
16
17 class LinePrinter;
18
19 typedef int CompilandDumpFlags;
20 class CompilandDumper : public PDBSymDumper {
21 public:
22 enum Flags { None = 0x0, Children = 0x1, Symbols = 0x2, Lines = 0x4 };
23
24 CompilandDumper(LinePrinter &P);
25
26 void start(const PDBSymbolCompiland &Symbol, CompilandDumpFlags flags);
27
28 void dump(const PDBSymbolCompilandDetails &Symbol) override;
29 void dump(const PDBSymbolCompilandEnv &Symbol) override;
30 void dump(const PDBSymbolData &Symbol) override;
31 void dump(const PDBSymbolFunc &Symbol) override;
32 void dump(const PDBSymbolLabel &Symbol) override;
33 void dump(const PDBSymbolThunk &Symbol) override;
34 void dump(const PDBSymbolTypeTypedef &Symbol) override;
35 void dump(const PDBSymbolUnknown &Symbol) override;
36
37 private:
38 LinePrinter &Printer;
39 };
40 }
41 }
42
43 #endif
0 //===- PrettyEnumDumper.cpp -------------------------------------*- C++ -*-===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8
9 #include "PrettyEnumDumper.h"
10
11 #include "LinePrinter.h"
12 #include "PrettyBuiltinDumper.h"
13 #include "llvm-pdbdump.h"
14
15 #include "llvm/DebugInfo/PDB/PDBSymbolData.h"
16 #include "llvm/DebugInfo/PDB/PDBSymbolTypeBuiltin.h"
17 #include "llvm/DebugInfo/PDB/PDBSymbolTypeEnum.h"
18
19 using namespace llvm;
20 using namespace llvm::pdb;
21
22 EnumDumper::EnumDumper(LinePrinter &P) : PDBSymDumper(true), Printer(P) {}
23
24 void EnumDumper::start(const PDBSymbolTypeEnum &Symbol) {
25 WithColor(Printer, PDB_ColorItem::Keyword).get() << "enum ";
26 WithColor(Printer, PDB_ColorItem::Type).get() << Symbol.getName();
27 if (!opts::pretty::NoEnumDefs) {
28 auto BuiltinType = Symbol.getUnderlyingType();
29 if (BuiltinType->getBuiltinType() != PDB_BuiltinType::Int ||
30 BuiltinType->getLength() != 4) {
31 Printer << " : ";
32 BuiltinDumper Dumper(Printer);
33 Dumper.start(*BuiltinType);
34 }
35 Printer << " {";
36 Printer.Indent();
37 auto EnumValues = Symbol.findAllChildren();
38 while (auto EnumValue = EnumValues->getNext()) {
39 if (EnumValue->getDataKind() != PDB_DataKind::Constant)
40 continue;
41 Printer.NewLine();
42 WithColor(Printer, PDB_ColorItem::Identifier).get()
43 << EnumValue->getName();
44 Printer << " = ";
45 WithColor(Printer, PDB_ColorItem::LiteralValue).get()
46 << EnumValue->getValue();
47 }
48 Printer.Unindent();
49 Printer.NewLine();
50 Printer << "}";
51 }
52 }
0 //===- PrettyEnumDumper.h ---------------------------------------*- C++ -*-===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8
9 #ifndef LLVM_TOOLS_LLVMPDBDUMP_PRETTYENUMDUMPER_H
10 #define LLVM_TOOLS_LLVMPDBDUMP_PRETTYENUMDUMPER_H
11
12 #include "llvm/DebugInfo/PDB/PDBSymDumper.h"
13
14 namespace llvm {
15 namespace pdb {
16
17 class LinePrinter;
18
19 class EnumDumper : public PDBSymDumper {
20 public:
21 EnumDumper(LinePrinter &P);
22
23 void start(const PDBSymbolTypeEnum &Symbol);
24
25 private:
26 LinePrinter &Printer;
27 };
28 }
29 }
30 #endif
0 //===- PrettyExternalSymbolDumper.cpp -------------------------- *- C++ *-===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8
9 #include "PrettyExternalSymbolDumper.h"
10 #include "LinePrinter.h"
11
12 #include "llvm/DebugInfo/PDB/PDBSymbolExe.h"
13 #include "llvm/DebugInfo/PDB/PDBSymbolPublicSymbol.h"
14 #include "llvm/Support/Format.h"
15
16 using namespace llvm;
17 using namespace llvm::pdb;
18
19 ExternalSymbolDumper::ExternalSymbolDumper(LinePrinter &P)
20 : PDBSymDumper(true), Printer(P) {}
21
22 void ExternalSymbolDumper::start(const PDBSymbolExe &Symbol) {
23 auto Vars = Symbol.findAllChildren();
24 while (auto Var = Vars->getNext())
25 Var->dump(*this);
26 }
27
28 void ExternalSymbolDumper::dump(const PDBSymbolPublicSymbol &Symbol) {
29 std::string LinkageName = Symbol.getName();
30 if (Printer.IsSymbolExcluded(LinkageName))
31 return;
32
33 Printer.NewLine();
34 uint64_t Addr = Symbol.getVirtualAddress();
35
36 Printer << "[";
37 WithColor(Printer, PDB_ColorItem::Address).get() << format_hex(Addr, 10);
38 Printer << "] ";
39 WithColor(Printer, PDB_ColorItem::Identifier).get() << LinkageName;
40 }
0 //===- PrettyExternalSymbolDumper.h --------------------------- *- C++ --*-===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8
9 #ifndef LLVM_TOOLS_LLVMPDBDUMP_PRETTYEXTERNALSYMBOLDUMPER_H
10 #define LLVM_TOOLS_LLVMPDBDUMP_PRETTYEXTERNALSYMBOLDUMPER_H
11
12 #include "llvm/DebugInfo/PDB/PDBSymDumper.h"
13
14 namespace llvm {
15 namespace pdb {
16
17 class LinePrinter;
18
19 class ExternalSymbolDumper : public PDBSymDumper {
20 public:
21 ExternalSymbolDumper(LinePrinter &P);
22
23 void start(const PDBSymbolExe &Symbol);
24
25 void dump(const PDBSymbolPublicSymbol &Symbol) override;
26
27 private:
28 LinePrinter &Printer;
29 };
30 }
31 }
32
33 #endif
0 //===- PrettyFunctionDumper.cpp --------------------------------- *- C++ *-===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8
9 #include "PrettyFunctionDumper.h"
10 #include "LinePrinter.h"
11 #include "PrettyBuiltinDumper.h"
12 #include "llvm-pdbdump.h"
13
14 #include "llvm/DebugInfo/PDB/IPDBSession.h"
15 #include "llvm/DebugInfo/PDB/PDBExtras.h"
16 #include "llvm/DebugInfo/PDB/PDBSymbolData.h"
17 #include "llvm/DebugInfo/PDB/PDBSymbolFunc.h"
18 #include "llvm/DebugInfo/PDB/PDBSymbolFuncDebugEnd.h"
19 #include "llvm/DebugInfo/PDB/PDBSymbolFuncDebugStart.h"
20 #include "llvm/DebugInfo/PDB/PDBSymbolTypeArray.h"
21 #include "llvm/DebugInfo/PDB/PDBSymbolTypeEnum.h"
22 #include "llvm/DebugInfo/PDB/PDBSymbolTypeFunctionArg.h"
23 #include "llvm/DebugInfo/PDB/PDBSymbolTypeFunctionSig.h"
24 #include "llvm/DebugInfo/PDB/PDBSymbolTypePointer.h"
25 #include "llvm/DebugInfo/PDB/PDBSymbolTypeTypedef.h"
26 #include "llvm/DebugInfo/PDB/PDBSymbolTypeUDT.h"
27 #include "llvm/Support/Format.h"
28
29 using namespace llvm;
30 using namespace llvm::codeview;
31 using namespace llvm::pdb;
32
33 namespace {
34 template
35 void dumpClassParentWithScopeOperator(const T &Symbol, LinePrinter &Printer,
36 FunctionDumper &Dumper) {
37 uint32_t ClassParentId = Symbol.getClassParentId();
38 auto ClassParent =
39 Symbol.getSession().template getConcreteSymbolById(
40 ClassParentId);
41 if (!ClassParent)
42 return;
43
44 WithColor(Printer, PDB_ColorItem::Type).get() << ClassParent->getName();
45 Printer << "::";
46 }
47 }
48
49 FunctionDumper::FunctionDumper(LinePrinter &P)
50 : PDBSymDumper(true), Printer(P) {}
51
52 void FunctionDumper::start(const PDBSymbolTypeFunctionSig &Symbol,
53 const char *Name, PointerType Pointer) {
54 auto ReturnType = Symbol.getReturnType();
55 ReturnType->dump(*this);
56 Printer << " ";
57 uint32_t ClassParentId = Symbol.getClassParentId();
58 auto ClassParent =
59 Symbol.getSession().getConcreteSymbolById(
60 ClassParentId);
61
62 PDB_CallingConv CC = Symbol.getCallingConvention();
63 bool ShouldDumpCallingConvention = true;
64 if ((ClassParent && CC == CallingConvention::ThisCall) ||
65 (!ClassParent && CC == CallingConvention::NearStdCall)) {
66 ShouldDumpCallingConvention = false;
67 }
68
69 if (Pointer == PointerType::None) {
70 if (ShouldDumpCallingConvention)
71 WithColor(Printer, PDB_ColorItem::Keyword).get() << CC << " ";
72 if (ClassParent) {
73 Printer << "(";
74 WithColor(Printer, PDB_ColorItem::Identifier).get()
75 << ClassParent->getName();
76 Printer << "::)";
77 }
78 } else {
79 Printer << "(";
80 if (ShouldDumpCallingConvention)
81 WithColor(Printer, PDB_ColorItem::Keyword).get() << CC << " ";
82 if (ClassParent) {
83 WithColor(Printer, PDB_ColorItem::Identifier).get()
84 << ClassParent->getName();
85 Printer << "::";
86 }
87 if (Pointer == PointerType::Reference)
88 Printer << "&";
89 else
90 Printer << "*";
91 if (Name)
92 WithColor(Printer, PDB_ColorItem::Identifier).get() << Name;
93 Printer << ")";
94 }
95
96 Printer << "(";
97 if (auto ChildEnum = Symbol.getArguments()) {
98 uint32_t Index = 0;
99 while (auto Arg = ChildEnum->getNext()) {
100 Arg->dump(*this);
101 if (++Index < ChildEnum->getChildCount())
102 Printer << ", ";
103 }
104 }
105 Printer << ")";
106
107 if (Symbol.isConstType())
108 WithColor(Printer, PDB_ColorItem::Keyword).get() << " const";
109 if (Symbol.isVolatileType())
110 WithColor(Printer, PDB_ColorItem::Keyword).get() << " volatile";
111 }
112
113 void FunctionDumper::start(const PDBSymbolFunc &Symbol, PointerType Pointer) {
114 uint64_t FuncStart = Symbol.getVirtualAddress();
115 uint64_t FuncEnd = FuncStart + Symbol.getLength();
116
117 Printer << "func [";
118 WithColor(Printer, PDB_ColorItem::Address).get() << format_hex(FuncStart, 10);
119 if (auto DebugStart = Symbol.findOneChild()) {
120 uint64_t Prologue = DebugStart->getVirtualAddress() - FuncStart;
121 WithColor(Printer, PDB_ColorItem::Offset).get() << "+" << Prologue;
122 }
123 Printer << " - ";
124 WithColor(Printer, PDB_ColorItem::Address).get() << format_hex(FuncEnd, 10);
125 if (auto DebugEnd = Symbol.findOneChild()) {
126 uint64_t Epilogue = FuncEnd - DebugEnd->getVirtualAddress();
127 WithColor(Printer, PDB_ColorItem::Offset).get() << "-" << Epilogue;
128 }
129 Printer << "] (";
130
131 if (Symbol.hasFramePointer()) {
132 WithColor(Printer, PDB_ColorItem::Register).get()
133 << Symbol.getLocalBasePointerRegisterId();
134 } else {
135 WithColor(Printer, PDB_ColorItem::Register).get() << "FPO";
136 }
137 Printer << ") ";
138
139 if (Symbol.isVirtual() || Symbol.isPureVirtual())
140 WithColor(Printer, PDB_ColorItem::Keyword).get() << "virtual ";
141
142 auto Signature = Symbol.getSignature();
143 if (!Signature) {
144 WithColor(Printer, PDB_ColorItem::Identifier).get() << Symbol.getName();
145 if (Pointer == PointerType::Pointer)
146 Printer << "*";
147 else if (Pointer == FunctionDumper::PointerType::Reference)
148 Printer << "&";
149 return;
150 }
151
152 auto ReturnType = Signature->getReturnType();
153 ReturnType->dump(*this);
154 Printer << " ";
155
156 auto ClassParent = Symbol.getClassParent();
157 CallingConvention CC = Signature->getCallingConvention();
158 if (Pointer != FunctionDumper::PointerType::None)
159 Printer << "(";
160
161 if ((ClassParent && CC != CallingConvention::ThisCall) ||
162 (!ClassParent && CC != CallingConvention::NearStdCall)) {
163 WithColor(Printer, PDB_ColorItem::Keyword).get()
164 << Signature->getCallingConvention() << " ";
165 }
166 WithColor(Printer, PDB_ColorItem::Identifier).get() << Symbol.getName();
167 if (Pointer != FunctionDumper::PointerType::None) {
168 if (Pointer == PointerType::Pointer)
169 Printer << "*";
170 else if (Pointer == FunctionDumper::PointerType::Reference)
171 Printer << "&";
172 Printer << ")";
173 }
174
175 Printer << "(";
176 if (auto Arguments = Symbol.getArguments()) {
177 uint32_t Index = 0;
178 while (auto Arg = Arguments->getNext()) {
179 auto ArgType = Arg->getType();
180 ArgType->dump(*this);
181 WithColor(Printer, PDB_ColorItem::Identifier).get() << " "
182 << Arg->getName();
183 if (++Index < Arguments->getChildCount())
184 Printer << ", ";
185 }
186 }
187 Printer << ")";
188 if (Symbol.isConstType())
189 WithColor(Printer, PDB_ColorItem::Keyword).get() << " const";
190 if (Symbol.isVolatileType())
191 WithColor(Printer, PDB_ColorItem::Keyword).get() << " volatile";
192 if (Symbol.isPureVirtual())
193 Printer << " = 0";
194 }
195
196 void FunctionDumper::dump(const PDBSymbolTypeArray &Symbol) {
197 uint32_t ElementTypeId = Symbol.getTypeId();
198 auto ElementType = Symbol.getSession().getSymbolById(ElementTypeId);
199 if (!ElementType)
200 return;
201
202 ElementType->dump(*this);
203 Printer << "[";
204 WithColor(Printer, PDB_ColorItem::LiteralValue).get() << Symbol.getLength();
205 Printer << "]";
206 }
207
208 void FunctionDumper::dump(const PDBSymbolTypeBuiltin &Symbol) {
209 BuiltinDumper Dumper(Printer);
210 Dumper.start(Symbol);
211 }
212
213 void FunctionDumper::dump(const PDBSymbolTypeEnum &Symbol) {
214 dumpClassParentWithScopeOperator(Symbol, Printer, *this);
215 WithColor(Printer, PDB_ColorItem::Type).get() << Symbol.getName();
216 }
217
218 void FunctionDumper::dump(const PDBSymbolTypeFunctionArg &Symbol) {
219 // PDBSymbolTypeFunctionArg is just a shim over the real argument. Just drill
220 // through to the real thing and dump it.
221 uint32_t TypeId = Symbol.getTypeId();
222 auto Type = Symbol.getSession().getSymbolById(TypeId);
223 if (!Type)
224 return;
225 Type->dump(*this);
226 }
227
228 void FunctionDumper::dump(const PDBSymbolTypeTypedef &Symbol) {
229 dumpClassParentWithScopeOperator(Symbol, Printer, *this);
230 WithColor(Printer, PDB_ColorItem::Type).get() << Symbol.getName();
231 }
232
233 void FunctionDumper::dump(const PDBSymbolTypePointer &Symbol) {
234 uint32_t PointeeId = Symbol.getTypeId();
235 auto PointeeType = Symbol.getSession().getSymbolById(PointeeId);
236 if (!PointeeType)
237 return;
238
239 if (auto FuncSig = dyn_cast(PointeeType.get())) {
240 FunctionDumper NestedDumper(Printer);
241 PointerType Pointer =
242 Symbol.isReference() ? PointerType::Reference : PointerType::Pointer;
243 NestedDumper.start(*FuncSig, nullptr, Pointer);
244 } else {
245 if (Symbol.isConstType())
246 WithColor(Printer, PDB_ColorItem::Keyword).get() << "const ";
247 if (Symbol.isVolatileType())
248 WithColor(Printer, PDB_ColorItem::Keyword).get() << "volatile ";
249 PointeeType->dump(*this);
250 Printer << (Symbol.isReference() ? "&" : "*");
251 }
252 }
253
254 void FunctionDumper::dump(const PDBSymbolTypeUDT &Symbol) {
255 WithColor(Printer, PDB_ColorItem::Type).get() << Symbol.getName();
256 }
0 //===- PrettyFunctionDumper.h --------------------------------- *- C++ --*-===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8
9 #ifndef LLVM_TOOLS_LLVMPDBDUMP_PRETTYFUNCTIONDUMPER_H
10 #define LLVM_TOOLS_LLVMPDBDUMP_PRETTYFUNCTIONDUMPER_H
11
12 #include "llvm/DebugInfo/PDB/PDBSymDumper.h"
13
14 namespace llvm {
15 namespace pdb {