1 //===--------------------- LLDBAssert.cpp ------------------------*- 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 #include "lldb/Utility/LLDBAssert.h"
10 
11 #include "llvm/Support/Format.h"
12 #include "llvm/Support/Signals.h"
13 #include "llvm/Support/raw_ostream.h"
14 
15 using namespace llvm;
16 using namespace lldb_private;
17 
18 void lldb_private::lldb_assert(bool expression, const char *expr_text,
19                                const char *func, const char *file,
20                                unsigned int line) {
21   if (LLVM_LIKELY(expression))
22     return;
23 
24   errs() << format("Assertion failed: (%s), function %s, file %s, line %u\n",
25                    expr_text, func, file, line);
26   errs() << "backtrace leading to the failure:\n";
27   llvm::sys::PrintStackTrace(errs());
28   errs() << "please file a bug report against lldb reporting this failure "
29             "log, and as many details as possible\n";
30 }
31