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