brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.5 KiB · bbf0ddf Raw
45 lines · cpp
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 dladdr5// symbolizer actually leaks memory because the call to6// `__sanitizer::DemangleCXXABI` leaks memory which LSan detects7// (rdar://problem/42868950).8 9// RUN: %clangxx_asan %s -O0 -o %t10// 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>&111// RUN: FileCheck -input-file=%t.output %s12#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: External symbolizer is explicitly disabled37// CHECK: Using dladdr symbolizer38 39// These `function_offset` patterns are designed to disallow `0x0` which is the40// 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