2
0

TypeDumper.cpp 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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. #include "TypeDumper.h"
  10. #include "BuiltinDumper.h"
  11. #include "ClassDefinitionDumper.h"
  12. #include "EnumDumper.h"
  13. #include "LinePrinter.h"
  14. #include "llvm-pdbdump.h"
  15. #include "TypedefDumper.h"
  16. #include "llvm/DebugInfo/PDB/IPDBSession.h"
  17. #include "llvm/DebugInfo/PDB/PDBSymbolExe.h"
  18. #include "llvm/DebugInfo/PDB/PDBSymbolTypeBuiltin.h"
  19. #include "llvm/DebugInfo/PDB/PDBSymbolTypeEnum.h"
  20. #include "llvm/DebugInfo/PDB/PDBSymbolTypeTypedef.h"
  21. #include "llvm/DebugInfo/PDB/PDBSymbolTypeUDT.h"
  22. using namespace llvm;
  23. TypeDumper::TypeDumper(LinePrinter &P) : PDBSymDumper(true), Printer(P) {}
  24. void TypeDumper::start(const PDBSymbolExe &Exe) {
  25. auto Enums = Exe.findAllChildren<PDBSymbolTypeEnum>();
  26. Printer.NewLine();
  27. WithColor(Printer, PDB_ColorItem::Identifier).get() << "Enums";
  28. Printer << ": (" << Enums->getChildCount() << " items)";
  29. Printer.Indent();
  30. while (auto Enum = Enums->getNext())
  31. Enum->dump(*this);
  32. Printer.Unindent();
  33. auto Typedefs = Exe.findAllChildren<PDBSymbolTypeTypedef>();
  34. Printer.NewLine();
  35. WithColor(Printer, PDB_ColorItem::Identifier).get() << "Typedefs";
  36. Printer << ": (" << Typedefs->getChildCount() << " items)";
  37. Printer.Indent();
  38. while (auto Typedef = Typedefs->getNext())
  39. Typedef->dump(*this);
  40. Printer.Unindent();
  41. auto Classes = Exe.findAllChildren<PDBSymbolTypeUDT>();
  42. Printer.NewLine();
  43. WithColor(Printer, PDB_ColorItem::Identifier).get() << "Classes";
  44. Printer << ": (" << Classes->getChildCount() << " items)";
  45. Printer.Indent();
  46. while (auto Class = Classes->getNext())
  47. Class->dump(*this);
  48. Printer.Unindent();
  49. }
  50. void TypeDumper::dump(const PDBSymbolTypeEnum &Symbol) {
  51. if (Symbol.getUnmodifiedTypeId() != 0)
  52. return;
  53. if (Printer.IsTypeExcluded(Symbol.getName()))
  54. return;
  55. // Dump member enums when dumping their class definition.
  56. if (Symbol.isNested())
  57. return;
  58. Printer.NewLine();
  59. EnumDumper Dumper(Printer);
  60. Dumper.start(Symbol);
  61. }
  62. void TypeDumper::dump(const PDBSymbolTypeTypedef &Symbol) {
  63. if (Printer.IsTypeExcluded(Symbol.getName()))
  64. return;
  65. Printer.NewLine();
  66. TypedefDumper Dumper(Printer);
  67. Dumper.start(Symbol);
  68. }
  69. void TypeDumper::dump(const PDBSymbolTypeUDT &Symbol) {
  70. if (Symbol.getUnmodifiedTypeId() != 0)
  71. return;
  72. if (Printer.IsTypeExcluded(Symbol.getName()))
  73. return;
  74. Printer.NewLine();
  75. if (opts::NoClassDefs) {
  76. WithColor(Printer, PDB_ColorItem::Keyword).get() << "class ";
  77. WithColor(Printer, PDB_ColorItem::Identifier).get() << Symbol.getName();
  78. } else {
  79. ClassDefinitionDumper Dumper(Printer);
  80. Dumper.start(Symbol);
  81. }
  82. }