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