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