[Dexter][NFC] Add Missing Commands to Commands.md Contents
[llvm-project.git] / lld / test / COFF / pdb-relative-source-lines.test
blob547056785962adffdcbcea2f35d85a53239bc9ef
1 Test the linker line tables on roughly the following example:
3 ==> foo.h <==
4 void bar(void);
5 inline void foo(void) {
6   bar();
8 ==> pdb_lines_1.c <==
9 #include "foo.h"
10 int main(void) {
11   foo();
12   return 42;
14 ==> pdb_lines_2.c <==
15 void bar(void) {
18 $ clang-cl -Xclang -fdebug-compilation-dir -Xclang . -c -Z7 pdb_lines*.c
20 /pdbsourcepath: only sets the directory that relative paths are considered
21 relative to, so this test needs to pass relative paths to lld-link for:
22 1. The input obj files
23 2. The /pdb: switch
24 3. The lld-link invocation itself
25 To achieve this, put all inputs of the lld-link invocation (including lld-link
26 itself) in a temp directory that's cwd and then make sure to only use relative
27 arguments when calling ./lld-link below.
28 RUN: rm -rf %t
29 RUN: mkdir %t
30 RUN: cp lld-link %t/lld-link
31 RUN: cd %t
33 RUN: yaml2obj %S/Inputs/pdb_lines_1_relative.yaml -o %t/pdb_lines_1_relative.obj
34 RUN: yaml2obj %S/Inputs/pdb_lines_2_relative.yaml -o %t/pdb_lines_2_relative.obj
35 RUN: ./lld-link -debug "-pdbsourcepath:c:\src" -entry:main -nodefaultlib -out:out.exe -pdb:out.pdb pdb_lines_1_relative.obj pdb_lines_2_relative.obj
36 RUN: llvm-pdbutil pdb2yaml -modules -module-files -module-syms -subsections=lines,fc %t/out.pdb | FileCheck %s
37 RUN: ./lld-link -debug "-pdbsourcepath:/usr/src" -entry:main -nodefaultlib -out:out.exe -pdb:out.pdb pdb_lines_1_relative.obj pdb_lines_2_relative.obj
38 RUN: llvm-pdbutil pdb2yaml -modules -module-files -module-syms -subsections=lines,fc %t/out.pdb | FileCheck --check-prefix=POSIX %s
40 CHECK-LABEL:  - Module:          'c:\src\pdb_lines_1_relative.obj'
41 CHECK-NEXT:     ObjFile:         'c:\src\pdb_lines_1_relative.obj'
42 CHECK:          SourceFiles:
43 CHECK-NEXT:       - 'c:\src\pdb_lines_1.c'
44 CHECK-NEXT:       - 'c:\src\foo.h'
45 CHECK:          Subsections:
46 CHECK:                - FileName:        'c:\src\pdb_lines_1.c'
47 CHECK:                - FileName:        'c:\src\foo.h'
48 CHECK:            - !FileChecksums
49 CHECK:                - FileName:        'c:\src\pdb_lines_1.c'
50 CHECK:                - FileName:        'c:\src\foo.h'
52 CHECK-LABEL:  - Module:          'c:\src\pdb_lines_2_relative.obj'
53 CHECK-NEXT:     ObjFile:         'c:\src\pdb_lines_2_relative.obj'
54 CHECK:          SourceFiles:
55 CHECK-NEXT:       - 'c:\src\pdb_lines_2.c'
56 CHECK:          Subsections:
57 CHECK:                - FileName:        'c:\src\pdb_lines_2.c'
58 CHECK:            - !FileChecksums
59 CHECK:                - FileName:        'c:\src\pdb_lines_2.c'
61 CHECK-LABEL:  - Kind:            S_ENVBLOCK
62 CHECK-NEXT:     EnvBlockSym:     
63 CHECK-NEXT:       Entries:     
64 CHECK-NEXT:         - cwd
65 CHECK-NEXT:         - 'c:\src'
66 CHECK-NEXT:         - exe
67 CHECK-NEXT:         - 'c:\src\lld-link'
68 CHECK-NEXT:         - pdb 
69 CHECK-NEXT:         - 'c:\src\out.pdb'
70 CHECK-NEXT:         - cmd
71 CHECK-NEXT:         - '-debug -pdbsourcepath:c:\src -entry:main -nodefaultlib -out:out.exe -pdb:out.pdb pdb_lines_1_relative.obj pdb_lines_2_relative.obj'
74 POSIX-LABEL:  - Module:          '/usr/src/pdb_lines_1_relative.obj'
75 POSIX-NEXT:     ObjFile:         '/usr/src/pdb_lines_1_relative.obj'
76 POSIX:          SourceFiles:
77 POSIX-NEXT:       - '/usr/src/pdb_lines_1.c'
78 POSIX-NEXT:       - '/usr/src/foo.h'
79 POSIX:          Subsections:
80 POSIX:                - FileName:        '/usr/src/pdb_lines_1.c'
81 POSIX:                - FileName:        '/usr/src/foo.h'
82 POSIX:            - !FileChecksums
83 POSIX:                - FileName:        '/usr/src/pdb_lines_1.c'
84 POSIX:                - FileName:        '/usr/src/foo.h'
86 POSIX-LABEL:  - Module:          '/usr/src/pdb_lines_2_relative.obj'
87 POSIX-NEXT:     ObjFile:         '/usr/src/pdb_lines_2_relative.obj'
88 POSIX:          SourceFiles:
89 POSIX-NEXT:       - '/usr/src/pdb_lines_2.c'
90 POSIX:          Subsections:
91 POSIX:                - FileName:        '/usr/src/pdb_lines_2.c'
92 POSIX:            - !FileChecksums
93 POSIX:                - FileName:        '/usr/src/pdb_lines_2.c'
95 POSIX-LABEL:  - Kind:            S_ENVBLOCK
96 POSIX-NEXT:     EnvBlockSym:     
97 POSIX-NEXT:       Entries:     
98 POSIX-NEXT:         - cwd
99 POSIX-NEXT:         - '/usr/src'
100 POSIX-NEXT:         - exe
101 POSIX-NEXT:         - '/usr/src/lld-link'
102 POSIX-NEXT:         - pdb 
103 POSIX-NEXT:         - '/usr/src/out.pdb'
104 POSIX-NEXT:         - cmd
105 POSIX-NEXT:         - '-debug -pdbsourcepath:/usr/src -entry:main -nodefaultlib -out:out.exe -pdb:out.pdb pdb_lines_1_relative.obj pdb_lines_2_relative.obj'