Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:42:57

0001 //===----------------- LLDBAssert.h ------------------------------*- C++-*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 
0009 #ifndef LLDB_UTILITY_LLDBASSERT_H
0010 #define LLDB_UTILITY_LLDBASSERT_H
0011 
0012 #include "llvm/ADT/StringRef.h"
0013 
0014 #ifndef NDEBUG
0015 #define lldbassert(x) assert(x)
0016 #else
0017 #if defined(__clang__)
0018 // __FILE_NAME__ is a Clang-specific extension that functions similar to
0019 // __FILE__ but only renders the last path component (the filename) instead of
0020 // an invocation dependent full path to that file.
0021 #define lldbassert(x)                                                          \
0022   lldb_private::_lldb_assert(static_cast<bool>(x), #x, __FUNCTION__,           \
0023                              __FILE_NAME__, __LINE__)
0024 #else
0025 #define lldbassert(x)                                                          \
0026   lldb_private::_lldb_assert(static_cast<bool>(x), #x, __FUNCTION__, __FILE__, \
0027                              __LINE__)
0028 #endif
0029 #endif
0030 
0031 namespace lldb_private {
0032 
0033 /// Don't use _lldb_assert directly. Use the lldbassert macro instead so that
0034 /// LLDB asserts become regular asserts in NDEBUG builds.
0035 void _lldb_assert(bool expression, const char *expr_text, const char *func,
0036                   const char *file, unsigned int line);
0037 
0038 /// The default LLDB assert callback, which prints to stderr.
0039 typedef void (*LLDBAssertCallback)(llvm::StringRef message,
0040                                    llvm::StringRef backtrace,
0041                                    llvm::StringRef prompt);
0042 
0043 /// Replace the LLDB assert callback.
0044 void SetLLDBAssertCallback(LLDBAssertCallback callback);
0045 
0046 } // namespace lldb_private
0047 
0048 #endif // LLDB_UTILITY_LLDBASSERT_H