File: pdb-relative-source-lines.test

package info (click to toggle)
swiftlang 6.0.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,519,992 kB
  • sloc: cpp: 9,107,863; ansic: 2,040,022; asm: 1,135,751; python: 296,500; objc: 82,456; f90: 60,502; lisp: 34,951; pascal: 19,946; sh: 18,133; perl: 7,482; ml: 4,937; javascript: 4,117; makefile: 3,840; awk: 3,535; xml: 914; fortran: 619; cs: 573; ruby: 573
file content (145 lines) | stat: -rw-r--r-- 5,966 bytes parent folder | download | duplicates (14)
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
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 -fdebug-compilation-dir . -no-canonical-prefixes -c -Z7 pdb_lines*.c
$ obj2yaml pdb_lines_1.obj > pdb_lines_1_relative.yaml
$ obj2yaml pdb_lines_2.obj > pdb_lines_2_relative.yaml

/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 -ipi-stream -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 -ipi-stream -modules -module-files -module-syms -subsections=lines,fc %t/out.pdb | FileCheck --check-prefix=POSIX %s

Also check without -pdbsourcepath
RUN: ./lld-link -debug -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=ABSOLUTE %s

Clean up copy of large binary copied into temp directory to avoid bloat.
RUN: rm -f ./lld-link || true

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'

CHECK-LABEL: IpiStream:

CHECK:    - Kind:            LF_STRING_ID
CHECK-NEXT:      StringId:
CHECK-NEXT:        Id:              0
CHECK-NEXT:        String:          .
CHECK-NEXT:     - Kind:            LF_STRING_ID
CHECK-NEXT:       StringId:
CHECK-NEXT:         Id:              0
CHECK-NEXT:         String:          pdb_lines_1.c
CHECK-NEXT:     - Kind:            LF_STRING_ID
CHECK-NEXT:       StringId:
CHECK-NEXT:         Id:              0
CHECK-NEXT:         String:          'buildninjaRel\bin\clang-cl.exe'

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'

ABSOLUTE-LABEL: StringTable:
ABSOLUTE-NOT: {{/|\\}}.{{/|\\}}pdb_lines_1.c

POSIX-LABEL: IpiStream:
POSIX:    - Kind:            LF_STRING_ID
POSIX-NEXT:      StringId:
POSIX-NEXT:        Id:              0
POSIX-NEXT:        String:          .
POSIX-NEXT:     - Kind:            LF_STRING_ID
POSIX-NEXT:       StringId:
POSIX-NEXT:         Id:              0
POSIX-NEXT:         String:          pdb_lines_1.c
POSIX-NEXT:     - Kind:            LF_STRING_ID
POSIX-NEXT:       StringId:
POSIX-NEXT:         Id:              0
POSIX-NEXT:         String:          'buildninjaRel\bin\clang-cl.exe'