2017-06-10 04:46:17 +08:00
|
|
|
//===- llvm-pdbutil.h ----------------------------------------- *- C++ --*-===//
|
2015-02-23 06:03:38 +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
|
2015-02-23 06:03:38 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef LLVM_TOOLS_LLVMPDBDUMP_LLVMPDBDUMP_H
|
|
|
|
#define LLVM_TOOLS_LLVMPDBDUMP_LLVMPDBDUMP_H
|
|
|
|
|
2017-08-04 04:30:09 +08:00
|
|
|
#include "llvm/ADT/DenseMap.h"
|
2016-09-10 02:17:52 +08:00
|
|
|
#include "llvm/ADT/Optional.h"
|
2017-09-02 04:06:56 +08:00
|
|
|
#include "llvm/ADT/PointerUnion.h"
|
2015-03-02 12:39:56 +08:00
|
|
|
#include "llvm/Support/CommandLine.h"
|
2015-02-23 06:03:38 +08:00
|
|
|
#include "llvm/Support/raw_ostream.h"
|
|
|
|
|
2017-05-14 09:13:40 +08:00
|
|
|
#include <memory>
|
|
|
|
#include <stdint.h>
|
|
|
|
|
|
|
|
namespace llvm {
|
2017-09-02 04:06:56 +08:00
|
|
|
namespace object {
|
|
|
|
class COFFObjectFile;
|
|
|
|
}
|
2017-05-14 09:13:40 +08:00
|
|
|
namespace pdb {
|
|
|
|
class PDBSymbolData;
|
|
|
|
class PDBSymbolFunc;
|
2017-09-02 04:06:56 +08:00
|
|
|
class PDBFile;
|
2017-05-14 09:13:40 +08:00
|
|
|
uint32_t getTypeLength(const PDBSymbolData &Symbol);
|
|
|
|
}
|
2017-09-02 04:06:56 +08:00
|
|
|
typedef llvm::PointerUnion<object::COFFObjectFile *, pdb::PDBFile *>
|
|
|
|
PdbOrCoffObj;
|
2017-05-14 09:13:40 +08:00
|
|
|
}
|
|
|
|
|
2015-03-02 12:39:56 +08:00
|
|
|
namespace opts {
|
2016-06-04 03:28:33 +08:00
|
|
|
|
2017-06-16 06:24:24 +08:00
|
|
|
enum class DumpLevel { None, Basic, Verbose };
|
|
|
|
|
2017-06-09 07:39:33 +08:00
|
|
|
enum class ModuleSubsection {
|
|
|
|
Unknown,
|
|
|
|
Lines,
|
|
|
|
FileChecksums,
|
|
|
|
InlineeLines,
|
|
|
|
CrossScopeImports,
|
|
|
|
CrossScopeExports,
|
2017-06-09 08:28:08 +08:00
|
|
|
StringTable,
|
|
|
|
Symbols,
|
|
|
|
FrameData,
|
2017-06-10 04:46:52 +08:00
|
|
|
CoffSymbolRVAs,
|
2017-06-09 07:39:33 +08:00
|
|
|
All
|
|
|
|
};
|
|
|
|
|
2016-07-01 01:42:48 +08:00
|
|
|
namespace pretty {
|
2017-04-11 03:33:29 +08:00
|
|
|
|
2017-04-25 01:47:52 +08:00
|
|
|
enum class ClassDefinitionFormat { None, Layout, All };
|
2017-04-26 04:22:29 +08:00
|
|
|
enum class ClassSortMode {
|
|
|
|
None,
|
|
|
|
Name,
|
|
|
|
Size,
|
|
|
|
Padding,
|
|
|
|
PaddingPct,
|
|
|
|
PaddingImmediate,
|
|
|
|
PaddingPctImmediate
|
|
|
|
};
|
2017-04-07 07:43:39 +08:00
|
|
|
|
2017-05-14 09:13:40 +08:00
|
|
|
enum class SymbolSortMode { None, Name, Size };
|
|
|
|
|
|
|
|
enum class SymLevel { Functions, Data, Thunks, All };
|
|
|
|
|
|
|
|
bool shouldDumpSymLevel(SymLevel Level);
|
|
|
|
bool compareFunctionSymbols(
|
|
|
|
const std::unique_ptr<llvm::pdb::PDBSymbolFunc> &F1,
|
|
|
|
const std::unique_ptr<llvm::pdb::PDBSymbolFunc> &F2);
|
|
|
|
bool compareDataSymbols(const std::unique_ptr<llvm::pdb::PDBSymbolData> &F1,
|
|
|
|
const std::unique_ptr<llvm::pdb::PDBSymbolData> &F2);
|
|
|
|
|
2018-07-07 05:01:42 +08:00
|
|
|
extern llvm::cl::list<std::string> WithName;
|
|
|
|
|
2015-03-02 12:39:56 +08:00
|
|
|
extern llvm::cl::opt<bool> Compilands;
|
|
|
|
extern llvm::cl::opt<bool> Symbols;
|
|
|
|
extern llvm::cl::opt<bool> Globals;
|
2017-04-07 07:43:12 +08:00
|
|
|
extern llvm::cl::opt<bool> Classes;
|
|
|
|
extern llvm::cl::opt<bool> Enums;
|
2018-09-22 06:36:28 +08:00
|
|
|
extern llvm::cl::opt<bool> Funcsigs;
|
2018-10-01 00:19:18 +08:00
|
|
|
extern llvm::cl::opt<bool> Arrays;
|
2017-04-07 07:43:12 +08:00
|
|
|
extern llvm::cl::opt<bool> Typedefs;
|
2018-09-30 07:28:19 +08:00
|
|
|
extern llvm::cl::opt<bool> Pointers;
|
2018-10-02 01:55:16 +08:00
|
|
|
extern llvm::cl::opt<bool> VTShapes;
|
2015-03-02 12:39:56 +08:00
|
|
|
extern llvm::cl::opt<bool> All;
|
2016-07-01 01:42:48 +08:00
|
|
|
extern llvm::cl::opt<bool> ExcludeCompilerGenerated;
|
|
|
|
|
|
|
|
extern llvm::cl::opt<bool> NoEnumDefs;
|
|
|
|
extern llvm::cl::list<std::string> ExcludeTypes;
|
|
|
|
extern llvm::cl::list<std::string> ExcludeSymbols;
|
|
|
|
extern llvm::cl::list<std::string> ExcludeCompilands;
|
|
|
|
extern llvm::cl::list<std::string> IncludeTypes;
|
|
|
|
extern llvm::cl::list<std::string> IncludeSymbols;
|
|
|
|
extern llvm::cl::list<std::string> IncludeCompilands;
|
2017-05-14 09:13:40 +08:00
|
|
|
extern llvm::cl::opt<SymbolSortMode> SymbolOrder;
|
2017-04-14 05:11:00 +08:00
|
|
|
extern llvm::cl::opt<ClassSortMode> ClassOrder;
|
|
|
|
extern llvm::cl::opt<uint32_t> SizeThreshold;
|
|
|
|
extern llvm::cl::opt<uint32_t> PaddingThreshold;
|
2017-04-26 04:22:29 +08:00
|
|
|
extern llvm::cl::opt<uint32_t> ImmediatePaddingThreshold;
|
2017-04-11 03:33:29 +08:00
|
|
|
extern llvm::cl::opt<ClassDefinitionFormat> ClassFormat;
|
2017-04-25 01:47:52 +08:00
|
|
|
extern llvm::cl::opt<uint32_t> ClassRecursionDepth;
|
2016-07-01 01:42:48 +08:00
|
|
|
}
|
2015-02-23 06:03:38 +08:00
|
|
|
|
2017-06-23 04:58:11 +08:00
|
|
|
namespace bytes {
|
2017-06-24 03:54:44 +08:00
|
|
|
struct NumberRange {
|
|
|
|
uint64_t Min;
|
|
|
|
llvm::Optional<uint64_t> Max;
|
2016-09-10 02:17:52 +08:00
|
|
|
};
|
2017-06-24 03:54:44 +08:00
|
|
|
|
|
|
|
extern llvm::Optional<NumberRange> DumpBlockRange;
|
|
|
|
extern llvm::Optional<NumberRange> DumpByteRange;
|
2017-06-23 04:58:11 +08:00
|
|
|
extern llvm::cl::list<std::string> DumpStreamData;
|
2017-06-24 04:18:38 +08:00
|
|
|
extern llvm::cl::opt<bool> NameMap;
|
2017-08-03 06:25:52 +08:00
|
|
|
extern llvm::cl::opt<bool> Fpm;
|
2017-06-24 05:11:54 +08:00
|
|
|
|
|
|
|
extern llvm::cl::opt<bool> SectionContributions;
|
|
|
|
extern llvm::cl::opt<bool> SectionMap;
|
|
|
|
extern llvm::cl::opt<bool> ModuleInfos;
|
|
|
|
extern llvm::cl::opt<bool> FileInfo;
|
|
|
|
extern llvm::cl::opt<bool> TypeServerMap;
|
|
|
|
extern llvm::cl::opt<bool> ECData;
|
|
|
|
|
2017-06-24 05:50:54 +08:00
|
|
|
extern llvm::cl::list<uint32_t> TypeIndex;
|
|
|
|
extern llvm::cl::list<uint32_t> IdIndex;
|
|
|
|
|
2017-06-24 07:08:57 +08:00
|
|
|
extern llvm::cl::opt<uint32_t> ModuleIndex;
|
|
|
|
extern llvm::cl::opt<bool> ModuleSyms;
|
|
|
|
extern llvm::cl::opt<bool> ModuleC11;
|
|
|
|
extern llvm::cl::opt<bool> ModuleC13;
|
2017-06-27 01:22:36 +08:00
|
|
|
extern llvm::cl::opt<bool> SplitChunks;
|
2017-06-23 04:58:11 +08:00
|
|
|
} // namespace bytes
|
|
|
|
|
|
|
|
namespace dump {
|
2016-09-10 02:17:52 +08:00
|
|
|
|
2017-06-16 06:24:24 +08:00
|
|
|
extern llvm::cl::opt<bool> DumpSummary;
|
2017-08-03 06:25:52 +08:00
|
|
|
extern llvm::cl::opt<bool> DumpFpm;
|
2017-06-16 06:24:24 +08:00
|
|
|
extern llvm::cl::opt<bool> DumpStreams;
|
2017-09-01 04:43:22 +08:00
|
|
|
extern llvm::cl::opt<bool> DumpSymbolStats;
|
[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-23 05:22:13 +08:00
|
|
|
extern llvm::cl::opt<bool> DumpTypeStats;
|
2017-09-01 04:43:22 +08:00
|
|
|
extern llvm::cl::opt<bool> DumpUdtStats;
|
2017-06-24 04:28:14 +08:00
|
|
|
extern llvm::cl::opt<bool> DumpStreamBlocks;
|
2017-06-16 07:56:19 +08:00
|
|
|
|
|
|
|
extern llvm::cl::opt<bool> DumpLines;
|
|
|
|
extern llvm::cl::opt<bool> DumpInlineeLines;
|
2017-06-16 08:04:24 +08:00
|
|
|
extern llvm::cl::opt<bool> DumpXmi;
|
|
|
|
extern llvm::cl::opt<bool> DumpXme;
|
2018-03-24 02:43:39 +08:00
|
|
|
extern llvm::cl::opt<bool> DumpNamedStreams;
|
2017-06-16 06:24:24 +08:00
|
|
|
extern llvm::cl::opt<bool> DumpStringTable;
|
2018-03-24 02:43:39 +08:00
|
|
|
extern llvm::cl::opt<bool> DumpStringTableDetails;
|
2017-06-16 06:24:24 +08:00
|
|
|
extern llvm::cl::opt<bool> DumpTypes;
|
|
|
|
extern llvm::cl::opt<bool> DumpTypeData;
|
2017-06-16 07:04:42 +08:00
|
|
|
extern llvm::cl::opt<bool> DumpTypeExtras;
|
2017-06-17 07:42:15 +08:00
|
|
|
extern llvm::cl::list<uint32_t> DumpTypeIndex;
|
2017-07-01 02:15:47 +08:00
|
|
|
extern llvm::cl::opt<bool> DumpTypeDependents;
|
[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
|
|
|
extern llvm::cl::opt<bool> DumpTypeRefStats;
|
2017-08-05 04:02:38 +08:00
|
|
|
extern llvm::cl::opt<bool> DumpSectionHeaders;
|
2017-06-17 07:42:15 +08:00
|
|
|
|
2017-06-16 06:24:24 +08:00
|
|
|
extern llvm::cl::opt<bool> DumpIds;
|
|
|
|
extern llvm::cl::opt<bool> DumpIdData;
|
2017-06-16 07:04:42 +08:00
|
|
|
extern llvm::cl::opt<bool> DumpIdExtras;
|
2017-06-17 07:42:15 +08:00
|
|
|
extern llvm::cl::list<uint32_t> DumpIdIndex;
|
2017-08-04 07:11:52 +08:00
|
|
|
extern llvm::cl::opt<uint32_t> DumpModi;
|
2017-08-21 22:53:25 +08:00
|
|
|
extern llvm::cl::opt<bool> JustMyCode;
|
2018-09-20 23:50:13 +08:00
|
|
|
extern llvm::cl::opt<bool> DontResolveForwardRefs;
|
2017-06-16 06:24:24 +08:00
|
|
|
extern llvm::cl::opt<bool> DumpSymbols;
|
|
|
|
extern llvm::cl::opt<bool> DumpSymRecordBytes;
|
2018-07-06 10:59:25 +08:00
|
|
|
extern llvm::cl::opt<bool> DumpGSIRecords;
|
2017-07-26 08:40:36 +08:00
|
|
|
extern llvm::cl::opt<bool> DumpGlobals;
|
2018-10-08 12:19:16 +08:00
|
|
|
extern llvm::cl::list<std::string> DumpGlobalNames;
|
2017-07-26 08:40:36 +08:00
|
|
|
extern llvm::cl::opt<bool> DumpGlobalExtras;
|
2016-06-04 03:28:33 +08:00
|
|
|
extern llvm::cl::opt<bool> DumpPublics;
|
2017-07-22 02:28:55 +08:00
|
|
|
extern llvm::cl::opt<bool> DumpPublicExtras;
|
2016-06-04 03:28:33 +08:00
|
|
|
extern llvm::cl::opt<bool> DumpSectionContribs;
|
|
|
|
extern llvm::cl::opt<bool> DumpSectionMap;
|
2017-06-16 06:24:24 +08:00
|
|
|
extern llvm::cl::opt<bool> DumpModules;
|
|
|
|
extern llvm::cl::opt<bool> DumpModuleFiles;
|
2018-09-12 06:35:01 +08:00
|
|
|
extern llvm::cl::opt<bool> DumpFpo;
|
2017-06-16 06:24:24 +08:00
|
|
|
extern llvm::cl::opt<bool> RawAll;
|
2016-07-01 01:42:48 +08:00
|
|
|
}
|
2016-06-04 03:28:33 +08:00
|
|
|
|
2016-07-01 01:42:48 +08:00
|
|
|
namespace pdb2yaml {
|
2017-05-27 07:46:20 +08:00
|
|
|
extern llvm::cl::opt<bool> All;
|
2016-07-12 05:45:09 +08:00
|
|
|
extern llvm::cl::opt<bool> NoFileHeaders;
|
2017-03-16 06:18:53 +08:00
|
|
|
extern llvm::cl::opt<bool> Minimal;
|
2016-07-01 01:42:48 +08:00
|
|
|
extern llvm::cl::opt<bool> StreamMetadata;
|
|
|
|
extern llvm::cl::opt<bool> StreamDirectory;
|
2017-01-21 06:42:09 +08:00
|
|
|
extern llvm::cl::opt<bool> StringTable;
|
2016-07-07 02:05:57 +08:00
|
|
|
extern llvm::cl::opt<bool> PdbStream;
|
2016-07-12 05:45:26 +08:00
|
|
|
extern llvm::cl::opt<bool> DbiStream;
|
2016-08-19 00:49:29 +08:00
|
|
|
extern llvm::cl::opt<bool> TpiStream;
|
2016-09-16 02:22:31 +08:00
|
|
|
extern llvm::cl::opt<bool> IpiStream;
|
2018-10-26 08:17:31 +08:00
|
|
|
extern llvm::cl::opt<bool> PublicsStream;
|
2016-07-01 01:42:48 +08:00
|
|
|
extern llvm::cl::list<std::string> InputFilename;
|
2017-06-09 07:39:33 +08:00
|
|
|
extern llvm::cl::opt<bool> DumpModules;
|
|
|
|
extern llvm::cl::opt<bool> DumpModuleFiles;
|
|
|
|
extern llvm::cl::list<ModuleSubsection> DumpModuleSubsections;
|
|
|
|
extern llvm::cl::opt<bool> DumpModuleSyms;
|
2017-06-16 06:24:24 +08:00
|
|
|
} // namespace pdb2yaml
|
Fix some differences between lld and MSVC generated PDBs.
A couple of things were different about our generated PDBs.
1) We were outputting the wrong Version on the PDB Stream.
The version we were setting was newer than what MSVC is setting.
It's not clear what the implications are, but we change LLD
to use PdbImplVC70, as MSVC does.
2) For the optional debug stream indices in the DBI Stream, we
were outputting 0 to mean "the stream is not present". MSVC
outputs uint16_t(-1), which is the "correct" way to specify
that a stream is not present. So we fix that as well.
3) We were setting the PDB Stream signature to 0. This is supposed
to be the result of calling time(nullptr). Although this leads
to non-deterministic builds, a better way to solve that is by
having a command line option explicitly for generating a
reproducible build, and have the default behavior of lld-link
match the default behavior of link.
To test this, I'm making use of the new and improved `pdb diff`
sub command. To make it suitable for writing tests against, I had
to modify the diff subcommand slightly to print less verbose output.
Previously it would always print | <column> | <value1> | <value2> |
which is quite verbose, and the values are fragile. All we really
want to know is "did we produce the same value as link?" So I added
command line options to print a single character representing the
result status (different, identical, equivalent), and another to
hide the value display. Note that just inspecting the diff output
used to write the test, you can see some things that are obviously
wrong. That is just reflective of the fact that this is the state
of affairs today, not that we're asserting that this is "correct".
We can use this as a starting point to discover differences, fix
them, and update the test.
Differential Revision: https://reviews.llvm.org/D35086
llvm-svn: 307422
2017-07-08 02:45:56 +08:00
|
|
|
|
2018-03-30 00:28:20 +08:00
|
|
|
namespace explain {
|
2018-04-05 01:29:09 +08:00
|
|
|
enum class InputFileType { PDBFile, PDBStream, DBIStream, Names, ModuleStream };
|
|
|
|
|
2018-03-30 00:28:20 +08:00
|
|
|
extern llvm::cl::list<std::string> InputFilename;
|
2018-03-31 01:16:50 +08:00
|
|
|
extern llvm::cl::list<uint64_t> Offsets;
|
2018-04-05 01:29:09 +08:00
|
|
|
extern llvm::cl::opt<InputFileType> InputType;
|
2018-03-30 00:28:20 +08:00
|
|
|
} // namespace explain
|
2018-04-03 02:35:21 +08:00
|
|
|
|
|
|
|
namespace exportstream {
|
|
|
|
extern llvm::cl::opt<std::string> OutputFile;
|
|
|
|
extern llvm::cl::opt<std::string> Stream;
|
|
|
|
extern llvm::cl::opt<bool> ForceName;
|
|
|
|
} // namespace exportstream
|
2015-02-23 06:03:38 +08:00
|
|
|
}
|
|
|
|
|
2016-05-14 05:21:53 +08:00
|
|
|
#endif
|