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.
Both GDB and LLDB are of course excellent debuggers without doubt. GDB is debugger part of the GNU project created to work along the GNU compiler. LLDB is debugger part of the LLVM project created to work along LLVM compiler. The majority of the commands are the same.
In lldb you can set breakpoints by typing either break or b followed by information on where you want the program to pause. After the b command, you can put either: a function name (e.g., b my_subroutine ) a line number (e.g., b 12 )
An exception breakpoint is a type of breakpoint that is created when some exception occurs in the code. On occurrence of such exception our application stops at that given condition causing the exception and we can access all variables in scope at that breakpoint.
Use break set -E c++
to break on all exceptions and break set -F std::range_error
to break on a specific exception.
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++
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With