blob: c95490e95df43823b14bcdf26421875d2554aa73 [file] [log] [blame]
Zachary Turner7df69952017-06-22 20:57:39 +00001//===- DumpOutputStyle.h -------------------------------------- *- C++ --*-===//
Zachary Turnerd3117392016-06-03 19:28:33 +00002//
Chandler Carruth2946cd72019-01-19 08:50:56 +00003// 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
Zachary Turnerd3117392016-06-03 19:28:33 +00006//
7//===----------------------------------------------------------------------===//
8
Zachary Turner7df69952017-06-22 20:57:39 +00009#ifndef LLVM_TOOLS_LLVMPDBDUMP_DUMPOUTPUTSTYLE_H
10#define LLVM_TOOLS_LLVMPDBDUMP_DUMPOUTPUTSTYLE_H
Zachary Turnerd3117392016-06-03 19:28:33 +000011
Zachary Turner63055452017-06-15 22:24:24 +000012#include "LinePrinter.h"
Zachary Turnerd3117392016-06-03 19:28:33 +000013#include "OutputStyle.h"
Zachary Turnerd1de2f42017-08-21 14:53:25 +000014#include "StreamUtil.h"
Zachary Turnerd3117392016-06-03 19:28:33 +000015
Zachary Turnerd1de2f42017-08-21 14:53:25 +000016#include "llvm/ADT/DenseMap.h"
Zachary Turner20d773c2017-05-04 23:53:01 +000017#include "llvm/ADT/Optional.h"
Zachary Turner6ac232c2017-03-13 23:28:25 +000018#include "llvm/ADT/SmallVector.h"
Zachary Turnerfb1cd502017-08-04 20:02:38 +000019#include "llvm/DebugInfo/PDB/Native/RawConstants.h"
Zachary Turnerd3117392016-06-03 19:28:33 +000020
Zachary Turner6ac232c2017-03-13 23:28:25 +000021#include <string>
22
Zachary Turnerd3117392016-06-03 19:28:33 +000023namespace llvm {
Zachary Turnerd3c7b8e2016-08-01 21:19:45 +000024class BitVector;
Zachary Turner526f4f22017-05-19 19:26:58 +000025
26namespace codeview {
27class LazyRandomTypeCollection;
28}
29
Zachary Turnerabb17cc2017-09-01 20:06:56 +000030namespace object {
31class COFFObjectFile;
32}
33
Zachary Turnerd3117392016-06-03 19:28:33 +000034namespace pdb {
Reid Kleckner14d90fd2017-07-26 00:40:36 +000035class GSIHashTable;
Zachary Turnerabb17cc2017-09-01 20:06:56 +000036class InputFile;
Reid Kleckner14d90fd2017-07-26 00:40:36 +000037
Zachary Turnerd1de2f42017-08-21 14:53:25 +000038struct StatCollection {
39 struct Stat {
40 Stat() {}
41 Stat(uint32_t Count, uint32_t Size) : Count(Count), Size(Size) {}
42 uint32_t Count = 0;
43 uint32_t Size = 0;
44
45 void update(uint32_t RecordSize) {
46 ++Count;
47 Size += RecordSize;
48 }
49 };
50
51 void update(uint32_t Kind, uint32_t RecordSize) {
52 Totals.update(RecordSize);
53 auto Iter = Individual.try_emplace(Kind, 1, RecordSize);
54 if (!Iter.second)
55 Iter.first->second.update(RecordSize);
56 }
57 Stat Totals;
58 DenseMap<uint32_t, Stat> Individual;
59};
60
Zachary Turner7df69952017-06-22 20:57:39 +000061class DumpOutputStyle : public OutputStyle {
Zachary Turnerd1de2f42017-08-21 14:53:25 +000062
Zachary Turnerd3117392016-06-03 19:28:33 +000063public:
Zachary Turnerabb17cc2017-09-01 20:06:56 +000064 DumpOutputStyle(InputFile &File);
Zachary Turnerd3117392016-06-03 19:28:33 +000065
Zachary Turnera30bd1a2016-06-30 17:42:48 +000066 Error dump() override;
Zachary Turner7120a472016-06-06 20:37:05 +000067
Zachary Turnerd3117392016-06-03 19:28:33 +000068private:
Zachary Turnerabb17cc2017-09-01 20:06:56 +000069 PDBFile &getPdb();
70 object::COFFObjectFile &getObj();
Zachary Turner20d773c2017-05-04 23:53:01 +000071
Alexandre Ganea741cc352018-08-06 19:35:00 +000072 void printStreamNotValidForObj();
73 void printStreamNotPresent(StringRef StreamName);
74
Zachary Turner63055452017-06-15 22:24:24 +000075 Error dumpFileSummary();
Zachary Turnera30bd1a2016-06-30 17:42:48 +000076 Error dumpStreamSummary();
Zachary Turner99c69822017-08-31 20:43:22 +000077 Error dumpSymbolStats();
78 Error dumpUdtStats();
Zachary Turnera6fb5362018-03-23 18:43:39 +000079 Error dumpNamedStreams();
Zachary Turner760ad4d2017-01-20 22:42:09 +000080 Error dumpStringTable();
Zachary Turner60478582018-01-05 19:12:40 +000081 Error dumpStringTableFromPdb();
82 Error dumpStringTableFromObj();
Zachary Turner4e950642017-06-15 23:56:19 +000083 Error dumpLines();
84 Error dumpInlineeLines();
Zachary Turner47d9a562017-06-16 00:04:24 +000085 Error dumpXmi();
86 Error dumpXme();
Zachary Turner42e7cc1b2018-09-11 22:35:01 +000087 Error dumpFpo();
Zachary Turnera1f85f82018-09-12 21:02:01 +000088 Error dumpOldFpo(PDBFile &File);
89 Error dumpNewFpo(PDBFile &File);
Zachary Turnera30bd1a2016-06-30 17:42:48 +000090 Error dumpTpiStream(uint32_t StreamIdx);
Zachary Turner376d4372017-12-05 23:58:18 +000091 Error dumpTypesFromObjectFile();
Zachary Turner63055452017-06-15 22:24:24 +000092 Error dumpModules();
Zachary Turner0e327d02017-06-15 23:12:41 +000093 Error dumpModuleFiles();
Zachary Turnerabb17cc2017-09-01 20:06:56 +000094 Error dumpModuleSymsForPdb();
95 Error dumpModuleSymsForObj();
Zachary Turner457cc342018-07-06 02:59:25 +000096 Error dumpGSIRecords();
Reid Kleckner14d90fd2017-07-26 00:40:36 +000097 Error dumpGlobals();
Zachary Turner63055452017-06-15 22:24:24 +000098 Error dumpPublics();
Reid Kleckner14d90fd2017-07-26 00:40:36 +000099 Error dumpSymbolsFromGSI(const GSIHashTable &Table, bool HashExtras);
Zachary Turnerfb1cd502017-08-04 20:02:38 +0000100 Error dumpSectionHeaders();
Zachary Turnera30bd1a2016-06-30 17:42:48 +0000101 Error dumpSectionContribs();
102 Error dumpSectionMap();
Zachary Turnera30bd1a2016-06-30 17:42:48 +0000103
Zachary Turnerfb1cd502017-08-04 20:02:38 +0000104 void dumpSectionHeaders(StringRef Label, DbgHeaderType Type);
105
Zachary Turnerabb17cc2017-09-01 20:06:56 +0000106 InputFile &File;
Zachary Turner63055452017-06-15 22:24:24 +0000107 LinePrinter P;
Zachary Turnerd1de2f42017-08-21 14:53:25 +0000108 SmallVector<StreamInfo, 32> StreamPurposes;
Zachary Turnerd3117392016-06-03 19:28:33 +0000109};
Zachary Turner63055452017-06-15 22:24:24 +0000110} // namespace pdb
111} // namespace llvm
Zachary Turnerd3117392016-06-03 19:28:33 +0000112
113#endif