1 //===- TypeDumper.cpp - PDBSymDumper implementation for types *----- C++ *-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #include "TypeDumper.h"
12 #include "ClassDefinitionDumper.h"
13 #include "LinePrinter.h"
14 #include "llvm-pdbdump.h"
15 #include "TypedefDumper.h"
17 #include "llvm/DebugInfo/PDB/IPDBSession.h"
18 #include "llvm/DebugInfo/PDB/PDBSymbolExe.h"
19 #include "llvm/DebugInfo/PDB/PDBSymbolTypeEnum.h"
20 #include "llvm/DebugInfo/PDB/PDBSymbolTypeTypedef.h"
21 #include "llvm/DebugInfo/PDB/PDBSymbolTypeUDT.h"
25 TypeDumper::TypeDumper(LinePrinter &P, bool Inline, bool ClassDefs)
26 : PDBSymDumper(true), Printer(P), InlineDump(Inline),
27 FullClassDefs(ClassDefs) {}
29 void TypeDumper::start(const PDBSymbolExe &Exe, raw_ostream &OS, int Indent) {
30 auto Enums = Exe.findAllChildren<PDBSymbolTypeEnum>();
32 WithColor(Printer, PDB_ColorItem::Identifier).get() << "Enums";
33 Printer << ": (" << Enums->getChildCount() << " items)";
35 while (auto Enum = Enums->getNext())
36 Enum->dump(OS, Indent + 2, *this);
39 auto Typedefs = Exe.findAllChildren<PDBSymbolTypeTypedef>();
41 WithColor(Printer, PDB_ColorItem::Identifier).get() << "Typedefs";
42 Printer << ": (" << Typedefs->getChildCount() << " items)";
44 while (auto Typedef = Typedefs->getNext())
45 Typedef->dump(OS, Indent + 2, *this);
48 auto Classes = Exe.findAllChildren<PDBSymbolTypeUDT>();
50 WithColor(Printer, PDB_ColorItem::Identifier).get() << "Classes";
51 Printer << ": (" << Classes->getChildCount() << " items)";
53 while (auto Class = Classes->getNext())
54 Class->dump(OS, Indent + 2, *this);
58 void TypeDumper::dump(const PDBSymbolTypeEnum &Symbol, raw_ostream &OS,
60 if (Symbol.getUnmodifiedTypeId() != 0)
66 WithColor(Printer, PDB_ColorItem::Keyword).get() << "enum ";
67 WithColor(Printer, PDB_ColorItem::Identifier).get() << Symbol.getName();
70 void TypeDumper::dump(const PDBSymbolTypeTypedef &Symbol, raw_ostream &OS,
75 TypedefDumper Dumper(Printer);
76 Dumper.start(Symbol, OS, Indent);
79 void TypeDumper::dump(const PDBSymbolTypeUDT &Symbol, raw_ostream &OS,
81 if (Symbol.getUnmodifiedTypeId() != 0)
87 ClassDefinitionDumper Dumper(Printer);
88 Dumper.start(Symbol, OS, Indent);
90 WithColor(Printer, PDB_ColorItem::Keyword).get() << "class ";
91 WithColor(Printer, PDB_ColorItem::Identifier).get() << Symbol.getName();