1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 02:52:53 +02:00

[llvm-pdbdump] Improve consistency among subcommands.

The pdb2yaml and raw subcommands did something very
similar but with a different output format, and they
used a lot of the same command line options, but each
one re-implemented the command line option with slightly
different spellings / options.  This patch merges them
together into a single definition which is shared by
both subcommands.  This new syntax also allows for more
flexibility in the way debug subsections are dumped.

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

llvm-svn: 305032
This commit is contained in:
Zachary Turner 2017-06-08 23:39:33 +00:00
parent c45fbaf4f0
commit e0fa44a72e
16 changed files with 362 additions and 341 deletions

View File

@ -1,24 +0,0 @@
DbiStream:
Modules:
- Module: 'Foo.obj'
ObjFile: 'Foo.obj'
Subsections:
- !CrossModuleExports
Exports:
- LocalId: 4852
GlobalId: 9283
- LocalId: 2147487875
GlobalId: 9123
- Module: 'Bar.obj'
ObjFile: 'Bar.obj'
Subsections:
- !CrossModuleExports
Exports:
- LocalId: 4265
GlobalId: 6097
- LocalId: 4297
GlobalId: 4677
- !CrossModuleImports
Imports:
- Module: 'Foo.obj'
Imports: [ 4852, 2147487875 ]

View File

@ -1,6 +1,27 @@
---
DbiStream:
Modules:
DbiStream:
Modules:
- Module: 'Foo.obj'
ObjFile: 'Foo.obj'
Subsections:
- !CrossModuleExports
Exports:
- LocalId: 4852
GlobalId: 9283
- LocalId: 2147487875
GlobalId: 9123
- Module: 'Bar.obj'
ObjFile: 'Bar.obj'
Subsections:
- !CrossModuleExports
Exports:
- LocalId: 4265
GlobalId: 6097
- LocalId: 4297
GlobalId: 4677
- !CrossModuleImports
Imports:
- Module: 'Foo.obj'
Imports: [ 4852, 2147487875 ]
- Module: 'd:\src\llvm\test\DebugInfo\PDB\Inputs\empty.obj'
ObjFile: 'd:\src\llvm\test\DebugInfo\PDB\Inputs\empty.obj'
SourceFiles:
@ -41,4 +62,3 @@ DbiStream:
- FileName: 'f:\dd\externalapis\windows\10\sdk\inc\winerror.h'
LineNum: 26950
Inlinee: 22767
...

View File

@ -1,60 +0,0 @@
; RUN: llvm-pdbdump yaml2pdb -pdb=%t.pdb %p/Inputs/cross-module-import-export.yaml
; RUN: llvm-pdbdump pdb2yaml -all -no-file-headers %t.pdb | FileCheck --check-prefix=YAML %s
; RUN: llvm-pdbdump raw -all %t.pdb | FileCheck --check-prefix=RAW %s
YAML: Modules:
YAML-NEXT: - Module: Foo.obj
YAML-NEXT: ObjFile: Foo.obj
YAML-NEXT: Subsections:
YAML-NEXT: - !CrossModuleExports
YAML-NEXT: Exports:
YAML-NEXT: - LocalId: 4852
YAML-NEXT: GlobalId: 9283
YAML-NEXT: - LocalId: 2147487875
YAML-NEXT: GlobalId: 9123
YAML: - Module: Bar.obj
YAML-NEXT: ObjFile: Bar.obj
YAML-NEXT: Subsections:
YAML-NEXT: - !CrossModuleExports
YAML-NEXT: Exports:
YAML-NEXT: - LocalId: 4265
YAML-NEXT: GlobalId: 6097
YAML-NEXT: - LocalId: 4297
YAML-NEXT: GlobalId: 4677
YAML-NEXT: - !CrossModuleImports
YAML-NEXT: Imports:
YAML-NEXT: - Module: Foo.obj
YAML-NEXT: Imports: [ 4852, 2147487875 ]
RAW: DBI Stream {
RAW: Modules [
RAW-NEXT: {
RAW-NEXT: Name: Foo.obj
RAW: LineInfo [
RAW-NEXT: CrossModuleExports {
RAW-NEXT: Local: 0x12F4
RAW-NEXT: Global: 0x2443
RAW-NEXT: Local: 0x80001083
RAW-NEXT: Global: 0x23A3
RAW-NEXT: }
RAW-NEXT: ]
RAW-NEXT: }
RAW-NEXT: {
RAW-NEXT: Name: Bar.obj
RAW: LineInfo [
RAW-NEXT: CrossModuleExports {
RAW-NEXT: Local: 0x10A9
RAW-NEXT: Global: 0x17D1
RAW-NEXT: Local: 0x10C9
RAW-NEXT: Global: 0x1245
RAW-NEXT: }
RAW-NEXT: CrossModuleImports {
RAW-NEXT: Module: Foo.obj
RAW-NEXT: Imports: [0x12F4, 0x80001083]
RAW-NEXT: }
RAW-NEXT: ]
RAW-NEXT: }
RAW-NEXT: ]
RAW-NEXT: }

View File

@ -1,11 +1,11 @@
; This testcase verifies that we can produce a minimal PDB, while
; serving as an example for how to construct a minimal PDB for other
; testcases. It takes as input a small fragment of hand-written yaml
; that specifies nothing about the PDB other than a definition of one
; symbol that it contains. Then it produces a PDB, and uses the
; resulting PDB to go back to yaml, and verify that the resulting yaml
; is identical.
; RUN: llvm-pdbdump yaml2pdb -pdb=%t.pdb %p/Inputs/one-symbol.yaml
; RUN: llvm-pdbdump pdb2yaml -minimal -dbi-module-syms -no-file-headers %t.pdb > %t.pdb.yaml
; RUN: diff -b %p/Inputs/one-symbol.yaml %t.pdb.yaml
; This testcase verifies that we can produce a minimal PDB, while
; serving as an example for how to construct a minimal PDB for other
; testcases. It takes as input a small fragment of hand-written yaml
; that specifies nothing about the PDB other than a definition of one
; symbol that it contains. Then it produces a PDB, and uses the
; resulting PDB to go back to yaml, and verify that the resulting yaml
; is identical.
; RUN: llvm-pdbdump yaml2pdb -pdb=%t.pdb %p/Inputs/one-symbol.yaml
; RUN: llvm-pdbdump pdb2yaml -minimal -module-syms -no-file-headers %t.pdb > %t.pdb.yaml
; RUN: diff -b %p/Inputs/one-symbol.yaml %t.pdb.yaml

