1// RUN: %clangxx -O0 %s -o %t && %env_tool_opts=stack_trace_format=DEFAULT %run %t 2>&1 | FileCheck %s
2// RUN: %env_tool_opts=stack_trace_format='"frame:%n lineno:%l"' %run %t 2>&1 | FileCheck %s --check-prefix=CUSTOM
3
4#include <sanitizer/common_interface_defs.h>
5
6static inline void FooBarBaz() {
7 __sanitizer_print_stack_trace();
8}
9
10int main() {
11 FooBarBaz();
12 return 0;
13}
14// CHECK: {{ #0 0x.* in __sanitizer_print_stack_trace}}
15// CHECK: {{ #1 0x.* in FooBarBaz(\(\))? .*}}print-stack-trace.cpp:[[@LINE-8]]
16// CHECK: {{ #2 0x.* in main.*}}print-stack-trace.cpp:[[@LINE-5]]
17
18// CUSTOM: frame:1 lineno:[[@LINE-11]]
19// CUSTOM: frame:2 lineno:[[@LINE-8]]
20

source code of compiler-rt/test/sanitizer_common/TestCases/Darwin/print-stack-trace.cpp