blob: 497c51fdbe482ffcd60b3c92e84f009ff59bb389 [file] [log] [blame]
Zachary Turner7df69952017-06-22 20:57:39 +00001//===- DumpOutputStyle.h -------------------------------------- *- C++ --*-===//
Zachary Turnerd3117392016-06-03 19:28:33 +00002//
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
Zachary Turner7df69952017-06-22 20:57:39 +000010#ifndef LLVM_TOOLS_LLVMPDBDUMP_DUMPOUTPUTSTYLE_H
11#define LLVM_TOOLS_LLVMPDBDUMP_DUMPOUTPUTSTYLE_H
Zachary Turnerd3117392016-06-03 19:28:33 +000012
Zachary Turner63055452017-06-15 22:24:24 +000013#include "LinePrinter.h"
Zachary Turnerd3117392016-06-03 19:28:33 +000014#include "OutputStyle.h"
Zachary Turnerd1de2f42017-08-21 14:53:25 +000015#include "StreamUtil.h"
Zachary Turnerd3117392016-06-03 19:28:33 +000016
Zachary Turnerd1de2f42017-08-21 14:53:25 +000017#include "llvm/ADT/DenseMap.h"
Zachary Turner20d773c2017-05-04 23:53:01 +000018#include "llvm/ADT/Optional.h"
Zachary Turner6ac232c2017-03-13 23:28:25 +000019#include "llvm/ADT/SmallVector.h"
Zachary Turnerfb1cd502017-08-04 20:02:38 +000020#include "llvm/DebugInfo/PDB/Native/RawConstants.h"
Zachary Turnerd3117392016-06-03 19:28:33 +000021
Zachary Turner6ac232c2017-03-13 23:28:25 +000022#include <string>
23
Zachary Turnerd3117392016-06-03 19:28:33 +000024namespace llvm {
Zachary Turnerd3c7b8e2016-08-01 21:19:45 +000025class BitVector;
Zachary Turner526f4f22017-05-19 19:26:58 +000026
27namespace codeview {
28class LazyRandomTypeCollection;
29}
30
Zachary Turnerd3117392016-06-03 19:28:33 +000031namespace pdb {
Reid Kleckner14d90fd2017-07-26 00:40:36 +000032class GSIHashTable;
33
Zachary Turnerd1de2f42017-08-21 14:53:25 +000034struct StatCollection {
35 struct Stat {
36 Stat() {}
37 Stat(uint32_t Count, uint32_t Size) : Count(Count), Size(Size) {}
38 uint32_t Count = 0;
39 uint32_t Size = 0;
40
41 void update(uint32_t RecordSize) {
42 ++Count;
43 Size += RecordSize;
44 }
45 };
46
47 void update(uint32_t Kind, uint32_t RecordSize) {
48 Totals.update(RecordSize);
49 auto Iter = Individual.try_emplace(Kind, 1, RecordSize);
50 if (!Iter.second)
51 Iter.first->second.update(RecordSize);
52 }
53 Stat Totals;
54 DenseMap<uint32_t, Stat> Individual;
55};
56
Zachary Turner7df69952017-06-22 20:57:39 +000057class DumpOutputStyle : public OutputStyle {
Zachary Turnerd1de2f42017-08-21 14:53:25 +000058
Zachary Turnerd3117392016-06-03 19:28:33 +000059public:
Zachary Turner7df69952017-06-22 20:57:39 +000060 DumpOutputStyle(PDBFile &File);
Zachary Turnerd3117392016-06-03 19:28:33 +000061
Zachary Turnera30bd1a2016-06-30 17:42:48 +000062 Error dump() override;
Zachary Turner7120a472016-06-06 20:37:05 +000063
Zachary Turnerd3117392016-06-03 19:28:33 +000064private:
Zachary Turner59224cb2017-06-16 23:42:15 +000065 Expected<codeview::LazyRandomTypeCollection &> initializeTypes(uint32_t SN);
Zachary Turner20d773c2017-05-04 23:53:01 +000066
Zachary Turner63055452017-06-15 22:24:24 +000067 Error dumpFileSummary();
Zachary Turnera30bd1a2016-06-30 17:42:48 +000068 Error dumpStreamSummary();
Zachary Turnerd1de2f42017-08-21 14:53:25 +000069 Error dumpModuleStats();
Zachary Turner760ad4d2017-01-20 22:42:09 +000070 Error dumpStringTable();
Zachary Turner4e950642017-06-15 23:56:19 +000071 Error dumpLines();
72 Error dumpInlineeLines();
Zachary Turner47d9a562017-06-16 00:04:24 +000073 Error dumpXmi();
74 Error dumpXme();
Zachary Turnera30bd1a2016-06-30 17:42:48 +000075 Error dumpTpiStream(uint32_t StreamIdx);
Zachary Turner63055452017-06-15 22:24:24 +000076 Error dumpModules();
Zachary Turner0e327d02017-06-15 23:12:41 +000077 Error dumpModuleFiles();
Zachary Turner63055452017-06-15 22:24:24 +000078 Error dumpModuleSyms();
Reid Kleckner14d90fd2017-07-26 00:40:36 +000079 Error dumpGlobals();
Zachary Turner63055452017-06-15 22:24:24 +000080 Error dumpPublics();
Reid Kleckner14d90fd2017-07-26 00:40:36 +000081 Error dumpSymbolsFromGSI(const GSIHashTable &Table, bool HashExtras);
Zachary Turnerfb1cd502017-08-04 20:02:38 +000082 Error dumpSectionHeaders();
Zachary Turnera30bd1a2016-06-30 17:42:48 +000083 Error dumpSectionContribs();
84 Error dumpSectionMap();
Zachary Turnera30bd1a2016-06-30 17:42:48 +000085
Zachary Turnerfb1cd502017-08-04 20:02:38 +000086 void dumpSectionHeaders(StringRef Label, DbgHeaderType Type);
87
Zachary Turnerd3117392016-06-03 19:28:33 +000088 PDBFile &File;
Zachary Turner63055452017-06-15 22:24:24 +000089 LinePrinter P;
Zachary Turner526f4f22017-05-19 19:26:58 +000090 std::unique_ptr<codeview::LazyRandomTypeCollection> TpiTypes;
91 std::unique_ptr<codeview::LazyRandomTypeCollection> IpiTypes;
Zachary Turnerd1de2f42017-08-21 14:53:25 +000092 SmallVector<StreamInfo, 32> StreamPurposes;
Zachary Turnerd3117392016-06-03 19:28:33 +000093};
Zachary Turner63055452017-06-15 22:24:24 +000094} // namespace pdb
95} // namespace llvm
Zachary Turnerd3117392016-06-03 19:28:33 +000096
97#endif