作者热门文章
- r - 以节省内存的方式增长 data.frame
- ruby-on-rails - ruby/ruby on rails 内存泄漏检测
- android - 无法解析导入android.support.v7.app
- UNIX 域套接字与共享内存(映射文件)
我在 Xcode 中配置了一个 All Exceptions 断点:
有时 Xcode 会停在如下一行:
[managedObjectContext save:&error];
使用以下回溯:
但如果您单击“继续”,程序将继续运行,就好像什么也没发生一样。
我怎样才能忽略这些“正常”异常,但仍然让调试器在我自己的代码出现异常时停止?
(我知道发生这种情况是因为 Core Data 在内部抛出并捕获异常,并且 Xcode 只是尊重我的请求,在抛出异常时暂停程序。但是,我想忽略这些,以便我可以返回调试我自己的代码!)
主持人:这类似于 "Xcode 4 exception breakpoint filtering" ,但我认为这个问题花了太长时间才能达到目的,而且没有任何有用的答案。它们可以链接起来吗?
最佳答案
对于核心数据异常,我通常做的是从 Xcode 中删除“所有异常”断点,而是:
objc_exception_throw
上添加符号断点(BOOL)(! (BOOL)[[(NSException *)$x0 className] hasPrefix:@"_NSCoreData"])
配置的断点应该是这样的:
这将忽略任何用于控制流的私有(private)核心数据异常(由前缀为 _NSCoreData
的类名决定)。请注意,适当的寄存器将取决于您正在运行的目标设备/模拟器。看看 this table供引用。
请注意,此技术可以很容易地适应其他条件。棘手的部分是制作 BOOL 和 NSException 强制转换以使 lldb 对条件满意。
关于iphone - 使用 Xcode 的 All Exceptions 断点时忽略某些异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14370632/
我是一名优秀的程序员,十分优秀!