Whether assertions are enabled or not is orthogonal to the build type
which could lead to surprising behavior for lldbassert. Previously, when
doing a debug build with assertions disabled, lldbassert would become a
NOOP, rather than printing an error like it does in a release build. By
definining lldbassert in terms of NDEBUG, it behaves like a regular
assert when assertions are enabled, and like a soft assert.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
This patch also uses __FILE_NAME__ (Clang-specific extension that functions similar to FILE but only renders the last path component (the filename) instead of an invocation dependent full path to that file.) when building with clang.
+1 to being surprised this is not already the case
Some other places should be updated after this, e.g. lldb/source/Symbol/SymbolFile.cpp also has a use that can be trivially updated:
#if defined(LLDB_CONFIGURATION_DEBUG) // We assert that we have to module lock by trying to acquire the lock from a // different thread. Note that we must abort if the result is true to // guarantee correctness. assert(std::async( std::launch::async, [this] { return this->GetModuleMutex().try_lock(); }).get() == false && "Module is not locked"); #endif
-> just wrap it in lldbassert
Can you put this comment in LLDBAssert.h itself?
This code actually has a comment right above it explaining that it's too expensive to do in release builds, so this isn't a good candidate for lldbassert. But this logic can be improved: it duplicates checking the LLDB_CONFIGURATION_DEBUG in both ASSERT_MODULE_LOCK and AssertModuleLock and should use NDEBUG too. I'll address that in a separate patch.
Can you put this comment in LLDBAssert.h itself?
Good idea.
WDYT about just replacing LLDB_CONFIGURATION_DEBUG with LLVM's EXPENSIVE_CHECKS in this case?
Can you put this comment in LLDBAssert.h itself?
Good idea.