View File

@ -1,4 +1,4 @@
; RUN: llvm-pdbdump pdb2yaml -dbi-module-syms %p/Inputs/empty.pdb \
; RUN: llvm-pdbdump pdb2yaml -module-syms %p/Inputs/empty.pdb \
; RUN: | FileCheck -check-prefix=YAML %s

View File

@ -0,0 +1,162 @@
; RUN: llvm-pdbdump yaml2pdb -pdb=%t.pdb %p/Inputs/debug-subsections.yaml
; RUN: llvm-pdbdump pdb2yaml -all -no-file-headers %t.pdb | FileCheck --check-prefix=YAML %s
; RUN: llvm-pdbdump raw -subsections=all %t.pdb | FileCheck --check-prefix=RAW %s
YAML: Modules:
YAML-NEXT: - Module: Foo.obj
YAML-NEXT: ObjFile: Foo.obj
YAML-NEXT: Subsections:
YAML-NEXT: - !CrossModuleExports
YAML-NEXT: Exports:
YAML-NEXT: - LocalId: 4852
YAML-NEXT: GlobalId: 9283
YAML-NEXT: - LocalId: 2147487875
YAML-NEXT: GlobalId: 9123
YAML: - Module: Bar.obj
YAML-NEXT: ObjFile: Bar.obj
YAML-NEXT: Subsections:
YAML-NEXT: - !CrossModuleExports
YAML-NEXT: Exports:
YAML-NEXT: - LocalId: 4265
YAML-NEXT: GlobalId: 6097
YAML-NEXT: - LocalId: 4297
YAML-NEXT: GlobalId: 4677
YAML-NEXT: - !CrossModuleImports
YAML-NEXT: Imports:
YAML-NEXT: - Module: Foo.obj
YAML-NEXT: Imports: [ 4852, 2147487875 ]
YAML: - Module: 'd:\src\llvm\test\DebugInfo\PDB\Inputs\empty.obj'
YAML-NEXT: ObjFile: 'd:\src\llvm\test\DebugInfo\PDB\Inputs\empty.obj'
YAML-NEXT: SourceFiles:
YAML-NEXT: - 'd:\src\llvm\test\debuginfo\pdb\inputs\empty.cpp'
YAML-NEXT: Subsections:
YAML-NEXT: - !FileChecksums
YAML-NEXT: Checksums:
YAML-NEXT: - FileName: 'd:\src\llvm\test\debuginfo\pdb\inputs\empty.cpp'
YAML-NEXT: Kind: MD5
YAML-NEXT: Checksum: A0A5BD0D3ECD93FC29D19DE826FBF4BC
YAML-NEXT: - FileName: 'f:\dd\externalapis\windows\10\sdk\inc\winerror.h'
YAML-NEXT: Kind: MD5
YAML-NEXT: Checksum: 1154D69F5B2650196E1FC34F4134E56B
YAML-NEXT: - !Lines
YAML-NEXT: CodeSize: 10
YAML-NEXT: Flags: [ ]
YAML-NEXT: RelocOffset: 16
YAML-NEXT: RelocSegment: 1
YAML-NEXT: Blocks:
YAML-NEXT: - FileName: 'd:\src\llvm\test\debuginfo\pdb\inputs\empty.cpp'
YAML-NEXT: Lines:
YAML-NEXT: - Offset: 0
YAML-NEXT: LineStart: 5
YAML-NEXT: IsStatement: true
YAML-NEXT: EndDelta: 0
YAML-NEXT: - Offset: 3
YAML-NEXT: LineStart: 6
YAML-NEXT: IsStatement: true
YAML-NEXT: EndDelta: 0
YAML-NEXT: - Offset: 8
YAML-NEXT: LineStart: 7
YAML-NEXT: IsStatement: true
YAML-NEXT: EndDelta: 0
YAML-NEXT: Columns:
YAML-NEXT: - !InlineeLines
YAML-NEXT: HasExtraFiles: false
YAML-NEXT: Sites:
YAML-NEXT: - FileName: 'f:\dd\externalapis\windows\10\sdk\inc\winerror.h'
YAML-NEXT: LineNum: 26950
YAML-NEXT: Inlinee: 22767
RAW: DBI Stream {
RAW: Modules [
RAW-NEXT: {
RAW-NEXT: Name: Foo.obj
RAW: Subsections [
RAW-NEXT: CrossModuleExports {
RAW-NEXT: Local: 0x12F4
RAW-NEXT: Global: 0x2443
RAW-NEXT: Local: 0x80001083
RAW-NEXT: Global: 0x23A3
RAW-NEXT: }
RAW-NEXT: ]
RAW-NEXT: }
RAW-NEXT: {
RAW-NEXT: Name: Bar.obj
RAW: Subsections [
RAW-NEXT: CrossModuleExports {
RAW-NEXT: Local: 0x10A9
RAW-NEXT: Global: 0x17D1
RAW-NEXT: Local: 0x10C9
RAW-NEXT: Global: 0x1245
RAW-NEXT: }
RAW-NEXT: CrossModuleImports {
RAW-NEXT: Module: Foo.obj
RAW-NEXT: Imports: [0x12F4, 0x80001083]
RAW-NEXT: }
RAW-NEXT: ]
RAW-NEXT: }
RAW-NEXT: {
RAW-NEXT: Name: d:\src\llvm\test\DebugInfo\PDB\Inputs\empty.obj
RAW: Subsections [
RAW-NEXT: FileChecksums {
RAW-NEXT: Checksum {
RAW-NEXT: FileName: d:\src\llvm\test\debuginfo\pdb\inputs\empty.cpp
RAW-NEXT: Kind: MD5 (0x1)
RAW-NEXT: Checksum (
RAW-NEXT: 0000: A0A5BD0D 3ECD93FC 29D19DE8 26FBF4BC |....>...)...&...|
RAW-NEXT: )
RAW-NEXT: }
RAW-NEXT: Checksum {
RAW-NEXT: FileName: f:\dd\externalapis\windows\10\sdk\inc\winerror.h
RAW-NEXT: Kind: MD5 (0x1)
RAW-NEXT: Checksum (
RAW-NEXT: 0000: 1154D69F 5B265019 6E1FC34F 4134E56B |.T..[&P.n..OA4.k|
RAW-NEXT: )
RAW-NEXT: }
RAW-NEXT: }
RAW-NEXT: Lines {
RAW-NEXT: Block {
RAW-NEXT: RelocSegment: 1
RAW-NEXT: RelocOffset: 16
RAW-NEXT: CodeSize: 10
RAW-NEXT: HasColumns: No
RAW-NEXT: Lines {
RAW-NEXT: FileName: d:\src\llvm\test\debuginfo\pdb\inputs\empty.cpp
RAW-NEXT: Line {
RAW-NEXT: Offset: 0
RAW-NEXT: LineNumberStart: 5
RAW-NEXT: EndDelta: 0
RAW-NEXT: IsStatement: Yes
RAW-NEXT: }
RAW-NEXT: Line {
RAW-NEXT: Offset: 3
RAW-NEXT: LineNumberStart: 6
RAW-NEXT: EndDelta: 0
RAW-NEXT: IsStatement: Yes
RAW-NEXT: }
RAW-NEXT: Line {
RAW-NEXT: Offset: 8
RAW-NEXT: LineNumberStart: 7
RAW-NEXT: EndDelta: 0
RAW-NEXT: IsStatement: Yes
RAW-NEXT: }
RAW-NEXT: }
RAW-NEXT: }
RAW-NEXT: }
RAW-NEXT: InlineeLines {
RAW-NEXT: HasExtraFiles: No
RAW-NEXT: Lines [
RAW-NEXT: Inlinee {
RAW-NEXT: FileName: f:\dd\externalapis\windows\10\sdk\inc\winerror.h
RAW-NEXT: Function {
RAW-NEXT: Index: 0x58ef (unknown function)
RAW-NEXT: }
RAW-NEXT: SourceLine: 26950
RAW-NEXT: }
RAW-NEXT: ]
RAW-NEXT: }
RAW-NEXT: ]
RAW-NEXT: }
RAW-NEXT: ]
RAW-NEXT:}

