DumpOutputStyle.h 2.9 KB

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