lldb:异常断点(相当于 gdb 的 catch throw)
我正在尝试使用 lldb 进行 C++ 调试,并且希望在抛出异常时停止,例如 gdb 的 catch throw
,并且我在 lldb 文档中找不到等效项。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
使用
breakpoint set -E c++
来中断所有异常,使用breakpoint set -F std::range_error
来中断特定异常。Use
breakpoint set -E c++
to break on all exceptions andbreakpoint set -F std::range_error
to break on a specific exception.在 Xcode 中,您可以设置异常断点(View > Navigators > Show Breakpoint Navigator,点击断点列表窗口底部的 + 按钮添加新断点)。
如果您使用命令行 lldb,请在
__cxa_throw
上放置一个断点(对于 C++ 异常抛出),在objc_exception_throw
上放置一个断点(对于 Objective-C 异常抛出)。对于所有 C++ 异常:
break set -E C++
。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++
.我认为
breakpoint set -w
是正确的答案,你可以使用help breakpoint set
查看文档。I think
breakpoint set -w <boolean>
is the correct answer, you can usehelp breakpoint set
to see the document.您可以进入
LLDB 来执行此操作。
但如果您希望将 LLDB 配置为始终执行此操作,请打开
~/.lldbinit
并将同一行放入该文件中。You can enter
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.