1 //===----------------- LLDBAssert.h ------------------------------*- 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 #ifndef LLDB_UTILITY_LLDBASSERT_H
10 #define LLDB_UTILITY_LLDBASSERT_H
11 
12 #include "llvm/ADT/StringRef.h"
13 
14 #ifndef NDEBUG
15 #define lldbassert(x) assert(x)
16 #else
17 #if defined(__clang__)
18 // __FILE_NAME__ is a Clang-specific extension that functions similar to
19 // __FILE__ but only renders the last path component (the filename) instead of
20 // an invocation dependent full path to that file.
21 #define lldbassert(x)                                                          \
22   lldb_private::lldb_assert(static_cast<bool>(x), #x, __FUNCTION__,            \
23                             __FILE_NAME__, __LINE__)
24 #else
25 #define lldbassert(x)                                                          \
26   lldb_private::lldb_assert(static_cast<bool>(x), #x, __FUNCTION__, __FILE__,  \
27                             __LINE__)
28 #endif
29 #endif
30 
31 namespace lldb_private {
32 void lldb_assert(bool expression, const char *expr_text, const char *func,
33                  const char *file, unsigned int line);
34 
35 typedef void (*LLDBAssertCallback)(llvm::StringRef message,
36                                    llvm::StringRef backtrace,
37                                    llvm::StringRef prompt);
38 
39 void SetLLDBAssertCallback(LLDBAssertCallback callback);
40 } // namespace lldb_private
41 
42 #endif // LLDB_UTILITY_LLDBASSERT_H
43