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
diff --git a/lldb/source/Utility/LLDBAssert.cpp b/lldb/source/Utility/LLDBAssert.cpp
new file mode 100644
index 0000000..875dd51
--- /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());
+    }
+}