85 lines · cpp
1// REQUIRES: lld2 3// RUN: %clangxx %s -g -c -o %t.o --target=x86_64-pc-linux -gno-pubnames4// RUN: ld.lld %t.o -o %t5// RUN: lldb-test symbols --name=foo --find=variable --context=context %t | \6// RUN: FileCheck --check-prefix=CONTEXT %s7// RUN: lldb-test symbols --name=foo --find=variable %t | \8// RUN: FileCheck --check-prefix=NAME %s9// RUN: lldb-test symbols --regex --name=foo --find=variable %t | \10// RUN: FileCheck --check-prefix=REGEX %s11// RUN: lldb-test symbols --name=not_there --find=variable %t | \12// RUN: FileCheck --check-prefix=EMPTY %s13//14// RUN: %clangxx %s -g -c -o %t --target=x86_64-apple-macosx15// RUN: lldb-test symbols --name=foo --find=variable --context=context %t | \16// RUN: FileCheck --check-prefix=CONTEXT %s17// RUN: lldb-test symbols --name=foo --find=variable %t | \18// RUN: FileCheck --check-prefix=NAME %s19// RUN: lldb-test symbols --regex --name=foo --find=variable %t | \20// RUN: FileCheck --check-prefix=REGEX %s21// RUN: lldb-test symbols --name=not_there --find=variable %t | \22// RUN: FileCheck --check-prefix=EMPTY %s23//24// RUN: %clangxx %s -g -c -o %t.o --target=x86_64-pc-linux -gdwarf-5 -gpubnames25// RUN: ld.lld %t.o -o %t26// RUN: llvm-readobj --sections %t | FileCheck %s --check-prefix NAMES27// RUN: lldb-test symbols --name=foo --find=variable --context=context %t | \28// RUN: FileCheck --check-prefix=CONTEXT %s29// RUN: lldb-test symbols --name=foo --find=variable %t | \30// RUN: FileCheck --check-prefix=NAME %s31// RUN: lldb-test symbols --regex --name=foo --find=variable %t | \32// RUN: FileCheck --check-prefix=REGEX %s33// RUN: lldb-test symbols --name=not_there --find=variable %t | \34// RUN: FileCheck --check-prefix=EMPTY %s35 36/// Test a per-module index built by lld.37// RUN: ld.lld --debug-names %t.o -o %t38// RUN: lldb-test symbols --name=foo --find=variable --context=context %t | \39// RUN: FileCheck --check-prefix=CONTEXT %s40 41// NAMES: Name: .debug_names42 43// EMPTY: Found 0 variables:44// NAME: Found 4 variables:45// CONTEXT: Found 1 variables:46// REGEX: Found 5 variables:47int 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]]50namespace bar {51int context;52long 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]]56namespace baz {57static 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 63struct 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};68int sbar::foo;69 70int foobar;71// REGEX-DAG: name = "foobar", type = {{.*}} (int), {{.*}} decl = find-basic-variable.cpp:[[@LINE-1]]72 73int fbar() {74 static int foo;75 return foo + bar::baz::foo;76}77 78int Foo;79 80struct ssbar {81 int foo;82};83 84extern "C" void _start(sbar, ssbar) {}85