1 // FIXME(dliew): Duplicated from `test/sanitizer_common/TestCases/Darwin/symbolizer-function-offset-dladdr.cpp`.
2 // This case can be dropped once sanitizer_common tests work on iOS devices (rdar://problem/47333049).
3
4 // NOTE: `detect_leaks=0` is necessary because with LSan enabled the dladdr
5 // symbolizer actually leaks memory because the call to
6 // `__sanitizer::DemangleCXXABI` leaks memory which LSan detects
7 // (rdar://problem/42868950).
8
9 // RUN: %clangxx_asan %s -O0 -o %t
10 // RUN: %env_asan_opts=detect_leaks=0,verbosity=2,external_symbolizer_path=,stack_trace_format='"function_name_%f___function_offset_%q"' %run %t > %t.output 2>&1
11 // RUN: FileCheck -input-file=%t.output %s
12 #include <sanitizer/common_interface_defs.h>
13 #include <stdio.h>
14
baz()15 void baz() {
16 printf("Do stuff in baz\n");
17 __sanitizer_print_stack_trace();
18 }
19
bar()20 void bar() {
21 printf("Do stuff in bar\n");
22 baz();
23 }
24
foo()25 void foo() {
26 printf("Do stuff in foo\n");
27 bar();
28 }
29
main()30 int main() {
31 printf("Do stuff in main\n");
32 foo();
33 return 0;
34 }
35
36 // CHECK: External symbolizer is explicitly disabled
37 // CHECK: Using dladdr symbolizer
38
39 // These `function_offset` patterns are designed to disallow `0x0` which is the
40 // value printed for `kUnknown`.
41 // CHECK: function_name_baz{{(\(\))?}}___function_offset_0x{{0*[1-9a-f][0-9a-f]*$}}
42 // CHECK: function_name_bar{{(\(\))?}}___function_offset_0x{{0*[1-9a-f][0-9a-f]*$}}
43 // CHECK: function_name_foo{{(\(\))?}}___function_offset_0x{{0*[1-9a-f][0-9a-f]*$}}
44 // CHECK: function_name_main{{(\(\))?}}___function_offset_0x{{0*[1-9a-f][0-9a-f]*$}}
45