|
| 1 | +// When `external_symbolizer_path` is empty on Darwin we fallback on using |
| 2 | +// dladdr as the symbolizer which means we get the symbol name |
| 3 | +// but no source location. The current implementation also doesn't try to |
| 4 | +// change the module name so we end up with the full name so we actually don't |
| 5 | +// need the module map here. |
| 6 | + |
| 7 | +// RUN: %clangxx_asan -O0 -g %s -o %t.executable |
| 8 | +// RUN: %env_asan_opts=symbolize=1,print_module_map=0,external_symbolizer_path= not %run %t.executable > %t2.log 2>&1 |
| 9 | +// RUN: FileCheck -input-file=%t2.log -check-prefix=CHECK-PS %s |
| 10 | +// RUN: %asan_symbolize --force-system-symbolizer < %t2.log > %t2.fully_symbolized |
| 11 | +// RUN: FileCheck -input-file=%t2.fully_symbolized -check-prefix=CHECK-FS %s |
| 12 | + |
| 13 | +// Due a quirk in the way atos reports module names we have to use the module |
| 14 | +// map here, otherwise we don't know what the full path to the module is. |
| 15 | + |
| 16 | +// FIXME(dliew): We currently have to use module map for this test due to the atos |
| 17 | +// symbolizer changing the module name from an absolute path to just the file name. |
| 18 | +// rdar://problem/49784442 |
| 19 | +// |
| 20 | +// Simulate partial symbolication (can happen with %L specifier) by printing |
| 21 | +// out %L's fallback which will print the module name and offset instead of a |
| 22 | +// source location. |
| 23 | +// RUN: %clangxx_asan -O0 -g %s -o %t2.executable |
| 24 | +// RUN: %env_asan_opts=symbolize=1,print_module_map=1,stack_trace_format='" #%%n %%p %%F %%M"' not %run %t.executable > %t2.log 2>&1 |
| 25 | +// RUN: FileCheck -input-file=%t2.log -check-prefix=CHECK-PS %s |
| 26 | +// Now try to full symbolicate using the module map. |
| 27 | +// RUN: %asan_symbolize --module-map %t2.log --force-system-symbolizer < %t2.log > %t2.fully_symbolized |
| 28 | +// RUN: FileCheck -input-file=%t2.fully_symbolized -check-prefix=CHECK-FS %s |
| 29 | + |
| 30 | +#include <cstdlib> |
| 31 | + |
| 32 | +// Partially symbolicated back-trace where symbol is available but |
| 33 | +// source location is not and instead module name and offset are |
| 34 | +// printed. |
| 35 | +// CHECK-PS: WRITE of size 4 |
| 36 | +// CHECK-PS: #0 0x{{.+}} in foo ({{.+}}.executable:{{.+}}+0x{{.+}}) |
| 37 | +// CHECK-PS: #1 0x{{.+}} in main ({{.+}}.executable:{{.+}}+0x{{.+}}) |
| 38 | + |
| 39 | +// CHECK-FS: WRITE of size 4 |
| 40 | + |
| 41 | +extern "C" void foo(int* a) { |
| 42 | + // CHECK-FS: #0 0x{{.+}} in foo {{.*}}asan-symbolize-partial-report-with-module-map.cc:[[@LINE+1]] |
| 43 | + *a = 5; |
| 44 | +} |
| 45 | + |
| 46 | +int main() { |
| 47 | + int* a = (int*) malloc(sizeof(int)); |
| 48 | + if (!a) |
| 49 | + return 0; |
| 50 | + free(a); |
| 51 | + // CHECK-FS: #1 0x{{.+}} in main {{.*}}asan-symbolize-partial-report-with-module-map.cc:[[@LINE+1]] |
| 52 | + foo(a); |
| 53 | + return 0; |
| 54 | +} |
0 commit comments