1 //===- TypeDumper.cpp - PDBSymDumper implementation for types *----- C++ *-===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 #include "TypeDumper.h" 11 12 #include "BuiltinDumper.h" 13 #include "ClassDefinitionDumper.h" 14 #include "EnumDumper.h" 15 #include "LinePrinter.h" 16 #include "llvm-pdbdump.h" 17 #include "TypedefDumper.h" 18 19 #include "llvm/DebugInfo/PDB/IPDBSession.h" 20 #include "llvm/DebugInfo/PDB/PDBSymbolExe.h" 21 #include "llvm/DebugInfo/PDB/PDBSymbolTypeBuiltin.h" 22 #include "llvm/DebugInfo/PDB/PDBSymbolTypeEnum.h" 23 #include "llvm/DebugInfo/PDB/PDBSymbolTypeTypedef.h" 24 #include "llvm/DebugInfo/PDB/PDBSymbolTypeUDT.h" 25 26 using namespace llvm; 27 using namespace llvm::pdb; 28 TypeDumper(LinePrinter & P)29TypeDumper::TypeDumper(LinePrinter &P) : PDBSymDumper(true), Printer(P) {} 30 start(const PDBSymbolExe & Exe)31void TypeDumper::start(const PDBSymbolExe &Exe) { 32 auto Enums = Exe.findAllChildren<PDBSymbolTypeEnum>(); 33 Printer.NewLine(); 34 WithColor(Printer, PDB_ColorItem::Identifier).get() << "Enums"; 35 Printer << ": (" << Enums->getChildCount() << " items)"; 36 Printer.Indent(); 37 while (auto Enum = Enums->getNext()) 38 Enum->dump(*this); 39 Printer.Unindent(); 40 41 auto Typedefs = Exe.findAllChildren<PDBSymbolTypeTypedef>(); 42 Printer.NewLine(); 43 WithColor(Printer, PDB_ColorItem::Identifier).get() << "Typedefs"; 44 Printer << ": (" << Typedefs->getChildCount() << " items)"; 45 Printer.Indent(); 46 while (auto Typedef = Typedefs->getNext()) 47 Typedef->dump(*this); 48 Printer.Unindent(); 49 50 auto Classes = Exe.findAllChildren<PDBSymbolTypeUDT>(); 51 Printer.NewLine(); 52 WithColor(Printer, PDB_ColorItem::Identifier).get() << "Classes"; 53 Printer << ": (" << Classes->getChildCount() << " items)"; 54 Printer.Indent(); 55 while (auto Class = Classes->getNext()) 56 Class->dump(*this); 57 Printer.Unindent(); 58 } 59 dump(const PDBSymbolTypeEnum & Symbol)60void TypeDumper::dump(const PDBSymbolTypeEnum &Symbol) { 61 if (Symbol.getUnmodifiedTypeId() != 0) 62 return; 63 if (Printer.IsTypeExcluded(Symbol.getName())) 64 return; 65 // Dump member enums when dumping their class definition. 66 if (nullptr != Symbol.getClassParent()) 67 return; 68 69 Printer.NewLine(); 70 EnumDumper Dumper(Printer); 71 Dumper.start(Symbol); 72 } 73 dump(const PDBSymbolTypeTypedef & Symbol)74void TypeDumper::dump(const PDBSymbolTypeTypedef &Symbol) { 75 if (Printer.IsTypeExcluded(Symbol.getName())) 76 return; 77 78 Printer.NewLine(); 79 TypedefDumper Dumper(Printer); 80 Dumper.start(Symbol); 81 } 82 dump(const PDBSymbolTypeUDT & Symbol)83void TypeDumper::dump(const PDBSymbolTypeUDT &Symbol) { 84 if (Symbol.getUnmodifiedTypeId() != 0) 85 return; 86 if (Printer.IsTypeExcluded(Symbol.getName())) 87 return; 88 89 Printer.NewLine(); 90 91 if (opts::pretty::NoClassDefs) { 92 WithColor(Printer, PDB_ColorItem::Keyword).get() << "class "; 93 WithColor(Printer, PDB_ColorItem::Identifier).get() << Symbol.getName(); 94 } else { 95 ClassDefinitionDumper Dumper(Printer); 96 Dumper.start(Symbol); 97 } 98 } 99