]> git.proxmox.com Git - rustc.git/blame - src/libcompiler_builtins/compiler-rt/lib/tsan/rtl/tsan_interceptors.h
New upstream version 1.25.0+dfsg1
[rustc.git] / src / libcompiler_builtins / compiler-rt / lib / tsan / rtl / tsan_interceptors.h
CommitLineData
92a42be0
SL
1#ifndef TSAN_INTERCEPTORS_H
2#define TSAN_INTERCEPTORS_H
3
4#include "sanitizer_common/sanitizer_stacktrace.h"
5#include "tsan_rtl.h"
6
7namespace __tsan {
8
9class ScopedInterceptor {
10 public:
11 ScopedInterceptor(ThreadState *thr, const char *fname, uptr pc);
12 ~ScopedInterceptor();
7cac9316
XL
13 void DisableIgnores();
14 void EnableIgnores();
92a42be0
SL
15 private:
16 ThreadState *const thr_;
17 const uptr pc_;
18 bool in_ignored_lib_;
7cac9316 19 bool ignoring_;
92a42be0
SL
20};
21
2c00a5a8
XL
22LibIgnore *libignore();
23
92a42be0
SL
24} // namespace __tsan
25
26#define SCOPED_INTERCEPTOR_RAW(func, ...) \
27 ThreadState *thr = cur_thread(); \
28 const uptr caller_pc = GET_CALLER_PC(); \
29 ScopedInterceptor si(thr, #func, caller_pc); \
30 const uptr pc = StackTrace::GetCurrentPc(); \
31 (void)pc; \
32/**/
33
3157f602
XL
34#define SCOPED_TSAN_INTERCEPTOR(func, ...) \
35 SCOPED_INTERCEPTOR_RAW(func, __VA_ARGS__); \
36 if (REAL(func) == 0) { \
37 Report("FATAL: ThreadSanitizer: failed to intercept %s\n", #func); \
38 Die(); \
39 } \
5bcae85e 40 if (!thr->is_inited || thr->ignore_interceptors || thr->in_ignored_lib) \
3157f602
XL
41 return REAL(func)(__VA_ARGS__); \
42/**/
43
44#define SCOPED_TSAN_INTERCEPTOR_USER_CALLBACK_START() \
7cac9316 45 si.DisableIgnores();
3157f602
XL
46
47#define SCOPED_TSAN_INTERCEPTOR_USER_CALLBACK_END() \
7cac9316 48 si.EnableIgnores();
3157f602
XL
49
50#define TSAN_INTERCEPTOR(ret, func, ...) INTERCEPTOR(ret, func, __VA_ARGS__)
51
2c00a5a8
XL
52#if SANITIZER_NETBSD
53# define TSAN_INTERCEPTOR_NETBSD_ALIAS(ret, func, ...) \
54 TSAN_INTERCEPTOR(ret, __libc_##func, __VA_ARGS__) \
55 ALIAS(WRAPPER_NAME(pthread_##func));
56# define TSAN_INTERCEPTOR_NETBSD_ALIAS_THR(ret, func, ...) \
57 TSAN_INTERCEPTOR(ret, __libc_thr_##func, __VA_ARGS__) \
58 ALIAS(WRAPPER_NAME(pthread_##func));
59#else
60# define TSAN_INTERCEPTOR_NETBSD_ALIAS(ret, func, ...)
61# define TSAN_INTERCEPTOR_NETBSD_ALIAS_THR(ret, func, ...)
62#endif
63
92a42be0 64#endif // TSAN_INTERCEPTORS_H