llvm.org GIT mirror llvm / 437cbaf
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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@346010 91177308-0d34-0410-b5e6-96231b3b80d8 Leonard Mosescu 9 months ago
21 changed file(s) with 165 addition(s) and 21 deletion(s). Raw diff Collapse all Expand all
0 ; REQUIRES: diasdk
1 ; RUN: llvm-pdbutil pretty -lines %p/Inputs/PrettyFuncDumperTest.pdb > %t
12
23 ; CHECK: ---COMPILANDS---
0 ; REQUIRES: diasdk
1
2 ; RUN: llvm-pdbutil pretty -all -class-recurse-depth=1 \
13 ; RUN: %p/Inputs/ClassLayoutTest.pdb > %t
24 ; RUN: FileCheck -input-file=%t %s -check-prefix=GLOBALS_TEST
0 ; REQUIRES: diasdk
1
2 ; RUN: llvm-pdbutil pretty -classes -class-definitions=layout \
13 ; RUN: -include-types=Test %p/Inputs/ComplexPaddingTest.pdb > %t
24
0 ; REQUIRES: diasdk
1
2 ; RUN: llvm-pdbutil pretty -types %p/Inputs/ClassLayoutTest.pdb > %t
13 ; RUN: FileCheck -input-file=%t %s -check-prefix=GLOBAL_ENUM
24 ; RUN: FileCheck -input-file=%t %s -check-prefix=MEMBER_ENUM
0 ; REQUIRES: diasdk
1
2 ; RUN: llvm-pdbutil explain \
13 ; RUN: -offset=0xF000 \
24 ; RUN: -offset=0xF004 \
0 ; REQUIRES: diasdk
1
2 ; RUN: llvm-pdbutil explain \
13 ; RUN: -offset=0x11000 \
24 ; RUN: -offset=0x11004 \
0 ; REQUIRES: diasdk
1
2 ; RUN: llvm-pdbutil explain -offset=0 %p/Inputs/InjectedSource.pdb \
13 ; RUN: | FileCheck --check-prefix=ZERO %s
24 ; RUN: llvm-pdbutil explain -offset=40 %p/Inputs/InjectedSource.pdb \
0 ; The PDB committed to the repo does not seem to be recognized by older
11 ; versions of DIA SDK, so we xfail the test temporarily until we can
22 ; figure out how to get a PDB that makes all versions of MSVC happy.
3 ; REQUIRES: diasdk
4
35 ; RUN: llvm-pdbutil pretty -injected-sources -injected-source-content \
46 ; RUN: %p/Inputs/InjectedSource.pdb | FileCheck %s
57 ; RUN: llvm-pdbutil pretty -injected-sources -injected-source-content \
None config.unsupported = not config.have_dia_sdk
0 if config.have_dia_sdk:
1 config.available_features.add("diasdk")
0 ; REQUIRES: diasdk
1
2 ; RUN: llvm-pdbutil pretty -externals %p/Inputs/LoadAddressTest.pdb \
13 ; RUN: | FileCheck --check-prefix=RVA %s
24 ; RUN: llvm-pdbutil pretty -externals -load-address=0x40000000 \
0 ; REQUIRES: diasdk
1
2 ; RUN: llvm-pdbutil pretty -all -class-recurse-depth=1 \
13 ; RUN: %p/Inputs/PrettyFuncDumperTest.pdb > %t
24 ; RUN: FileCheck -input-file=%t %s -check-prefix=GLOBALS_FUNC
0 ; REQUIRES: diasdk
1
2 ; RUN: llvm-pdbutil pretty -module-syms -globals -types %p/Inputs/FilterTest.pdb \
13 ; RUN: | FileCheck --check-prefix=NO_FILTER %s
24
0 ; REQUIRES: diasdk
1
2 ; RUN: llvm-pdbutil pretty -classes -class-definitions=layout \
13 ; RUN: -include-types=SimplePad %p/Inputs/SimplePaddingTest.pdb > %t
24
0 ; RUN: llvm-pdbutil dump -all %p/Inputs/Stripped.pdb > %t
1 ; RUN: FileCheck -input-file=%t %s
2
3 ; CHECK: Summary
4 ; CHECK-NEXT: ============================================================
5 ; CHECK-NEXT: Block Size: 4096
6 ; CHECK-NEXT: Number of blocks: 17
7 ; CHECK-NEXT: Number of streams: 12
8 ; CHECK-NEXT: Signature: 1541179274
9 ; CHECK-NEXT: Age: 2
10 ; CHECK-NEXT: GUID: {FF4F9B62-D99A-4647-97A7-22C702B1E053}
11 ; CHECK-NEXT: Features: 0x1
12 ; CHECK-NEXT: Has Debug Info: true
13 ; CHECK-NEXT: Has Types: true
14 ; CHECK-NEXT: Has IDs: true
15 ; CHECK-NEXT: Has Globals: true
16 ; CHECK-NEXT: Has Publics: true
17 ; CHECK-NEXT: Is incrementally linked: false
18 ; CHECK-NEXT: Has conflicting types: false
19 ; CHECK-NEXT: Is stripped: true
20
21 ; CHECK: Streams
22 ; CHECK-NEXT: ============================================================
23 ; CHECK-NEXT: Stream 0 ( 88 bytes): [Old MSF Directory]
24 ; CHECK-NEXT: Blocks: [4]
25 ; CHECK-NEXT: Stream 1 ( 78 bytes): [PDB Stream]
26 ; CHECK-NEXT: Blocks: [14]
27 ; CHECK-NEXT: Stream 2 ( 56 bytes): [TPI Stream]
28 ; CHECK-NEXT: Blocks: [13]
29 ; CHECK-NEXT: Stream 3 (1355 bytes): [DBI Stream]
30 ; CHECK-NEXT: Blocks: [7]
31 ; CHECK-NEXT: Stream 4 ( 56 bytes): [IPI Stream]
32 ; CHECK-NEXT: Blocks: [6]
33 ; CHECK-NEXT: Stream 5 ( 0 bytes): [Named Stream "/LinkInfo"]
34 ; CHECK-NEXT: Blocks: []
35 ; CHECK-NEXT: Stream 6 ( 200 bytes): [Section Header Data]
36 ; CHECK-NEXT: Blocks: [8]
37 ; CHECK-NEXT: Stream 7 ( 16 bytes): [Global Symbol Hash]
38 ; CHECK-NEXT: Blocks: [9]
39 ; CHECK-NEXT: Stream 8 ( 928 bytes): [Public Symbol Hash]
40 ; CHECK-NEXT: Blocks: [11]
41 ; CHECK-NEXT: Stream 9 ( 716 bytes): [Symbol Records]
42 ; CHECK-NEXT: Blocks: [10]
43 ; CHECK-NEXT: Stream 10 ( 0 bytes): [TPI Hash]
44 ; CHECK-NEXT: Blocks: []
45 ; CHECK-NEXT: Stream 11 ( 0 bytes): [IPI Hash]
46 ; CHECK-NEXT: Blocks: []
47
48 ; CHECK: Module Stats
49 ; CHECK-NEXT: ============================================================
50
51 ; CHECK: S_UDT Record Stats
52 ; CHECK-NEXT: ============================================================
53
54 ; CHECK: String Table
55 ; CHECK-NEXT: ============================================================
56
57 ; CHECK: Modules
58 ; CHECK-NEXT: ============================================================
59
60 ; CHECK: Files
61 ; CHECK-NEXT: ============================================================
62
63 ; CHECK: Lines
64 ; CHECK-NEXT: ============================================================
65
66 ; CHECK: Inlinee Lines
67 ; CHECK-NEXT: ============================================================
68
69 ; CHECK: Cross Module Imports
70 ; CHECK-NEXT: ============================================================
71
72 ; CHECK: Cross Module Exports
73 ; CHECK-NEXT: ============================================================
74
75 ; CHECK: Old FPO Data
76 ; CHECK-NEXT: ============================================================
77
78 ; CHECK: New FPO Data
79 ; CHECK-NEXT: ============================================================
80
81 ; CHECK: Types (TPI Stream)
82 ; CHECK-NEXT: ============================================================
83
84 ; CHECK: Types (IPI Stream)
85 ; CHECK-NEXT: ============================================================
86
87 ; CHECK: Global Symbols
88 ; CHECK-NEXT: ============================================================
89
90 ; CHECK: Public Symbols
91 ; CHECK-NEXT: ============================================================
92
93 ; CHECK: Symbols
94 ; CHECK-NEXT: ============================================================
95
96 ; CHECK: Section Headers
97 ; CHECK-NEXT: ============================================================
98
99 ; CHECK: Original Section Headers
100 ; CHECK-NEXT: ============================================================
101
102 ; CHECK: Section Contributions
103 ; CHECK-NEXT: ============================================================
104
105 ; CHECK: Section Map
106 ; CHECK-NEXT: ============================================================
107
108
0 ; REQUIRES: diasdk
1
2 ; RUN: llvm-pdbutil pretty -globals -module-syms -sym-types=data %p/Inputs/FilterTest.pdb \
13 ; RUN: | FileCheck --check-prefix=ONLY_DATA %s
24
0 ; REQUIRES: diasdk
1
2 ; RUN: llvm-pdbutil pretty -all -class-recurse-depth=1 \
13 ; RUN: %p/Inputs/TypeQualifiersTest.pdb > %t
24 ; RUN: FileCheck -input-file=%t %s -check-prefix=GLOBALS_FUNC
0 ; REQUIRES: diasdk
1
2 ; RUN: llvm-pdbutil pretty -module-syms %p/Inputs/UsingNamespaceTest.pdb > %t
13 ; RUN: FileCheck -input-file=%t %s
24
249249 static StatCollection getSymbolStats(const SymbolGroup &SG,
250250 StatCollection &CumulativeStats) {
251251 StatCollection Stats;
252 if (SG.getFile().isPdb()) {
252 if (SG.getFile().isPdb() && SG.hasDebugStream()) {
253253 // For PDB files, all symbols are packed into one stream.
254254 for (const auto &S : SG.getPdbModuleStream().symbols(nullptr)) {
255255 Stats.update(S.kind(), S.length());
14191419 P.formatLine("TI: {0}, Offset: {1}", IO.Type, fmtle(IO.Offset));
14201420 }
14211421
1422 P.NewLine();
1423 P.formatLine("Hash Adjusters:");
1424 auto &Adjusters = Stream.getHashAdjusters();
1425 auto &Strings = Err(getPdb().getStringTable());
1426 for (const auto &A : Adjusters) {
1427 AutoIndent Indent2(P);
1428 auto ExpectedStr = Strings.getStringForID(A.first);
1429 TypeIndex TI(A.second);
1430 if (ExpectedStr)
1431 P.formatLine("`{0}` -> {1}", *ExpectedStr, TI);
1432 else {
1433 P.formatLine("unknown str id ({0}) -> {1}", A.first, TI);
1434 consumeError(ExpectedStr.takeError());
1422 if (getPdb().hasPDBStringTable()) {
1423 P.NewLine();
1424 P.formatLine("Hash Adjusters:");
1425 auto &Adjusters = Stream.getHashAdjusters();
1426 auto &Strings = Err(getPdb().getStringTable());
1427 for (const auto &A : Adjusters) {
1428 AutoIndent Indent2(P);
1429 auto ExpectedStr = Strings.getStringForID(A.first);
1430 TypeIndex TI(A.second);
1431 if (ExpectedStr)
1432 P.formatLine("`{0}` -> {1}", *ExpectedStr, TI);
1433 else {
1434 P.formatLine("unknown str id ({0}) -> {1}", A.first, TI);
1435 consumeError(ExpectedStr.takeError());
1436 }
14351437 }
14361438 }
14371439 }
115115 return formatUnknownEnum(Kind);
116116 }
117117
118 static const DebugStringTableSubsectionRef &extractStringTable(PDBFile &File) {
119 return cantFail(File.getStringTable()).getStringTable();
120 }
121
122118 template
123119 static void formatInternal(LinePrinter &Printer, bool Append, Args &&... args) {
124120 if (Append)
167163
168164 // PDB always uses the same string table, but each module has its own
169165 // checksums. So we only set the strings if they're not already set.
170 if (!SC.hasStrings())
171 SC.setStrings(extractStringTable(File->pdb()));
166 if (!SC.hasStrings()) {
167 auto StringTable = File->pdb().getStringTable();
168 if (StringTable)
169 SC.setStrings(StringTable->getStringTable());
170 else
171 consumeError(StringTable.takeError());
172 }
172173
173174 SC.resetChecksums();
174175 auto MDS = getModuleDebugStream(File->pdb(), Name, Modi);
109109 const InputFile &getFile() const { return *File; }
110110 InputFile &getFile() { return *File; }
111111
112 bool hasDebugStream() const { return DebugStream != nullptr; }
113
112114 private:
113115 void initializeForPdb(uint32_t Modi);
114116 void updatePdbModi(uint32_t Modi);