1Replicate this scenario: 2 3$ cat a.c 4struct Foo { int x; }; 5int g(struct Foo *p); 6int main() { 7 struct Foo f = {42}; 8 return g(&f); 9} 10 11$ cat b.c 12struct Foo { int x; }; 13int g(struct Foo *p) { return p->x; } 14 15$ cl -c a.c b.c -Zi -Fdts.pdb 16 17$ lld-link a.obj b.obj -debug -entry:main -nodefaultlib -out:t.exe 18 19RUN: rm -rf %t && mkdir -p %t && cd %t 20RUN: yaml2obj %S/Inputs/pdb-type-server-simple-a.yaml -o a.obj 21RUN: yaml2obj %S/Inputs/pdb-type-server-simple-b.yaml -o b.obj 22RUN: llvm-pdbutil yaml2pdb %S/Inputs/pdb-type-server-simple-ts.yaml -pdb ts.pdb 23RUN: lld-link a.obj b.obj -entry:main -debug:noghash -out:t.exe -pdb:t.pdb -nodefaultlib -summary | FileCheck %s -check-prefix SUMMARY 24RUN: llvm-pdbutil dump -symbols -types -ids -globals %t/t.pdb | FileCheck %s 25 26Re-run with /DEBUG:GHASH 27RUN: lld-link a.obj b.obj -entry:main -debug:ghash -out:t.exe -pdb:t.pdb -nodefaultlib -summary -verbose 28RUN: llvm-pdbutil dump -symbols -types -ids -globals %t/t.pdb | FileCheck %s 29 30Re-run with pdb from outputpath 31RUN: mkdir -p libs 32RUN: cp a.obj libs/a.obj && cp b.obj libs/b.obj 33RUN: lld-link libs/a.obj libs/b.obj -entry:main -debug:ghash -out:t.exe -pdb:t.pdb -nodefaultlib -summary 2>&1 | FileCheck %s -check-prefix FAILURE-MISSING-PDBFILE 34 35CHECK-LABEL: Types (TPI Stream) 36CHECK: ============================================================ 37 38CHECK: [[FOO_DECL:[^ ]*]] | LF_STRUCTURE [size = 36] `Foo` 39 40CHECK: [[FOO_PTR:[^ ]*]] | LF_POINTER [size = 12] 41CHECK-NEXT: referent = [[FOO_DECL]] 42 43CHECK: [[G_ARGS:[^ ]*]] | LF_ARGLIST [size = 12] 44CHECK-NEXT: [[FOO_PTR]]: `Foo*` 45 46CHECK: [[G_PROTO:[^ ]*]] | LF_PROCEDURE [size = 16] 47CHECK-NEXT: return type = 0x0074 (int), # args = 1, param list = [[G_ARGS]] 48CHECK-NEXT: calling conv = cdecl, options = None 49 50CHECK: [[FOO_COMPLETE:[^ ]*]] | LF_STRUCTURE [size = 36] `Foo` 51CHECK-NEXT: unique name: `.?AUFoo@@` 52CHECK-NEXT: vtable: <no type>, base list: <no type>, field list: 0x{{.*}} 53CHECK: options: has unique name 54CHECK: [[MAIN_PROTO:[^ ]*]] | LF_PROCEDURE [size = 16] 55CHECK: return type = 0x0074 (int), # args = 0, param list = 0x{{.*}} 56CHECK: calling conv = cdecl, options = None 57 58 59CHECK-LABEL: Types (IPI Stream) 60CHECK: ============================================================ 61CHECK: [[MAIN_ID:[^ ]*]] | LF_FUNC_ID [size = 20] 62CHECK: name = main, type = [[MAIN_PROTO]], parent scope = <no type> 63CHECK: [[G_ID:[^ ]*]] | LF_FUNC_ID [size = 16] 64CHECK: name = g, type = [[G_PROTO]], parent scope = <no type> 65CHECK: [[A_BUILD:[^ ]*]] | LF_BUILDINFO [size = 28] 66CHECK: {{.*}}: `a.c` 67CHECK: [[B_BUILD:[^ ]*]] | LF_BUILDINFO [size = 28] 68CHECK: {{.*}}: `b.c` 69 70CHECK-LABEL: Global Symbols 71CHECK: ============================================================ 72CHECK-NEXT: Records 73CHECK-NEXT: 36 | S_PROCREF [size = 20] `main` 74CHECK-NEXT: module = 1, sum name = 0, offset = 104 75CHECK-NEXT: 68 | S_PROCREF [size = 16] `g` 76CHECK-NEXT: module = 2, sum name = 0, offset = 104 77CHECK-NEXT: 56 | S_UDT [size = 12] `Foo` 78CHECK-NEXT: original type = 0x1006 79 80CHECK-LABEL: Symbols 81CHECK: ============================================================ 82CHECK-LABEL: Mod 0000 | `{{.*}}a.obj`: 83CHECK: 4 | S_OBJNAME [size = 40] sig=0, `C:\src\llvm-project\build\a.obj` 84CHECK: 104 | S_GPROC32 [size = 44] `main` 85CHECK: parent = 0, end = 196, addr = 0001:0000, code size = 27 86CHECK: type = {{.*}}, debug start = 4, debug end = 22, flags = none 87CHECK: 200 | S_BUILDINFO [size = 8] BuildId = `[[A_BUILD]]` 88CHECK-LABEL: Mod 0001 | `{{.*}}b.obj`: 89CHECK: 4 | S_OBJNAME [size = 40] sig=0, `C:\src\llvm-project\build\b.obj` 90CHECK: 44 | S_COMPILE3 [size = 60] 91CHECK: machine = intel x86-x64, Ver = Microsoft (R) Optimizing Compiler, language = c 92CHECK: frontend = 19.0.24215.1, backend = 19.0.24215.1 93CHECK: flags = security checks | hot patchable 94CHECK: 104 | S_GPROC32 [size = 44] `g` 95CHECK: parent = 0, end = 196, addr = 0001:0032, code size = 13 96CHECK: type = {{.*}}, debug start = 5, debug end = 12, flags = none 97CHECK: 148 | S_FRAMEPROC [size = 32] 98CHECK: size = 0, padding size = 0, offset to padding = 0 99CHECK: bytes of callee saved registers = 0, exception handler addr = 0000:0000 100CHECK: flags = has async eh | opt speed 101CHECK: 180 | S_REGREL32 [size = 16] `p` 102CHECK: type = [[FOO_PTR]] (Foo*), register = RSP, offset = 8 103CHECK: 196 | S_END [size = 4] 104CHECK: 200 | S_BUILDINFO [size = 8] BuildId = `[[B_BUILD]]` 105CHECK-LABEL: Mod 0002 | `* Linker *`: 106 107SUMMARY: Summary 108SUMMARY-NEXT: -------------------------------------------------------------------------------- 109SUMMARY-NEXT: 2 Input OBJ files (expanded from all cmd-line inputs) 110SUMMARY-NEXT: 1 PDB type server dependencies 111SUMMARY-NEXT: 0 Precomp OBJ dependencies 112SUMMARY-NEXT: 25 Input type records 113SUMMARY-NEXT: 868 Input type records bytes 114SUMMARY-NEXT: 9 Merged TPI records 115SUMMARY-NEXT: 16 Merged IPI records 116SUMMARY-NEXT: 3 Output PDB strings 117SUMMARY-NEXT: 4 Global symbol records 118SUMMARY-NEXT: 14 Module symbol records 119SUMMARY-NEXT: 2 Public symbol records 120 121SUMMARY: Top 10 types responsible for the most TPI input: 122SUMMARY-NEXT: index total bytes count size 123SUMMARY-NEXT: 0x1006: 36 = 1 * 36 124SUMMARY: Run llvm-pdbutil to print details about a particular record: 125SUMMARY-NEXT: llvm-pdbutil dump -types -type-index 0x1006 t.pdb 126 127SUMMARY: Top 10 types responsible for the most IPI input: 128SUMMARY-NEXT: index total bytes count size 129SUMMARY-NEXT: 0x1006: 256 = 1 * 256 130SUMMARY: Run llvm-pdbutil to print details about a particular record: 131SUMMARY-NEXT: llvm-pdbutil dump -ids -id-index 0x1006 t.pdb 132 133FAILURE-MISSING-PDBFILE-NOT: Cannot use debug info for '{{.*}}.obj' 134FAILURE-MISSING-PDBFILE-NOT: failed to load reference '{{.*}}.pdb': no such file or directory 135