1 | // REQUIRES: lld |
2 | |
3 | // Now test with DWARF5 |
4 | // RUN: %clang -target x86_64-pc-linux -gsplit-dwarf -gdwarf-5 -c %s -o %t.dwarf5.o |
5 | // RUN: ld.lld %t.dwarf5.o -o %t.dwarf5 |
6 | // RUN: llvm-dwp %t.dwarf5.dwo -o %t.dwarf5.dwp |
7 | // RUN: rm %t.dwarf5.dwo |
8 | // RUN: llvm-objcopy --only-keep-debug %t.dwarf5 %t.dwarf5.debug |
9 | // RUN: llvm-objcopy --strip-all --add-gnu-debuglink=%t.dwarf5.debug %t.dwarf5 |
10 | // RUN: %lldb \ |
11 | // RUN: -O "log enable dwarf split" \ |
12 | // RUN: -o "target variable a" \ |
13 | // RUN: -b %t.dwarf5 | FileCheck %s |
14 | |
15 | // Run one time with the index cache enabled to populate the index cache. When |
16 | // we populate the index cache we have to parse all of the DWARF debug info |
17 | // and it is always available. |
18 | // RUN: rm -rf %t.lldb-index-cache |
19 | // RUN: %lldb \ |
20 | // RUN: -O 'settings set symbols.enable-lldb-index-cache true' \ |
21 | // RUN: -O 'settings set symbols.lldb-index-cache-path %t.lldb-index-cache' \ |
22 | // RUN: -O 'settings set target.preload-symbols false' \ |
23 | // RUN: -o "script lldb.target.modules[0].FindTypes('::A').GetTypeAtIndex(0)" \ |
24 | // RUN: -o "statistics dump" \ |
25 | // RUN: %t.dwarf5 -b | FileCheck %s -check-prefix=CACHE |
26 | |
27 | // Run again after index cache was enabled, which load the index cache. When we |
28 | // load the index cache from disk, we don't have any DWARF parsed yet and this |
29 | // can cause us to try and access information in the .dwp directly without |
30 | // parsing the .debug_info, but this caused crashes when the DWO files didn't |
31 | // have a backlink to the skeleton compile unit. This test verifies that we |
32 | // don't crash and that we can find types when using .dwp files. |
33 | // RUN: %lldb \ |
34 | // RUN: -O 'settings set symbols.enable-lldb-index-cache true' \ |
35 | // RUN: -O 'settings set symbols.lldb-index-cache-path %t.lldb-index-cache' \ |
36 | // RUN: -O 'settings set target.preload-symbols false' \ |
37 | // RUN: -o "script lldb.target.modules[0].FindTypes('::A').GetTypeAtIndex(0)" \ |
38 | // RUN: -o "statistics dump" \ |
39 | // RUN: %t.dwarf5 -b | FileCheck %s -check-prefix=CACHED |
40 | |
41 | // Make sure that if we load the "%t.dwarf5.debug" file, that we can find and |
42 | // load the .dwo file from the .dwp when it is "%t.dwarf5.dwp" |
43 | // RUN: %lldb %t.dwarf5.debug -o "b main" -b | FileCheck %s -check-prefix=DEBUG |
44 | |
45 | // Make sure that if we load the "%t.dwarf5" file, that we can find and |
46 | // load the .dwo file from the .dwp when it is "%t.dwarf5.debug.dwp" |
47 | // RUN: mv %t.dwarf5.dwp %t.dwarf5.debug.dwp |
48 | // RUN: %lldb %t.dwarf5 -o "b main" -b | FileCheck %s -check-prefix=DEBUG |
49 | |
50 | // Make sure that if we load the "%t.dwarf5.debug" file, that we can find and |
51 | // load the .dwo file from the .dwp when it is "%t.dwarf5.debug.dwp" |
52 | // RUN: %lldb %t.dwarf5.debug -o "b main" -b | FileCheck %s -check-prefix=DEBUG |
53 | |
54 | // Make sure that if we remove the .dwp file we see an appropriate error. |
55 | // RUN: rm %t.dwarf5.debug.dwp |
56 | // RUN: %lldb \ |
57 | // RUN: -O "log enable dwarf split" \ |
58 | // RUN: -o "b main" \ |
59 | // RUN: -b %t.dwarf5 2>&1 | FileCheck %s -check-prefix=NODWP |
60 | |
61 | // RUN: %lldb \ |
62 | // RUN: -O "log enable dwarf split" \ |
63 | // RUN: -o "b main" \ |
64 | // RUN: -b %t.dwarf5.debug 2>&1 | FileCheck %s -check-prefix=NODWP |
65 | |
66 | // Now test with DWARF4 |
67 | // RUN: %clang -target x86_64-pc-linux -gsplit-dwarf -gdwarf-4 -c %s -o %t.dwarf4.o |
68 | // RUN: ld.lld %t.dwarf4.o -o %t.dwarf4 |
69 | // RUN: llvm-dwp %t.dwarf4.dwo -o %t.dwarf4.dwp |
70 | // RUN: rm %t.dwarf4.dwo |
71 | // RUN: llvm-objcopy --only-keep-debug %t.dwarf4 %t.dwarf4.debug |
72 | // RUN: llvm-objcopy --strip-all --add-gnu-debuglink=%t.dwarf4.debug %t.dwarf4 |
73 | // RUN: %lldb \ |
74 | // RUN: -O "log enable dwarf split" \ |
75 | // RUN: -o "target variable a" \ |
76 | // RUN: -b %t.dwarf4 | FileCheck %s |
77 | |
78 | // Run one time with the index cache enabled to populate the index cache. When |
79 | // we populate the index cache we have to parse all of the DWARF debug info |
80 | // and it is always available. |
81 | // RUN: rm -rf %t.lldb-index-cache |
82 | // RUN: %lldb \ |
83 | // RUN: -O 'settings set symbols.enable-lldb-index-cache true' \ |
84 | // RUN: -O 'settings set symbols.lldb-index-cache-path %t.lldb-index-cache' \ |
85 | // RUN: -O 'settings set target.preload-symbols false' \ |
86 | // RUN: -o "script lldb.target.modules[0].FindTypes('::A').GetTypeAtIndex(0)" \ |
87 | // RUN: -o "statistics dump" \ |
88 | // RUN: %t.dwarf4 -b | FileCheck %s -check-prefix=CACHE |
89 | |
90 | // Run again after index cache was enabled, which load the index cache. When we |
91 | // load the index cache from disk, we don't have any DWARF parsed yet and this |
92 | // can cause us to try and access information in the .dwp directly without |
93 | // parsing the .debug_info, but this caused crashes when the DWO files didn't |
94 | // have a backlink to the skeleton compile unit. This test verifies that we |
95 | // don't crash and that we can find types when using .dwp files. |
96 | // RUN: %lldb \ |
97 | // RUN: -O 'settings set symbols.enable-lldb-index-cache true' \ |
98 | // RUN: -O 'settings set symbols.lldb-index-cache-path %t.lldb-index-cache' \ |
99 | // RUN: -O 'settings set target.preload-symbols false' \ |
100 | // RUN: -o "script lldb.target.modules[0].FindTypes('::A').GetTypeAtIndex(0)" \ |
101 | // RUN: -o "statistics dump" \ |
102 | // RUN: %t.dwarf4 -b | FileCheck %s -check-prefix=CACHED |
103 | |
104 | // Make sure that if we load the "%t.dwarf4.debug" file, that we can find and |
105 | // load the .dwo file from the .dwp when it is "%t.dwarf4.dwp" |
106 | // RUN: %lldb %t.dwarf4.debug -o "b main" -b | FileCheck %s -check-prefix=DEBUG |
107 | |
108 | // Make sure that if we load the "%t.dwarf4" file, that we can find and |
109 | // load the .dwo file from the .dwp when it is "%t.dwarf4.debug.dwp" |
110 | // RUN: mv %t.dwarf4.dwp %t.dwarf4.debug.dwp |
111 | // RUN: %lldb %t.dwarf4 -o "b main" -b | FileCheck %s -check-prefix=DEBUG |
112 | |
113 | // Make sure that if we load the "%t.dwarf4.debug" file, that we can find and |
114 | // load the .dwo file from the .dwp when it is "%t.dwarf4.debug.dwp" |
115 | // RUN: %lldb %t.dwarf4.debug -o "b main" -b | FileCheck %s -check-prefix=DEBUG |
116 | |
117 | // Make sure that if we remove the .dwp file we see an appropriate error. |
118 | // RUN: rm %t.dwarf4.debug.dwp |
119 | // RUN: %lldb \ |
120 | // RUN: -O "log enable dwarf split" \ |
121 | // RUN: -o "b main" \ |
122 | // RUN: -b %t.dwarf4 2>&1 | FileCheck %s -check-prefix=NODWP |
123 | |
124 | // RUN: %lldb \ |
125 | // RUN: -O "log enable dwarf split" \ |
126 | // RUN: -o "b main" \ |
127 | // RUN: -b %t.dwarf4.debug 2>&1 | FileCheck %s -check-prefix=NODWP |
128 | |
129 | // Test if we have a GNU build ID in our main executable and in our debug file, |
130 | // and we have a .dwp file that doesn't, that we can still load our .dwp file. |
131 | // RUN: %clang -target x86_64-pc-linux -gsplit-dwarf -gdwarf-5 -c %s -o %t.o |
132 | // RUN: ld.lld %t.o --build-id=md5 -o %t |
133 | // RUN: llvm-dwp %t.dwo -o %t.dwp |
134 | // RUN: rm %t.dwo |
135 | // RUN: llvm-objcopy --only-keep-debug %t %t.debug |
136 | // RUN: llvm-objcopy --strip-all --add-gnu-debuglink=%t.debug %t |
137 | // RUN: %lldb \ |
138 | // RUN: -O "log enable dwarf split" \ |
139 | // RUN: -o "target variable a" \ |
140 | // RUN: -b %t | FileCheck %s |
141 | |
142 | // Now move the .debug and .dwp file into another directory so that we can use |
143 | // the target.debug-file-search-paths setting to search for the files. |
144 | // RUN: mkdir -p %t-debug-info-dir |
145 | // RUN: mv %t.dwp %t-debug-info-dir |
146 | // RUN: mv %t.debug %t-debug-info-dir |
147 | // RUN: %lldb \ |
148 | // RUN: -O "log enable dwarf split" \ |
149 | // RUN: -O "setting set target.debug-file-search-paths '%t-debug-info-dir'" \ |
150 | // RUN: -o "target variable a" \ |
151 | // RUN: -b %t | FileCheck %s |
152 | // RUN: |
153 | |
154 | // Now move the .debug and .dwp file into another directory so that we can use |
155 | // the target.debug-file-search-paths setting to search for the files. |
156 | // CHECK: Searching for DWP using: |
157 | // CHECK: Found DWP file: |
158 | // CHECK: (A) a = (x = 47) |
159 | |
160 | // CACHE: script lldb.target.modules[0].FindTypes('::A').GetTypeAtIndex(0) |
161 | // CACHE: struct A { |
162 | // CACHE-NEXT: int x; |
163 | // CACHE-NEXT: } |
164 | // CACHE: "totalDebugInfoIndexSavedToCache": 1 |
165 | |
166 | // CACHED: script lldb.target.modules[0].FindTypes('::A').GetTypeAtIndex(0) |
167 | // CACHED: struct A { |
168 | // CACHED-NEXT: int x; |
169 | // CACHED-NEXT: } |
170 | // CACHED: "totalDebugInfoIndexLoadedFromCache": 1 |
171 | |
172 | // Make sure debug information was loaded by verifying that the |
173 | // DEBUG: Breakpoint 1: where = dwp-separate-debug-file.cpp.tmp.dwarf{{[45]}}{{(\.debug)?}}`main + {{[0-9]+}} at dwp-separate-debug-file.cpp:{{[0-9]+}}:{{[0-9]+}}, address = {{0x[0-9a-fA-F]+}} |
174 | |
175 | // Make sure if we load the stripped binary or the debug info file with no .dwp |
176 | // nor any .dwo files that we are not able to fine the .dwp or .dwo files. |
177 | // NODWP: Searching for DWP using: |
178 | // NODWP: Searching for DWP using: |
179 | // NODWP: Unable to locate for DWP file for: |
180 | // NODWP: unable to locate separate debug file (dwo, dwp). Debugging will be degraded. |
181 | |
182 | struct A { |
183 | int x = 47; |
184 | }; |
185 | A a; |
186 | int main() {} |
187 | |