summaryrefslogtreecommitdiffstats
path: root/lldb/source/Utility/LLDBAssert.cpp
diff options
context:
space:
mode:
authorEnrico Granata <egranata@apple.com>2015-03-04 22:59:20 +0000
committerEnrico Granata <egranata@apple.com>2015-03-04 22:59:20 +0000
commit53ed89c6da24c2fa45bea84ddc9742f9bea0db14 (patch)
tree963b52523303b581367af9e9f1573b3d76c38960 /lldb/source/Utility/LLDBAssert.cpp
parentdc8f979b412792a1da9842d6d003a1ec4fea86f0 (diff)
downloadbcm5719-llvm-53ed89c6da24c2fa45bea84ddc9742f9bea0db14.tar.gz
bcm5719-llvm-53ed89c6da24c2fa45bea84ddc9742f9bea0db14.zip
Introduce lldbassert(x)
We would like it if LLDB never crashed, especially if we never caused LLDB to crash On the other hand, having assertions can sometimes be useful lldbassert(x) is the best of both worlds: - in debug builds, it turns into a regular assert, which is fine because we don't mind debug LLDB to crash on development machines - in non-debug builds, it emits a message formatted just like assert(x) would, but then instead of crashing, it dumps a backtrace, suggests filing a bug, and keeps running llvm-svn: 231310
Diffstat (limited to 'lldb/source/Utility/LLDBAssert.cpp')
-rw-r--r--lldb/source/Utility/LLDBAssert.cpp38
1 files changed, 38 insertions, 0 deletions
diff --git a/lldb/source/Utility/LLDBAssert.cpp b/lldb/source/Utility/LLDBAssert.cpp
new file mode 100644
index 00000000000..875dd51bca3
--- /dev/null
+++ b/lldb/source/Utility/LLDBAssert.cpp
@@ -0,0 +1,38 @@
+//===--------------------- LLDBAssert.cpp --------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "lldb/Utility/LLDBAssert.h"
+#include "lldb/Core/StreamString.h"
+#include "lldb/Host/Host.h"
+
+using namespace lldb_private;
+
+void
+lldb_private::lldb_assert (int expression,
+ const char* expr_text,
+ const char* func,
+ const char* file,
+ unsigned int line)
+{
+ if (expression)
+ ;
+ else
+ {
+ StreamString stream;
+ stream.Printf("Assertion failed: (%s), function %s, file %s, line %u\n",
+ expr_text,
+ func,
+ file,
+ line);
+ stream.Printf("backtrace leading to the failure:\n");
+ Host::Backtrace(stream, 1000);
+ stream.Printf("please file a bug report against lldb reporting this failure log, and as many details as possible\n");
+ printf("%s\n", stream.GetData());
+ }
+}
OpenPOWER on IntegriCloud