1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-18 18:42:46 +02:00

Fix a few small issues in llvm-pdbutil

Running "llvm-pdbutil dump -all" on linux (using the native PDB reader),
over a few PDBs pulled from the Microsoft public symbol store uncovered 
a few small issues:

- stripped PDBs might not have the strings stream (/names)
- stripped PDBs might not have the "module info" stream

Differential Revision: https://reviews.llvm.org/D54006

llvm-svn: 346010
This commit is contained in:
Leonard Mosescu 2018-11-02 18:00:37 +00:00
parent 14c7a87da5
commit f728f0d1e8
21 changed files with 165 additions and 21 deletions

Binary file not shown.

View File

@ -1,3 +1,4 @@
; REQUIRES: diasdk
; RUN: llvm-pdbutil pretty -lines %p/Inputs/PrettyFuncDumperTest.pdb > %t
; CHECK: ---COMPILANDS---

View File

@ -1,3 +1,5 @@
; REQUIRES: diasdk
; RUN: llvm-pdbutil pretty -all -class-recurse-depth=1 \
; RUN: %p/Inputs/ClassLayoutTest.pdb > %t
; RUN: FileCheck -input-file=%t %s -check-prefix=GLOBALS_TEST

View File

@ -1,3 +1,5 @@
; REQUIRES: diasdk
; RUN: llvm-pdbutil pretty -classes -class-definitions=layout \
; RUN: -include-types=Test %p/Inputs/ComplexPaddingTest.pdb > %t

View File

@ -1,3 +1,5 @@
; REQUIRES: diasdk
; RUN: llvm-pdbutil pretty -types %p/Inputs/ClassLayoutTest.pdb > %t
; RUN: FileCheck -input-file=%t %s -check-prefix=GLOBAL_ENUM
; RUN: FileCheck -input-file=%t %s -check-prefix=MEMBER_ENUM

View File

@ -1,3 +1,5 @@
; REQUIRES: diasdk
; RUN: llvm-pdbutil explain \
; RUN: -offset=0xF000 \
; RUN: -offset=0xF004 \

View File

@ -1,3 +1,5 @@
; REQUIRES: diasdk
; RUN: llvm-pdbutil explain \
; RUN: -offset=0x11000 \
; RUN: -offset=0x11004 \

View File

@ -1,3 +1,5 @@
; REQUIRES: diasdk
; RUN: llvm-pdbutil explain -offset=0 %p/Inputs/InjectedSource.pdb \
; RUN: | FileCheck --check-prefix=ZERO %s
; RUN: llvm-pdbutil explain -offset=40 %p/Inputs/InjectedSource.pdb \

View File

@ -1,6 +1,8 @@
; The PDB committed to the repo does not seem to be recognized by older
; versions of DIA SDK, so we xfail the test temporarily until we can
; figure out how to get a PDB that makes all versions of MSVC happy.
; REQUIRES: diasdk
; RUN: llvm-pdbutil pretty -injected-sources -injected-source-content \
; RUN: %p/Inputs/InjectedSource.pdb | FileCheck %s
; RUN: llvm-pdbutil pretty -injected-sources -injected-source-content \

View File

@ -1 +1,2 @@
config.unsupported = not config.have_dia_sdk
if config.have_dia_sdk:
config.available_features.add("diasdk")

View File

@ -1,3 +1,5 @@
; REQUIRES: diasdk
; RUN: llvm-pdbutil pretty -externals %p/Inputs/LoadAddressTest.pdb \
; RUN: | FileCheck --check-prefix=RVA %s
; RUN: llvm-pdbutil pretty -externals -load-address=0x40000000 \

View File

@ -1,3 +1,5 @@
; REQUIRES: diasdk
; RUN: llvm-pdbutil pretty -all -class-recurse-depth=1 \
; RUN: %p/Inputs/PrettyFuncDumperTest.pdb > %t
; RUN: FileCheck -input-file=%t %s -check-prefix=GLOBALS_FUNC

View File

@ -1,3 +1,5 @@
; REQUIRES: diasdk
; RUN: llvm-pdbutil pretty -module-syms -globals -types %p/Inputs/FilterTest.pdb \
; RUN: | FileCheck --check-prefix=NO_FILTER %s

View File

