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