DumpOutputStyle.h 2.9 KB

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