diff options
author | Kostya Serebryany <kcc@google.com> | 2012-01-31 00:52:18 +0000 |
---|---|---|
committer | Kostya Serebryany <kcc@google.com> | 2012-01-31 00:52:18 +0000 |
commit | bca91defcbd6e1b262f2ff5624c82e204eb6d953 (patch) | |
tree | ae8c3b243eff2c53e2b4765e94a4cbda3acf64ec | |
parent | 5d0d607b6b64b25723f3906bc984786e475556ed (diff) | |
download | bcm5719-llvm-bca91defcbd6e1b262f2ff5624c82e204eb6d953.tar.gz bcm5719-llvm-bca91defcbd6e1b262f2ff5624c82e204eb6d953.zip |
[asan] new run-time flag: sleep_before_dying (asan Issue #31)
llvm-svn: 149306
-rw-r--r-- | compiler-rt/lib/asan/asan_internal.h | 1 | ||||
-rw-r--r-- | compiler-rt/lib/asan/asan_posix.cc | 4 | ||||
-rw-r--r-- | compiler-rt/lib/asan/asan_rtl.cc | 2 | ||||
-rwxr-xr-x | compiler-rt/lib/asan/tests/test_output.sh | 5 |
4 files changed, 12 insertions, 0 deletions
diff --git a/compiler-rt/lib/asan/asan_internal.h b/compiler-rt/lib/asan/asan_internal.h index fc92e9c0d16..eecedd655c6 100644 --- a/compiler-rt/lib/asan/asan_internal.h +++ b/compiler-rt/lib/asan/asan_internal.h @@ -166,6 +166,7 @@ extern bool FLAG_use_fake_stack; extern size_t FLAG_max_malloc_fill_size; extern int FLAG_exitcode; extern bool FLAG_allow_user_poisoning; +extern int FLAG_sleep_before_dying; extern bool FLAG_handle_segv; extern int asan_inited; diff --git a/compiler-rt/lib/asan/asan_posix.cc b/compiler-rt/lib/asan/asan_posix.cc index cac35899bc8..2d48a19613c 100644 --- a/compiler-rt/lib/asan/asan_posix.cc +++ b/compiler-rt/lib/asan/asan_posix.cc @@ -70,6 +70,10 @@ void AsanDisableCoreDumper() { } void AsanDie() { + if (FLAG_sleep_before_dying) { + Report("Sleeping for %d second(s)\n", FLAG_sleep_before_dying); + sleep(FLAG_sleep_before_dying); + } _exit(FLAG_exitcode); } diff --git a/compiler-rt/lib/asan/asan_rtl.cc b/compiler-rt/lib/asan/asan_rtl.cc index 5a0da376343..b40bc41f09f 100644 --- a/compiler-rt/lib/asan/asan_rtl.cc +++ b/compiler-rt/lib/asan/asan_rtl.cc @@ -47,6 +47,7 @@ size_t FLAG_max_malloc_fill_size = 0; bool FLAG_use_fake_stack; int FLAG_exitcode = EXIT_FAILURE; bool FLAG_allow_user_poisoning; +int FLAG_sleep_before_dying; // -------------------------- Globals --------------------- {{{1 int asan_inited; @@ -411,6 +412,7 @@ void __asan_init() { FLAG_exitcode = IntFlagValue(options, "exitcode=", EXIT_FAILURE); FLAG_allow_user_poisoning = IntFlagValue(options, "allow_user_poisoning=", 1); + FLAG_sleep_before_dying = IntFlagValue(options, "sleep_before_dying=", 0); if (FLAG_atexit) { atexit(asan_atexit); diff --git a/compiler-rt/lib/asan/tests/test_output.sh b/compiler-rt/lib/asan/tests/test_output.sh index 1dfe9598ddf..385fba25325 100755 --- a/compiler-rt/lib/asan/tests/test_output.sh +++ b/compiler-rt/lib/asan/tests/test_output.sh @@ -19,6 +19,11 @@ $CC -g -faddress-sanitizer -O2 $C_TEST.c -pie ./a.out 2>&1 | grep "heap-use-after-free" > /dev/null rm ./a.out +echo "Testing sleep_before_dying" +$CC -g -faddress-sanitizer -O2 $C_TEST.c +ASAN_OPTIONS=sleep_before_dying=1 ./a.out 2>&1 | grep "Sleeping for 1 second" > /dev/null +rm a.out + for t in *.tmpl; do for b in 32 64; do for O in 0 1 2 3; do |