[Esan] Port cache frag to FreeBSD

Data involving struct accesses accounting work (plan to support only efficiency-cache-frag flag in the frontend side).

Reviewers: krytarowski, vitalybuka, jfb

Reviewed By : vitalybuka

Differential Revision: https://reviews.llvm.org/D52608

llvm-svn: 343812
This commit is contained in:
David Carlier 2018-10-04 20:58:18 +00:00
parent 37b742e208
commit bbe5d55fea
14 changed files with 39 additions and 9 deletions

View File

@ -625,7 +625,7 @@ else()
endif()
if (COMPILER_RT_HAS_SANITIZER_COMMON AND ESAN_SUPPORTED_ARCH AND
OS_NAME MATCHES "Linux")
OS_NAME MATCHES "Linux|FreeBSD")
set(COMPILER_RT_HAS_ESAN TRUE)
else()
set(COMPILER_RT_HAS_ESAN FALSE)

View File

@ -14,6 +14,7 @@ set(ESAN_SOURCES
esan_interceptors.cpp
esan_linux.cpp
esan_sideline_linux.cpp
esan_sideline_bsd.cpp
cache_frag.cpp
working_set.cpp
working_set_posix.cpp)

View File

@ -327,7 +327,7 @@ INTERCEPTOR(int, rmdir, char *path) {
// Signal-related interceptors
//===----------------------------------------------------------------------===//
#if SANITIZER_LINUX
#if SANITIZER_LINUX || SANITIZER_FREEBSD
typedef void (*signal_handler_t)(int);
INTERCEPTOR(signal_handler_t, signal, int signum, signal_handler_t handler) {
void *ctx;
@ -344,7 +344,7 @@ INTERCEPTOR(signal_handler_t, signal, int signum, signal_handler_t handler) {
#define ESAN_MAYBE_INTERCEPT_SIGNAL
#endif
#if SANITIZER_LINUX
#if SANITIZER_LINUX || SANITIZER_FREEBSD
DECLARE_REAL(int, sigaction, int signum, const struct sigaction *act,
struct sigaction *oldact)
INTERCEPTOR(int, sigaction, int signum, const struct sigaction *act,
@ -363,7 +363,11 @@ int real_sigaction(int signum, const void *act, void *oldact) {
if (REAL(sigaction) == nullptr) {
// With an instrumented allocator, this is called during interceptor init
// and we need a raw syscall solution.
#if SANITIZER_LINUX
return internal_sigaction_syscall(signum, act, oldact);
#else
return internal_sigaction(signum, act, oldact);
#endif
}
return REAL(sigaction)(signum, (const struct sigaction *)act,
(struct sigaction *)oldact);
@ -376,7 +380,7 @@ int real_sigaction(int signum, const void *act, void *oldact) {
#define ESAN_MAYBE_INTERCEPT_SIGACTION
#endif
#if SANITIZER_LINUX
#if SANITIZER_LINUX || SANITIZER_FREEBSD
INTERCEPTOR(int, sigprocmask, int how, __sanitizer_sigset_t *set,
__sanitizer_sigset_t *oldset) {
void *ctx;

View File

@ -30,7 +30,7 @@ struct ApplicationRegion {
bool ShadowMergedWithPrev;
};
#if SANITIZER_LINUX && defined(__x86_64__)
#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && defined(__x86_64__)
// Linux x86_64
//
// Application memory falls into these 5 regions (ignoring the corner case

View File

@ -906,8 +906,18 @@ bool internal_sigismember(__sanitizer_sigset_t *set, int signum) {
const uptr bit = signum % (sizeof(k_set->sig[0]) * 8);
return k_set->sig[idx] & (1 << bit);
}
#endif // SANITIZER_LINUX
#endif // !SANITIZER_SOLARIS && !SANITIZER_NETBSD
#elif SANITIZER_FREEBSD
void internal_sigdelset(__sanitizer_sigset_t *set, int signum) {
sigset_t *rset = reinterpret_cast<sigset_t *>(set);
sigdelset(rset, signum);
}
bool internal_sigismember(__sanitizer_sigset_t *set, int signum) {
sigset_t *rset = reinterpret_cast<sigset_t *>(set);
return sigismember(rset, signum);
}
#endif
#endif // !SANITIZER_SOLARIS
#if !SANITIZER_NETBSD
// ThreadLister implementation.

View File

@ -69,6 +69,8 @@ void internal_sigdelset(__sanitizer_sigset_t *set, int signum);
uptr internal_clone(int (*fn)(void *), void *child_stack, int flags, void *arg,
int *parent_tidptr, void *newtls, int *child_tidptr);
#endif
#elif SANITIZER_FREEBSD
void internal_sigdelset(__sanitizer_sigset_t *set, int signum);
#endif // SANITIZER_LINUX
// This class reads thread IDs from /proc/<pid>/task using only syscalls.

View File

@ -1,5 +1,7 @@
// RUN: %clang_esan_wset -O0 %s -o %t 2>&1
// RUN: %env_esan_opts="verbosity=1 record_snapshots=0" %run %t %t 2>&1 | FileCheck %s
// Stucks at init and no clone feature equivalent.
// UNSUPPORTED: freebsd
#include <assert.h>
#include <stdio.h>

View File

@ -3,6 +3,8 @@
//
// RUN: %clang_esan_wset %s -o %t
// RUN: %run %t 2>&1 | FileCheck %s
// Stucks at init and no clone feature equivalent.
// UNSUPPORTED: freebsd
#include <stdio.h>
#include <stdlib.h>

View File

@ -1,5 +1,7 @@
// RUN: %clang_esan_wset -O0 %s -o %t 2>&1
// RUN: %run %t 2>&1 | FileCheck %s
// Stucks at init and no clone feature equivalent.
// UNSUPPORTED: freebsd
#include <stdlib.h>
#include <string.h>

View File

@ -6,6 +6,8 @@
// FIXME: Re-enable once PR33590 is fixed.
// UNSUPPORTED: x86_64
// Stucks at init and no clone feature equivalent.
// UNSUPPORTED: freebsd
#include <sanitizer/esan_interface.h>
#include <sched.h>

View File

@ -3,6 +3,8 @@
// FIXME: Re-enable once PR33590 is fixed.
// UNSUPPORTED: x86_64
// Stucks at init and no clone feature equivalent.
// UNSUPPORTED: freebsd
#include <sanitizer/esan_interface.h>
#include <sched.h>

View File

@ -1,5 +1,7 @@
// RUN: %clang_esan_wset -O0 %s -o %t 2>&1
// RUN: %run %t 2>&1 | FileCheck %s
// Stucks at init and no clone feature equivalent.
// UNSUPPORTED: freebsd
#include <assert.h>
#include <setjmp.h>

View File

@ -3,6 +3,8 @@
// FIXME: Re-enable once PR33590 is fixed.
// UNSUPPORTED: x86_64
// Stucks at init and no clone feature equivalent.
// UNSUPPORTED: freebsd
#include <stdlib.h>
#include <string.h>

View File

@ -39,6 +39,5 @@ config.substitutions.append(('%env_esan_opts=',
# Default test suffixes.
config.suffixes = ['.c', '.cpp']
# EfficiencySanitizer tests are currently supported on Linux x86-64 only.
if config.host_os not in ['Linux'] or config.target_arch not in ['x86_64', 'mips64'] :
if config.host_os not in ['Linux', 'FreeBSD'] or config.target_arch not in ['x86_64', 'mips64'] :
config.unsupported = True