forked from OSchip/llvm-project
[sanitizer-coverage] disable coverage_direct=1, will remove the code in a few weeks
llvm-svn: 301826
This commit is contained in:
parent
5699969912
commit
f151b848c0
|
|
@ -165,6 +165,8 @@ void CoverageData::Enable() {
|
|||
MmapNoReserveOrDie(sizeof(uptr) * kPcArrayMaxSize, "CovInit"));
|
||||
atomic_store(&pc_array_index, 0, memory_order_relaxed);
|
||||
if (common_flags()->coverage_direct) {
|
||||
Report("coverage_direct=1 is deprecated, don't use it.\n");
|
||||
Die();
|
||||
atomic_store(&pc_array_size, 0, memory_order_relaxed);
|
||||
} else {
|
||||
atomic_store(&pc_array_size, kPcArrayMaxSize, memory_order_relaxed);
|
||||
|
|
|
|||
|
|
@ -1,59 +0,0 @@
|
|||
// Test for direct coverage writing enabled at activation time.
|
||||
|
||||
// RUN: %clangxx_asan -fsanitize-coverage=func -DSHARED %s -shared -o %dynamiclib -fPIC
|
||||
// RUN: %clangxx -c -DSO_DIR=\"%T\" %s -o %t.o
|
||||
// RUN: %clangxx_asan -fsanitize-coverage=func %t.o %libdl -o %t
|
||||
|
||||
// RUN: rm -rf %T/coverage-direct-activation
|
||||
|
||||
// RUN: mkdir -p %T/coverage-direct-activation/normal
|
||||
// RUN: %env_asan_opts=coverage=1,coverage_direct=0,coverage_dir=%T/coverage-direct-activation/normal:verbosity=1 %run %t %dynamiclib
|
||||
// RUN: %sancov print %T/coverage-direct-activation/normal/*.sancov >%T/coverage-direct-activation/normal/out.txt
|
||||
|
||||
// RUN: mkdir -p %T/coverage-direct-activation/direct
|
||||
// RUN: %env_asan_opts=start_deactivated=1,coverage_direct=1,verbosity=1 \
|
||||
// RUN: ASAN_ACTIVATION_OPTIONS=coverage=1,coverage_dir=%T/coverage-direct-activation/direct %run %t %dynamiclib
|
||||
// RUN: cd %T/coverage-direct-activation/direct
|
||||
// RUN: %sancov rawunpack *.sancov.raw
|
||||
// RUN: %sancov print *.sancov >out.txt
|
||||
// RUN: cd ../..
|
||||
|
||||
// Test start_deactivated=1,coverage=1 in ASAN_OPTIONS.
|
||||
|
||||
// RUN: diff -u coverage-direct-activation/normal/out.txt coverage-direct-activation/direct/out.txt
|
||||
|
||||
// RUN: mkdir -p %T/coverage-direct-activation/direct2
|
||||
// RUN: %env_asan_opts=start_deactivated=1,coverage=1,coverage_direct=1,verbosity=1 \
|
||||
// RUN: ASAN_ACTIVATION_OPTIONS=coverage_dir=%T/coverage-direct-activation/direct2 %run %t %dynamiclib
|
||||
// RUN: cd %T/coverage-direct-activation/direct2
|
||||
// RUN: %sancov rawunpack *.sancov.raw
|
||||
// RUN: %sancov print *.sancov >out.txt
|
||||
// RUN: cd ../..
|
||||
|
||||
// RUN: diff -u coverage-direct-activation/normal/out.txt coverage-direct-activation/direct2/out.txt
|
||||
|
||||
// XFAIL: android
|
||||
|
||||
#include <assert.h>
|
||||
#include <dlfcn.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#ifdef SHARED
|
||||
extern "C" {
|
||||
void bar() { printf("bar\n"); }
|
||||
}
|
||||
#else
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
fprintf(stderr, "PID: %d\n", getpid());
|
||||
assert(argc > 1);
|
||||
void *handle1 = dlopen(argv[1], RTLD_LAZY); // %dynamiclib
|
||||
assert(handle1);
|
||||
void (*bar1)() = (void (*)())dlsym(handle1, "bar");
|
||||
assert(bar1);
|
||||
bar1();
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
|
@ -1,65 +0,0 @@
|
|||
// Test for direct coverage writing with lots of data.
|
||||
// Current implementation maps output file in chunks of 64K. This test overflows
|
||||
// 1 chunk.
|
||||
|
||||
// RUN: %clangxx_asan -fsanitize-coverage=func -O0 -DSHARED %s -shared -o %dynamiclib -fPIC
|
||||
// RUN: %clangxx_asan -fsanitize-coverage=func -O0 %s %libdl -o %t
|
||||
|
||||
// RUN: rm -rf %T/coverage-direct-large
|
||||
|
||||
// RUN: mkdir -p %T/coverage-direct-large/normal && cd %T/coverage-direct-large/normal
|
||||
// RUN: %env_asan_opts=coverage=1:coverage_direct=0:verbosity=1 %run %t %dynamiclib
|
||||
// RUN: %sancov print *.sancov >out.txt
|
||||
// RUN: cd ../..
|
||||
|
||||
// RUN: mkdir -p %T/coverage-direct-large/direct && cd %T/coverage-direct-large/direct
|
||||
// RUN: %env_asan_opts=coverage=1:coverage_direct=1:verbosity=1 %run %t %dynamiclib
|
||||
// RUN: %sancov rawunpack *.sancov.raw
|
||||
// RUN: %sancov print *.sancov >out.txt
|
||||
// RUN: cd ../..
|
||||
|
||||
// RUN: diff -u coverage-direct-large/normal/out.txt coverage-direct-large/direct/out.txt
|
||||
//
|
||||
// XFAIL: android
|
||||
|
||||
#define F0(Q, x) Q(x)
|
||||
#define F1(Q, x) \
|
||||
F0(Q, x##0) F0(Q, x##1) F0(Q, x##2) F0(Q, x##3) F0(Q, x##4) F0(Q, x##5) \
|
||||
F0(Q, x##6) F0(Q, x##7) F0(Q, x##8) F0(Q, x##9)
|
||||
#define F2(Q, x) \
|
||||
F1(Q, x##0) F1(Q, x##1) F1(Q, x##2) F1(Q, x##3) F1(Q, x##4) F1(Q, x##5) \
|
||||
F1(Q, x##6) F1(Q, x##7) F1(Q, x##8) F1(Q, x##9)
|
||||
#define F3(Q, x) \
|
||||
F2(Q, x##0) F2(Q, x##1) F2(Q, x##2) F2(Q, x##3) F2(Q, x##4) F2(Q, x##5) \
|
||||
F2(Q, x##6) F2(Q, x##7) F2(Q, x##8) F2(Q, x##9)
|
||||
#define F4(Q, x) \
|
||||
F3(Q, x##0) F3(Q, x##1) F3(Q, x##2) F3(Q, x##3) F3(Q, x##4) F3(Q, x##5) \
|
||||
F3(Q, x##6) F3(Q, x##7) F3(Q, x##8) F3(Q, x##9)
|
||||
|
||||
#define DECL(x) __attribute__((noinline)) static void x() {}
|
||||
#define CALL(x) x();
|
||||
|
||||
F4(DECL, f)
|
||||
|
||||
#ifdef SHARED
|
||||
extern "C" void so_entry() {
|
||||
F4(CALL, f)
|
||||
}
|
||||
#else
|
||||
|
||||
#include <assert.h>
|
||||
#include <dlfcn.h>
|
||||
#include <stdio.h>
|
||||
int main(int argc, char **argv) {
|
||||
F4(CALL, f)
|
||||
assert(argc > 1);
|
||||
void *handle1 = dlopen(argv[1], RTLD_LAZY); // %dynamiclib
|
||||
assert(handle1);
|
||||
void (*so_entry)() = (void (*)())dlsym(handle1, "so_entry");
|
||||
assert(so_entry);
|
||||
so_entry();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif // SHARED
|
||||
|
|
@ -1,83 +0,0 @@
|
|||
// Test for direct coverage writing with dlopen at coverage level 1 to 3.
|
||||
|
||||
// RUN: %clangxx_asan -fsanitize-coverage=func -DSHARED %s -shared -o %dynamiclib -fPIC
|
||||
// RUN: %clangxx_asan -fsanitize-coverage=func %s %libdl -o %t
|
||||
|
||||
// RUN: rm -rf %T/coverage-direct
|
||||
|
||||
// RUN: mkdir -p %T/coverage-direct/normal
|
||||
// RUN: %env_asan_opts=coverage=1:coverage_direct=0:coverage_dir=%T/coverage-direct/normal:verbosity=1 %run %t %dynamiclib
|
||||
// RUN: %sancov print %T/coverage-direct/normal/*.sancov >%T/coverage-direct/normal/out.txt
|
||||
|
||||
// RUN: mkdir -p %T/coverage-direct/direct
|
||||
// RUN: %env_asan_opts=coverage=1:coverage_direct=1:coverage_dir=%T/coverage-direct/direct:verbosity=1 %run %t %dynamiclib
|
||||
// RUN: cd %T/coverage-direct/direct
|
||||
// RUN: %sancov rawunpack *.sancov.raw
|
||||
// RUN: %sancov print *.sancov >out.txt
|
||||
// RUN: cd ../..
|
||||
|
||||
// RUN: diff -u coverage-direct/normal/out.txt coverage-direct/direct/out.txt
|
||||
|
||||
|
||||
// RUN: %clangxx_asan -fsanitize-coverage=bb -DSHARED %s -shared -o %dynamiclib -fPIC
|
||||
// RUN: %clangxx_asan -fsanitize-coverage=bb -DSO_DIR=\"%T\" %s %libdl -o %t
|
||||
|
||||
// RUN: rm -rf %T/coverage-direct
|
||||
|
||||
// RUN: mkdir -p %T/coverage-direct/normal
|
||||
// RUN: %env_asan_opts=coverage=1:coverage_direct=0:coverage_dir=%T/coverage-direct/normal:verbosity=1 %run %t %dynamiclib
|
||||
// RUN: %sancov print %T/coverage-direct/normal/*.sancov >%T/coverage-direct/normal/out.txt
|
||||
|
||||
// RUN: mkdir -p %T/coverage-direct/direct
|
||||
// RUN: %env_asan_opts=coverage=1:coverage_direct=1:coverage_dir=%T/coverage-direct/direct:verbosity=1 %run %t %dynamiclib
|
||||
// RUN: cd %T/coverage-direct/direct
|
||||
// RUN: %sancov rawunpack *.sancov.raw
|
||||
// RUN: %sancov print *.sancov >out.txt
|
||||
// RUN: cd ../..
|
||||
|
||||
// RUN: diff -u coverage-direct/normal/out.txt coverage-direct/direct/out.txt
|
||||
|
||||
|
||||
// RUN: %clangxx_asan -fsanitize-coverage=edge -DSHARED %s -shared -o %dynamiclib -fPIC
|
||||
// RUN: %clangxx_asan -fsanitize-coverage=edge -DSO_DIR=\"%T\" %s %libdl -o %t
|
||||
|
||||
// RUN: rm -rf %T/coverage-direct
|
||||
|
||||
// RUN: mkdir -p %T/coverage-direct/normal
|
||||
// RUN: %env_asan_opts=coverage=1:coverage_direct=0:coverage_dir=%T/coverage-direct/normal:verbosity=1 %run %t %dynamiclib
|
||||
// RUN: %sancov print %T/coverage-direct/normal/*.sancov >%T/coverage-direct/normal/out.txt
|
||||
|
||||
// RUN: mkdir -p %T/coverage-direct/direct
|
||||
// RUN: %env_asan_opts=coverage=1:coverage_direct=1:coverage_dir=%T/coverage-direct/direct:verbosity=1 %run %t %dynamiclib
|
||||
// RUN: cd %T/coverage-direct/direct
|
||||
// RUN: %sancov rawunpack *.sancov.raw
|
||||
// RUN: %sancov print *.sancov >out.txt
|
||||
// RUN: cd ../..
|
||||
|
||||
// RUN: diff -u coverage-direct/normal/out.txt coverage-direct/direct/out.txt
|
||||
|
||||
// XFAIL: android
|
||||
|
||||
#include <assert.h>
|
||||
#include <dlfcn.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#ifdef SHARED
|
||||
extern "C" {
|
||||
void bar() { printf("bar\n"); }
|
||||
}
|
||||
#else
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
fprintf(stderr, "PID: %d\n", getpid());
|
||||
assert(argc > 1);
|
||||
void *handle1 = dlopen(argv[1], RTLD_LAZY);
|
||||
assert(handle1);
|
||||
void (*bar1)() = (void (*)())dlsym(handle1, "bar");
|
||||
assert(bar1);
|
||||
bar1();
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
|
@ -1,45 +0,0 @@
|
|||
// RUN: %clangxx_asan -fsanitize-coverage=func %s -o %t
|
||||
// RUN: rm -rf %T/coverage-fork-direct
|
||||
// RUN: mkdir -p %T/coverage-fork-direct && cd %T/coverage-fork-direct
|
||||
// RUN: %env_asan_opts=coverage=1:coverage_direct=1:verbosity=1 %run %t > %t.log 2>&1
|
||||
// RUN: %sancov rawunpack *.sancov.raw
|
||||
// RUN: %sancov print *.sancov >> %t.log 2>&1
|
||||
// RUN: FileCheck %s < %t.log
|
||||
//
|
||||
// XFAIL: android
|
||||
// UNSUPPORTED: powerpc64le
|
||||
// FIXME: This test occasionally fails on powerpc64 LE possibly starting with
|
||||
// r279664. Re-enable the test once the problem(s) have been fixed.
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
__attribute__((noinline))
|
||||
void foo() { printf("foo\n"); }
|
||||
|
||||
__attribute__((noinline))
|
||||
void bar() { printf("bar\n"); }
|
||||
|
||||
__attribute__((noinline))
|
||||
void baz() { printf("baz\n"); }
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
pid_t child_pid = fork();
|
||||
if (child_pid == 0) {
|
||||
fprintf(stderr, "Child PID: %d\n", getpid());
|
||||
baz();
|
||||
} else {
|
||||
fprintf(stderr, "Parent PID: %d\n", getpid());
|
||||
foo();
|
||||
bar();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// CHECK-DAG: Child PID: [[ChildPID:[0-9]+]]
|
||||
// CHECK-DAG: Parent PID: [[ParentPID:[0-9]+]]
|
||||
// CHECK-DAG: read 3 {{64|32}}-bit PCs from {{.*}}.[[ParentPID]].sancov
|
||||
|
||||
// FIXME: this is missing
|
||||
// XCHECK-DAG: read 1 {{64|32}}-bit PCs from {{.*}}.[[ChildPID]].sancov
|
||||
|
|
@ -8,11 +8,6 @@
|
|||
// RUN: %env_asan_opts=coverage_direct=0:coverage_dir='"%T/coverage-disabled/normal"':verbosity=1 %run %t
|
||||
// RUN: not %sancov print %T/coverage-disabled/normal/*.sancov 2>&1
|
||||
//
|
||||
// RUN: mkdir -p %T/coverage-disabled/direct
|
||||
// RUN: %env_asan_opts=coverage_direct=1:coverage_dir='"%T/coverage-disabled/direct"':verbosity=1 %run %t
|
||||
// RUN: cd %T/coverage-disabled/direct
|
||||
// RUN: not %sancov rawunpack *.sancov
|
||||
//
|
||||
// UNSUPPORTED: android
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue