Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / test / sanitizer_common / TestCases / Darwin / symbolizer-function-offset-atos.cpp
blobda1bf2cdcf2520c68f4d4a47807337e284d090d5
1 // RUN: %clangxx %s -g -O0 -o %t-with-debug
3 // With debug info atos reports the source location, but no function offset. We fallback to dladdr() to retrieve the function offset.
4 // RUN: %env_tool_opts=verbosity=2,stack_trace_format='"function_name:%f function_offset:%q"' %run %t-with-debug > %t-with-debug.output 2>&1
5 // RUN: FileCheck -input-file=%t-with-debug.output %s
7 // Without debug info atos reports the function offset and so dladdr() fallback is not used.
8 // RUN: rm -rf %t-with-debug.dSYM
9 // RUN: %env_tool_opts=verbosity=2,stack_trace_format='"function_name:%f function_offset:%q"' %run %t-with-debug > %t-no-debug.output 2>&1
10 // RUN: FileCheck -input-file=%t-no-debug.output %s
12 #include <sanitizer/common_interface_defs.h>
13 #include <stdio.h>
15 void baz() {
16 printf("Do stuff in baz\n");
17 __sanitizer_print_stack_trace();
20 void bar() {
21 printf("Do stuff in bar\n");
22 baz();
25 void foo() {
26 printf("Do stuff in foo\n");
27 bar();
30 int main() {
31 printf("Do stuff in main\n");
32 foo();
33 return 0;
36 // CHECK: Using atos found at:
38 // These `function_offset` patterns are designed to disallow `0x0` which is the
39 // value printed for `kUnknown`.
40 // CHECK: function_name:baz{{(\(\))?}} function_offset:0x{{0*[1-9a-f][0-9a-f]*$}}
41 // CHECK: function_name:bar{{(\(\))?}} function_offset:0x{{0*[1-9a-f][0-9a-f]*$}}
42 // CHECK: function_name:foo{{(\(\))?}} function_offset:0x{{0*[1-9a-f][0-9a-f]*$}}
43 // CHECK: function_name:main{{(\(\))?}} function_offset:0x{{0*[1-9a-f][0-9a-f]*$}}