1 # This test checks the case when an address is specified by a symbol name rather
4 # It uses ELF shared object `Inputs/symbols.so` built for x86_64 using
5 # the instructions from `Inputs/symbols.h`.
7 # Show that the "CODE" command supports search by symbol name.
8 RUN: llvm-addr2line --obj=%p/Inputs/symbols.so "CODE func_01" | FileCheck --check-prefix=CODE-CMD %s
9 RUN: llvm-symbolizer --obj=%p/Inputs/symbols.so "CODE func_01" | FileCheck --check-prefix=CODE-CMD %s
10 CODE-CMD: /tmp/dbginfo{{[/\]+}}symbols.part1.cpp:12
12 # Check if a symbol name can be specified on the command-line.
13 RUN: llvm-addr2line -e %p/Inputs/symbols.so func_01 | FileCheck --check-prefix=SYMB %s
14 RUN: llvm-symbolizer -e %p/Inputs/symbols.so func_01 | FileCheck --check-prefix=SYMB %s
15 SYMB: /tmp/dbginfo{{[/\]+}}symbols.part1.cpp:12
17 # Check that if a symbol has a space in its name, ignore everything from the space onwards.
18 RUN: llvm-addr2line -e %p/Inputs/symbols.so "func_01 ignored text" | FileCheck --check-prefix=SYMB %s
19 RUN: llvm-symbolizer -e %p/Inputs/symbols.so "func_01 ignored text" | FileCheck --check-prefix=SYMB %s
21 # Show that a symbol name may be resolved to more than one location.
22 RUN: llvm-addr2line -e %p/Inputs/symbols.so static_func | FileCheck --check-prefix=SYMB-MULTI %s
23 SYMB-MULTI: /tmp/dbginfo{{[/\]+}}symbols.part3.c:4
24 SYMB-MULTI-NEXT: /tmp/dbginfo{{[/\]+}}symbols.part4.c:4
26 # Show that if a symbol is not found, a special mark is printed.
27 RUN: llvm-addr2line --obj=%p/Inputs/symbols.so func_666 | FileCheck --check-prefix=NONEXISTENT %s
28 RUN: llvm-symbolizer --obj=%p/Inputs/symbols.so func_666 | FileCheck --check-prefix=NONEXISTENT %s
31 # Show that more than one symbol may be specified.
32 RUN: llvm-addr2line --obj=%p/Inputs/symbols.so func_01 func_02 | FileCheck --check-prefix=FUNCS %s
33 RUN: llvm-symbolizer --obj=%p/Inputs/symbols.so func_01 func_02 | FileCheck --check-prefix=FUNCS %s
34 FUNCS: /tmp/dbginfo{{[/\]+}}symbols.part1.cpp:12
35 FUNCS: /tmp/dbginfo{{[/\]+}}symbols.part2.cpp:10
37 # Show that C++ mangled names may be specified.
38 RUN: llvm-addr2line --obj=%p/Inputs/symbols.so _ZL14static_func_01i | FileCheck --check-prefix=MULTI-CXX %s
39 RUN: llvm-symbolizer --obj=%p/Inputs/symbols.so _ZL14static_func_01i | FileCheck --check-prefix=MULTI-CXX %s
40 MULTI-CXX: /tmp/dbginfo{{[/\]+}}symbols.part1.cpp:7
41 MULTI-CXX: /tmp/dbginfo{{[/\]+}}symbols.part2.cpp:5
43 # Show that containing function name can be printed in mangled form.
44 RUN: llvm-symbolizer --obj=%p/Inputs/symbols.so --no-demangle _Z7func_04i | FileCheck --check-prefix=MANGLED %s
45 RUN: llvm-addr2line --obj=%p/Inputs/symbols.so -f _Z7func_04i | FileCheck --check-prefix=MANGLED %s
47 MANGLED-NEXT: /tmp/dbginfo{{[/\]+}}symbols.part1.cpp:22
49 # Show that containing function name can be printed in demangled form.
50 RUN: llvm-symbolizer --obj=%p/Inputs/symbols.so _Z7func_04i | FileCheck --check-prefix=NOTMANGLED %s
51 RUN: llvm-addr2line --obj=%p/Inputs/symbols.so -f --demangle _Z7func_04i | FileCheck --check-prefix=NOTMANGLED %s
52 NOTMANGLED: func_04(int)
53 NOTMANGLED-NEXT: /tmp/dbginfo{{[/\]+}}symbols.part1.cpp:22
55 # Show that both the symbol and input file can be specified in the search string on the command-line.
56 RUN: llvm-addr2line "%p/Inputs/symbols.so func_01" | FileCheck --check-prefix=SYMBIN %s
57 RUN: llvm-symbolizer "%p/Inputs/symbols.so func_01" | FileCheck --check-prefix=SYMBIN %s
58 SYMBIN: /tmp/dbginfo{{[/\]+}}symbols.part1.cpp:12
60 # Show that the case of missing input file specified in the search string on the command-line is properly treated.
61 RUN: llvm-addr2line "%p/Inputs/666.so func_01" 2> %t.1.stderr | FileCheck --check-prefix=NONEXISTENT %s
62 RUN: FileCheck --input-file=%t.1.stderr --check-prefix=BINARY-NOT-FOUND -DMSG=%errc_ENOENT %s
63 RUN: llvm-symbolizer "%p/Inputs/666.so func_01" 2> %t.2.stderr | FileCheck --check-prefix=NONEXISTENT %s
64 RUN: FileCheck --input-file=%t.2.stderr --check-prefix=BINARY-NOT-FOUND -DMSG=%errc_ENOENT %s
65 BINARY-NOT-FOUND: error: '{{.*}}666.so': [[MSG]]