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.
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++
.
break set -E c++
didn't work for me (perhaps because I'm using real GNU g++ instead of Apple's clang++?), but break set -n __cxa_throw
did. @AnthonyHall's comment is lacking set
. –
Macaronic break set -E c++
breaks on the rethrow statement. __cxa_throw
works for me. Thank you. –
Valvate Use breakpoint set -E c++
to break on all exceptions and breakpoint set -F std::range_error
to break on a specific exception.
breakpoint set -F std::regex_error
did not work for me. That does a full string match on function name and is thus fragile. However, breakpoint set -r regex_error
, breaking on any function matching regex_error
as a regex (targeting its constructor) did work. –
Crescin 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++
.
break set -E c++
didn't work for me (perhaps because I'm using real GNU g++ instead of Apple's clang++?), but break set -n __cxa_throw
did. @AnthonyHall's comment is lacking set
. –
Macaronic break set -E c++
breaks on the rethrow statement. __cxa_throw
works for me. Thank you. –
Valvate I think breakpoint set -w <boolean>
is the correct answer, you can use help breakpoint set
to see the document.
You can enter
breakpoint set -E c++
into LLDB to do this.
But if you want to configure LLDB to always do this, open ~/.lldbinit
and put the same line into that file.
© 2022 - 2024 — McMap. All rights reserved.