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).
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).
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>
16 printf("Do stuff in baz\n");
17 __sanitizer_print_stack_trace();
21 printf("Do stuff in bar\n");
26 printf("Do stuff in foo\n");
31 printf("Do stuff in main\n");
36 // CHECK: External symbolizer is explicitly disabled
37 // CHECK: Using dladdr symbolizer
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]*$}}