View File

@ -1,7 +1,7 @@
; RUN: llvm-pdbdump raw -headers -string-table -tpi-records -tpi-record-bytes -module-syms \
; RUN: -sym-record-bytes -globals -publics -module-files \
; RUN: -stream-summary -stream-blocks -ipi-records -ipi-record-bytes \
; RUN: -section-contribs -section-map -section-headers -line-info \
; RUN: -section-contribs -section-map -section-headers -subsections=all \
; RUN: -tpi-hash -fpo -page-stats %p/Inputs/empty.pdb | FileCheck -check-prefix=EMPTY %s
; RUN: llvm-pdbdump raw -all %p/Inputs/empty.pdb | FileCheck -check-prefix=ALL %s
; RUN: llvm-pdbdump raw -headers -modules -module-files \
@ -484,7 +484,7 @@
; EMPTY-NEXT: )
; EMPTY-NEXT: }
; EMPTY-NEXT: ]
; EMPTY-NEXT: LineInfo [
; EMPTY-NEXT: Subsections [
; EMPTY-NEXT: FileChecksums {
; EMPTY-NEXT: Checksum {
; EMPTY-NEXT: FileName: d:\src\llvm\test\debuginfo\pdb\inputs\empty.cpp
@ -757,7 +757,7 @@
; EMPTY-NEXT: )
; EMPTY-NEXT: }
; EMPTY-NEXT: ]
; EMPTY-NEXT: LineInfo [
; EMPTY-NEXT: Subsections [
; EMPTY-NEXT: ]
; EMPTY-NEXT: }
; EMPTY-NEXT: ]

View File

@ -1,5 +1,5 @@
RUN: llvm-pdbdump pdb2yaml -dbi-module-info -dbi-module-source-info \
RUN: -dbi-stream -pdb-stream -string-table -tpi-stream -stream-directory \
RUN: llvm-pdbdump pdb2yaml -modules -module-files -dbi-stream \
RUN: -pdb-stream -string-table -tpi-stream -stream-directory \
RUN: -stream-metadata %p/Inputs/empty.pdb > %t.1
RUN: llvm-pdbdump yaml2pdb -pdb=%t.2 %t.1

View File

@ -7,10 +7,10 @@
# pass if alignment is implemented correctly.
RUN: llvm-pdbdump yaml2pdb -pdb=%T/source-names-1.pdb %p/Inputs/source-names-1.yaml
RUN: llvm-pdbdump pdb2yaml -dbi-module-source-info %T/source-names-1.pdb \
RUN: llvm-pdbdump pdb2yaml -module-files %T/source-names-1.pdb \
RUN: | FileCheck -check-prefix=CHECK1 %s
RUN: llvm-pdbdump yaml2pdb -pdb=%T/source-names-2.pdb %p/Inputs/source-names-2.yaml
RUN: llvm-pdbdump pdb2yaml -dbi-module-source-info %T/source-names-2.pdb \
RUN: llvm-pdbdump pdb2yaml -module-files %T/source-names-2.pdb \
RUN: | FileCheck -check-prefix=CHECK2 %s
CHECK1: SourceFiles:

