[转]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开发中减少调试时间,提高效率不可或 ...
随机推荐
- Linux查看非root流程执行
Linux查看非root流程执行 youhaidong@youhaidong-ThinkPad-Edge-E545:~$ ps -U root -u root -N PID TTY TIME CMD ...
- 【百度地图API】如何获取行政区域的边界?
原文:[百度地图API]如何获取行政区域的边界? 摘要:以前教过大家如何自行获取行政区域,或者自定义获取一个区域的边界值.今天来教大家直接调用百度地图API1.3(目前最新版本)来获取行政区域的边界值 ...
- [Android]Parcelable encountered IOException writing serializable object (name = xxx)
Activity之间通过Intent传递值,支持基本数据类型和String对象及它们的数组对象byte.byte[].char.char[].boolean.boolean[].short.short ...
- Yii Framework2.0开发教程(10)配合mysql数据库实现用户登录
1.首先在mysql创建一个存用户的表格 create table test_user ( user_id bigint(20) unsigned not null auto_increment co ...
- Swift入门教程:基本语法(三)
打印输出 Swift提供了2个打印输出函数 println :输出内容后会自动换行 print :对比println,少了个自动换行的功能 示例 输出字符串 println("欢迎学习传智播 ...
- NotePad++ for PHP
原文:NotePad++ for PHP 一.安装设置 1.首先根据你的系统下载相应的安装文件.http://notepad-plus-plus.org/ Notepad++插件:http://sou ...
- Yii Framework2.0开发教程(4)在yii中定义全局变量
在yii中定义全局变量最好的地方是入口脚本处.也就是web目录中的index.php文件 比如我们在defined('YII_ENV') or define('YII_ENV', 'dev');后写上 ...
- Hibernate实体映射配置(XML)简单三步完美配置
我们在使用Hibernate框架的时候,非常纠结的地方就是实体和表之间的映射,今天借助汤老师的思路写了小教程,以后配置不用纠结了! 第一步:写注释 格式为:?属性,表达的是本对象与?的?关系. 例:“ ...
- 去除a标签链接触摸时产生边框
排除误解 网络资料说这个属性只用于iOS(iPhone和iPad),其实是错误的,android手机大部分也是支持的,只是显示效果不一样,移动开发并不成熟,更多的还需要大家去实践来辨别真伪- - -w ...
- 我的MYSQL学习心得(十三)
原文:我的MYSQL学习心得(十三) 我的MYSQL学习心得(十三) 我的MYSQL学习心得(一) 我的MYSQL学习心得(二) 我的MYSQL学习心得(三) 我的MYSQL学习心得(四) 我的MYS ...