1 | /** |
2 | * Copyright (c) Glow Contributors. See CONTRIBUTORS file. |
3 | * |
4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
5 | * you may not use this file except in compliance with the License. |
6 | * You may obtain a copy of the License at |
7 | * |
8 | * http://www.apache.org/licenses/LICENSE-2.0 |
9 | * |
10 | * Unless required by applicable law or agreed to in writing, software |
11 | * distributed under the License is distributed on an "AS IS" BASIS, |
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
13 | * See the License for the specific language governing permissions and |
14 | * limitations under the License. |
15 | */ |
16 | #ifndef GLOW_SUPPORT_DEBUG_H |
17 | #define GLOW_SUPPORT_DEBUG_H |
18 | |
19 | namespace glow { |
20 | |
21 | #ifndef NDEBUG |
22 | |
23 | /// \returns true if \p type matches the activated debug type. |
24 | bool isCurrentDebugType(const char *type); |
25 | |
26 | /// Macro to perform debug actions when TYPE is activated. |
27 | #define DEBUG_GLOW_WITH_TYPE(TYPE, X) \ |
28 | do { \ |
29 | if (glow::DebugFlag || glow::isCurrentDebugType(TYPE)) { \ |
30 | X; \ |
31 | } \ |
32 | } while (false) |
33 | |
34 | #else |
35 | |
36 | #define DEBUG_GLOW_WITH_TYPE(TYPE, X) \ |
37 | do { \ |
38 | } while (false) |
39 | |
40 | #endif |
41 | |
42 | /// Set to true if '-debug-glow' command line option is specified. |
43 | extern bool DebugFlag; |
44 | |
45 | /// DEBUG_GLOW macros. Used to emit debug information. Enabled via |
46 | /// '-debug-glow' or '-debug-glow-only'. |
47 | #define DEBUG_GLOW(X) DEBUG_GLOW_WITH_TYPE(DEBUG_TYPE, X) |
48 | |
49 | } // namespace glow |
50 | |
51 | #endif // GLOW_SUPPORT_DEBUG_H |
52 | |