1 | //===--- rtsan_context.h - Realtime Sanitizer -------------------*- C++ -*-===// |
2 | // |
3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
4 | // See https://llvm.org/LICENSE.txt for license information. |
5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
6 | // |
7 | //===----------------------------------------------------------------------===// |
8 | // |
9 | //===----------------------------------------------------------------------===// |
10 | |
11 | #pragma once |
12 | |
13 | namespace __rtsan { |
14 | |
15 | class Context { |
16 | public: |
17 | Context(); |
18 | |
19 | void RealtimePush(); |
20 | void RealtimePop(); |
21 | |
22 | void BypassPush(); |
23 | void BypassPop(); |
24 | |
25 | void ExpectNotRealtime(const char *intercepted_function_name); |
26 | |
27 | private: |
28 | bool InRealtimeContext() const; |
29 | bool IsBypassed() const; |
30 | void PrintDiagnostics(const char *intercepted_function_name); |
31 | |
32 | int realtime_depth{0}; |
33 | int bypass_depth{0}; |
34 | }; |
35 | |
36 | Context &GetContextForThisThread(); |
37 | |
38 | } // namespace __rtsan |
39 | |