1// UNSUPPORTED: ios
2// When `external_symbolizer_path` is empty on Darwin we fallback on using
3// dladdr as the symbolizer which means we get the symbol name
4// but no source location. The current implementation also doesn't try to
5// change the module name so we end up with the full name so we actually don't
6// need the module map here.
7
8// RUN: %clangxx_asan -O0 -g %s -o %t.executable
9// RUN: %env_asan_opts=symbolize=1,print_module_map=0,external_symbolizer_path= not %run %t.executable > %t2.log 2>&1
10// RUN: FileCheck -input-file=%t2.log -check-prefix=CHECK-PS %s
11// RUN: %asan_symbolize --force-system-symbolizer < %t2.log > %t2.fully_symbolized
12// RUN: FileCheck -input-file=%t2.fully_symbolized -check-prefix=CHECK-FS %s
13
14#include <cstdlib>
15
16// Partially symbolicated back-trace where symbol is available but
17// source location is not and instead module name and offset are
18// printed.
19// CHECK-PS: WRITE of size 4
20// CHECK-PS: #0 0x{{.+}} in foo{{(\+0x[0-9a-f]+)?}} ({{.+}}.executable:{{.+}}+0x{{.+}})
21// CHECK-PS: #1 0x{{.+}} in main{{(\+0x[0-9a-f]+)?}} ({{.+}}.executable:{{.+}}+0x{{.+}})
22
23// CHECK-FS: WRITE of size 4
24
25extern "C" void foo(int* a) {
26 // CHECK-FS: #0 0x{{.+}} in foo {{.*}}asan-symbolize-partial-report-no-external-symbolizer.cpp:[[@LINE+1]]
27 *a = 5;
28}
29
30int main() {
31 int* a = (int*) malloc(size: sizeof(int));
32 if (!a)
33 return 0;
34 free(ptr: a);
35 // CHECK-FS: #1 0x{{.+}} in main {{.*}}asan-symbolize-partial-report-no-external-symbolizer.cpp:[[@LINE+1]]
36 foo(a);
37 return 0;
38}
39

source code of compiler-rt/test/asan/TestCases/Darwin/asan-symbolize-partial-report-no-external-symbolizer.cpp