[lldb-dev] LLDB Evolution - Final Form

Zachary Turner via lldb-dev lldb-dev at lists.llvm.org
Mon Sep 19 14:31:23 PDT 2016


On Mon, Sep 19, 2016 at 2:20 PM Mehdi Amini <mehdi.amini at apple.com> wrote:

>
>
> I’m surprise by your aversion to assertions, what is your suggested
> alternative? Are you expecting to check and handle every possible
> invariants everywhere and recover (or signal an error) properly? That does
> not seem practical, and it seems to me that it'd lead to just involving UB
> (or breaking design invariant) without actually noticing it.
>
> > Also many asserts are in header files so even if you build llvm and
> clang with asserts off, but then build our project that uses LLVM with
> asserts on, you get LLVM and clang asserts when you don't want them.
>
> It is not really supported to use the LLVM C++ headers without assertions
> and link to a LLVM build with assertions (and vice-versa).
>


> It seems to me that you are mixing two things: asserting on user inputs vs
> asserting on internal invariants of the system. LLVM is very intensive
> about asserting on the second category and this seems fine to me.
> Asserting on external inputs is not great (in LLVM as much as in LLDB).
>
> The asserting error class above falls into the second category and is a
> great tool to enforce programmer error
>
>
I can kind of see both sides on this one.  Yes, if you can catch instances
of UB before it happens that's helpful.  At the same time, when you've got
a product (such as, say, Xcode), you also want to try as hard as possible
not to bring the whole product down.  In lldb we have lldbassert, which
asserts for real in debug, but in release it logs an error to a file.  This
is nice because if someone submits a crash report, we can see the assertion
failure in the log file.

Now, obviously the *real* solution is to make LLDB out-of-process so it
doesn't bring down Xcode when it crashes.  But (and I have no knowledge of
the Xcode / LLDB integration) I can easily see this being a monumental
amount of effort.

Personally, asserting in LLDB doesn't affect me and I'm fine with
lldb::Error asserting..  But I can kind of see the argument for not wanting
it to assert.

On the other hand, if we had better test coverage, then all of these
assertions would be caught during test anyway.  Which brings us back to
item #2 on my list...
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-dev/attachments/20160919/c6c4ffd5/attachment.html>


More information about the lldb-dev mailing list