[转]http://www.russbishop.net/xcode-exception-breakpoints
原文:http://www.russbishop.net/xcode-exception-breakpoints
Many people are not aware of Xcode's powerful features for managing breakpoints during debugging. One such feature is the Exception breakpoint. Go to the Breakpoint navigator pane, click +, then click Add Exception Breakpoint. Cool, now you'll break right at any exception, instead of in main() long after the context has been lost.
However if you happen to use CoreData, you'll discover that it throws and catches exceptions internally as a form of stack unwinding and control flow which makes debugging such an application highly annoying. You can fix that by excluding all CoreData exceptions. First remove the All Exceptions breakpoint, then and add a new Symbolic breakpoint on objc_exception_throw, then set a condition on the Breakpoint for (BOOL)(! (BOOL)[[(NSException *)$eax className] hasPrefix:@"_NSCoreData"]).
That works just fine... on the 32-bit simulator or a 32-bit Mac application. Unfortunately the register names are quite different on 64-bit Intel and both 32-bit and 64-bit ARM:
| Architecture | Exception Register |
|---|---|
| x86 | $eax |
| x86-64 | $rdi |
| ARM | $r0 |
| ARM-64 | $x0 |
We could create an lldb Python script to help us figure out the proper register and setup exception exclusions, but fortunately poster chendo over on StackOverflow has done the work for us.
Just create the script as shown in the answer and hook it up in your ~/.lldbinit. Then you can create the vanilla All Exceptions breakpoint, but make the first action your ignore script with the proper parameters. During execution the breakpoint will be hit, but Xcode will run the command causing it to immediately resume execution. This delay would be intolerable in a tight loop, but exceptions should be exceptional events so the performance should be perfectly acceptable.
This also highlights some awesome power debugging features many people don't take advantage of; if you can script it in Python, you can make Xcode do it for you automatically. Just setup your breakpoint conditions and have Xcode launch one or more scripts in response. You dump network responses, log all initializer parameters for a certain class, and many other things without having to include that code explicitly in every project and gate it behind preprocessor flags.
[1] Who clicks on these kinds of advertisements!? My pet theory is they're designed to weed out those with intelligence and common sense to ensure only the most gullible people become sales leads.
[转]http://www.russbishop.net/xcode-exception-breakpoints的更多相关文章
- IOS调试技巧:当程序崩溃的时候怎么办 xcode调试
转自:http://www.ityran.com/archives/1143 ------------------------------------------------ 欢迎回到当程序崩溃的时候 ...
- Xcode 的正确打开方式——Debugging
程序员日常开发中有大量时间都会花费在 debug 上,从事 iOS 开发不可避免地需要使用 Xcode.这篇博客就主要介绍了 Xcode 中几种能够大幅提升代码调试效率的方式. “If debuggi ...
- 【转】 当程序崩溃的时候怎么办 Part-2
转自:http://www.tairan.com/archives/1143 欢迎回到当程序崩溃的时候怎么办 教程! 在这个教程的第一部分,我们介绍了SIGABRT和EXC_BAD_ACCESS错误, ...
- [ios-必看] IOS调试技巧:当程序崩溃的时候怎么办 iphone IOS
from:http://article.ityran.com/archives/1143 有这样一种情形:当我们正在快乐的致力于我们的app时,并且什么看都是无比顺利,但是突然,坑爹啊,它崩溃了.(悲 ...
- 【转】你所不知道的Android Studio调试技巧
这篇写Android studio debug技巧个人觉得写得不错,转自:http://www.jianshu.com/p/011eb88f4e0d# Android Studio目前已经成为开发An ...
- Eclipse Debug
[IT168 专稿]调试的方法虽然千千万万,但归根结底,就是找到引发错误的代码.Eclipse调试器的目标是让程序员能对本地或远程程序进行错误侦测与诊断.该调试器提供所有标准调试功能,包括进行单步执行 ...
- 你所不知道的Android Studio调试技巧
转载:http://www.jianshu.com/p/011eb88f4e0d Android Studio目前已经成为开发Android的主要工具,用熟了可谓相当顺手.作为开发者,调试并发现bug ...
- 在Intellij IDEA中使用Debug
Debug用来追踪代码的运行流程,通常在程序运行过程中出现异常,启用Debug模式可以分析定位异常发生的位置,以及在运行过程中参数的变化.通常我们也可以启用Debug模式来跟踪代码的运行流程去学习三方 ...
- idea之debug
[转载]原文地址:https://www.cnblogs.com/nihaorz/p/7613967.html 在Intellij IDEA中使用Debug Debug用来追踪代码的运行流程,通常在程 ...
- debug2
调试常用功能介绍 日常java开发中实际写代码的时间并不会很多,花在整理思路,代码重构,调试bug会占用很大部分时间. 熟练掌握调试工具,了解调试相关技巧,是java开发中减少调试时间,提高效率不可或 ...
随机推荐
- Git批量删除
Git批量删除 git的改动都需要stage过程后才能commit.当git中有大量改动时就需要能够批量操作在方便.改动分三种: modify: 有文件修改 add: 有文件增加 rm: 有文件删除 ...
- Web项目
Eclipse部署Web项目(图文讲解) 讲解是在linux下完成的,但对windows系统,操作也是一样的,不要被吓到了 1.下载Eclipse
- oracle_oracle中修改日期的显示格式
我的现在的日期格式是 ,要改成英文的需要输入一下命令: ALTER SESSION SET NLS_DATE_LANGUAGE=AMERICAN; 修改后变为: 同样也得若是英文要想 ...
- measureChildren作品
无论是在改写View依然是ViewGroup什么时候.特别ViewGrop什么时候,通常是不可避免的重写onMeasure方法,我们一定会调用setMeasuredDimension()将測量好的宽高 ...
- linux_redhat_线程后台运行方法
建议看完1:后直接看2 screen 方式熟练些可靠. 次方法适用于redhat系统,unbunt* 系统用screen 命令 产看系统版本 cat /proc/version 首先项目制作的sh文件 ...
- java_model_dao_自动生成_generator-mybatis-generator-1.3.2 基于maven插件
用mybatis原因很简单,易用,性能.是介于jdbc和hibernate之间的一个完美方案. 很简单: 1:配置pom <project xmlns="http://maven.ap ...
- 实战parse_ini_file()及扩展函数解析ini文件完整版
文章来源:PHP开发学习门户 地址:http://www.phpthinking.com/archives/587 在PHP站点开发的过程中,往往会用到读取ini參数配置文件,比方须要訪问一些复杂的借 ...
- Android锁定EditText内容和随机生成验证码
昨天写了个小Demo,实现了随机生成验证码,和锁定EditText两个小功能,先看一下效果图: 锁定EditText在我们不须要用户编辑EditText内容的时候能够用到,实现还是非常easy的,一行 ...
- 数据库 基于索引的SQL语句优化之降龙十八掌(转)
一篇挺不错的关于SQL语句优化的文章,因不知原始出处,故未作引用说明! 1 前言 客服业务受到SQL语句的影响非常大,在规模比较大的局点,往往因为一个小的SQL语句不够优化,导致数据库性能急 ...
- 基础总结篇之五:BroadcastReceiver应用具体解释
問渠那得清如許?為有源頭活水來.南宋.朱熹<觀書有感> 据说程序猿是最爱学习的群体,IT男都知道,这个行业日新月异,必须不断地学习新知识,不断地为自己注入新奇的血液,才干使自己跟上技术的步 ...