[compiler-rt] r175618 - [asan] add a lit test for invoke-with-no-return instrumentation

Kostya Serebryany kcc at google.com
Wed Feb 20 04:37:23 PST 2013


Author: kcc
Date: Wed Feb 20 06:37:22 2013
New Revision: 175618

URL: http://llvm.org/viewvc/llvm-project?rev=175618&view=rev
Log:
[asan] add a lit test for invoke-with-no-return instrumentation

Added:
    compiler-rt/trunk/lib/asan/lit_tests/throw_invoke_test.cc

Added: compiler-rt/trunk/lib/asan/lit_tests/throw_invoke_test.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/lit_tests/throw_invoke_test.cc?rev=175618&view=auto
==============================================================================
--- compiler-rt/trunk/lib/asan/lit_tests/throw_invoke_test.cc (added)
+++ compiler-rt/trunk/lib/asan/lit_tests/throw_invoke_test.cc Wed Feb 20 06:37:22 2013
@@ -0,0 +1,50 @@
+// RUN: %clangxx_asan %s -o %t && %t
+// RUN: %clangxx_asan %s -o %t -static-libstdc++ && %t
+#include <stdio.h>
+static volatile int zero = 0;
+inline void pretend_to_do_something(void *x) {
+  __asm__ __volatile__("" : : "r" (x) : "memory");
+}
+
+__attribute__((noinline))
+void ReallyThrow() {
+  fprintf(stderr, "ReallyThrow\n");
+  try {
+    if (zero == 0)
+      throw 42;
+    else if (zero == 1)
+      throw 1.;
+  } catch(double x) {
+  }
+}
+
+__attribute__((noinline))
+void Throw() {
+  int a, b, c, d, e;
+  pretend_to_do_something(&a);
+  pretend_to_do_something(&b);
+  pretend_to_do_something(&c);
+  pretend_to_do_something(&d);
+  pretend_to_do_something(&e);
+  fprintf(stderr, "Throw stack = %p\n", &a);
+  ReallyThrow();
+}
+
+__attribute__((noinline))
+void CheckStack() {
+  int ar[100];
+  pretend_to_do_something(ar);
+  for (int i = 0; i < 100; i++)
+    ar[i] = i;
+  fprintf(stderr, "CheckStack stack = %p, %p\n", ar, ar + 100);
+}
+
+int main(int argc, char** argv) {
+  try {
+    Throw();
+  } catch(int a) {
+    fprintf(stderr, "a = %d\n", a);
+  }
+  CheckStack();
+}
+





More information about the llvm-commits mailing list