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 # Symbol may be combined with offset.
38 RUN: llvm-symbolizer --obj=%p/Inputs/symbols.so func_01+0 | FileCheck --check-prefix=SYMLINE0 %s
39 RUN: llvm-addr2line -e %p/Inputs/symbols.so func_01+0 | FileCheck --check-prefix=SYMLINE0 %s
40 SYMLINE0: /tmp/dbginfo{{[/\]+}}symbols.part1.cpp:12
42 RUN: llvm-symbolizer --obj=%p/Inputs/symbols.so func_01+12 | FileCheck --check-prefix=SYMLINE1 %s
43 RUN: llvm-addr2line -e %p/Inputs/symbols.so func_01+12 | FileCheck --check-prefix=SYMLINE1 %s
44 SYMLINE1: /tmp/dbginfo{{[/\]+}}symbols.part1.cpp:13
46 RUN: llvm-symbolizer --obj=%p/Inputs/symbols.so func_01+19 | FileCheck --check-prefix=SYMLINE2 %s
47 RUN: llvm-addr2line -e %p/Inputs/symbols.so func_01+19 | FileCheck --check-prefix=SYMLINE2 %s
48 SYMLINE2: /tmp/dbginfo{{[/\]+}}symbols.part1.cpp:14
50 # Offset can be specified with various bases.
51 RUN: llvm-symbolizer --obj=%p/Inputs/symbols.so func_01+0x0C | FileCheck --check-prefix=SYMLINE1 %s
52 RUN: llvm-addr2line -e %p/Inputs/symbols.so func_01+0x0C | FileCheck --check-prefix=SYMLINE1 %s
54 RUN: llvm-symbolizer --obj=%p/Inputs/symbols.so func_01+014 | FileCheck --check-prefix=SYMLINE1 %s
55 RUN: llvm-addr2line -e %p/Inputs/symbols.so func_01+014 | FileCheck --check-prefix=SYMLINE1 %s
57 # If '+' is not followed by a number, it is part of the symbol name, not an offset separator.
58 RUN: llvm-symbolizer --obj=%p/Inputs/symbols.so func_01+ | FileCheck --check-prefix=NONEXISTENT %s
59 RUN: llvm-addr2line --obj=%p/Inputs/symbols.so func_01+ | FileCheck --check-prefix=NONEXISTENT %s
61 RUN: llvm-symbolizer --obj=%p/Inputs/symbols.so func_01+abc | FileCheck --check-prefix=NONEXISTENT %s
62 RUN: llvm-addr2line --obj=%p/Inputs/symbols.so func_01+abc | FileCheck --check-prefix=NONEXISTENT %s
64 RUN: llvm-symbolizer --obj=%p/Inputs/symbols.so func_01+0A | FileCheck --check-prefix=NONEXISTENT %s
65 RUN: llvm-addr2line --obj=%p/Inputs/symbols.so func_01+0A | FileCheck --check-prefix=NONEXISTENT %s
67 # If '+' is not preceded by a symbol, it is part of a symbol name, not an offset separator.
68 RUN: llvm-symbolizer --obj=%p/Inputs/symbols.so +0x1138 | FileCheck --check-prefix=NONEXISTENT %s
69 RUN: llvm-addr2line --obj=%p/Inputs/symbols.so +0x1138 | FileCheck --check-prefix=NONEXISTENT %s
71 # Show that C++ mangled names may be specified.
72 RUN: llvm-addr2line --obj=%p/Inputs/symbols.so _ZL14static_func_01i | FileCheck --check-prefix=MULTI-CXX %s
73 RUN: llvm-symbolizer --obj=%p/Inputs/symbols.so _ZL14static_func_01i | FileCheck --check-prefix=MULTI-CXX %s
74 MULTI-CXX: /tmp/dbginfo{{[/\]+}}symbols.part1.cpp:7
75 MULTI-CXX: /tmp/dbginfo{{[/\]+}}symbols.part2.cpp:5
77 # Show that containing function name can be printed in mangled form.
78 RUN: llvm-symbolizer --obj=%p/Inputs/symbols.so --no-demangle _Z7func_04i | FileCheck --check-prefix=MANGLED %s
79 RUN: llvm-addr2line --obj=%p/Inputs/symbols.so -f _Z7func_04i | FileCheck --check-prefix=MANGLED %s
81 MANGLED-NEXT: /tmp/dbginfo{{[/\]+}}symbols.part1.cpp:22
83 # Show that containing function name can be printed in demangled form.
84 RUN: llvm-symbolizer --obj=%p/Inputs/symbols.so _Z7func_04i | FileCheck --check-prefix=NOTMANGLED %s
85 RUN: llvm-addr2line --obj=%p/Inputs/symbols.so -f --demangle _Z7func_04i | FileCheck --check-prefix=NOTMANGLED %s
86 NOTMANGLED: func_04(int)
87 NOTMANGLED-NEXT: /tmp/dbginfo{{[/\]+}}symbols.part1.cpp:22
89 # Show that both the symbol and input file can be specified in the search string on the command-line.
90 RUN: llvm-addr2line "%p/Inputs/symbols.so func_01" | FileCheck --check-prefix=SYMBIN %s
91 RUN: llvm-symbolizer "%p/Inputs/symbols.so func_01" | FileCheck --check-prefix=SYMBIN %s
92 SYMBIN: /tmp/dbginfo{{[/\]+}}symbols.part1.cpp:12
94 # Show that the case of missing input file specified in the search string on the command-line is properly treated.
95 RUN: llvm-addr2line "%p/Inputs/666.so func_01" 2> %t.1.stderr | FileCheck --check-prefix=NONEXISTENT %s
96 RUN: FileCheck --input-file=%t.1.stderr --check-prefix=BINARY-NOT-FOUND -DMSG=%errc_ENOENT %s
97 RUN: llvm-symbolizer "%p/Inputs/666.so func_01" 2> %t.2.stderr | FileCheck --check-prefix=NONEXISTENT %s
98 RUN: FileCheck --input-file=%t.2.stderr --check-prefix=BINARY-NOT-FOUND -DMSG=%errc_ENOENT %s
99 BINARY-NOT-FOUND: error: '{{.*}}666.so': [[MSG]]