@ -1,3 +1,5 @@
; REQUIRES: diasdk
; RUN: llvm-pdbutil pretty -classes -class-definitions=layout \
; RUN: -include-types=SimplePad %p/Inputs/SimplePaddingTest.pdb > %t

View File

@ -0,0 +1,109 @@
; RUN: llvm-pdbutil dump -all %p/Inputs/Stripped.pdb > %t
; RUN: FileCheck -input-file=%t %s
; CHECK: Summary
; CHECK-NEXT: ============================================================
; CHECK-NEXT: Block Size: 4096
; CHECK-NEXT: Number of blocks: 17
; CHECK-NEXT: Number of streams: 12
; CHECK-NEXT: Signature: 1541179274
; CHECK-NEXT: Age: 2
; CHECK-NEXT: GUID: {FF4F9B62-D99A-4647-97A7-22C702B1E053}
; CHECK-NEXT: Features: 0x1
; CHECK-NEXT: Has Debug Info: true
; CHECK-NEXT: Has Types: true
; CHECK-NEXT: Has IDs: true
; CHECK-NEXT: Has Globals: true
; CHECK-NEXT: Has Publics: true
; CHECK-NEXT: Is incrementally linked: false
; CHECK-NEXT: Has conflicting types: false
; CHECK-NEXT: Is stripped: true
; CHECK: Streams
; CHECK-NEXT: ============================================================
; CHECK-NEXT: Stream 0 ( 88 bytes): [Old MSF Directory]
; CHECK-NEXT: Blocks: [4]
; CHECK-NEXT: Stream 1 ( 78 bytes): [PDB Stream]
; CHECK-NEXT: Blocks: [14]
; CHECK-NEXT: Stream 2 ( 56 bytes): [TPI Stream]
; CHECK-NEXT: Blocks: [13]
; CHECK-NEXT: Stream 3 (1355 bytes): [DBI Stream]
; CHECK-NEXT: Blocks: [7]
; CHECK-NEXT: Stream 4 ( 56 bytes): [IPI Stream]
; CHECK-NEXT: Blocks: [6]
; CHECK-NEXT: Stream 5 ( 0 bytes): [Named Stream "/LinkInfo"]
; CHECK-NEXT: Blocks: []
; CHECK-NEXT: Stream 6 ( 200 bytes): [Section Header Data]
; CHECK-NEXT: Blocks: [8]
; CHECK-NEXT: Stream 7 ( 16 bytes): [Global Symbol Hash]
; CHECK-NEXT: Blocks: [9]
; CHECK-NEXT: Stream 8 ( 928 bytes): [Public Symbol Hash]
; CHECK-NEXT: Blocks: [11]
; CHECK-NEXT: Stream 9 ( 716 bytes): [Symbol Records]
; CHECK-NEXT: Blocks: [10]
; CHECK-NEXT: Stream 10 ( 0 bytes): [TPI Hash]
; CHECK-NEXT: Blocks: []
; CHECK-NEXT: Stream 11 ( 0 bytes): [IPI Hash]
; CHECK-NEXT: Blocks: []
; CHECK: Module Stats
; CHECK-NEXT: ============================================================
; CHECK: S_UDT Record Stats
; CHECK-NEXT: ============================================================
; CHECK: String Table
; CHECK-NEXT: ============================================================
; CHECK: Modules
; CHECK-NEXT: ============================================================
; CHECK: Files
; CHECK-NEXT: ============================================================
; CHECK: Lines
; CHECK-NEXT: ============================================================
; CHECK: Inlinee Lines
; CHECK-NEXT: ============================================================
; CHECK: Cross Module Imports
; CHECK-NEXT: ============================================================
; CHECK: Cross Module Exports
; CHECK-NEXT: ============================================================
; CHECK: Old FPO Data
; CHECK-NEXT: ============================================================
; CHECK: New FPO Data
; CHECK-NEXT: ============================================================
; CHECK: Types (TPI Stream)
; CHECK-NEXT: ============================================================
; CHECK: Types (IPI Stream)
; CHECK-NEXT: ============================================================
; CHECK: Global Symbols
; CHECK-NEXT: ============================================================
; CHECK: Public Symbols
; CHECK-NEXT: ============================================================
; CHECK: Symbols
; CHECK-NEXT: ============================================================
; CHECK: Section Headers
; CHECK-NEXT: ============================================================
; CHECK: Original Section Headers
; CHECK-NEXT: ============================================================
; CHECK: Section Contributions
; CHECK-NEXT: ============================================================
; CHECK: Section Map
; CHECK-NEXT: ============================================================

