Retro68/gcc/libsanitizer/tsan/tsan_interceptors.h

65 lines
1.8 KiB
C
Raw Normal View History

2017-04-10 11:32:00 +00:00
#ifndef TSAN_INTERCEPTORS_H
#define TSAN_INTERCEPTORS_H
2017-04-10 11:32:00 +00:00
#include "sanitizer_common/sanitizer_stacktrace.h"
#include "tsan_rtl.h"
namespace __tsan {
class ScopedInterceptor {
public:
ScopedInterceptor(ThreadState *thr, const char *fname, uptr pc);
~ScopedInterceptor();
2018-12-28 15:30:48 +00:00
void DisableIgnores();
void EnableIgnores();
2017-04-10 11:32:00 +00:00
private:
ThreadState *const thr_;
const uptr pc_;
bool in_ignored_lib_;
2018-12-28 15:30:48 +00:00
bool ignoring_;
2017-04-10 11:32:00 +00:00
};
2018-12-28 15:30:48 +00:00
LibIgnore *libignore();
2017-04-10 11:32:00 +00:00
} // namespace __tsan
#define SCOPED_INTERCEPTOR_RAW(func, ...) \
ThreadState *thr = cur_thread(); \
const uptr caller_pc = GET_CALLER_PC(); \
ScopedInterceptor si(thr, #func, caller_pc); \
const uptr pc = StackTrace::GetCurrentPc(); \
(void)pc; \
/**/
#define SCOPED_TSAN_INTERCEPTOR(func, ...) \
SCOPED_INTERCEPTOR_RAW(func, __VA_ARGS__); \
if (REAL(func) == 0) { \
Report("FATAL: ThreadSanitizer: failed to intercept %s\n", #func); \
Die(); \
} \
if (!thr->is_inited || thr->ignore_interceptors || thr->in_ignored_lib) \
2017-04-10 11:32:00 +00:00
return REAL(func)(__VA_ARGS__); \
/**/
#define SCOPED_TSAN_INTERCEPTOR_USER_CALLBACK_START() \
2018-12-28 15:30:48 +00:00
si.DisableIgnores();
2017-04-10 11:32:00 +00:00
#define SCOPED_TSAN_INTERCEPTOR_USER_CALLBACK_END() \
2018-12-28 15:30:48 +00:00
si.EnableIgnores();
2017-04-10 11:32:00 +00:00
#define TSAN_INTERCEPTOR(ret, func, ...) INTERCEPTOR(ret, func, __VA_ARGS__)
2017-04-10 11:32:00 +00:00
2019-06-02 15:48:37 +00:00
#if SANITIZER_NETBSD
# define TSAN_INTERCEPTOR_NETBSD_ALIAS(ret, func, ...) \
TSAN_INTERCEPTOR(ret, __libc_##func, __VA_ARGS__) \
ALIAS(WRAPPER_NAME(pthread_##func));
# define TSAN_INTERCEPTOR_NETBSD_ALIAS_THR(ret, func, ...) \
TSAN_INTERCEPTOR(ret, __libc_thr_##func, __VA_ARGS__) \
ALIAS(WRAPPER_NAME(pthread_##func));
#else
# define TSAN_INTERCEPTOR_NETBSD_ALIAS(ret, func, ...)
# define TSAN_INTERCEPTOR_NETBSD_ALIAS_THR(ret, func, ...)
#endif
2017-04-10 11:32:00 +00:00
#endif // TSAN_INTERCEPTORS_H