#include <pthread.h>
#include "dd_rtl.h"
#include "interception/interception.h"
#include "sanitizer_common/sanitizer_allocator_internal.h"
#include "sanitizer_common/sanitizer_procmaps.h"
usingnamespace__dsan;
__attribute__((tls_model("initial-exec")))
static __thread Thread *thr;
__attribute__((tls_model("initial-exec")))
static __thread volatile int initing;
static bool inited;
static uptr g_data_start;
static uptr g_data_end;
static bool InitThread() { … }
INTERCEPTOR(int, pthread_mutex_destroy, pthread_mutex_t *m) { … }
INTERCEPTOR(int, pthread_mutex_lock, pthread_mutex_t *m) { … }
INTERCEPTOR(int, pthread_mutex_trylock, pthread_mutex_t *m) { … }
INTERCEPTOR(int, pthread_mutex_unlock, pthread_mutex_t *m) { … }
INTERCEPTOR(int, pthread_spin_destroy, pthread_spinlock_t *m) { … }
INTERCEPTOR(int, pthread_spin_lock, pthread_spinlock_t *m) { … }
INTERCEPTOR(int, pthread_spin_trylock, pthread_spinlock_t *m) { … }
INTERCEPTOR(int, pthread_spin_unlock, pthread_spinlock_t *m) { … }
INTERCEPTOR(int, pthread_rwlock_destroy, pthread_rwlock_t *m) { … }
INTERCEPTOR(int, pthread_rwlock_rdlock, pthread_rwlock_t *m) { … }
INTERCEPTOR(int, pthread_rwlock_tryrdlock, pthread_rwlock_t *m) { … }
INTERCEPTOR(int, pthread_rwlock_timedrdlock, pthread_rwlock_t *m,
const timespec *abstime) { … }
INTERCEPTOR(int, pthread_rwlock_wrlock, pthread_rwlock_t *m) { … }
INTERCEPTOR(int, pthread_rwlock_trywrlock, pthread_rwlock_t *m) { … }
INTERCEPTOR(int, pthread_rwlock_timedwrlock, pthread_rwlock_t *m,
const timespec *abstime) { … }
INTERCEPTOR(int, pthread_rwlock_unlock, pthread_rwlock_t *m) { … }
static pthread_cond_t *init_cond(pthread_cond_t *c, bool force = false) { … }
INTERCEPTOR(int, pthread_cond_init, pthread_cond_t *c,
const pthread_condattr_t *a) { … }
INTERCEPTOR(int, pthread_cond_wait, pthread_cond_t *c, pthread_mutex_t *m) { … }
INTERCEPTOR(int, pthread_cond_timedwait, pthread_cond_t *c, pthread_mutex_t *m,
const timespec *abstime) { … }
INTERCEPTOR(int, pthread_cond_signal, pthread_cond_t *c) { … }
INTERCEPTOR(int, pthread_cond_broadcast, pthread_cond_t *c) { … }
INTERCEPTOR(int, pthread_cond_destroy, pthread_cond_t *c) { … }
INTERCEPTOR(char*, realpath, const char *path, char *resolved_path) { … }
INTERCEPTOR(SSIZE_T, read, int fd, void *ptr, SIZE_T count) { … }
INTERCEPTOR(SSIZE_T, pread, int fd, void *ptr, SIZE_T count, OFF_T offset) { … }
extern "C" {
void __dsan_before_mutex_lock(uptr m, int writelock) { … }
void __dsan_after_mutex_lock(uptr m, int writelock, int trylock) { … }
void __dsan_before_mutex_unlock(uptr m, int writelock) { … }
void __dsan_mutex_destroy(uptr m) { … }
}
namespace __dsan {
static void InitDataSeg() { … }
void InitializeInterceptors() { … }
}