• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===- DumpOutputStyle.h -------------------------------------- *- C++ --*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 #ifndef LLVM_TOOLS_LLVMPDBDUMP_DUMPOUTPUTSTYLE_H
11 #define LLVM_TOOLS_LLVMPDBDUMP_DUMPOUTPUTSTYLE_H
12 
13 #include "LinePrinter.h"
14 #include "OutputStyle.h"
15 #include "StreamUtil.h"
16 
17 #include "llvm/ADT/DenseMap.h"
18 #include "llvm/ADT/Optional.h"
19 #include "llvm/ADT/SmallVector.h"
20 #include "llvm/DebugInfo/PDB/Native/RawConstants.h"
21 
22 #include <string>
23 
24 namespace llvm {
25 class BitVector;
26 
27 namespace codeview {
28 class LazyRandomTypeCollection;
29 }
30 
31 namespace object {
32 class COFFObjectFile;
33 }
34 
35 namespace pdb {
36 class GSIHashTable;
37 class InputFile;
38 
39 struct StatCollection {
40   struct Stat {
StatStatCollection::Stat41     Stat() {}
StatStatCollection::Stat42     Stat(uint32_t Count, uint32_t Size) : Count(Count), Size(Size) {}
43     uint32_t Count = 0;
44     uint32_t Size = 0;
45 
updateStatCollection::Stat46     void update(uint32_t RecordSize) {
47       ++Count;
48       Size += RecordSize;
49     }
50   };
51 
updateStatCollection52   void update(uint32_t Kind, uint32_t RecordSize) {
53     Totals.update(RecordSize);
54     auto Iter = Individual.try_emplace(Kind, 1, RecordSize);
55     if (!Iter.second)
56       Iter.first->second.update(RecordSize);
57   }
58   Stat Totals;
59   DenseMap<uint32_t, Stat> Individual;
60 };
61 
62 class DumpOutputStyle : public OutputStyle {
63 
64 public:
65   DumpOutputStyle(InputFile &File);
66 
67   Error dump() override;
68 
69 private:
70   PDBFile &getPdb();
71   object::COFFObjectFile &getObj();
72 
73   Error dumpFileSummary();
74   Error dumpStreamSummary();
75   Error dumpSymbolStats();
76   Error dumpUdtStats();
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 dumpTpiStream(uint32_t StreamIdx);
86   Error dumpTypesFromObjectFile();
87   Error dumpModules();
88   Error dumpModuleFiles();
89   Error dumpModuleSymsForPdb();
90   Error dumpModuleSymsForObj();
91   Error dumpGSIRecords();
92   Error dumpGlobals();
93   Error dumpPublics();
94   Error dumpSymbolsFromGSI(const GSIHashTable &Table, bool HashExtras);
95   Error dumpSectionHeaders();
96   Error dumpSectionContribs();
97   Error dumpSectionMap();
98 
99   void dumpSectionHeaders(StringRef Label, DbgHeaderType Type);
100 
101   InputFile &File;
102   LinePrinter P;
103   SmallVector<StreamInfo, 32> StreamPurposes;
104 };
105 } // namespace pdb
106 } // namespace llvm
107 
108 #endif
109