2017-06-22 22:57:39 +02:00
|
|
|
//===- DumpOutputStyle.h -------------------------------------- *- C++ --*-===//
|
2016-06-03 21:28:33 +02:00
|
|
|
//
|
2019-01-19 09:50:56 +01:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2016-06-03 21:28:33 +02:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2017-06-22 22:57:39 +02:00
|
|
|
#ifndef LLVM_TOOLS_LLVMPDBDUMP_DUMPOUTPUTSTYLE_H
|
|
|
|
#define LLVM_TOOLS_LLVMPDBDUMP_DUMPOUTPUTSTYLE_H
|
2016-06-03 21:28:33 +02:00
|
|
|
|
2017-06-16 00:24:24 +02:00
|
|
|
#include "LinePrinter.h"
|
2016-06-03 21:28:33 +02:00
|
|
|
#include "OutputStyle.h"
|
2017-08-21 16:53:25 +02:00
|
|
|
#include "StreamUtil.h"
|
2016-06-03 21:28:33 +02:00
|
|
|
|
2017-08-21 16:53:25 +02:00
|
|
|
#include "llvm/ADT/DenseMap.h"
|
2017-05-05 01:53:01 +02:00
|
|
|
#include "llvm/ADT/Optional.h"
|
2017-03-14 00:28:25 +01:00
|
|
|
#include "llvm/ADT/SmallVector.h"
|
2017-08-04 22:02:38 +02:00
|
|
|
#include "llvm/DebugInfo/PDB/Native/RawConstants.h"
|
2016-06-03 21:28:33 +02:00
|
|
|
|
2017-03-14 00:28:25 +01:00
|
|
|
#include <string>
|
|
|
|
|
2016-06-03 21:28:33 +02:00
|
|
|
namespace llvm {
|
2016-08-01 23:19:45 +02:00
|
|
|
class BitVector;
|
2017-05-19 21:26:58 +02:00
|
|
|
|
|
|
|
namespace codeview {
|
|
|
|
class LazyRandomTypeCollection;
|
|
|
|
}
|
|
|
|
|
2017-09-01 22:06:56 +02:00
|
|
|
namespace object {
|
|
|
|
class COFFObjectFile;
|
|
|
|
}
|
|
|
|
|
2016-06-03 21:28:33 +02:00
|
|
|
namespace pdb {
|
2017-07-26 02:40:36 +02:00
|
|
|
class GSIHashTable;
|
2017-09-01 22:06:56 +02:00
|
|
|
class InputFile;
|
[llvm-pdbutil] Add -type-ref-stats to help find unused type info
Summary:
This considers module symbol streams and the global symbol stream to be
roots. Most types that this considers "unreferenced" are referenced by
LF_UDT_MOD_SRC_LINE id records, which VC seems to always include.
Essentially, they are types that the user can only find in the debugger
if they call them by name, they cannot be found by traversing a symbol.
In practice, around 80% of type information in a PDB is referenced by a
symbol. That seems like a reasonable number.
I don't really plan to do anything with this tool. It mostly just exists
for informational purposes, and to confirm that we probably don't need
to implement type reference tracking in LLD. We can continue to merge
all types as we do today without wasting space.
Reviewers: zturner, aganea
Subscribers: mgorny, hiraditya, arphaman, jdoerfert, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D59620
llvm-svn: 356692
2019-03-21 19:02:34 +01:00
|
|
|
class TypeReferenceTracker;
|
2017-07-26 02:40:36 +02:00
|
|
|
|
2017-08-21 16:53:25 +02:00
|
|
|
struct StatCollection {
|
|
|
|
struct Stat {
|
|
|
|
Stat() {}
|
|
|
|
Stat(uint32_t Count, uint32_t Size) : Count(Count), Size(Size) {}
|
|
|
|
uint32_t Count = 0;
|
|
|
|
uint32_t Size = 0;
|
|
|
|
|
|
|
|
void update(uint32_t RecordSize) {
|
|
|
|
++Count;
|
|
|
|
Size += RecordSize;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
[pdb] Add -type-stats and sort stats by descending size
Summary:
It prints this on chromium browser_tests.exe.pdb:
Types
Total: 5647475 entries ( 371,897,512 bytes, 65.85 avg)
--------------------------------------------------------------------------
LF_CLASS: 397894 entries ( 119,537,780 bytes, 300.43 avg)
LF_STRUCTURE: 236351 entries ( 83,208,084 bytes, 352.05 avg)
LF_FIELDLIST: 291003 entries ( 66,087,920 bytes, 227.10 avg)
LF_MFUNCTION: 1884176 entries ( 52,756,928 bytes, 28.00 avg)
LF_POINTER: 1149030 entries ( 13,877,344 bytes, 12.08 avg)
LF_ARGLIST: 789980 entries ( 12,436,752 bytes, 15.74 avg)
LF_METHODLIST: 361498 entries ( 8,351,008 bytes, 23.10 avg)
LF_ENUM: 16069 entries ( 6,108,340 bytes, 380.13 avg)
LF_PROCEDURE: 269374 entries ( 4,309,984 bytes, 16.00 avg)
LF_MODIFIER: 235602 entries ( 2,827,224 bytes, 12.00 avg)
LF_UNION: 9131 entries ( 2,072,168 bytes, 226.94 avg)
LF_VFTABLE: 323 entries ( 207,784 bytes, 643.29 avg)
LF_ARRAY: 6639 entries ( 106,380 bytes, 16.02 avg)
LF_VTSHAPE: 126 entries ( 6,472 bytes, 51.37 avg)
LF_BITFIELD: 278 entries ( 3,336 bytes, 12.00 avg)
LF_LABEL: 1 entries ( 8 bytes, 8.00 avg)
The PDB is overall 1.9GB, so the LF_CLASS and LF_STRUCTURE declarations
account for about 10% of the overall file size. I was surprised to find
that on average LF_FIELDLIST records are short. Maybe this is because
there are many more types with short member lists than there are
instantiations with lots of members, like std::vector.
Reviewers: aganea, zturner
Subscribers: llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D59672
llvm-svn: 356813
2019-03-22 22:22:13 +01:00
|
|
|
using KindAndStat = std::pair<uint32_t, Stat>;
|
|
|
|
|
2017-08-21 16:53:25 +02:00
|
|
|
void update(uint32_t Kind, uint32_t RecordSize) {
|
|
|
|
Totals.update(RecordSize);
|
|
|
|
auto Iter = Individual.try_emplace(Kind, 1, RecordSize);
|
|
|
|
if (!Iter.second)
|
|
|
|
Iter.first->second.update(RecordSize);
|
|
|
|
}
|
|
|
|
Stat Totals;
|
|
|
|
DenseMap<uint32_t, Stat> Individual;
|
[pdb] Add -type-stats and sort stats by descending size
Summary:
It prints this on chromium browser_tests.exe.pdb:
Types
Total: 5647475 entries ( 371,897,512 bytes, 65.85 avg)
--------------------------------------------------------------------------
LF_CLASS: 397894 entries ( 119,537,780 bytes, 300.43 avg)
LF_STRUCTURE: 236351 entries ( 83,208,084 bytes, 352.05 avg)
LF_FIELDLIST: 291003 entries ( 66,087,920 bytes, 227.10 avg)
LF_MFUNCTION: 1884176 entries ( 52,756,928 bytes, 28.00 avg)
LF_POINTER: 1149030 entries ( 13,877,344 bytes, 12.08 avg)
LF_ARGLIST: 789980 entries ( 12,436,752 bytes, 15.74 avg)
LF_METHODLIST: 361498 entries ( 8,351,008 bytes, 23.10 avg)
LF_ENUM: 16069 entries ( 6,108,340 bytes, 380.13 avg)
LF_PROCEDURE: 269374 entries ( 4,309,984 bytes, 16.00 avg)
LF_MODIFIER: 235602 entries ( 2,827,224 bytes, 12.00 avg)
LF_UNION: 9131 entries ( 2,072,168 bytes, 226.94 avg)
LF_VFTABLE: 323 entries ( 207,784 bytes, 643.29 avg)
LF_ARRAY: 6639 entries ( 106,380 bytes, 16.02 avg)
LF_VTSHAPE: 126 entries ( 6,472 bytes, 51.37 avg)
LF_BITFIELD: 278 entries ( 3,336 bytes, 12.00 avg)
LF_LABEL: 1 entries ( 8 bytes, 8.00 avg)
The PDB is overall 1.9GB, so the LF_CLASS and LF_STRUCTURE declarations
account for about 10% of the overall file size. I was surprised to find
that on average LF_FIELDLIST records are short. Maybe this is because
there are many more types with short member lists than there are
instantiations with lots of members, like std::vector.
Reviewers: aganea, zturner
Subscribers: llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D59672
llvm-svn: 356813
2019-03-22 22:22:13 +01:00
|
|
|
|
|
|
|
std::vector<KindAndStat> getStatsSortedBySize() const;
|
2017-08-21 16:53:25 +02:00
|
|
|
};
|
|
|
|
|
2017-06-22 22:57:39 +02:00
|
|
|
class DumpOutputStyle : public OutputStyle {
|
2017-08-21 16:53:25 +02:00
|
|
|
|
2016-06-03 21:28:33 +02:00
|
|
|
public:
|
2017-09-01 22:06:56 +02:00
|
|
|
DumpOutputStyle(InputFile &File);
|
[llvm-pdbutil] Add -type-ref-stats to help find unused type info
Summary:
This considers module symbol streams and the global symbol stream to be
roots. Most types that this considers "unreferenced" are referenced by
LF_UDT_MOD_SRC_LINE id records, which VC seems to always include.
Essentially, they are types that the user can only find in the debugger
if they call them by name, they cannot be found by traversing a symbol.
In practice, around 80% of type information in a PDB is referenced by a
symbol. That seems like a reasonable number.
I don't really plan to do anything with this tool. It mostly just exists
for informational purposes, and to confirm that we probably don't need
to implement type reference tracking in LLD. We can continue to merge
all types as we do today without wasting space.
Reviewers: zturner, aganea
Subscribers: mgorny, hiraditya, arphaman, jdoerfert, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D59620
llvm-svn: 356692
2019-03-21 19:02:34 +01:00
|
|
|
~DumpOutputStyle() override;
|
2016-06-03 21:28:33 +02:00
|
|
|
|
2016-06-30 19:42:48 +02:00
|
|
|
Error dump() override;
|
2016-06-06 22:37:05 +02:00
|
|
|
|
2016-06-03 21:28:33 +02:00
|
|
|
private:
|
2017-09-01 22:06:56 +02:00
|
|
|
PDBFile &getPdb();
|
|
|
|
object::COFFObjectFile &getObj();
|
2017-05-05 01:53:01 +02:00
|
|
|
|
2018-08-06 21:35:00 +02:00
|
|
|
void printStreamNotValidForObj();
|
|
|
|
void printStreamNotPresent(StringRef StreamName);
|
|
|
|
|
2017-06-16 00:24:24 +02:00
|
|
|
Error dumpFileSummary();
|
2016-06-30 19:42:48 +02:00
|
|
|
Error dumpStreamSummary();
|
2017-08-31 22:43:22 +02:00
|
|
|
Error dumpSymbolStats();
|
|
|
|
Error dumpUdtStats();
|
[pdb] Add -type-stats and sort stats by descending size
Summary:
It prints this on chromium browser_tests.exe.pdb:
Types
Total: 5647475 entries ( 371,897,512 bytes, 65.85 avg)
--------------------------------------------------------------------------
LF_CLASS: 397894 entries ( 119,537,780 bytes, 300.43 avg)
LF_STRUCTURE: 236351 entries ( 83,208,084 bytes, 352.05 avg)
LF_FIELDLIST: 291003 entries ( 66,087,920 bytes, 227.10 avg)
LF_MFUNCTION: 1884176 entries ( 52,756,928 bytes, 28.00 avg)
LF_POINTER: 1149030 entries ( 13,877,344 bytes, 12.08 avg)
LF_ARGLIST: 789980 entries ( 12,436,752 bytes, 15.74 avg)
LF_METHODLIST: 361498 entries ( 8,351,008 bytes, 23.10 avg)
LF_ENUM: 16069 entries ( 6,108,340 bytes, 380.13 avg)
LF_PROCEDURE: 269374 entries ( 4,309,984 bytes, 16.00 avg)
LF_MODIFIER: 235602 entries ( 2,827,224 bytes, 12.00 avg)
LF_UNION: 9131 entries ( 2,072,168 bytes, 226.94 avg)
LF_VFTABLE: 323 entries ( 207,784 bytes, 643.29 avg)
LF_ARRAY: 6639 entries ( 106,380 bytes, 16.02 avg)
LF_VTSHAPE: 126 entries ( 6,472 bytes, 51.37 avg)
LF_BITFIELD: 278 entries ( 3,336 bytes, 12.00 avg)
LF_LABEL: 1 entries ( 8 bytes, 8.00 avg)
The PDB is overall 1.9GB, so the LF_CLASS and LF_STRUCTURE declarations
account for about 10% of the overall file size. I was surprised to find
that on average LF_FIELDLIST records are short. Maybe this is because
there are many more types with short member lists than there are
instantiations with lots of members, like std::vector.
Reviewers: aganea, zturner
Subscribers: llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D59672
llvm-svn: 356813
2019-03-22 22:22:13 +01:00
|
|
|
Error dumpTypeStats();
|
2018-03-23 19:43:39 +01:00
|
|
|
Error dumpNamedStreams();
|
2017-01-20 23:42:09 +01:00
|
|
|
Error dumpStringTable();
|
2018-01-05 20:12:40 +01:00
|
|
|
Error dumpStringTableFromPdb();
|
|
|
|
Error dumpStringTableFromObj();
|
2017-06-16 01:56:19 +02:00
|
|
|
Error dumpLines();
|
|
|
|
Error dumpInlineeLines();
|
2017-06-16 02:04:24 +02:00
|
|
|
Error dumpXmi();
|
|
|
|
Error dumpXme();
|
2018-09-12 00:35:01 +02:00
|
|
|
Error dumpFpo();
|
2018-09-12 23:02:01 +02:00
|
|
|
Error dumpOldFpo(PDBFile &File);
|
|
|
|
Error dumpNewFpo(PDBFile &File);
|
2016-06-30 19:42:48 +02:00
|
|
|
Error dumpTpiStream(uint32_t StreamIdx);
|
2017-12-06 00:58:18 +01:00
|
|
|
Error dumpTypesFromObjectFile();
|
[llvm-pdbutil] Add -type-ref-stats to help find unused type info
Summary:
This considers module symbol streams and the global symbol stream to be
roots. Most types that this considers "unreferenced" are referenced by
LF_UDT_MOD_SRC_LINE id records, which VC seems to always include.
Essentially, they are types that the user can only find in the debugger
if they call them by name, they cannot be found by traversing a symbol.
In practice, around 80% of type information in a PDB is referenced by a
symbol. That seems like a reasonable number.
I don't really plan to do anything with this tool. It mostly just exists
for informational purposes, and to confirm that we probably don't need
to implement type reference tracking in LLD. We can continue to merge
all types as we do today without wasting space.
Reviewers: zturner, aganea
Subscribers: mgorny, hiraditya, arphaman, jdoerfert, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D59620
llvm-svn: 356692
2019-03-21 19:02:34 +01:00
|
|
|
Error dumpTypeRefStats();
|
2017-06-16 00:24:24 +02:00
|
|
|
Error dumpModules();
|
2017-06-16 01:12:41 +02:00
|
|
|
Error dumpModuleFiles();
|
2017-09-01 22:06:56 +02:00
|
|
|
Error dumpModuleSymsForPdb();
|
|
|
|
Error dumpModuleSymsForObj();
|
2018-07-06 04:59:25 +02:00
|
|
|
Error dumpGSIRecords();
|
2017-07-26 02:40:36 +02:00
|
|
|
Error dumpGlobals();
|
2017-06-16 00:24:24 +02:00
|
|
|
Error dumpPublics();
|
2017-07-26 02:40:36 +02:00
|
|
|
Error dumpSymbolsFromGSI(const GSIHashTable &Table, bool HashExtras);
|
2017-08-04 22:02:38 +02:00
|
|
|
Error dumpSectionHeaders();
|
2016-06-30 19:42:48 +02:00
|
|
|
Error dumpSectionContribs();
|
|
|
|
Error dumpSectionMap();
|
|
|
|
|
2017-08-04 22:02:38 +02:00
|
|
|
void dumpSectionHeaders(StringRef Label, DbgHeaderType Type);
|
|
|
|
|
2017-09-01 22:06:56 +02:00
|
|
|
InputFile &File;
|
[llvm-pdbutil] Add -type-ref-stats to help find unused type info
Summary:
This considers module symbol streams and the global symbol stream to be
roots. Most types that this considers "unreferenced" are referenced by
LF_UDT_MOD_SRC_LINE id records, which VC seems to always include.
Essentially, they are types that the user can only find in the debugger
if they call them by name, they cannot be found by traversing a symbol.
In practice, around 80% of type information in a PDB is referenced by a
symbol. That seems like a reasonable number.
I don't really plan to do anything with this tool. It mostly just exists
for informational purposes, and to confirm that we probably don't need
to implement type reference tracking in LLD. We can continue to merge
all types as we do today without wasting space.
Reviewers: zturner, aganea
Subscribers: mgorny, hiraditya, arphaman, jdoerfert, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D59620
llvm-svn: 356692
2019-03-21 19:02:34 +01:00
|
|
|
std::unique_ptr<TypeReferenceTracker> RefTracker;
|
2017-06-16 00:24:24 +02:00
|
|
|
LinePrinter P;
|
2017-08-21 16:53:25 +02:00
|
|
|
SmallVector<StreamInfo, 32> StreamPurposes;
|
2016-06-03 21:28:33 +02:00
|
|
|
};
|
2017-06-16 00:24:24 +02:00
|
|
|
} // namespace pdb
|
|
|
|
} // namespace llvm
|
2016-06-03 21:28:33 +02:00
|
|
|
|
|
|
|
#endif
|