gpt4 book ai didi

iphone - 使用 Xcode 的 All Exceptions 断点时忽略某些异常

转载 作者:IT王子 更新时间:2023-10-29 07:31:23 31 4
gpt4 key购买 nike

我在 Xcode 中配置了一个 All Exceptions 断点:

screenshot of an exception breakpoint configured in Xcode breakpoint pain, configured to make a sound when an exception is thrown

有时 Xcode 会停在如下一行:

[managedObjectContext save:&error];

使用以下回溯:

backtrace showing NSPersistentStoreCoordinator throwing an exception inside the call to save:

但如果您单击“继续”,程序将继续运行,就好像什么也没发生一样。

我怎样才能忽略这些“正常”异常,但仍然让调试器在我自己的代码出现异常时停止?

(我知道发生这种情况是因为 Core Data 在内部抛出并捕获异常,并且 Xcode 只是尊重我的请求,在抛出异常时暂停程序。但是,我想忽略这些,以便我可以返回调试我自己的代码!)

主持人:这类似于 "Xcode 4 exception breakpoint filtering" ,但我认为这个问题花了太长时间才能达到目的,而且没有任何有用的答案。它们可以链接起来吗?

最佳答案

对于核心数据异常,我通常做的是从 Xcode 中删除“所有异常”断点,而是:

  1. objc_exception_throw 上添加符号断点
  2. 将断点上的条件设置为 (BOOL)(! (BOOL)[[(NSException *)$x0 className] hasPrefix:@"_NSCoreData"])

配置的断点应该是这样的: Configuring the Breakpoint

这将忽略任何用于控制流的私有(private)核心数据异常(由前缀为 _NSCoreData 的类名决定)。请注意,适当的寄存器将取决于您正在运行的目标设备/模拟器。看看 this table供引用。

请注意,此技术可以很容易地适应其他条件。棘手的部分是制作 BOOL 和 NSException 强制转换以使 lldb 对条件满意。

关于iphone - 使用 Xcode 的 All Exceptions 断点时忽略某些异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14370632/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com