summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lldb/include/lldb/Utility/LLDBAssert.h30
-rw-r--r--lldb/lldb.xcodeproj/project.pbxproj6
-rw-r--r--lldb/source/Utility/LLDBAssert.cpp38
3 files changed, 74 insertions, 0 deletions
diff --git a/lldb/include/lldb/Utility/LLDBAssert.h b/lldb/include/lldb/Utility/LLDBAssert.h
new file mode 100644
index 00000000000..c68c1bb7b1b
--- /dev/null
+++ b/lldb/include/lldb/Utility/LLDBAssert.h
@@ -0,0 +1,30 @@
+//===----------------- LLDBAssert.h --------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef utility_LLDBAssert_h_
+#define utility_LLDBAssert_h_
+
+#include <assert.h>
+
+#ifdef LLDB_CONFIGURATION_DEBUG
+#define lldbassert(x) assert(x)
+#else
+#define lldbassert(x) lldb_private::lldb_assert(x, #x, __FUNCTION__, __FILE__, __LINE__)
+#endif
+
+namespace lldb_private {
+ void
+ lldb_assert (int expression,
+ const char* expr_text,
+ const char* func,
+ const char* file,
+ unsigned int line);
+}
+
+#endif // utility_LLDBAssert_h_
diff --git a/lldb/lldb.xcodeproj/project.pbxproj b/lldb/lldb.xcodeproj/project.pbxproj
index fa36cceee78..7b97f6b0481 100644
--- a/lldb/lldb.xcodeproj/project.pbxproj
+++ b/lldb/lldb.xcodeproj/project.pbxproj
@@ -770,6 +770,7 @@
942AFF0719F84C02007B43B4 /* LibCxxInitializerList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 942AFF0619F84C02007B43B4 /* LibCxxInitializerList.cpp */; };
94380B8219940B0A00BFE4A8 /* StringLexer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 94380B8119940B0A00BFE4A8 /* StringLexer.cpp */; };
9439FB1A19EF140C006FD6A4 /* NSIndexPath.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9439FB1919EF140C006FD6A4 /* NSIndexPath.cpp */; };
+ 943BDEFE1AA7B2F800789CE8 /* LLDBAssert.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 943BDEFD1AA7B2F800789CE8 /* LLDBAssert.cpp */; };
944372DC171F6B4300E57C32 /* RegisterContextDummy.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 944372DA171F6B4300E57C32 /* RegisterContextDummy.cpp */; };
944372DD171F6B4300E57C32 /* RegisterContextDummy.h in Headers */ = {isa = PBXBuildFile; fileRef = 944372DB171F6B4300E57C32 /* RegisterContextDummy.h */; };
9443B122140C18C40013457C /* SBData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9443B121140C18C10013457C /* SBData.cpp */; };
@@ -2397,6 +2398,8 @@
94380B8019940B0300BFE4A8 /* StringLexer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = StringLexer.h; path = include/lldb/Utility/StringLexer.h; sourceTree = "<group>"; };
94380B8119940B0A00BFE4A8 /* StringLexer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = StringLexer.cpp; path = source/Utility/StringLexer.cpp; sourceTree = "<group>"; };
9439FB1919EF140C006FD6A4 /* NSIndexPath.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = NSIndexPath.cpp; path = source/DataFormatters/NSIndexPath.cpp; sourceTree = "<group>"; };
+ 943BDEFC1AA7B2DE00789CE8 /* LLDBAssert.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = LLDBAssert.h; path = include/lldb/Utility/LLDBAssert.h; sourceTree = "<group>"; };
+ 943BDEFD1AA7B2F800789CE8 /* LLDBAssert.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = LLDBAssert.cpp; path = source/Utility/LLDBAssert.cpp; sourceTree = "<group>"; };
944372DA171F6B4300E57C32 /* RegisterContextDummy.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RegisterContextDummy.cpp; path = Utility/RegisterContextDummy.cpp; sourceTree = "<group>"; };
944372DB171F6B4300E57C32 /* RegisterContextDummy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RegisterContextDummy.h; path = Utility/RegisterContextDummy.h; sourceTree = "<group>"; };
9443B120140C18A90013457C /* SBData.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SBData.h; path = include/lldb/API/SBData.h; sourceTree = "<group>"; };
@@ -3455,6 +3458,8 @@
4C73152119B7D71700F865A4 /* Iterable.h */,
942829541A89614000521B30 /* JSON.h */,
942829551A89614C00521B30 /* JSON.cpp */,
+ 943BDEFC1AA7B2DE00789CE8 /* LLDBAssert.h */,
+ 943BDEFD1AA7B2F800789CE8 /* LLDBAssert.cpp */,
26D1804416CEE12500EDFB5B /* KQueue.h */,
26D1803C16CEBFD300EDFB5B /* KQueue.cpp */,
94031A9F13CF5B3D00DCFF3C /* PriorityPointerPair.h */,
@@ -5946,6 +5951,7 @@
2689006413353E0E00698AC0 /* ClangUserExpression.cpp in Sources */,
4C3ADCD61810D88B00357218 /* BreakpointResolverFileRegex.cpp in Sources */,
2689006513353E0E00698AC0 /* ClangUtilityFunction.cpp in Sources */,
+ 943BDEFE1AA7B2F800789CE8 /* LLDBAssert.cpp in Sources */,
26474CB418D0CB180073DEBA /* RegisterContextLinux_x86_64.cpp in Sources */,
2689006613353E0E00698AC0 /* DWARFExpression.cpp in Sources */,
2689006713353E0E00698AC0 /* ASTDumper.cpp in Sources */,
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