Skip to content

Commit

Permalink
lldb_assert: abort when assertions are enabled.
Browse files Browse the repository at this point in the history
We had a long discussion in D59911 about lldb_assert and what it means.
The result was the assert manifesto on lldb.llvm.org.

> LLDB provides lldb_assert() as a soft alternative to cover the middle
> ground of situations that indicate a recoverable bug in LLDB. In a
> Debug configuration lldb_assert() behaves like assert(). In a Release
> configuration it will print a warning and encourage the user to file a
> bug report, similar to LLVM’s crash handler, and then return
> execution.

However, currently lldb_assert doesn't behave they way it's being
described there: it doesn't abort in a debug/assert build. This patch
fixes that by adding a call to assert() in lldb_assert().

Differential revision: https://reviews.llvm.org/D64267#1571962

llvm-svn: 365246
  • Loading branch information
JDevlieghere committed Jul 5, 2019
1 parent 5e9610a commit b0fc4d4
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lldb/source/Utility/LLDBAssert.cpp
Expand Up @@ -21,6 +21,12 @@ void lldb_private::lldb_assert(bool expression, const char *expr_text,
if (LLVM_LIKELY(expression))
return;

// In a Debug configuration lldb_assert() behaves like assert().
assert(false && "lldb_assert failed");

// In a Release configuration it will print a warning and encourage the user
// to file a bug report, similar to LLVM’s crash handler, and then return
// execution.
errs() << format("Assertion failed: (%s), function %s, file %s, line %u\n",
expr_text, func, file, line);
errs() << "backtrace leading to the failure:\n";
Expand Down

0 comments on commit b0fc4d4

Please sign in to comment.