Xcode高级调试技巧5
来源:互联网 发布:新闻联播软件 编辑:程序博客网 时间:2024/05/21 20:24
This blog will enhance your in hand experience about most advance tricks for Debugging Xcode Projects. Required Xcode 6.0 Or above.
Table of content
- Introduction
- NSZombie
- Crash
- Crazy Trick
- More Advance Trick
Introduction
I believe we are having a lot of fun on regular basis with scheduled iOS programming. This can also be more interesting by adding more ways to Advance debugging technique.
Often we were working with conventional ways to debug our code using Xcode. However we didn’t reached to any Advance technique in Xcode (Objective-C & Swift).I recently ran into a very tricky exception toward the tail end of a long fruitful day of programming for my project. The only clue that I was given that there was any problem whatsoever was seeing the following statement where the program halted since I have a global breakpoint set up to halt on all exceptions:
EXCBADACCESS
That’s not exactly the most inviting error to debug. Needless to say I wasn’t entirely clear how to even extract more hints as to what was going on since I already output all of the exception details when they’re thrown (in this case there were none). Additionally the stack trace was blank past the entry point to the application delegate – equally puzzling. After some digging around on this vague exception, the conclusion being drawn was one of only two likely possibilities:
Accessing something uninitialized
Accessing something already released by ARC (memory garbage collection essentially). I felt above listed is a more common scenario. Given that, I did some additional digging and stumbled upon a sneaky area within Xcode 6 project configurations that enables developers to squeeze more information out of the debugger in these scenarios.
NSZombie
Xcode 6 Memory Management Zombie ObjectsNavigate to the following area in your project: Product -> Scheme -> Edit Scheme -> Run Debug Section -> Diagnostics Section -> (Check) Enable Zombie Objects.
The zombie objects are basically a memory debugging tool we can take advantage of during development. For more information, please check out Apple Documentation, as it gives a great explanation. This is one of the advance trick we are using so far.
However, Over the long time and by exploring many ways to find out Advance Debugging Technique, This have been reached to another advancement pinnacle with WWDC15 Session. There is super cool ad-ons to debugging trick i have worked so far.
Crash
To write it down this blog, I have created a sample Project having around Few types of different crashes that is horrible to identify, Moreover developer dread to way and dig more in order to pin nail.
Sample Code Download
At a first look on real issues/errors, Click on the objcexceptionthrow in your Thread as shown above.
Yeah, As it realize that, this is all baffle. It’s more complex to understand and deal with.
Crazy Trick
However this is where from the fun part starts. Simply go to your Debug console section and Type “po $arg1” and Press Enter. Wow you got something that is human readable version of error. “po $arg1” brief the Error/Exception first argument and that is what we were alway looking at. This details ways to an easy solutions.
More Advance Trick
We can also add the “po $arg1” command to our Exception Break point, So it would be like Automated debug log behavior for all exceptions.
Steps : 1.Go to breakpoint Navigation. 2.Create a breakpoint (+) at bottom left. 3.Add Exception Break Point. 4.Right Click on (All Exceptions) Breakpoint . 5.Edit Breakpoint. 6.Add Action. 7.add “po $arg1”.
Run your code and Yeah that’s an easiest way to fix.
Have fun with debugging and deal with crashes.
You could also add few more action like : po $eax . That tells more about line causing exception and reason of exception.
- Xcode高级调试技巧5
- Xcode高级调试技巧
- Xcode 高级调试技巧
- Xcode高级调试技巧(2)
- Xcode高级调试技巧(1)
- Xcode高级调试技巧3
- Xcode高级调试技巧4
- Xcode高级调试技巧6
- xcode 5中调试技巧
- iOS开发之Xcode常用调试技巧总结 断点高级
- 5个Xcode开发调试技巧
- 5个Xcode开发调试技巧---超好用
- 5个Xcode开发调试技巧
- 5个Xcode开发调试技巧
- 5个Xcode开发调试技巧
- 5个Xcode开发调试技巧
- 5个Xcode开发调试技巧
- 5个Xcode开发调试技巧[zz]
- 织梦上传显示302错误
- Crazy Android Note
- iOS---UIButton笔记
- memcache和redis对比
- ecshop 商品详细页出现读取信息有缓存 需要后台清除缓存才能正常 一段时间后产品显示又不正常的
- Xcode高级调试技巧5
- Android 自定义imageview 图片高度固定大小宽度按比例自适应
- 正则化方法:L1和L2 regularization、数据集扩增、dropout
- Firefox访问https出现 ssl_error_weak_server_ephemeral_dh_key错误
- @property和@synthesize 用法
- 【FAQ】MAC,ping IP能通,ping域名不通,为何?
- Netty使用实例
- A星算法
- Android开发一些边角数据