1 #ifndef TSAN_INTERCEPTORS_H
2 #include "sanitizer_common/sanitizer_stacktrace.h"
7 class ScopedInterceptor
{
9 ScopedInterceptor(ThreadState
*thr
, const char *fname
, uptr pc
);
11 void UserCallbackStart();
12 void UserCallbackEnd();
14 ThreadState
*const thr_
;
21 #define SCOPED_INTERCEPTOR_RAW(func, ...) \
22 ThreadState *thr = cur_thread(); \
23 const uptr caller_pc = GET_CALLER_PC(); \
24 ScopedInterceptor si(thr, #func, caller_pc); \
25 const uptr pc = StackTrace::GetCurrentPc(); \
29 #define SCOPED_TSAN_INTERCEPTOR(func, ...) \
30 SCOPED_INTERCEPTOR_RAW(func, __VA_ARGS__); \
31 if (REAL(func) == 0) { \
32 Report("FATAL: ThreadSanitizer: failed to intercept %s\n", #func); \
35 if (!thr->is_inited || thr->ignore_interceptors || thr->in_ignored_lib) \
36 return REAL(func)(__VA_ARGS__); \
39 #define SCOPED_TSAN_INTERCEPTOR_USER_CALLBACK_START() \
40 si.UserCallbackStart();
42 #define SCOPED_TSAN_INTERCEPTOR_USER_CALLBACK_END() \
45 #define TSAN_INTERCEPTOR(ret, func, ...) INTERCEPTOR(ret, func, __VA_ARGS__)
47 #endif // TSAN_INTERCEPTORS_H