lldb: Breakpoint on exceptions (equivalent of gdb's catch throw)

DebuggingLlvmLldb

Debugging Problem Overview


I am trying to use lldb for c++ debugging and I want to halt if an exception is thrown, like gdb's catch throw, and I cannot find an equivalent in the lldb documentation.

Debugging Solutions


Solution 1 - Debugging

Use break set -E c++ to break on all exceptions and break set -F std::range_error to break on a specific exception.

Solution 2 - Debugging

In Xcode, you can set an Exception breakpoint (View > Navigators > Show Breakpoint Navigator, hit the + button in the bottom of the breakpoint list window to add a new breakpoint).

If you're using command line lldb, put a breakpoint on __cxa_throw for C++ exception throws, objc_exception_throw for Objective-C exception throws.

For all c++ exceptions: break set -E C++.

Solution 3 - Debugging

I think breakpoint set -w <boolean> is the correct answer, you can use help breakpoint set to see the document.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionplaisthosView Question on Stackoverflow
Solution 1 - DebuggingJonas KView Answer on Stackoverflow
Solution 2 - DebuggingJason MolendaView Answer on Stackoverflow
Solution 3 - DebuggingCasa TaloyumView Answer on Stackoverflow