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=function --function-flags=base %t | \
6 // RUN:   FileCheck --check-prefix=BASE %s
7 // RUN: lldb-test symbols --name=foo --find=function --function-flags=method %t | \
8 // RUN:   FileCheck --check-prefix=METHOD %s
9 // RUN: lldb-test symbols --name=foo --find=function --function-flags=full %t | \
10 // RUN:   FileCheck --check-prefix=FULL %s
11 // RUN: lldb-test symbols --name=_Z3fooi --find=function --function-flags=full %t | \
12 // RUN:   FileCheck --check-prefix=FULL-MANGLED %s
13 // RUN: lldb-test symbols --name=foo --context=context --find=function --function-flags=base %t | \
14 // RUN:   FileCheck --check-prefix=CONTEXT %s
15 // RUN: lldb-test symbols --name=not_there --find=function %t | \
16 // RUN:   FileCheck --check-prefix=EMPTY %s
17 //
18 // RUN: %clang %s -g -c -o %t --target=x86_64-apple-macosx
19 // RUN: lldb-test symbols --name=foo --find=function --function-flags=base %t | \
20 // RUN:   FileCheck --check-prefix=BASE %s
21 // RUN: lldb-test symbols --name=foo --find=function --function-flags=method %t | \
22 // RUN:   FileCheck --check-prefix=METHOD %s
23 // RUN: lldb-test symbols --name=foo --find=function --function-flags=full %t | \
24 // RUN:   FileCheck --check-prefix=FULL-INDEXED %s
25 // RUN: lldb-test symbols --name=_Z3fooi --find=function --function-flags=full %t | \
26 // RUN:   FileCheck --check-prefix=FULL-MANGLED %s
27 // RUN: lldb-test symbols --name=foo --context=context --find=function --function-flags=base %t | \
28 // RUN:   FileCheck --check-prefix=CONTEXT %s
29 // RUN: lldb-test symbols --name=not_there --find=function %t | \
30 // RUN:   FileCheck --check-prefix=EMPTY %s
31 
32 // RUN: %clang %s -c -o %t.o --target=x86_64-pc-linux -gdwarf-5 -gpubnames
33 // RUN: ld.lld %t.o -o %t
34 // RUN: llvm-readobj --sections %t | FileCheck %s --check-prefix NAMES
35 // RUN: lldb-test symbols --name=foo --find=function --function-flags=base %t | \
36 // RUN:   FileCheck --check-prefix=BASE %s
37 // RUN: lldb-test symbols --name=foo --find=function --function-flags=method %t | \
38 // RUN:   FileCheck --check-prefix=METHOD %s
39 // RUN: lldb-test symbols --name=foo --find=function --function-flags=full %t | \
40 // RUN:   FileCheck --check-prefix=FULL-INDEXED %s
41 // RUN: lldb-test symbols --name=_Z3fooi --find=function --function-flags=full %t | \
42 // RUN:   FileCheck --check-prefix=FULL-MANGLED %s
43 // RUN: lldb-test symbols --name=foo --context=context --find=function --function-flags=base %t | \
44 // RUN:   FileCheck --check-prefix=CONTEXT %s
45 // RUN: lldb-test symbols --name=not_there --find=function %t | \
46 // RUN:   FileCheck --check-prefix=EMPTY %s
47 
48 // NAMES: Name: .debug_names
49 
50 // BASE: Found 4 functions:
51 // BASE-DAG: name = "foo()", mangled = "_Z3foov"
52 // BASE-DAG: name = "foo(int)", mangled = "_Z3fooi"
53 // BASE-DAG: name = "bar::foo()", mangled = "_ZN3bar3fooEv"
54 // BASE-DAG: name = "bar::baz::foo()", mangled = "_ZN3bar3baz3fooEv"
55 
56 // METHOD: Found 3 functions:
57 // METHOD-DAG: name = "sbar::foo()", mangled = "_ZN4sbar3fooEv"
58 // METHOD-DAG: name = "sbar::foo(int)", mangled = "_ZN4sbar3fooEi"
59 // METHOD-DAG: name = "ffbar()::sbaz::foo()", mangled = "_ZZ5ffbarvEN4sbaz3fooEv"
60 
61 // FULL-INDEXED: Found 7 functions:
62 // FULL-INDEXED-DAG: name = "foo()", mangled = "_Z3foov"
63 // FULL-INDEXED-DAG: name = "foo(int)", mangled = "_Z3fooi"
64 // FULL-INDEXED-DAG: name = "bar::foo()", mangled = "_ZN3bar3fooEv"
65 // FULL-INDEXED-DAG: name = "bar::baz::foo()", mangled = "_ZN3bar3baz3fooEv"
66 // FULL-INDEXED-DAG: name = "sbar::foo()", mangled = "_ZN4sbar3fooEv"
67 // FULL-INDEXED-DAG: name = "sbar::foo(int)", mangled = "_ZN4sbar3fooEi"
68 // FULL-INDEXED-DAG: name = "ffbar()::sbaz::foo()", mangled = "_ZZ5ffbarvEN4sbaz3fooEv"
69 
70 // FULL: Found 0 functions:
71 
72 // FULL-MANGLED: Found 1 functions:
73 // FULL-MANGLED-DAG: name = "foo(int)", mangled = "_Z3fooi"
74 
75 // CONTEXT: Found 1 functions:
76 // CONTEXT-DAG: name = "bar::foo()", mangled = "_ZN3bar3fooEv"
77 
78 // EMPTY: Found 0 functions:
79 
80 void foo() {}
81 void foo(int) {}
82 
83 namespace bar {
84 int context;
85 void foo() {}
86 namespace baz {
87 void foo() {}
88 } // namespace baz
89 } // namespace bar
90 
91 struct foo {};
92 void fbar(struct foo) {}
93 
94 void Foo() {}
95 
96 struct sbar {
97   void foo();
98   static void foo(int);
99 };
100 void sbar::foo() {}
101 void sbar::foo(int) {}
102 
103 void ffbar() {
104   struct sbaz {
105     void foo() {}
106   };
107   sbaz a;
108   a.foo();
109 }
110 
111 extern "C" void _start() {}
112