[PATCH] D60806: [HWASan] Added no-FP unit test for register dump.

Mitch Phillips via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 16 17:54:44 PDT 2019


hctim updated this revision to Diff 195496.
hctim marked 4 inline comments as done.
hctim added a comment.

Address @pcc and @eugenis comments.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D60806/new/

https://reviews.llvm.org/D60806

Files:
  compiler-rt/test/hwasan/TestCases/register-dump-no-fp.cc


Index: compiler-rt/test/hwasan/TestCases/register-dump-no-fp.cc
===================================================================
--- /dev/null
+++ compiler-rt/test/hwasan/TestCases/register-dump-no-fp.cc
@@ -0,0 +1,28 @@
+// RUN: %clangxx_hwasan -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer \
+// RUN:   -O0 %s -o %t && not %run %t 2>&1 | FileCheck %s --check-prefixes=CHECK
+// RUN: %clangxx_hwasan -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer \
+// RUN:   -O1 %s -o %t && not %run %t 2>&1 | FileCheck %s --check-prefixes=CHECK
+// RUN: %clangxx_hwasan -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer \
+// RUN:   -O2 %s -o %t && not %run %t 2>&1 | FileCheck %s --check-prefixes=CHECK
+// RUN: %clangxx_hwasan -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer \
+// RUN:   -O3 %s -o %t && not %run %t 2>&1 | FileCheck %s --check-prefixes=CHECK
+
+// This test ensures that the CFA is implemented properly for slow
+// (non-frame-pointer) unwinding.
+#include <sanitizer/hwasan_interface.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+__attribute__((noinline)) void f(int *p) { *p = 3; }
+
+// CHECK: ERROR: HWAddressSanitizer:
+// CHECK: #0 {{.*}} in f(int*) {{.*}}register-dump-no-fp.cc:[[@LINE-3]]
+
+int main() {
+  __hwasan_enable_allocator_tagging();
+
+  int *volatile a = new int;
+  a = (int *)__hwasan_tag_pointer(a, 0);
+  f(a);
+  // CHECK: #1 {{.*}} in main {{.*}}register-dump-no-fp.cc:[[@LINE-1]]
+}


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D60806.195496.patch
Type: text/x-patch
Size: 1442 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190417/cc634d4f/attachment.bin>


More information about the llvm-commits mailing list