2017-06-23 04:57:39 +08:00
|
|
|
//===- DumpOutputStyle.h -------------------------------------- *- C++ --*-===//
|
2016-06-04 03:28:33 +08:00
|
|
|
//
|
2019-01-19 16:50:56 +08: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-04 03:28:33 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2017-06-23 04:57:39 +08:00
|
|
|
#ifndef LLVM_TOOLS_LLVMPDBDUMP_DUMPOUTPUTSTYLE_H
|
|
|
|
#define LLVM_TOOLS_LLVMPDBDUMP_DUMPOUTPUTSTYLE_H
|
2016-06-04 03:28:33 +08:00
|
|
|
|
2017-06-16 06:24:24 +08:00
|
|
|
#include "LinePrinter.h"
|
2016-06-04 03:28:33 +08:00
|
|
|
#include "OutputStyle.h"
|
2017-08-21 22:53:25 +08:00
|
|
|
#include "StreamUtil.h"
|
2016-06-04 03:28:33 +08:00
|
|
|
|
2017-08-21 22:53:25 +08:00
|
|
|
#include "llvm/ADT/DenseMap.h"
|
2017-05-05 07:53:01 +08:00
|
|
|
#include "llvm/ADT/Optional.h"
|
2017-03-14 07:28:25 +08:00
|
|
|
#include "llvm/ADT/SmallVector.h"
|
2017-08-05 04:02:38 +08:00
|
|
|
#include "llvm/DebugInfo/PDB/Native/RawConstants.h"
|
2016-06-04 03:28:33 +08:00
|
|
|
|
2017-03-14 07:28:25 +08:00
|
|
|
#include <string>
|
|
|
|
|
2016-06-04 03:28:33 +08:00
|
|
|
namespace llvm {
|
2016-08-02 05:19:45 +08:00
|
|
|
class BitVector;
|
2017-05-20 03:26:58 +08:00
|
|
|
|
|
|
|
namespace codeview {
|
|
|
|
class LazyRandomTypeCollection;
|
|
|
|
}
|
|
|
|
|
2017-09-02 04:06:56 +08:00
|
|
|
namespace object {
|
|
|
|
class COFFObjectFile;
|
|
|
|
}
|
|
|
|
|
2016-06-04 03:28:33 +08:00
|
|
|
namespace pdb {
|
2017-07-26 08:40:36 +08:00
|
|
|
class GSIHashTable;
|
2017-09-02 04:06:56 +08: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-22 02:02:34 +08:00
|
|
|
class TypeReferenceTracker;
|
2017-07-26 08:40:36 +08:00
|
|
|
|
2017-08-21 22:53:25 +08: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;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
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;
|
|
|
|
};
|
|
|
|
|
2017-06-23 04:57:39 +08:00
|
|
|
class DumpOutputStyle : public OutputStyle {
|
2017-08-21 22:53:25 +08:00
|
|
|
|
2016-06-04 03:28:33 +08:00
|
|
|
public:
|
2017-09-02 04:06:56 +08: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-22 02:02:34 +08:00
|
|
|
~DumpOutputStyle() override;
|
2016-06-04 03:28:33 +08:00
|
|
|
|
2016-07-01 01:42:48 +08:00
|
|
|
Error dump() override;
|
2016-06-07 04:37:05 +08:00
|
|
|
|
2016-06-04 03:28:33 +08:00
|
|
|
private:
|
2017-09-02 04:06:56 +08:00
|
|
|
PDBFile &getPdb();
|
|
|
|
object::COFFObjectFile &getObj();
|
2017-05-05 07:53:01 +08:00
|
|
|
|
2018-08-07 03:35:00 +08:00
|
|
|
void printStreamNotValidForObj();
|
|
|
|
void printStreamNotPresent(StringRef StreamName);
|
|
|
|
|
2017-06-16 06:24:24 +08:00
|
|
|
Error dumpFileSummary();
|
2016-07-01 01:42:48 +08:00
|
|
|
Error dumpStreamSummary();
|
2017-09-01 04:43:22 +08:00
|
|
|
Error dumpSymbolStats();
|
|
|
|
Error dumpUdtStats();
|
2018-03-24 02:43:39 +08:00
|
|
|
Error dumpNamedStreams();
|
2017-01-21 06:42:09 +08:00
|
|
|
Error dumpStringTable();
|
2018-01-06 03:12:40 +08:00
|
|
|
Error dumpStringTableFromPdb();
|
|
|
|
Error dumpStringTableFromObj();
|
2017-06-16 07:56:19 +08:00
|
|
|
Error dumpLines();
|
|
|
|
Error dumpInlineeLines();
|
2017-06-16 08:04:24 +08:00
|
|
|
Error dumpXmi();
|
|
|
|
Error dumpXme();
|
2018-09-12 06:35:01 +08:00
|
|
|
Error dumpFpo();
|
2018-09-13 05:02:01 +08:00
|
|
|
Error dumpOldFpo(PDBFile &File);
|
|
|
|
Error dumpNewFpo(PDBFile &File);
|
2016-07-01 01:42:48 +08:00
|
|
|
Error dumpTpiStream(uint32_t StreamIdx);
|
2017-12-06 07:58:18 +08: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-22 02:02:34 +08:00
|
|
|
Error dumpTypeRefStats();
|
2017-06-16 06:24:24 +08:00
|
|
|
Error dumpModules();
|
2017-06-16 07:12:41 +08:00
|
|
|
Error dumpModuleFiles();
|
2017-09-02 04:06:56 +08:00
|
|
|
Error dumpModuleSymsForPdb();
|
|
|
|
Error dumpModuleSymsForObj();
|
2018-07-06 10:59:25 +08:00
|
|
|
Error dumpGSIRecords();
|
2017-07-26 08:40:36 +08:00
|
|
|
Error dumpGlobals();
|
2017-06-16 06:24:24 +08:00
|
|
|
Error dumpPublics();
|
2017-07-26 08:40:36 +08:00
|
|
|
Error dumpSymbolsFromGSI(const GSIHashTable &Table, bool HashExtras);
|
2017-08-05 04:02:38 +08:00
|
|
|
Error dumpSectionHeaders();
|
2016-07-01 01:42:48 +08:00
|
|
|
Error dumpSectionContribs();
|
|
|
|
Error dumpSectionMap();
|
|
|
|
|
2017-08-05 04:02:38 +08:00
|
|
|
void dumpSectionHeaders(StringRef Label, DbgHeaderType Type);
|
|
|
|
|
2017-09-02 04:06:56 +08: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-22 02:02:34 +08:00
|
|
|
std::unique_ptr<TypeReferenceTracker> RefTracker;
|
2017-06-16 06:24:24 +08:00
|
|
|
LinePrinter P;
|
2017-08-21 22:53:25 +08:00
|
|
|
SmallVector<StreamInfo, 32> StreamPurposes;
|
2016-06-04 03:28:33 +08:00
|
|
|
};
|
2017-06-16 06:24:24 +08:00
|
|
|
} // namespace pdb
|
|
|
|
} // namespace llvm
|
2016-06-04 03:28:33 +08:00
|
|
|
|
|
|
|
#endif
|