View File

@ -1,3 +1,5 @@
; REQUIRES: diasdk
; RUN: llvm-pdbutil pretty -globals -module-syms -sym-types=data %p/Inputs/FilterTest.pdb \
; RUN: | FileCheck --check-prefix=ONLY_DATA %s

View File

@ -1,3 +1,5 @@
; REQUIRES: diasdk
; RUN: llvm-pdbutil pretty -all -class-recurse-depth=1 \
; RUN: %p/Inputs/TypeQualifiersTest.pdb > %t
; RUN: FileCheck -input-file=%t %s -check-prefix=GLOBALS_FUNC

View File

@ -1,3 +1,5 @@
; REQUIRES: diasdk
; RUN: llvm-pdbutil pretty -module-syms %p/Inputs/UsingNamespaceTest.pdb > %t
; RUN: FileCheck -input-file=%t %s

View File

@ -250,7 +250,7 @@ Error DumpOutputStyle::dumpFileSummary() {
static StatCollection getSymbolStats(const SymbolGroup &SG,
StatCollection &CumulativeStats) {
StatCollection Stats;
if (SG.getFile().isPdb()) {
if (SG.getFile().isPdb() && SG.hasDebugStream()) {
// For PDB files, all symbols are packed into one stream.
for (const auto &S : SG.getPdbModuleStream().symbols(nullptr)) {
Stats.update(S.kind(), S.length());
@ -1420,19 +1420,21 @@ Error DumpOutputStyle::dumpTpiStream(uint32_t StreamIdx) {
P.formatLine("TI: {0}, Offset: {1}", IO.Type, fmtle(IO.Offset));
}
P.NewLine();
P.formatLine("Hash Adjusters:");
auto &Adjusters = Stream.getHashAdjusters();
auto &Strings = Err(getPdb().getStringTable());
for (const auto &A : Adjusters) {
AutoIndent Indent2(P);
auto ExpectedStr = Strings.getStringForID(A.first);
TypeIndex TI(A.second);
if (ExpectedStr)
P.formatLine("`{0}` -> {1}", *ExpectedStr, TI);
else {
P.formatLine("unknown str id ({0}) -> {1}", A.first, TI);
consumeError(ExpectedStr.takeError());
if (getPdb().hasPDBStringTable()) {
P.NewLine();
P.formatLine("Hash Adjusters:");
auto &Adjusters = Stream.getHashAdjusters();
auto &Strings = Err(getPdb().getStringTable());
for (const auto &A : Adjusters) {
AutoIndent Indent2(P);
auto ExpectedStr = Strings.getStringForID(A.first);
TypeIndex TI(A.second);
if (ExpectedStr)
P.formatLine("`{0}` -> {1}", *ExpectedStr, TI);
else {
P.formatLine("unknown str id ({0}) -> {1}", A.first, TI);
consumeError(ExpectedStr.takeError());
}
}
}
}

View File

@ -116,10 +116,6 @@ static std::string formatChecksumKind(FileChecksumKind Kind) {
return formatUnknownEnum(Kind);
}
static const DebugStringTableSubsectionRef &extractStringTable(PDBFile &File) {
return cantFail(File.getStringTable()).getStringTable();
}
template <typename... Args>
static void formatInternal(LinePrinter &Printer, bool Append, Args &&... args) {
if (Append)
@ -168,8 +164,13 @@ void SymbolGroup::initializeForPdb(uint32_t Modi) {
// PDB always uses the same string table, but each module has its own
// checksums. So we only set the strings if they're not already set.
if (!SC.hasStrings())
SC.setStrings(extractStringTable(File->pdb()));
if (!SC.hasStrings()) {
auto StringTable = File->pdb().getStringTable();
if (StringTable)
SC.setStrings(StringTable->getStringTable());
else
consumeError(StringTable.takeError());
}
SC.resetChecksums();
auto MDS = getModuleDebugStream(File->pdb(), Name, Modi);

View File

@ -110,6 +110,8 @@ public:
const InputFile &getFile() const { return *File; }
InputFile &getFile() { return *File; }
bool hasDebugStream() const { return DebugStream != nullptr; }
private:
void initializeForPdb(uint32_t Modi);
void updatePdbModi(uint32_t Modi);