blob: 9b3a85587bde3b00bce4673fa3c9ff2bbbd44bfc [file] [log] [blame]
Zachary Turner08950322017-06-22 20:57:39 +00001//===- DumpOutputStyle.h -------------------------------------- *- C++ --*-===//
Zachary Turner041e9f22016-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 Turner08950322017-06-22 20:57:39 +000010#ifndef LLVM_TOOLS_LLVMPDBDUMP_DUMPOUTPUTSTYLE_H
11#define LLVM_TOOLS_LLVMPDBDUMP_DUMPOUTPUTSTYLE_H
Zachary Turner041e9f22016-06-03 19:28:33 +000012
Zachary Turner7e5d31e2017-06-15 22:24:24 +000013#include "LinePrinter.h"
Zachary Turner041e9f22016-06-03 19:28:33 +000014#include "OutputStyle.h"
Zachary Turnerb6d8c582017-08-21 14:53:25 +000015#include "StreamUtil.h"
Zachary Turner041e9f22016-06-03 19:28:33 +000016
Zachary Turnerb6d8c582017-08-21 14:53:25 +000017#include "llvm/ADT/DenseMap.h"
Zachary Turnerb18693c2017-05-04 23:53:01 +000018#include "llvm/ADT/Optional.h"
Zachary Turner435ba4a2017-03-13 23:28:25 +000019#include "llvm/ADT/SmallVector.h"
Zachary Turner6c8e8ae2017-08-04 20:02:38 +000020#include "llvm/DebugInfo/PDB/Native/RawConstants.h"
Zachary Turner041e9f22016-06-03 19:28:33 +000021
Zachary Turner435ba4a2017-03-13 23:28:25 +000022#include <string>
23
Zachary Turner041e9f22016-06-03 19:28:33 +000024namespace llvm {
Zachary Turner822ef4e2016-08-01 21:19:45 +000025class BitVector;
Zachary Turnerd32a3822017-05-19 19:26:58 +000026
27namespace codeview {
28class LazyRandomTypeCollection;
29}
30
Zachary Turner6ef51e82017-09-01 20:06:56 +000031namespace object {
32class COFFObjectFile;
33}
34
Zachary Turner041e9f22016-06-03 19:28:33 +000035namespace pdb {
Reid Kleckner4a753bd2017-07-26 00:40:36 +000036class GSIHashTable;
Zachary Turner6ef51e82017-09-01 20:06:56 +000037class InputFile;
Reid Kleckner4a753bd2017-07-26 00:40:36 +000038
Zachary Turnerb6d8c582017-08-21 14:53:25 +000039struct StatCollection {
40 struct Stat {
41 Stat() {}
42 Stat(uint32_t Count, uint32_t Size) : Count(Count), Size(Size) {}
43 uint32_t Count = 0;
44 uint32_t Size = 0;
45
46 void update(uint32_t RecordSize) {
47 ++Count;
48 Size += RecordSize;
49 }
50 };
51
52 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
Zachary Turner08950322017-06-22 20:57:39 +000062class DumpOutputStyle : public OutputStyle {
Zachary Turnerb6d8c582017-08-21 14:53:25 +000063
Zachary Turner041e9f22016-06-03 19:28:33 +000064public:
Zachary Turner6ef51e82017-09-01 20:06:56 +000065 DumpOutputStyle(InputFile &File);
Zachary Turner041e9f22016-06-03 19:28:33 +000066
Zachary Turner3a4681d2016-06-30 17:42:48 +000067 Error dump() override;
Zachary Turner61e0e272016-06-06 20:37:05 +000068
Zachary Turner041e9f22016-06-03 19:28:33 +000069private:
Zachary Turner6ef51e82017-09-01 20:06:56 +000070 PDBFile &getPdb();
71 object::COFFObjectFile &getObj();
Zachary Turnerb18693c2017-05-04 23:53:01 +000072
Alexandre Ganeafabcc792018-08-06 19:35:00 +000073 void printStreamNotValidForObj();
74 void printStreamNotPresent(StringRef StreamName);
75
Zachary Turner7e5d31e2017-06-15 22:24:24 +000076 Error dumpFileSummary();
Zachary Turner3a4681d2016-06-30 17:42:48 +000077 Error dumpStreamSummary();
Zachary Turnerae734ae2017-08-31 20:43:22 +000078 Error dumpSymbolStats();
79 Error dumpUdtStats();
Zachary Turner0995a922018-03-23 18:43:39 +000080 Error dumpNamedStreams();
Zachary Turner9c1e7a62017-01-20 22:42:09 +000081 Error dumpStringTable();
Zachary Turnerd9e5a1f2018-01-05 19:12:40 +000082 Error dumpStringTableFromPdb();
83 Error dumpStringTableFromObj();
Zachary Turner7b1eb002017-06-15 23:56:19 +000084 Error dumpLines();
85 Error dumpInlineeLines();
Zachary Turner68e216b2017-06-16 00:04:24 +000086 Error dumpXmi();
87 Error dumpXme();
Zachary Turner77a68882018-09-11 22:35:01 +000088 Error dumpFpo();
Zachary Turner69d3b582018-09-12 21:02:01 +000089 Error dumpOldFpo(PDBFile &File);
90 Error dumpNewFpo(PDBFile &File);
Zachary Turner3a4681d2016-06-30 17:42:48 +000091 Error dumpTpiStream(uint32_t StreamIdx);
Zachary Turner7c192ee2017-12-05 23:58:18 +000092 Error dumpTypesFromObjectFile();
Zachary Turner7e5d31e2017-06-15 22:24:24 +000093 Error dumpModules();
Zachary Turnere6f0d3c2017-06-15 23:12:41 +000094 Error dumpModuleFiles();
Zachary Turner6ef51e82017-09-01 20:06:56 +000095 Error dumpModuleSymsForPdb();
96 Error dumpModuleSymsForObj();
Zachary Turner7f08d4a2018-07-06 02:59:25 +000097 Error dumpGSIRecords();
Reid Kleckner4a753bd2017-07-26 00:40:36 +000098 Error dumpGlobals();
Zachary Turner7e5d31e2017-06-15 22:24:24 +000099 Error dumpPublics();
Reid Kleckner4a753bd2017-07-26 00:40:36 +0000100 Error dumpSymbolsFromGSI(const GSIHashTable &Table, bool HashExtras);
Zachary Turner6c8e8ae2017-08-04 20:02:38 +0000101 Error dumpSectionHeaders();
Zachary Turner3a4681d2016-06-30 17:42:48 +0000102 Error dumpSectionContribs();
103 Error dumpSectionMap();
Zachary Turner3a4681d2016-06-30 17:42:48 +0000104
Zachary Turner6c8e8ae2017-08-04 20:02:38 +0000105 void dumpSectionHeaders(StringRef Label, DbgHeaderType Type);
106
Zachary Turner6ef51e82017-09-01 20:06:56 +0000107 InputFile &File;
Zachary Turner7e5d31e2017-06-15 22:24:24 +0000108 LinePrinter P;
Zachary Turnerb6d8c582017-08-21 14:53:25 +0000109 SmallVector<StreamInfo, 32> StreamPurposes;
Zachary Turner041e9f22016-06-03 19:28:33 +0000110};
Zachary Turner7e5d31e2017-06-15 22:24:24 +0000111} // namespace pdb
112} // namespace llvm
Zachary Turner041e9f22016-06-03 19:28:33 +0000113
114#endif