LLDB mainline
LLDBAssert.h
Go to the documentation of this file.
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
31namespace lldb_private {
32
33/// Don't use _lldb_assert directly. Use the lldbassert macro instead so that
34/// LLDB asserts become regular asserts in NDEBUG builds.
35void _lldb_assert(bool expression, const char *expr_text, const char *func,
36 const char *file, unsigned int line);
37
38/// The default LLDB assert callback, which prints to stderr.
39typedef void (*LLDBAssertCallback)(llvm::StringRef message,
40 llvm::StringRef backtrace,
41 llvm::StringRef prompt);
42
43/// Replace the LLDB assert callback.
45
46} // namespace lldb_private
47
48#endif // LLDB_UTILITY_LLDBASSERT_H
A class that represents a running process on the host machine.
void _lldb_assert(bool expression, const char *expr_text, const char *func, const char *file, unsigned int line)
Don't use _lldb_assert directly.
Definition: LLDBAssert.cpp:35
void SetLLDBAssertCallback(LLDBAssertCallback callback)
Replace the LLDB assert callback.
Definition: LLDBAssert.cpp:61
void(* LLDBAssertCallback)(llvm::StringRef message, llvm::StringRef backtrace, llvm::StringRef prompt)
The default LLDB assert callback, which prints to stderr.
Definition: LLDBAssert.h:39