[compiler-rt] r195959 - [asan] dump coverage even if asan has reported an error
Kostya Serebryany
kcc at google.com
Fri Nov 29 06:49:33 PST 2013
Author: kcc
Date: Fri Nov 29 08:49:32 2013
New Revision: 195959
URL: http://llvm.org/viewvc/llvm-project?rev=195959&view=rev
Log:
[asan] dump coverage even if asan has reported an error
Modified:
compiler-rt/trunk/lib/asan/asan_rtl.cc
compiler-rt/trunk/lib/asan/lit_tests/TestCases/Linux/coverage.cc
Modified: compiler-rt/trunk/lib/asan/asan_rtl.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_rtl.cc?rev=195959&r1=195958&r2=195959&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_rtl.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_rtl.cc Fri Nov 29 08:49:32 2013
@@ -51,6 +51,8 @@ static void AsanDie() {
UnmapOrDie((void*)kLowShadowBeg, kHighShadowEnd - kLowShadowBeg);
}
}
+ if (flags()->coverage)
+ __sanitizer_cov_dump();
if (death_callback)
death_callback();
if (flags()->abort_on_error)
Modified: compiler-rt/trunk/lib/asan/lit_tests/TestCases/Linux/coverage.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/lit_tests/TestCases/Linux/coverage.cc?rev=195959&r1=195958&r2=195959&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/lit_tests/TestCases/Linux/coverage.cc (original)
+++ compiler-rt/trunk/lib/asan/lit_tests/TestCases/Linux/coverage.cc Fri Nov 29 08:49:32 2013
@@ -5,6 +5,7 @@
// RUN: %t foo 2>&1 | FileCheck %s --check-prefix=CHECK-foo
// RUN: %t bar 2>&1 | FileCheck %s --check-prefix=CHECK-bar
// RUN: %t foo bar 2>&1 | FileCheck %s --check-prefix=CHECK-foo-bar
+// RUN: not %t foo bar 1 2 2>&1 | FileCheck %s --check-prefix=CHECK-report
#include <stdio.h>
#include <string.h>
@@ -17,6 +18,8 @@ __attribute__((noinline))
void foo() { printf("foo\n"); }
extern void bar();
+int G[4];
+
int main(int argc, char **argv) {
fprintf(stderr, "PID: %d\n", getpid());
for (int i = 1; i < argc; i++) {
@@ -25,6 +28,7 @@ int main(int argc, char **argv) {
if (!strcmp(argv[i], "bar"))
bar();
}
+ return G[argc]; // Buffer overflow if argc >= 4.
}
#endif
@@ -43,3 +47,6 @@ int main(int argc, char **argv) {
// CHECK-foo-bar: PID: [[PID:[0-9]+]]
// CHECK-foo-bar: [[PID]].sancov: 2 PCs written
// CHECK-foo-bar: so.[[PID]].sancov: 1 PCs written
+//
+// CHECK-report: AddressSanitizer: global-buffer-overflow
+// CHECK-report: PCs written
More information about the llvm-commits
mailing list