调试

Android崩溃异常捕获方法

我们先从Exception讲起。Exception分为两类:一种是CheckedException,一种是UncheckedException。这两种Exception的区别主要是CheckedException需要用try...catch...显示的捕获,而UncheckedException不需要捕获。通常UncheckedException又叫做RuntimeException。《effective java》指出:对于可恢复的条件使用被检查的异常(CheckedException),对于程序错误(言外之意不可恢复,大错已经酿成)使用运行时异常(RuntimeException)。我们常见的RuntimeExcepiton有IllegalArgumentException、IllegalStateException、NullPointerException、IndexOutOfBoundsException等等。对于那些CheckedException就不胜枚举了,我们在编写程序过程中try...catch...捕捉的异常都是CheckedException。io包中的IOException及其子类,这些都是CheckedException。

 

 调试设置选项,可以看到发送的错误方法

- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error
{

//一个页面没有被完全加载之前收到下一个请求,此时迅速会出现此error,error=-999
//此时可能已经加载完成,则忽略此error,继续进行加载。
//http://stackoverflow.com/questions/1024748/how-do-i-fix-nsurlerrordomain-error-999-in-iphone-3-0-os

    if([error code] == NSURLErrorCancelled)
    {
        return;
    }
}

  

NSUncaughtionHandler, Xcode调试相关与异常捕获 good

添加全局断点

Xcode4可以很方便的添加全局的异常断点

小技巧8-iOS 使用Global BreakPoint(全局断点)快速定位Bug

 

 

Xcode如何查看内存中的数据

 

(lldb) x/16xb bio_private->ptr
0x15e15b1c: 0x00 0x02 0x86 0x16 0x00 0x00 0x00 0x00
0x15e15b24: 0x00 0x00 0x00 0x00 0xa4 0x04 0x06 0x00

 

(lldb) p [NSString stringWithUTF8String:(char*)bio_private->ptr];
(id) $4 = 0x39139160
(lldb) po [NSString stringWithUTF8String:(char*)bio_private->ptr];
<object returned empty description>

 

xcode中查看内存数据

在代码中加入断点,中断后在debug area中的变量查看窗口中,选择想要查看的变量,右键选择View Memory of "变量名" 即可。

 

Error Domain=NSURLErrorDomain Code=-999错误

 

 

Xcode6 模拟器路径    和xcode5不同了

xcode6.0.1 document路径: /Users/wgyp/Library/Developer/CoreSimulator/Devices/DC38ADD9-F4D7-453D-8C11-D6935D516A80/data/Containers/Data/Application/8E5F6518-1262-448F-8270-B1DDFF773967/Documents

打印一个vidw的地址 用   %p view

outstring appendFormat:@"[%2d] [%p] %@,%@ frame:%@\n", indent,aView,aView,[[aView class] description], NSStringFromCGRect(aView.frame)];

 

Xcode7中你一定要知道的炸裂调试神技

发布后的crash跟踪,轻松定位崩溃代码

在Xcode中查看具体崩溃信息

Xcode中的iOS模拟器(iOS Simulator)的介绍和使用心得

开发过程中危机四伏的调试

iOS应用崩溃日志揭秘与分析 系列 good

 process Launch Failed:failed to Get the Task for Process 1285

Provisioning Profile 用开发者证书

 

 

 

layout:

[ 0] [0x7fe7da778690] UIWindow frame:{{0, 0}, {320, 568}}

--[ 1] [0x7fe7da696c00] UILayoutContainerView frame:{{0, 0}, {320, 568}}

----[ 2] [0x7fe7da556f70] UITransitionView frame:{{0, 0}, {320, 568}}

------[ 3] [0x7fe7da5aeb30] UIViewControllerWrapperView frame:{{0, 0}, {320, 568}}

--------[ 4] [0x7fe7da55b080] UILayoutContainerView frame:{{0, 0}, {320, 568}}

----------[ 5] [0x7fe7da6a9200] UINavigationTransitionView frame:{{0, 0}, {320, 568}}

