1//===- debug.h - Debugging output utilities ---------------------*- 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// This file is a part of the ORC runtime support library.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef ORC_RT_DEBUG_H
14#define ORC_RT_DEBUG_H
15
16#include <atomic>
17
18#ifndef NDEBUG
19
20namespace __orc_rt {
21
22extern std::atomic<const char *> DebugTypes;
23extern char DebugTypesAll;
24extern char DebugTypesNone;
25
26const char *initializeDebug();
27bool debugTypeEnabled(const char *Type, const char *Types);
28void printdbg(const char *format, ...);
29
30} // namespace __orc_rt
31
32#define ORC_RT_DEBUG_WITH_TYPE(TYPE, X) \
33 do { \
34 const char *Types = \
35 ::__orc_rt::DebugTypes.load(std::memory_order_relaxed); \
36 if (!Types) \
37 Types = initializeDebug(); \
38 if (Types == &DebugTypesNone) \
39 break; \
40 if (Types == &DebugTypesAll || \
41 ::__orc_rt::debugTypeEnabled(TYPE, Types)) { \
42 X; \
43 } \
44 } while (false)
45
46#else
47
48#define ORC_RT_DEBUG_WITH_TYPE(TYPE, X) \
49 do { \
50 } while (false)
51
52#endif // !NDEBUG
53
54#define ORC_RT_DEBUG(X) ORC_RT_DEBUG_WITH_TYPE(DEBUG_TYPE, X)
55
56#endif // ORC_RT_DEBUG_H
57

source code of compiler-rt/lib/orc/debug.h