ios调试经验
来源:互联网 发布:windows官网下载镜像 编辑:程序博客网 时间:2024/04/28 20:23
程序开发的时候,总会遇到这样那样的bug。有些情况下打印日志比较方便,更多的时候需要依靠Debug工具。
XCode为我们集成了图形化的调试工具,也提供了命令行接口,所以调试起来还是比较方便的。
如上图,左侧是图形化界面,右侧是命令行接口。
常用命令
p xxx :如果xxx是Object,打印地址,否则打印value
po xxx:xxx必须是Object,打印对象的description
expr xxx=???:将变量xxx的值修改成???
breakpoint set -n "-[UIView setFrame:]" :将断点设在某个方法上
breakpoint set --selector selectxxx:将断点设在某个selector上
watchpoint set variable xxx:设置变量断点,当变量被修改时会中断
watchpoint set expression -- xxx [-x byte_size]:设置内存区域断点,发生修改时会中断
异常断点:断点窗口左下角添加Add Exception Breakpoint,能在发生异常式断住
常见错误
EXC_BAD_ACCESS 内存访问错误
1、设置Enable Zombie Objects ,能够打印出一些有用信息
*** -[UIView superview]: message sent to deallocated instance 0xa081220
但有时候还不够,还想知道那个地址对应的对象是哪来的。需要再设置Malloc Stack。然后在命令行下执行malloc_history 线程号 内存地址
sudo malloc_history 1157 0x993baa0
就会打印出该地址对象的创建过程
malloc_history Report Version: 2.0Process: DebugDemo [1157]Path: /Users/minjieni/Library/Application Support/iPhone Simulator/7.0/Applications/0C40E6FA-9F86-462B-84E3-D480281EF48D/DebugDemo.app/DebugDemoLoad Address: 0x1000Identifier: DebugDemoVersion: ??? (???)Code Type: X86 (Native)Parent Process: debugserver [1158]Date/Time: 2013-10-11 22:53:17.117 +0800OS Version: Mac OS X 10.8.4 (12E3200)Report Version: 7ALLOC 0x993baa0-0x993baff [size=96]: thread_1ea8a28 |start | main | UIApplicationMain | GSEventRun | GSEventRunModal | CFRunLoopRunInMode | CFRunLoopRunSpecific | __CFRunLoopRun | __CFRunLoopDoSources0 | __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ | _UIApplicationHandleEventQueue | -[UIApplication sendEvent:] | -[UIWindow sendEvent:] | -[UIWindow _sendTouchesForEvent:] | -[UIControl touchesEnded:withEvent:] | -[UIControl _sendActionsForEvents:withEvent:] | -[UIControl sendAction:to:forEvent:] | -[UIApplication sendAction:toTarget:fromSender:forEvent:] | -[UIApplication sendAction:to:from:forEvent:] | -[NSObject performSelector:withObject:withObject:] | -[ViewController gotoDetailViewController] | -[UIViewController presentViewController:animated:completion:] | -[UIViewController presentViewController:withTransition:completion:] | -[UIWindowController transition:fromViewController:toViewController:target:didEndSelector:animation:] | -[UIViewController _preferredInterfaceOrientationForPresentationInWindow:fromInterfaceOrientation:] | -[UIViewController shouldAutorotate] | -[UIViewController view] | -[UIViewController loadViewIfRequired] | -[DetailViewController viewDidLoad] | _objc_rootAlloc | class_createInstance | calloc | malloc_zone_calloc
- ios调试经验
- 调试经验
- 调试经验
- 调试经验
- javascript调试经验
- Tomcat调试经验。
- 项目调试经验1
- 项目调试经验2
- Tomcat调试经验。
- BCB 串口调试经验
- 吐血VB6调试经验
- 程序调试经验
- OpenCV调试经验
- S3C44b0 RTC调试经验
- camera调试经验分享
- 系统调试经验
- i2c驱动调试经验
- camera调试经验分享
- hadoop初学之--------GenericOptionsParser解析器
- wikioi 1010 过河卒 (2002年NOIP全国联赛普及组)
- 前缀、中缀、后缀表达式及其相互转化的Java实现
- 中国开源基础类库 NDKK 正式命名
- 直接拿来用!最火的Android开源项目(一)
- ios调试经验
- Android 自定义权限 (<permission> <uses-permission>) 和 Android 系统启动时自启动一个app
- CopyOnWrite
- 从今天起改变自己
- 项目合作初有感
- Cocos2d-x学习之---2013年10月11日小记
- WHY YOU SHOULDN'T MERGE JAVASCRIPT IN MAGENTO
- file_put_contents以及file_get_contents的用法与在使用过程中遇到的问题(PHP学习)
- 整型数组处理算法(十一)请实现一个函数:线段重叠(性能优化)。[风林火山]