1 //===-------- Debug.h ---- Debug 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 //
10 //===----------------------------------------------------------------------===//
11 
12 #ifndef OMPTARGET_DEVICERTL_DEBUG_H
13 #define OMPTARGET_DEVICERTL_DEBUG_H
14 
15 /// Assertion
16 ///
17 /// {
18 extern "C" {
19 void __assert_assume(bool cond, const char *exp, const char *file, int line);
20 void __assert_fail(const char *assertion, const char *file, unsigned line,
21                    const char *function);
22 }
23 
24 #define ASSERT(e) __assert_assume(e, #e, __FILE__, __LINE__)
25 
26 ///}
27 
28 // TODO: We need to allow actual printf.
29 #define PRINTF(fmt, ...) (void)fmt;
30 #define PRINT(str) PRINTF("%s", str)
31 
32 ///}
33 
34 /// Enter a debugging scope for performing function traces. Enabled with
35 /// FunctionTracting set in the debug kind.
36 #define FunctionTracingRAII()                                                  \
37   DebugEntryRAII Entry(__LINE__, __PRETTY_FUNCTION__);
38 
39 /// An RAII class for handling entries to debug locations. The current location
40 /// and function will be printed on entry. Nested levels increase the
41 /// indentation shown in the debugging output.
42 struct DebugEntryRAII {
43   DebugEntryRAII(const unsigned Line, const char *Function);
44   ~DebugEntryRAII();
45 };
46 
47 #endif
48