------------[ 6] [0x7fe7dc8816c0] UIViewControllerWrapperView frame:{{0, 0}, {320, 568}}

--------------[ 7] [0x7fe7da610cd0] UIView frame:{{0, 64}, {320, 504}}

----------------[ 8] [0x7fe7da5b0c70] UILabel frame:{{10, 10}, {40, 30}}

----------------[ 8] [0x7fe7da8cca00] UIScrollView frame:{{52, 0}, {320, 50}}

------------------[ 9] [0x7fe7da44fb60] UIButton frame:{{10, 10}, {90, 30}}

--------------------[10] [0x7fe7da4f0b50] UIButtonLabel frame:{{10, 6.5}, {70, 17}}

------------------[ 9] [0x7fe7da57ece0] UIImageView frame:{{314.5, 3}, {2.5, 44}}

navbar:

----------[ 5] [0x7fe7da55b220] UINavigationBar frame:{{0, 20}, {320, 44}}

------------[ 6] [0x7fe7da6a7f70] _UINavigationBarBackground frame:{{0, -20}, {320, 64}}

--------------[ 7] [0x7fe7da6a8270] UIImageView frame:{{0, 64}, {320, 0.5}}

------------[ 6] [0x7fe7da6a8f40] _UINavigationBarBackIndicatorView frame:{{8, 11.5}, {13, 21}}

------------[ 6] [0x7fe7da7bafe0] UINavigationItemView frame:{{126, 8}, {68, 27}}

--------------[ 7] [0x7fe7da78d910] UILabel frame:{{0, 3.5}, {68, 21.5}}

 

UItabbar的布局

----[ 2] [0x7fe7da5561d0] UITabBar frame:{{0, 519}, {320, 49}}

------[ 3] [0x7fe7da526020] _UITabBarBackgroundView frame:{{0, 0}, {320, 49}}

--------[ 4] [0x7fe7da55e2a0] _UIBackdropView frame:{{0, 0}, {320, 49}}

----------[ 5] [0x7fe7da50b3a0] _UIBackdropEffectView frame:{{0, 0}, {320, 49}}

----------[ 5] [0x7fe7da55e5b0] UIView frame:{{0, 0}, {320, 49}}

------[ 3] [0x7fe7da7a4440] UITabBarButton frame:{{2, 1}, {76, 48}}

--------[ 4] [0x7fe7da6ca690] UITabBarSwappableImageView frame:{{25, 5}, {26, 26}}

--------[ 4] [0x7fe7da7a4ae0] UITabBarButtonLabel frame:{{28, 35}, {20, 12}}

------[ 3] [0x7fe7da6cb4c0] UITabBarButton frame:{{82, 1}, {76, 48}}

--------[ 4] [0x7fe7da6cf3a0] UITabBarSwappableImageView frame:{{25, 5}, {26, 26}}

--------[ 4] [0x7fe7da6cb720] UITabBarButtonLabel frame:{{28, 35}, {20, 12}}

------[ 3] [0x7fe7da6d0670] UITabBarButton frame:{{162, 1}, {76, 48}}

--------[ 4] [0x7fe7da470310] UITabBarSwappableImageView frame:{{25, 5}, {26, 26}}

--------[ 4] [0x7fe7da6d00a0] UITabBarButtonLabel frame:{{23, 35}, {30, 12}}

------[ 3] [0x7fe7da6d0eb0] UITabBarButton frame:{{242, 1}, {76, 48}}

--------[ 4] [0x7fe7da474d80] UITabBarSwappableImageView frame:{{25, 5}, {26, 26}}

--------[ 4] [0x7fe7da6ce460] UITabBarButtonLabel frame:{{28, 35}, {20, 12}}

------[ 3] [0x7fe7da55e720] UIImageView frame:{{0, -0.5}, {320, 0.5}}

 

posted @ 2015-02-12 11:29  米粥米  阅读(348)  评论(0编辑  收藏  举报