1*93266ecaSDavid Spickett // REQUIRES: lld, python
28a64d80aSDavid Spickett
35a45d32bSGreg Clayton // Now test with DWARF5
49258f3e6SGreg Clayton // RUN: %clang -target x86_64-pc-linux -gsplit-dwarf -gdwarf-5 -c %s -o %t.dwarf5.o
59258f3e6SGreg Clayton // RUN: ld.lld %t.dwarf5.o -o %t.dwarf5
69258f3e6SGreg Clayton // RUN: llvm-dwp %t.dwarf5.dwo -o %t.dwarf5.dwp
79258f3e6SGreg Clayton // RUN: rm %t.dwarf5.dwo
89258f3e6SGreg Clayton // RUN: llvm-objcopy --only-keep-debug %t.dwarf5 %t.dwarf5.debug
99258f3e6SGreg Clayton // RUN: llvm-objcopy --strip-all --add-gnu-debuglink=%t.dwarf5.debug %t.dwarf5
105a45d32bSGreg Clayton // RUN: %lldb \
115a45d32bSGreg Clayton // RUN: -O "log enable dwarf split" \
125a45d32bSGreg Clayton // RUN: -o "target variable a" \
135a45d32bSGreg Clayton // RUN: -b %t.dwarf5 | FileCheck %s
149258f3e6SGreg Clayton
159258f3e6SGreg Clayton // Run one time with the index cache enabled to populate the index cache. When
169258f3e6SGreg Clayton // we populate the index cache we have to parse all of the DWARF debug info
179258f3e6SGreg Clayton // and it is always available.
189258f3e6SGreg Clayton // RUN: rm -rf %t.lldb-index-cache
199258f3e6SGreg Clayton // RUN: %lldb \
209258f3e6SGreg Clayton // RUN: -O 'settings set symbols.enable-lldb-index-cache true' \
219258f3e6SGreg Clayton // RUN: -O 'settings set symbols.lldb-index-cache-path %t.lldb-index-cache' \
229258f3e6SGreg Clayton // RUN: -O 'settings set target.preload-symbols false' \
239258f3e6SGreg Clayton // RUN: -o "script lldb.target.modules[0].FindTypes('::A').GetTypeAtIndex(0)" \
249258f3e6SGreg Clayton // RUN: -o "statistics dump" \
259258f3e6SGreg Clayton // RUN: %t.dwarf5 -b | FileCheck %s -check-prefix=CACHE
269258f3e6SGreg Clayton
279258f3e6SGreg Clayton // Run again after index cache was enabled, which load the index cache. When we
289258f3e6SGreg Clayton // load the index cache from disk, we don't have any DWARF parsed yet and this
299258f3e6SGreg Clayton // can cause us to try and access information in the .dwp directly without
309258f3e6SGreg Clayton // parsing the .debug_info, but this caused crashes when the DWO files didn't
319258f3e6SGreg Clayton // have a backlink to the skeleton compile unit. This test verifies that we
329258f3e6SGreg Clayton // don't crash and that we can find types when using .dwp files.
339258f3e6SGreg Clayton // RUN: %lldb \
349258f3e6SGreg Clayton // RUN: -O 'settings set symbols.enable-lldb-index-cache true' \
359258f3e6SGreg Clayton // RUN: -O 'settings set symbols.lldb-index-cache-path %t.lldb-index-cache' \
369258f3e6SGreg Clayton // RUN: -O 'settings set target.preload-symbols false' \
379258f3e6SGreg Clayton // RUN: -o "script lldb.target.modules[0].FindTypes('::A').GetTypeAtIndex(0)" \
389258f3e6SGreg Clayton // RUN: -o "statistics dump" \
399258f3e6SGreg Clayton // RUN: %t.dwarf5 -b | FileCheck %s -check-prefix=CACHED
409258f3e6SGreg Clayton
415a45d32bSGreg Clayton // Make sure that if we load the "%t.dwarf5.debug" file, that we can find and
425a45d32bSGreg Clayton // load the .dwo file from the .dwp when it is "%t.dwarf5.dwp"
435a45d32bSGreg Clayton // RUN: %lldb %t.dwarf5.debug -o "b main" -b | FileCheck %s -check-prefix=DEBUG
445a45d32bSGreg Clayton
455a45d32bSGreg Clayton // Make sure that if we load the "%t.dwarf5" file, that we can find and
465a45d32bSGreg Clayton // load the .dwo file from the .dwp when it is "%t.dwarf5.debug.dwp"
475a45d32bSGreg Clayton // RUN: mv %t.dwarf5.dwp %t.dwarf5.debug.dwp
485a45d32bSGreg Clayton // RUN: %lldb %t.dwarf5 -o "b main" -b | FileCheck %s -check-prefix=DEBUG
495a45d32bSGreg Clayton
505a45d32bSGreg Clayton // Make sure that if we load the "%t.dwarf5.debug" file, that we can find and
515a45d32bSGreg Clayton // load the .dwo file from the .dwp when it is "%t.dwarf5.debug.dwp"
525a45d32bSGreg Clayton // RUN: %lldb %t.dwarf5.debug -o "b main" -b | FileCheck %s -check-prefix=DEBUG
535a45d32bSGreg Clayton
545a45d32bSGreg Clayton // Make sure that if we remove the .dwp file we see an appropriate error.
555a45d32bSGreg Clayton // RUN: rm %t.dwarf5.debug.dwp
565a45d32bSGreg Clayton // RUN: %lldb \
575a45d32bSGreg Clayton // RUN: -O "log enable dwarf split" \
585a45d32bSGreg Clayton // RUN: -o "b main" \
595a45d32bSGreg Clayton // RUN: -b %t.dwarf5 2>&1 | FileCheck %s -check-prefix=NODWP
605a45d32bSGreg Clayton
615a45d32bSGreg Clayton // RUN: %lldb \
625a45d32bSGreg Clayton // RUN: -O "log enable dwarf split" \
635a45d32bSGreg Clayton // RUN: -o "b main" \
645a45d32bSGreg Clayton // RUN: -b %t.dwarf5.debug 2>&1 | FileCheck %s -check-prefix=NODWP
655a45d32bSGreg Clayton
669258f3e6SGreg Clayton // Now test with DWARF4
679258f3e6SGreg Clayton // RUN: %clang -target x86_64-pc-linux -gsplit-dwarf -gdwarf-4 -c %s -o %t.dwarf4.o
689258f3e6SGreg Clayton // RUN: ld.lld %t.dwarf4.o -o %t.dwarf4
699258f3e6SGreg Clayton // RUN: llvm-dwp %t.dwarf4.dwo -o %t.dwarf4.dwp
709258f3e6SGreg Clayton // RUN: rm %t.dwarf4.dwo
719258f3e6SGreg Clayton // RUN: llvm-objcopy --only-keep-debug %t.dwarf4 %t.dwarf4.debug
729258f3e6SGreg Clayton // RUN: llvm-objcopy --strip-all --add-gnu-debuglink=%t.dwarf4.debug %t.dwarf4
735a45d32bSGreg Clayton // RUN: %lldb \
745a45d32bSGreg Clayton // RUN: -O "log enable dwarf split" \
755a45d32bSGreg Clayton // RUN: -o "target variable a" \
765a45d32bSGreg Clayton // RUN: -b %t.dwarf4 | FileCheck %s
779258f3e6SGreg Clayton
789258f3e6SGreg Clayton // Run one time with the index cache enabled to populate the index cache. When
799258f3e6SGreg Clayton // we populate the index cache we have to parse all of the DWARF debug info
809258f3e6SGreg Clayton // and it is always available.
819258f3e6SGreg Clayton // RUN: rm -rf %t.lldb-index-cache
829258f3e6SGreg Clayton // RUN: %lldb \
839258f3e6SGreg Clayton // RUN: -O 'settings set symbols.enable-lldb-index-cache true' \
849258f3e6SGreg Clayton // RUN: -O 'settings set symbols.lldb-index-cache-path %t.lldb-index-cache' \
859258f3e6SGreg Clayton // RUN: -O 'settings set target.preload-symbols false' \
869258f3e6SGreg Clayton // RUN: -o "script lldb.target.modules[0].FindTypes('::A').GetTypeAtIndex(0)" \
879258f3e6SGreg Clayton // RUN: -o "statistics dump" \
889258f3e6SGreg Clayton // RUN: %t.dwarf4 -b | FileCheck %s -check-prefix=CACHE
899258f3e6SGreg Clayton
909258f3e6SGreg Clayton // Run again after index cache was enabled, which load the index cache. When we
919258f3e6SGreg Clayton // load the index cache from disk, we don't have any DWARF parsed yet and this
929258f3e6SGreg Clayton // can cause us to try and access information in the .dwp directly without
939258f3e6SGreg Clayton // parsing the .debug_info, but this caused crashes when the DWO files didn't
949258f3e6SGreg Clayton // have a backlink to the skeleton compile unit. This test verifies that we
959258f3e6SGreg Clayton // don't crash and that we can find types when using .dwp files.
969258f3e6SGreg Clayton // RUN: %lldb \
979258f3e6SGreg Clayton // RUN: -O 'settings set symbols.enable-lldb-index-cache true' \
989258f3e6SGreg Clayton // RUN: -O 'settings set symbols.lldb-index-cache-path %t.lldb-index-cache' \
999258f3e6SGreg Clayton // RUN: -O 'settings set target.preload-symbols false' \
1009258f3e6SGreg Clayton // RUN: -o "script lldb.target.modules[0].FindTypes('::A').GetTypeAtIndex(0)" \
1019258f3e6SGreg Clayton // RUN: -o "statistics dump" \
1029258f3e6SGreg Clayton // RUN: %t.dwarf4 -b | FileCheck %s -check-prefix=CACHED
1038a64d80aSDavid Spickett
1045a45d32bSGreg Clayton // Make sure that if we load the "%t.dwarf4.debug" file, that we can find and
1055a45d32bSGreg Clayton // load the .dwo file from the .dwp when it is "%t.dwarf4.dwp"
1065a45d32bSGreg Clayton // RUN: %lldb %t.dwarf4.debug -o "b main" -b | FileCheck %s -check-prefix=DEBUG
1075a45d32bSGreg Clayton
1085a45d32bSGreg Clayton // Make sure that if we load the "%t.dwarf4" file, that we can find and
1095a45d32bSGreg Clayton // load the .dwo file from the .dwp when it is "%t.dwarf4.debug.dwp"
1105a45d32bSGreg Clayton // RUN: mv %t.dwarf4.dwp %t.dwarf4.debug.dwp
1115a45d32bSGreg Clayton // RUN: %lldb %t.dwarf4 -o "b main" -b | FileCheck %s -check-prefix=DEBUG
1125a45d32bSGreg Clayton
1135a45d32bSGreg Clayton // Make sure that if we load the "%t.dwarf4.debug" file, that we can find and
1145a45d32bSGreg Clayton // load the .dwo file from the .dwp when it is "%t.dwarf4.debug.dwp"
1155a45d32bSGreg Clayton // RUN: %lldb %t.dwarf4.debug -o "b main" -b | FileCheck %s -check-prefix=DEBUG
1165a45d32bSGreg Clayton
1175a45d32bSGreg Clayton // Make sure that if we remove the .dwp file we see an appropriate error.
1185a45d32bSGreg Clayton // RUN: rm %t.dwarf4.debug.dwp
1195a45d32bSGreg Clayton // RUN: %lldb \
1205a45d32bSGreg Clayton // RUN: -O "log enable dwarf split" \
1215a45d32bSGreg Clayton // RUN: -o "b main" \
1225a45d32bSGreg Clayton // RUN: -b %t.dwarf4 2>&1 | FileCheck %s -check-prefix=NODWP
1235a45d32bSGreg Clayton
1245a45d32bSGreg Clayton // RUN: %lldb \
1255a45d32bSGreg Clayton // RUN: -O "log enable dwarf split" \
1265a45d32bSGreg Clayton // RUN: -o "b main" \
1275a45d32bSGreg Clayton // RUN: -b %t.dwarf4.debug 2>&1 | FileCheck %s -check-prefix=NODWP
1285a45d32bSGreg Clayton
1295a45d32bSGreg Clayton // Test if we have a GNU build ID in our main executable and in our debug file,
1305a45d32bSGreg Clayton // and we have a .dwp file that doesn't, that we can still load our .dwp file.
1315a45d32bSGreg Clayton // RUN: %clang -target x86_64-pc-linux -gsplit-dwarf -gdwarf-5 -c %s -o %t.o
1325a45d32bSGreg Clayton // RUN: ld.lld %t.o --build-id=md5 -o %t
1335a45d32bSGreg Clayton // RUN: llvm-dwp %t.dwo -o %t.dwp
1345a45d32bSGreg Clayton // RUN: rm %t.dwo
1355a45d32bSGreg Clayton // RUN: llvm-objcopy --only-keep-debug %t %t.debug
1365a45d32bSGreg Clayton // RUN: llvm-objcopy --strip-all --add-gnu-debuglink=%t.debug %t
1375a45d32bSGreg Clayton // RUN: %lldb \
1385a45d32bSGreg Clayton // RUN: -O "log enable dwarf split" \
1395a45d32bSGreg Clayton // RUN: -o "target variable a" \
1405a45d32bSGreg Clayton // RUN: -b %t | FileCheck %s
1415a45d32bSGreg Clayton
142f0eb0c56SGreg Clayton // Now move the .debug and .dwp file into another directory so that we can use
143f0eb0c56SGreg Clayton // the target.debug-file-search-paths setting to search for the files.
144f0eb0c56SGreg Clayton // RUN: mkdir -p %t-debug-info-dir
145f0eb0c56SGreg Clayton // RUN: mv %t.dwp %t-debug-info-dir
146f0eb0c56SGreg Clayton // RUN: mv %t.debug %t-debug-info-dir
147f0eb0c56SGreg Clayton // RUN: %lldb \
148f0eb0c56SGreg Clayton // RUN: -O "log enable dwarf split" \
149f0eb0c56SGreg Clayton // RUN: -O "setting set target.debug-file-search-paths '%t-debug-info-dir'" \
150f0eb0c56SGreg Clayton // RUN: -o "target variable a" \
151f0eb0c56SGreg Clayton // RUN: -b %t | FileCheck %s
152f0eb0c56SGreg Clayton // RUN:
153f0eb0c56SGreg Clayton
154f0eb0c56SGreg Clayton // Now move the .debug and .dwp file into another directory so that we can use
155f0eb0c56SGreg Clayton // the target.debug-file-search-paths setting to search for the files.
1565a45d32bSGreg Clayton // CHECK: Searching for DWP using:
1575a45d32bSGreg Clayton // CHECK: Found DWP file:
1588a64d80aSDavid Spickett // CHECK: (A) a = (x = 47)
1598a64d80aSDavid Spickett
1609258f3e6SGreg Clayton // CACHE: script lldb.target.modules[0].FindTypes('::A').GetTypeAtIndex(0)
1619258f3e6SGreg Clayton // CACHE: struct A {
1629258f3e6SGreg Clayton // CACHE-NEXT: int x;
1639258f3e6SGreg Clayton // CACHE-NEXT: }
1649258f3e6SGreg Clayton // CACHE: "totalDebugInfoIndexSavedToCache": 1
1659258f3e6SGreg Clayton
1669258f3e6SGreg Clayton // CACHED: script lldb.target.modules[0].FindTypes('::A').GetTypeAtIndex(0)
1679258f3e6SGreg Clayton // CACHED: struct A {
1689258f3e6SGreg Clayton // CACHED-NEXT: int x;
1699258f3e6SGreg Clayton // CACHED-NEXT: }
1709258f3e6SGreg Clayton // CACHED: "totalDebugInfoIndexLoadedFromCache": 1
1719258f3e6SGreg Clayton
1725a45d32bSGreg Clayton // Make sure debug information was loaded by verifying that the
1735a45d32bSGreg Clayton // 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]+}}
1745a45d32bSGreg Clayton
1755a45d32bSGreg Clayton // Make sure if we load the stripped binary or the debug info file with no .dwp
1765a45d32bSGreg Clayton // nor any .dwo files that we are not able to fine the .dwp or .dwo files.
1775a45d32bSGreg Clayton // NODWP: Searching for DWP using:
1785a45d32bSGreg Clayton // NODWP: Searching for DWP using:
1795a45d32bSGreg Clayton // NODWP: Unable to locate for DWP file for:
1805a45d32bSGreg Clayton // NODWP: unable to locate separate debug file (dwo, dwp). Debugging will be degraded.
1815a45d32bSGreg Clayton
1828a64d80aSDavid Spickett struct A {
1838a64d80aSDavid Spickett int x = 47;
1848a64d80aSDavid Spickett };
1858a64d80aSDavid Spickett A a;
main()1868a64d80aSDavid Spickett int main() {}
187