View File

@ -11,10 +11,10 @@
; (for example if we don't write the entire stream)
;
; RUN: llvm-pdbdump pdb2yaml -stream-metadata -stream-directory \
; RUN: -pdb-stream -tpi-stream -dbi-module-syms %p/Inputs/empty.pdb > %t.1
; RUN: -pdb-stream -tpi-stream -module-syms %p/Inputs/empty.pdb > %t.1
; RUN: llvm-pdbdump yaml2pdb -pdb=%t.2 %t.1
; RUN: llvm-pdbdump pdb2yaml -pdb-stream -tpi-stream \
; RUN: -dbi-module-syms -no-file-headers %p/Inputs/empty.pdb > %t.3
; RUN: -module-syms -no-file-headers %p/Inputs/empty.pdb > %t.3
; RUN: llvm-pdbdump pdb2yaml -pdb-stream -tpi-stream \
; RUN: -dbi-module-syms -no-file-headers %t.2 > %t.4
; RUN: -module-syms -no-file-headers %t.2 > %t.4
; RUN: diff %t.3 %t.4

View File

@ -1,71 +0,0 @@
; This testcase verifies that we can produce a PDB with line
; information. It does this by describing some line information
; manually in YAML, creating a PDB out of it, then dumping then
; line information from the resulting PDB.
; RUN: llvm-pdbdump yaml2pdb -pdb=%t.pdb %p/Inputs/simple-line-info.yaml
; RUN: llvm-pdbdump raw -line-info %t.pdb | FileCheck -check-prefix=LINES %s
LINES: Modules [
LINES-NEXT: {
LINES-NEXT: Name: d:\src\llvm\test\DebugInfo\PDB\Inputs\empty.obj
LINES: LineInfo [
LINES-NEXT: FileChecksums {
LINES-NEXT: Checksum {
LINES-NEXT: FileName: d:\src\llvm\test\debuginfo\pdb\inputs\empty.cpp
LINES-NEXT: Kind: MD5 (0x1)
LINES-NEXT: Checksum (
LINES-NEXT: 0000: A0A5BD0D 3ECD93FC 29D19DE8 26FBF4BC |....>...)...&...|
LINES-NEXT: )
LINES-NEXT: }
LINES-NEXT: Checksum {
LINES-NEXT: FileName: f:\dd\externalapis\windows\10\sdk\inc\winerror.h
LINES-NEXT: Kind: MD5 (0x1)
LINES-NEXT: Checksum (
LINES-NEXT: 0000: 1154D69F 5B265019 6E1FC34F 4134E56B |.T..[&P.n..OA4.k|
LINES-NEXT: )
LINES-NEXT: }
LINES-NEXT: }
LINES-NEXT: Lines {
LINES-NEXT: Block {
LINES-NEXT: RelocSegment: 1
LINES-NEXT: RelocOffset: 16
LINES-NEXT: CodeSize: 10
LINES-NEXT: HasColumns: No
LINES-NEXT: Lines {
LINES-NEXT: FileName: d:\src\llvm\test\debuginfo\pdb\inputs\empty.cpp
LINES-NEXT: Line {
LINES-NEXT: Offset: 0
LINES-NEXT: LineNumberStart: 5
LINES-NEXT: EndDelta: 0
LINES-NEXT: IsStatement: Yes
LINES-NEXT: }
LINES-NEXT: Line {
LINES-NEXT: Offset: 3
LINES-NEXT: LineNumberStart: 6
LINES-NEXT: EndDelta: 0
LINES-NEXT: IsStatement: Yes
LINES-NEXT: }
LINES-NEXT: Line {
LINES-NEXT: Offset: 8
LINES-NEXT: LineNumberStart: 7
LINES-NEXT: EndDelta: 0
LINES-NEXT: IsStatement: Yes
LINES-NEXT: }
LINES-NEXT: }
LINES-NEXT: }
LINES-NEXT: }
LINES-NEXT: InlineeLines {
LINES-NEXT: HasExtraFiles: No
LINES-NEXT: Lines [
LINES-NEXT: Inlinee {
LINES-NEXT: FileName: f:\dd\externalapis\windows\10\sdk\inc\winerror.h
LINES-NEXT: Function {
LINES-NEXT: Index: 0x58ef (unknown function)
LINES-NEXT: }
LINES-NEXT: SourceLine: 26950
LINES-NEXT: }
LINES-NEXT: ]
LINES-NEXT: }
LINES-NEXT: ]
LINES-NEXT: }

View File

@ -1,60 +0,0 @@
; RUN: llvm-pdbdump pdb2yaml -dbi-module-lines %p/Inputs/empty.pdb \
; RUN: | FileCheck -check-prefix=YAML %s
YAML: ---
YAML: MSF:
YAML: SuperBlock:
YAML: BlockSize: 4096
YAML: FreeBlockMap: 2
YAML: NumBlocks: 25
YAML: NumDirectoryBytes: 136
YAML: Unknown1: 0
YAML: BlockMapAddr: 24
YAML: NumDirectoryBlocks: 1
YAML: DirectoryBlocks: [ 23 ]
YAML: NumStreams: 0
YAML: FileSize: 102400
YAML: DbiStream:
YAML: VerHeader: V70
YAML: Age: 1
YAML: BuildNumber: 35840
YAML: PdbDllVersion: 31101
YAML: PdbDllRbld: 0
YAML: Flags: 1
YAML: MachineType: x86
YAML: Modules:
YAML: - Module: 'd:\src\llvm\test\DebugInfo\PDB\Inputs\empty.obj'
YAML: ObjFile: 'd:\src\llvm\test\DebugInfo\PDB\Inputs\empty.obj'
YAML: SourceFiles:
YAML: - 'd:\src\llvm\test\debuginfo\pdb\inputs\empty.cpp'
YAML: Subsections:
YAML: - !Lines
YAML: CodeSize: 10
YAML: Flags: [ ]
YAML: RelocOffset: 16
YAML: RelocSegment: 1
YAML: Blocks:
YAML: - FileName: 'd:\src\llvm\test\debuginfo\pdb\inputs\empty.cpp'
YAML: Lines:
YAML: - Offset: 0
YAML: LineStart: 5
YAML: IsStatement: true
YAML: EndDelta: 0
YAML: - Offset: 3
YAML: LineStart: 6
YAML: IsStatement: true
YAML: EndDelta: 0
YAML: - Offset: 8
YAML: LineStart: 7
YAML: IsStatement: true
YAML: EndDelta: 0
YAML: Columns:
YAML: - !FileChecksums
YAML: Checksums:
YAML: - FileName: 'd:\src\llvm\test\debuginfo\pdb\inputs\empty.cpp'
YAML: Kind: MD5
YAML: Checksum: A0A5BD0D3ECD93FC29D19DE826FBF4BC
YAML: - Module: '* Linker *'
YAML: ObjFile: ''
YAML: ...

View File

@ -89,7 +89,8 @@ public:
: C13DebugFragmentVisitor(F), P(P), IPI(IPI) {}
Error handleLines() override {
if (Lines.empty())
if (Lines.empty() ||
!opts::checkModuleSubsection(opts::ModuleSubsection::Lines))
return Error::success();
DictScope DD(P, "Lines");
@ -132,7 +133,8 @@ public:
}
Error handleFileChecksums() override {
if (!Checksums.hasValue())
if (!Checksums.hasValue() ||
!opts::checkModuleSubsection(opts::ModuleSubsection::FileChecksums))
return Error::success();
DictScope DD(P, "FileChecksums");
@ -149,7 +151,8 @@ public:
}
Error handleInlineeLines() override {
if (InlineeLines.empty())
if (InlineeLines.empty() ||
!opts::checkModuleSubsection(opts::ModuleSubsection::InlineeLines))
return Error::success();
DictScope D(P, "InlineeLines");
@ -177,6 +180,10 @@ public:
}
Error handleCrossModuleExports() override {
if (CrossExports.empty() ||
!opts::checkModuleSubsection(opts::ModuleSubsection::CrossScopeExports))
return Error::success();
for (const auto &M : CrossExports) {
DictScope D(P, "CrossModuleExports");
for (const auto &E : M) {
@ -188,6 +195,10 @@ public:
}
Error handleCrossModuleImports() override {
if (CrossImports.empty() ||
!opts::checkModuleSubsection(opts::ModuleSubsection::CrossScopeImports))
return Error::success();
for (const auto &M : CrossImports) {
DictScope D(P, "CrossModuleImports");
for (const auto &ImportGroup : M) {
@ -755,8 +766,10 @@ LLVMOutputStyle::initializeTypeDatabase(uint32_t SN) {
}
Error LLVMOutputStyle::dumpDbiStream() {
bool DumpModules = opts::raw::DumpModules || opts::raw::DumpModuleSyms ||
opts::raw::DumpModuleFiles || opts::raw::DumpLineInfo;
bool DumpModules = opts::shared::DumpModules ||
opts::shared::DumpModuleSyms ||
opts::shared::DumpModuleFiles ||
!opts::shared::DumpModuleSubsections.empty();
if (!opts::raw::DumpHeaders && !DumpModules)
return Error::success();
if (!File.hasPDBDbiStream()) {
@ -806,7 +819,7 @@ Error LLVMOutputStyle::dumpDbiStream() {
P.printNumber("Symbol Byte Size", Modi.getSymbolDebugInfoByteSize());
P.printNumber("Type Server Index", Modi.getTypeServerIndex());
P.printBoolean("Has EC Info", Modi.hasECInfo());
if (opts::raw::DumpModuleFiles) {
if (opts::shared::DumpModuleFiles) {
std::string FileListName = to_string(Modules.getSourceFileCount(I)) +
" Contributing Source Files";
ListScope LL(P, FileListName);
@ -815,8 +828,9 @@ Error LLVMOutputStyle::dumpDbiStream() {
}
bool HasModuleDI = (Modi.getModuleStreamIndex() < File.getNumStreams());
bool ShouldDumpSymbols =
(opts::raw::DumpModuleSyms || opts::raw::DumpSymRecordBytes);
if (HasModuleDI && (ShouldDumpSymbols || opts::raw::DumpLineInfo)) {
(opts::shared::DumpModuleSyms || opts::raw::DumpSymRecordBytes);
if (HasModuleDI &&
(ShouldDumpSymbols || !opts::shared::DumpModuleSubsections.empty())) {
auto ModStreamData = MappedBlockStream::createIndexedStream(
File.getMsfLayout(), File.getMsfBuffer(),
Modi.getModuleStreamIndex(), File.getAllocator());
@ -837,7 +851,7 @@ Error LLVMOutputStyle::dumpDbiStream() {
bool HadError = false;
for (auto S : ModS.symbols(&HadError)) {
DictScope LL(P, "");
if (opts::raw::DumpModuleSyms) {
if (opts::shared::DumpModuleSyms) {
if (auto EC = SD.dump(S)) {
llvm::consumeError(std::move(EC));
HadError = true;
@ -852,8 +866,8 @@ Error LLVMOutputStyle::dumpDbiStream() {
raw_error_code::corrupt_file,
"DBI stream contained corrupt symbol record");
}
if (opts::raw::DumpLineInfo) {
ListScope SS(P, "LineInfo");
if (!opts::shared::DumpModuleSubsections.empty()) {
ListScope SS(P, "Subsections");
auto ExpectedTypes = initializeTypeDatabase(StreamIPI);
if (!ExpectedTypes)
return ExpectedTypes.takeError();

View File

@ -38,39 +38,8 @@ YAMLOutputStyle::YAMLOutputStyle(PDBFile &File)
}
Error YAMLOutputStyle::dump() {
if (opts::pdb2yaml::All) {
opts::pdb2yaml::StreamMetadata = true;
opts::pdb2yaml::StreamDirectory = true;
opts::pdb2yaml::PdbStream = true;
opts::pdb2yaml::StringTable = true;
opts::pdb2yaml::DbiStream = true;
opts::pdb2yaml::DbiModuleInfo = true;
opts::pdb2yaml::DbiModuleSyms = true;
opts::pdb2yaml::DbiModuleSourceFileInfo = true;
opts::pdb2yaml::DbiModuleSourceLineInfo = true;
opts::pdb2yaml::TpiStream = true;
opts::pdb2yaml::IpiStream = true;
}
if (opts::pdb2yaml::StreamDirectory)
opts::pdb2yaml::StreamMetadata = true;
if (opts::pdb2yaml::DbiModuleSyms)
opts::pdb2yaml::DbiModuleInfo = true;
if (opts::pdb2yaml::DbiModuleSourceLineInfo)
opts::pdb2yaml::DbiModuleSourceFileInfo = true;
if (opts::pdb2yaml::DbiModuleSourceFileInfo)
opts::pdb2yaml::DbiModuleInfo = true;
if (opts::pdb2yaml::DbiModuleInfo)
opts::pdb2yaml::DbiStream = true;
// Some names from the module source file info get pulled from the string
// table, so if we're writing module source info, we have to write the string
// table as well.
if (opts::pdb2yaml::DbiModuleSourceLineInfo)
opts::pdb2yaml::StringTable = true;
if (auto EC = dumpFileHeaders())
return EC;
@ -124,8 +93,8 @@ Error YAMLOutputStyle::dumpFileHeaders() {
}
Error YAMLOutputStyle::dumpStringTable() {
bool RequiresStringTable = opts::pdb2yaml::DbiModuleSourceFileInfo ||
opts::pdb2yaml::DbiModuleSourceLineInfo;
bool RequiresStringTable = opts::shared::DumpModuleFiles ||
!opts::shared::DumpModuleSubsections.empty();
bool RequestedStringTable = opts::pdb2yaml::StringTable;
if (!RequiresStringTable && !RequestedStringTable)
return Error::success();
@ -191,6 +160,24 @@ Error YAMLOutputStyle::dumpPDBStream() {
return Error::success();
}
static opts::ModuleSubsection convertSubsectionKind(DebugSubsectionKind K) {
switch (K) {
case DebugSubsectionKind::CrossScopeExports:
return opts::ModuleSubsection::CrossScopeExports;
case DebugSubsectionKind::CrossScopeImports:
return opts::ModuleSubsection::CrossScopeImports;
case DebugSubsectionKind::FileChecksums:
return opts::ModuleSubsection::FileChecksums;
case DebugSubsectionKind::InlineeLines:
return opts::ModuleSubsection::InlineeLines;
case DebugSubsectionKind::Lines:
return opts::ModuleSubsection::Lines;
default:
return opts::ModuleSubsection::Unknown;
}
llvm_unreachable("Unreachable!");
}
Error YAMLOutputStyle::dumpDbiStream() {
if (!opts::pdb2yaml::DbiStream)
return Error::success();
@ -208,7 +195,7 @@ Error YAMLOutputStyle::dumpDbiStream() {
Obj.DbiStream->PdbDllRbld = DS.getPdbDllRbld();
Obj.DbiStream->PdbDllVersion = DS.getPdbDllVersion();
Obj.DbiStream->VerHeader = DS.getDbiVersion();
if (opts::pdb2yaml::DbiModuleInfo) {
if (opts::shared::DumpModules) {
const auto &Modules = DS.modules();
for (uint32_t I = 0; I < Modules.getModuleCount(); ++I) {
DbiModuleDescriptor MI = Modules.getModuleDescriptor(I);
@ -218,7 +205,7 @@ Error YAMLOutputStyle::dumpDbiStream() {
DMI.Mod = MI.getModuleName();
DMI.Obj = MI.getObjFileName();
if (opts::pdb2yaml::DbiModuleSourceFileInfo) {
if (opts::shared::DumpModuleFiles) {
auto Files = Modules.source_files(I);
DMI.SourceFiles.assign(Files.begin(), Files.end());
}
@ -238,13 +225,17 @@ Error YAMLOutputStyle::dumpDbiStream() {
auto ExpectedST = File.getStringTable();
if (!ExpectedST)
return ExpectedST.takeError();
if (opts::pdb2yaml::DbiModuleSourceLineInfo &&
if (!opts::shared::DumpModuleSubsections.empty() &&
ModS.hasDebugSubsections()) {
auto ExpectedChecksums = ModS.findChecksumsSubsection();
if (!ExpectedChecksums)
return ExpectedChecksums.takeError();
for (const auto &SS : ModS.subsections()) {
opts::ModuleSubsection OptionKind = convertSubsectionKind(SS.kind());
if (!opts::checkModuleSubsection(OptionKind))
continue;
auto Converted =
CodeViewYAML::YAMLDebugSubsection::fromCodeViewSubection(
ExpectedST->getStringTable(), *ExpectedChecksums, SS);
@ -254,7 +245,7 @@ Error YAMLOutputStyle::dumpDbiStream() {
}
}
if (opts::pdb2yaml::DbiModuleSyms) {
if (opts::shared::DumpModuleSyms) {
DMI.Modi.emplace();
DMI.Modi->Signature = ModS.signature();

View File

@ -269,7 +269,6 @@ namespace raw {
cl::OptionCategory MsfOptions("MSF Container Options");
cl::OptionCategory TypeOptions("Type Record Options");
cl::OptionCategory FileOptions("Module & File Options");
cl::OptionCategory SymbolOptions("Symbol Options");
cl::OptionCategory MiscOptions("Miscellaneous Options");
@ -323,20 +322,9 @@ cl::opt<bool> DumpIpiRecordBytes(
cl::desc("dump CodeView type record raw bytes from IPI stream"),
cl::cat(TypeOptions), cl::sub(RawSubcommand));
// MODULE & FILE OPTIONS
cl::opt<bool> DumpModules("modules", cl::desc("dump compiland information"),
cl::cat(FileOptions), cl::sub(RawSubcommand));
cl::opt<bool> DumpModuleFiles("module-files", cl::desc("dump file information"),
cl::cat(FileOptions), cl::sub(RawSubcommand));
cl::opt<bool> DumpLineInfo("line-info",
cl::desc("dump file and line information"),
cl::cat(FileOptions), cl::sub(RawSubcommand));
// SYMBOL OPTIONS
cl::opt<bool> DumpGlobals("globals", cl::desc("dump globals stream data"),
cl::cat(SymbolOptions), cl::sub(RawSubcommand));
cl::opt<bool> DumpModuleSyms("module-syms", cl::desc("dump module symbols"),
cl::cat(SymbolOptions), cl::sub(RawSubcommand));
cl::opt<bool> DumpPublics("publics", cl::desc("dump Publics stream data"),
cl::cat(SymbolOptions), cl::sub(RawSubcommand));
cl::opt<bool>
@ -381,11 +369,9 @@ namespace pdb2yaml {
cl::opt<bool> All("all",
cl::desc("Dump everything we know how to dump."),
cl::sub(PdbToYamlSubcommand), cl::init(false));
cl::opt<bool>
NoFileHeaders("no-file-headers",
cl::desc("Do not dump MSF file headers (you will not be able "
"to generate a fresh PDB from the resulting YAML)"),
cl::sub(PdbToYamlSubcommand), cl::init(false));
cl::opt<bool> NoFileHeaders("no-file-headers",
cl::desc("Do not dump MSF file headers"),
cl::sub(PdbToYamlSubcommand), cl::init(false));
cl::opt<bool> Minimal("minimal",
cl::desc("Don't write fields with default values"),
cl::sub(PdbToYamlSubcommand), cl::init(false));
@ -406,29 +392,8 @@ cl::opt<bool> StringTable("string-table", cl::desc("Dump the PDB String Table"),
cl::sub(PdbToYamlSubcommand), cl::init(false));
cl::opt<bool> DbiStream("dbi-stream",
cl::desc("Dump the DBI Stream (Stream 2)"),
cl::desc("Dump the DBI Stream Headers (Stream 2)"),
cl::sub(PdbToYamlSubcommand), cl::init(false));
cl::opt<bool>
DbiModuleInfo("dbi-module-info",
cl::desc("Dump DBI Module Information (implies -dbi-stream)"),
cl::sub(PdbToYamlSubcommand), cl::init(false));
cl::opt<bool> DbiModuleSyms(
"dbi-module-syms",
cl::desc("Dump DBI Module Information (implies -dbi-module-info)"),
cl::sub(PdbToYamlSubcommand), cl::init(false));
cl::opt<bool> DbiModuleSourceFileInfo(
"dbi-module-source-info",
cl::desc(
"Dump DBI Module Source File Information (implies -dbi-module-info)"),
cl::sub(PdbToYamlSubcommand), cl::init(false));
cl::opt<bool>
DbiModuleSourceLineInfo("dbi-module-lines",
cl::desc("Dump DBI Module Source Line Information "
"(implies -dbi-module-source-info)"),
cl::sub(PdbToYamlSubcommand), cl::init(false));
cl::opt<bool> TpiStream("tpi-stream",
cl::desc("Dump the TPI Stream (Stream 3)"),
@ -443,6 +408,39 @@ cl::list<std::string> InputFilename(cl::Positional,
cl::sub(PdbToYamlSubcommand));
}
namespace shared {
cl::OptionCategory FileOptions("Module & File Options");
// MODULE & FILE OPTIONS
cl::opt<bool> DumpModules("modules", cl::desc("dump compiland information"),
cl::cat(FileOptions), cl::sub(RawSubcommand),
cl::sub(PdbToYamlSubcommand));
cl::opt<bool> DumpModuleFiles("module-files", cl::desc("dump file information"),
cl::cat(FileOptions), cl::sub(RawSubcommand),
cl::sub(PdbToYamlSubcommand));
cl::list<ModuleSubsection> DumpModuleSubsections(
"subsections", cl::ZeroOrMore, cl::CommaSeparated,
cl::desc("dump subsections from each module's debug stream"),
cl::values(
clEnumValN(
ModuleSubsection::CrossScopeExports, "cme",
"Cross module exports (DEBUG_S_CROSSSCOPEEXPORTS subsection)"),
clEnumValN(
ModuleSubsection::CrossScopeImports, "cmi",
"Cross module imports (DEBUG_S_CROSSSCOPEIMPORTS subsection)"),
clEnumValN(ModuleSubsection::FileChecksums, "fc",
"File checksums (DEBUG_S_CHECKSUMS subsection)"),
clEnumValN(ModuleSubsection::InlineeLines, "ilines",
"Inlinee lines (DEBUG_S_INLINEELINES subsection)"),
clEnumValN(ModuleSubsection::Lines, "lines",
"Lines (DEBUG_S_LINES subsection)"),
clEnumValN(ModuleSubsection::All, "all", "All known subsections")),
cl::cat(FileOptions), cl::sub(RawSubcommand), cl::sub(PdbToYamlSubcommand));
cl::opt<bool> DumpModuleSyms("module-syms", cl::desc("dump module symbols"),
cl::cat(FileOptions), cl::sub(RawSubcommand),
cl::sub(PdbToYamlSubcommand));
} // namespace shared
namespace analyze {
cl::opt<bool> StringTable("hash-collisions", cl::desc("Find hash collisions"),
cl::sub(AnalyzeSubcommand), cl::init(false));
@ -463,6 +461,13 @@ cl::opt<std::string>
static ExitOnError ExitOnErr;
bool opts::checkModuleSubsection(opts::ModuleSubsection MS) {
return any_of(opts::shared::DumpModuleSubsections,
[=](opts::ModuleSubsection M) {
return M == MS || M == opts::ModuleSubsection::All;
});
}
static void yamlToPdb(StringRef Path) {
BumpPtrAllocator Allocator;
ErrorOr<std::unique_ptr<MemoryBuffer>> ErrorOrBuffer =
@ -879,12 +884,29 @@ int main(int argc_, const char *argv_[]) {
}
}
if ((opts::RawSubcommand && opts::raw::RawAll) ||
(opts::PdbToYamlSubcommand && opts::pdb2yaml::All)) {
opts::shared::DumpModules = true;
opts::shared::DumpModuleFiles = true;
opts::shared::DumpModuleSyms = true;
opts::shared::DumpModuleSubsections.push_back(opts::ModuleSubsection::All);
if (llvm::is_contained(opts::shared::DumpModuleSubsections,
opts::ModuleSubsection::All)) {
opts::shared::DumpModuleSubsections.reset();
opts::shared::DumpModuleSubsections.push_back(
opts::ModuleSubsection::All);
}
}
if (opts::shared::DumpModuleSyms || opts::shared::DumpModuleFiles)
opts::shared::DumpModules = true;
if (opts::shared::DumpModules)
opts::pdb2yaml::DbiStream = true;
if (opts::RawSubcommand) {
if (opts::raw::RawAll) {
opts::raw::DumpHeaders = true;
opts::raw::DumpModules = true;
opts::raw::DumpModuleFiles = true;
opts::raw::DumpModuleSyms = true;
opts::raw::DumpGlobals = true;
opts::raw::DumpPublics = true;
opts::raw::DumpSectionHeaders = true;
@ -896,7 +918,6 @@ int main(int argc_, const char *argv_[]) {
opts::raw::DumpIpiRecords = true;
opts::raw::DumpSectionMap = true;
opts::raw::DumpSectionContribs = true;
opts::raw::DumpLineInfo = true;
opts::raw::DumpFpo = true;
opts::raw::DumpStringTable = true;
}
@ -908,6 +929,17 @@ int main(int argc_, const char *argv_[]) {
exit(1);
}
}
if (opts::PdbToYamlSubcommand) {
if (opts::pdb2yaml::All) {
opts::pdb2yaml::StreamMetadata = true;
opts::pdb2yaml::StreamDirectory = true;
opts::pdb2yaml::PdbStream = true;
opts::pdb2yaml::StringTable = true;
opts::pdb2yaml::DbiStream = true;
opts::pdb2yaml::TpiStream = true;
opts::pdb2yaml::IpiStream = true;
}
}
llvm::sys::InitializeCOMRAII COM(llvm::sys::COMThreadingMode::MultiThreaded);

View File

@ -27,6 +27,25 @@ uint32_t getTypeLength(const PDBSymbolData &Symbol);
namespace opts {
enum class ModuleSubsection {
Unknown,
Lines,
FileChecksums,
InlineeLines,
CrossScopeImports,
CrossScopeExports,
All
};
bool checkModuleSubsection(ModuleSubsection Kind);
template <typename... Ts>
bool checkModuleSubsection(ModuleSubsection K1, ModuleSubsection K2,
Ts &&... Rest) {
return checkModuleSubsection(K1) ||
checkModuleSubsection(K2, std::forward<Ts>(Rest)...);
}
namespace pretty {
enum class ClassDefinitionFormat { None, Layout, All };
@ -96,13 +115,8 @@ extern llvm::cl::opt<bool> DumpTpiRecordBytes;
extern llvm::cl::opt<bool> DumpTpiRecords;
extern llvm::cl::opt<bool> DumpIpiRecords;
extern llvm::cl::opt<bool> DumpIpiRecordBytes;
extern llvm::cl::opt<bool> DumpModules;
extern llvm::cl::opt<bool> DumpModuleFiles;
extern llvm::cl::opt<bool> DumpModuleLines;
extern llvm::cl::opt<bool> DumpModuleSyms;
extern llvm::cl::opt<bool> DumpPublics;
extern llvm::cl::opt<bool> DumpSectionContribs;
extern llvm::cl::opt<bool> DumpLineInfo;
extern llvm::cl::opt<bool> DumpSectionMap;
extern llvm::cl::opt<bool> DumpSymRecordBytes;
extern llvm::cl::opt<bool> DumpSectionHeaders;
@ -123,14 +137,17 @@ extern llvm::cl::opt<bool> StreamDirectory;
extern llvm::cl::opt<bool> StringTable;
extern llvm::cl::opt<bool> PdbStream;
extern llvm::cl::opt<bool> DbiStream;
extern llvm::cl::opt<bool> DbiModuleInfo;
extern llvm::cl::opt<bool> DbiModuleSyms;
extern llvm::cl::opt<bool> DbiModuleSourceFileInfo;
extern llvm::cl::opt<bool> DbiModuleSourceLineInfo;
extern llvm::cl::opt<bool> TpiStream;
extern llvm::cl::opt<bool> IpiStream;
extern llvm::cl::list<std::string> InputFilename;
}
namespace shared {
extern llvm::cl::opt<bool> DumpModules;
extern llvm::cl::opt<bool> DumpModuleFiles;
extern llvm::cl::list<ModuleSubsection> DumpModuleSubsections;
extern llvm::cl::opt<bool> DumpModuleSyms;
} // namespace shared
}
#endif