summaryrefslogtreecommitdiff
path: root/test/asan/TestCases
diff options
context:
space:
mode:
authorDan Liew <dan@su-root.co.uk>2019-04-26 16:54:09 +0000
committerDan Liew <dan@su-root.co.uk>2019-04-26 16:54:09 +0000
commit4a1c068085b733a4c08b5980a7967f47c3df3509 (patch)
tree70e6c0c4d34fc41a51cb08edf978505e7d992456 /test/asan/TestCases
parent1bcdbd68616dc7f8debe126caafef7a7242a0e6b (diff)
downloadcompiler-rt-4a1c068085b733a4c08b5980a7967f47c3df3509.tar.gz
[asan_symbolize] Teach `asan_symbolize.py` to symbolicate using a module map
Summary: The use case here is to be able get the UUIDs of the modules that need to be symbolicated so that external plugins can see them. This information can be extracted from ASan reports if the `print_module_map` ASan option is enabled. Currently printing of the module map is only implemented on Darwin and so this is effectively a Darwin only feature right now. The module map hooks into symbolization using the new plugin infrastructure. A new hook in `AsanSymbolizerPlugInProxy` (and in `AsanSymbolizerPlugIn`) is also provided to allow external plugins to hook into the module look up process. This will allow external plugins to look up modules with knowledge of their UUID. The new plug-in is currently stored in the `asan_symbolize.py` script. We could potentially move this into a separate file in the future (to reduce clutter) if we can come up with a policy for where to search for plugins that should always get loaded. rdar://problem/49476995 Reviewers: kubamracek, yln, samsonov, dvyukov, vitalybuka Subscribers: #sanitizers, llvm-commits Tags: #llvm, #sanitizers Differential Revision: https://reviews.llvm.org/D60531 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@359322 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/asan/TestCases')
-rw-r--r--test/asan/TestCases/Darwin/asan-symbolize-with-module-map.cc31
1 files changed, 31 insertions, 0 deletions
diff --git a/test/asan/TestCases/Darwin/asan-symbolize-with-module-map.cc b/test/asan/TestCases/Darwin/asan-symbolize-with-module-map.cc
new file mode 100644
index 000000000..4557adeb0
--- /dev/null
+++ b/test/asan/TestCases/Darwin/asan-symbolize-with-module-map.cc
@@ -0,0 +1,31 @@
+// UNSUPPORTED: ios
+// RUN: %clangxx_asan -O0 -g %s -o %t.executable
+
+// Deliberately don't produce the module map and then check that offline symbolization fails
+// when we try to look for it.
+// RUN: %env_asan_opts="symbolize=0,print_module_map=0" not %run %t.executable > %t_no_module_map.log 2>&1
+// RUN: not %asan_symbolize --module-map %t_no_module_map.log --force-system-symbolizer < %t_no_module_map.log 2>&1 | FileCheck -check-prefix=CHECK-NO-MM %s
+// CHECK-NO-MM: ERROR:{{.*}} Failed to find module map
+
+// Now produce the module map and check we can symbolize.
+// RUN: %env_asan_opts="symbolize=0,print_module_map=2" not %run %t.executable > %t_with_module_map.log 2>&1
+// RUN: %asan_symbolize --module-map %t_with_module_map.log --force-system-symbolizer < %t_with_module_map.log 2>&1 | FileCheck -check-prefix=CHECK-MM %s
+
+#include <cstdlib>
+
+// CHECK-MM: WRITE of size 4
+
+extern "C" void foo(int* a) {
+ // CHECK-MM: #0 0x{{.+}} in foo {{.*}}asan-symbolize-with-module-map.cc:[[@LINE+1]]
+ *a = 5;
+}
+
+int main() {
+ int* a = (int*) malloc(sizeof(int));
+ if (!a)
+ return 0;
+ free(a);
+ // CHECK-MM: #1 0x{{.+}} in main {{.*}}asan-symbolize-with-module-map.cc:[[@LINE+1]]
+ foo(a);
+ return 0;
+}