brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.5 KiB · da1bf2c Raw
44 lines · cpp
1// RUN: %clangxx %s -g -O0 -o %t-with-debug2 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>&15// RUN: FileCheck -input-file=%t-with-debug.output %s6 7// Without debug info atos reports the function offset and so dladdr() fallback is not used.8// RUN: rm -rf %t-with-debug.dSYM9// RUN: %env_tool_opts=verbosity=2,stack_trace_format='"function_name:%f function_offset:%q"' %run %t-with-debug > %t-no-debug.output 2>&110// RUN: FileCheck -input-file=%t-no-debug.output %s11 12#include <sanitizer/common_interface_defs.h>13#include <stdio.h>14 15void baz() {16  printf("Do stuff in baz\n");17  __sanitizer_print_stack_trace();18}19 20void bar() {21  printf("Do stuff in bar\n");22  baz();23}24 25void foo() {26  printf("Do stuff in foo\n");27  bar();28}29 30int main() {31  printf("Do stuff in main\n");32  foo();33  return 0;34}35 36// CHECK: Using atos found at:37 38// These `function_offset` patterns are designed to disallow `0x0` which is the39// 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]*$}}44