DumpOutputStyle.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. //===- DumpOutputStyle.h -------------------------------------- *- C++ --*-===//
  2. //
  3. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  4. // See https://llvm.org/LICENSE.txt for license information.
  5. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  6. //
  7. //===----------------------------------------------------------------------===//
  8. #ifndef LLVM_TOOLS_LLVMPDBDUMP_DUMPOUTPUTSTYLE_H
  9. #define LLVM_TOOLS_LLVMPDBDUMP_DUMPOUTPUTSTYLE_H
  10. #include "OutputStyle.h"
  11. #include "StreamUtil.h"
  12. #include "llvm/ADT/DenseMap.h"
  13. #include "llvm/ADT/SmallVector.h"
  14. #include "llvm/DebugInfo/PDB/Native/LinePrinter.h"
  15. #include "llvm/DebugInfo/PDB/Native/RawConstants.h"
  16. #include <string>
  17. namespace llvm {
  18. namespace object {
  19. class COFFObjectFile;
  20. }
  21. namespace pdb {
  22. class GSIHashTable;
  23. class InputFile;
  24. class TypeReferenceTracker;
  25. struct StatCollection {
  26. struct Stat {
  27. Stat() {}
  28. Stat(uint32_t Count, uint32_t Size) : Count(Count), Size(Size) {}
  29. uint32_t Count = 0;
  30. uint32_t Size = 0;
  31. void update(uint32_t RecordSize) {
  32. ++Count;
  33. Size += RecordSize;
  34. }
  35. };
  36. using KindAndStat = std::pair<uint32_t, Stat>;
  37. void update(uint32_t Kind, uint32_t RecordSize) {
  38. Totals.update(RecordSize);
  39. auto Iter = Individual.try_emplace(Kind, 1, RecordSize);
  40. if (!Iter.second)
  41. Iter.first->second.update(RecordSize);
  42. }
  43. Stat Totals;
  44. DenseMap<uint32_t, Stat> Individual;
  45. std::vector<KindAndStat> getStatsSortedBySize() const;
  46. };
  47. class DumpOutputStyle : public OutputStyle {
  48. public:
  49. DumpOutputStyle(InputFile &File);
  50. ~DumpOutputStyle() override;
  51. Error dump() override;
  52. private:
  53. PDBFile &getPdb();
  54. object::COFFObjectFile &getObj();
  55. void printStreamNotValidForObj();
  56. void printStreamNotPresent(StringRef StreamName);
  57. Error dumpFileSummary();
  58. Error dumpStreamSummary();
  59. Error dumpSymbolStats();
  60. Error dumpUdtStats();
  61. Error dumpTypeStats();
  62. Error dumpNamedStreams();
  63. Error dumpStringTable();
  64. Error dumpStringTableFromPdb();
  65. Error dumpStringTableFromObj();
  66. Error dumpLines();
  67. Error dumpInlineeLines();
  68. Error dumpXmi();
  69. Error dumpXme();
  70. Error dumpFpo();
  71. Error dumpOldFpo(PDBFile &File);
  72. Error dumpNewFpo(PDBFile &File);
  73. Error dumpTpiStream(uint32_t StreamIdx);
  74. Error dumpTypesFromObjectFile();
  75. Error dumpTypeRefStats();
  76. Error dumpModules();
  77. Error dumpModuleFiles();
  78. Error dumpModuleSymsForPdb();
  79. Error dumpModuleSymsForObj();
  80. Error dumpGSIRecords();
  81. Error dumpGlobals();
  82. Error dumpPublics();
  83. Error dumpSymbolsFromGSI(const GSIHashTable &Table, bool HashExtras);
  84. Error dumpSectionHeaders();
  85. Error dumpSectionContribs();
  86. Error dumpSectionMap();
  87. void dumpSectionHeaders(StringRef Label, DbgHeaderType Type);
  88. InputFile &File;
  89. std::unique_ptr<TypeReferenceTracker> RefTracker;
  90. LinePrinter P;
  91. SmallVector<StreamInfo, 32> StreamPurposes;
  92. };
  93. } // namespace pdb
  94. } // namespace llvm
  95. #endif