| 1 | // REQUIRES: lld |
| 2 | |
| 3 | // RUN: %clang %s -g -c -o %t.o --target=x86_64-pc-linux -gno-pubnames |
| 4 | // RUN: ld.lld %t.o -o %t |
| 5 | // RUN: lldb-test symbols --name=foo --find=variable --context=context %t | \ |
| 6 | // RUN: FileCheck --check-prefix=CONTEXT %s |
| 7 | // RUN: lldb-test symbols --name=foo --find=variable %t | \ |
| 8 | // RUN: FileCheck --check-prefix=NAME %s |
| 9 | // RUN: lldb-test symbols --regex --name=foo --find=variable %t | \ |
| 10 | // RUN: FileCheck --check-prefix=REGEX %s |
| 11 | // RUN: lldb-test symbols --name=not_there --find=variable %t | \ |
| 12 | // RUN: FileCheck --check-prefix=EMPTY %s |
| 13 | // |
| 14 | // RUN: %clang %s -g -c -o %t --target=x86_64-apple-macosx |
| 15 | // RUN: lldb-test symbols --name=foo --find=variable --context=context %t | \ |
| 16 | // RUN: FileCheck --check-prefix=CONTEXT %s |
| 17 | // RUN: lldb-test symbols --name=foo --find=variable %t | \ |
| 18 | // RUN: FileCheck --check-prefix=NAME %s |
| 19 | // RUN: lldb-test symbols --regex --name=foo --find=variable %t | \ |
| 20 | // RUN: FileCheck --check-prefix=REGEX %s |
| 21 | // RUN: lldb-test symbols --name=not_there --find=variable %t | \ |
| 22 | // RUN: FileCheck --check-prefix=EMPTY %s |
| 23 | // |
| 24 | // RUN: %clang %s -g -c -o %t.o --target=x86_64-pc-linux -gdwarf-5 -gpubnames |
| 25 | // RUN: ld.lld %t.o -o %t |
| 26 | // RUN: llvm-readobj --sections %t | FileCheck %s --check-prefix NAMES |
| 27 | // RUN: lldb-test symbols --name=foo --find=variable --context=context %t | \ |
| 28 | // RUN: FileCheck --check-prefix=CONTEXT %s |
| 29 | // RUN: lldb-test symbols --name=foo --find=variable %t | \ |
| 30 | // RUN: FileCheck --check-prefix=NAME %s |
| 31 | // RUN: lldb-test symbols --regex --name=foo --find=variable %t | \ |
| 32 | // RUN: FileCheck --check-prefix=REGEX %s |
| 33 | // RUN: lldb-test symbols --name=not_there --find=variable %t | \ |
| 34 | // RUN: FileCheck --check-prefix=EMPTY %s |
| 35 | |
| 36 | /// Test a per-module index built by lld. |
| 37 | // RUN: ld.lld --debug-names %t.o -o %t |
| 38 | // RUN: lldb-test symbols --name=foo --find=variable --context=context %t | \ |
| 39 | // RUN: FileCheck --check-prefix=CONTEXT %s |
| 40 | |
| 41 | // NAMES: Name: .debug_names |
| 42 | |
| 43 | // EMPTY: Found 0 variables: |
| 44 | // NAME: Found 4 variables: |
| 45 | // CONTEXT: Found 1 variables: |
| 46 | // REGEX: Found 5 variables: |
| 47 | int foo; |
| 48 | // NAME-DAG: name = "foo", type = {{.*}} (int), {{.*}} decl = find-basic-variable.cpp:[[@LINE-1]] |
| 49 | // REGEX-DAG: name = "foo", type = {{.*}} (int), {{.*}} decl = find-basic-variable.cpp:[[@LINE-2]] |
| 50 | namespace bar { |
| 51 | int context; |
| 52 | long foo; |
| 53 | // NAME-DAG: name = "foo", type = {{.*}} (long), {{.*}} decl = find-basic-variable.cpp:[[@LINE-1]] |
| 54 | // CONTEXT-DAG: name = "foo", type = {{.*}} (long), {{.*}} decl = find-basic-variable.cpp:[[@LINE-2]] |
| 55 | // REGEX-DAG: name = "foo", type = {{.*}} (long), {{.*}} decl = find-basic-variable.cpp:[[@LINE-3]] |
| 56 | namespace baz { |
| 57 | static short foo; |
| 58 | // NAME-DAG: name = "foo", type = {{.*}} (short), {{.*}} decl = find-basic-variable.cpp:[[@LINE-1]] |
| 59 | // REGEX-DAG: name = "foo", type = {{.*}} (short), {{.*}} decl = find-basic-variable.cpp:[[@LINE-2]] |
| 60 | } |
| 61 | } |
| 62 | |
| 63 | struct sbar { |
| 64 | static int foo; |
| 65 | // NAME-DAG: name = "foo", type = {{.*}} (int), {{.*}} decl = find-basic-variable.cpp:[[@LINE-1]] |
| 66 | // REGEX-DAG: name = "foo", type = {{.*}} (int), {{.*}} decl = find-basic-variable.cpp:[[@LINE-2]] |
| 67 | }; |
| 68 | int sbar::foo; |
| 69 | |
| 70 | int foobar; |
| 71 | // REGEX-DAG: name = "foobar", type = {{.*}} (int), {{.*}} decl = find-basic-variable.cpp:[[@LINE-1]] |
| 72 | |
| 73 | int fbar() { |
| 74 | static int foo; |
| 75 | return foo + bar::baz::foo; |
| 76 | } |
| 77 | |
| 78 | int Foo; |
| 79 | |
| 80 | struct ssbar { |
| 81 | int foo; |
| 82 | }; |
| 83 | |
| 84 | extern "C" void _start(sbar, ssbar) {} |
| 85 | |