1 #ifndef TSAN_INTERCEPTORS_H
2 #define TSAN_INTERCEPTORS_H
4 #include "sanitizer_common/sanitizer_stacktrace.h"
9 class ScopedInterceptor
{
11 ScopedInterceptor(ThreadState
*thr
, const char *fname
, uptr pc
);
13 void DisableIgnores();
16 ThreadState
*const thr_
;
22 LibIgnore
*libignore();
25 INLINE
bool in_symbolizer() {
27 return UNLIKELY(cur_thread()->in_symbolizer
);
33 #define SCOPED_INTERCEPTOR_RAW(func, ...) \
35 ThreadState *thr = cur_thread(); \
36 const uptr caller_pc = GET_CALLER_PC(); \
37 ScopedInterceptor si(thr, #func, caller_pc); \
38 const uptr pc = StackTrace::GetCurrentPc(); \
42 #define SCOPED_TSAN_INTERCEPTOR(func, ...) \
43 SCOPED_INTERCEPTOR_RAW(func, __VA_ARGS__); \
44 if (REAL(func) == 0) { \
45 Report("FATAL: ThreadSanitizer: failed to intercept %s\n", #func); \
48 if (!thr->is_inited || thr->ignore_interceptors || thr->in_ignored_lib) \
49 return REAL(func)(__VA_ARGS__); \
52 #define SCOPED_TSAN_INTERCEPTOR_USER_CALLBACK_START() \
55 #define SCOPED_TSAN_INTERCEPTOR_USER_CALLBACK_END() \
58 #define TSAN_INTERCEPTOR(ret, func, ...) INTERCEPTOR(ret, func, __VA_ARGS__)
61 # define TSAN_INTERCEPTOR_NETBSD_ALIAS(ret, func, ...) \
62 TSAN_INTERCEPTOR(ret, __libc_##func, __VA_ARGS__) \
63 ALIAS(WRAPPER_NAME(pthread_##func));
64 # define TSAN_INTERCEPTOR_NETBSD_ALIAS_THR(ret, func, ...) \
65 TSAN_INTERCEPTOR(ret, __libc_thr_##func, __VA_ARGS__) \
66 ALIAS(WRAPPER_NAME(pthread_##func));
67 # define TSAN_INTERCEPTOR_NETBSD_ALIAS_THR2(ret, func, func2, ...) \
68 TSAN_INTERCEPTOR(ret, __libc_thr_##func, __VA_ARGS__) \
69 ALIAS(WRAPPER_NAME(pthread_##func2));
71 # define TSAN_INTERCEPTOR_NETBSD_ALIAS(ret, func, ...)
72 # define TSAN_INTERCEPTOR_NETBSD_ALIAS_THR(ret, func, ...)
73 # define TSAN_INTERCEPTOR_NETBSD_ALIAS_THR2(ret, func, func2, ...)
76 #endif // TSAN_INTERCEPTORS_H