IOS收集崩溃日志,查找崩溃代码行
2014-07-29 15:59
453 查看
1.崩溃时候存储错误堆栈
2.系统再次启动时,向服务器发送错误信息。
3.从服务器记录中获取错误信息列表
4.根据内存找到错误代码行
1) 错误堆栈存储到文件中
appDelegate.m 在@interface -@end 之后增加全局方法
NSUncaughtExceptionHandler * uncaughtExceptionHandler =nil;
void UncaughExceptionHandler(NSException * exception) {
NSLog(@"CRASH: %@",exception);
NSLog(@"Stack Trace: %@",[exceptioncallStackSymbols]);
//异常出现时的版本信息
NSString *version = [[[NSBundlemainBundle]infoDictionary]objectForKey:@"CFBundleVersion"];
//异常的堆栈信息
NSArray * stackArray = [exceptioncallStackSymbols];
//出现异常的原因
NSString * reason = [exceptionreason];
//异常名称
NSString * name = [exceptionname];
NSString * errorReason = [NSStringstringWithFormat:@"Error
Detail:<br>version:%@<br>------<br>%@<br>-----------<br>%@<br>-----------<br>%@",version,name,reason,[stackArraycomponentsJoinedByString:@"<br>"]];
NSString * filePath = [NSHomeDirectory()stringByAppendingPathComponent:@"Documents/stackError.txt"];
[errorReason writeToFile:filePathatomically:YESencoding:NSUTF8StringEncodingerror:nil];
return ;
}
2)注册异常方法
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary
*)launchOptions
{
//系统再次启动后把异常文件取出来,传给服务器
NSString * filePath = [NSHomeDirectory()stringByAppendingPathComponent:@"Documents/stackError.txt"]];
//这里写传给服务器的请求代码 略。。
//保存系统处理异常的Handler
uncaughtExceptionHandler =NSGetUncaughtExceptionHandler();
//设置处理异常的handler
NSSetUncaughtExceptionHandler(&UncaughExceptionHandler);
}
3. 服务器获取到的传上来的错误信息是这个样子的,目测只能看出来是数组越界了,但是根本不知道是哪一行.找到自己应用名称后的内存地址。 0x001ff421
Error Detail:<br>version:2.30<br>------<br>NSRangeException<br>-----------<br>*** -[__NSArrayM objectAtIndex:]:
index 5 beyond bounds [0 .. 4]<br>-----------<br>0 CoreFoundation 0x2df93f9b <redacted> + 154<br>1 libobjc.A.dylib 0x38717ccf objc_exception_throw + 38<br>2 CoreFoundation 0x2deca7cb <redacted> + 230<br>3 ingage 0x001ff421 ingage + 1229857<br>4 ingage 0x00200b09
ingage + 1235721<br>5 UIKit 0x308cf03f <redacted> + 1078<br>6 UIKit 0x30981357 <redacted> + 214<br>7 UIKit 0x308306d5 <redacted> + 316<br>8 UIKit 0x307a953b <redacted> + 430<br>9 CoreFoundation 0x2df5f255 <redacted> + 20<br>10 CoreFoundation 0x2df5cbf9 <redacted>
+ 284<br>11 CoreFoundation 0x2df5cf3b <redacted> + 730<br>12 CoreFoundation 0x2dec7ebf CFRunLoopRunSpecific + 522<br>13 CoreFoundation 0x2dec7ca3 CFRunLoopRunInMode + 106<br>14 GraphicsServices 0x32dcd663 GSEventRunModal + 138<br>15 UIKit 0x3081414
97f2
d UIApplicationMain
+ 1136<br>16 ingage 0x000e6b21 ingage + 80673<br>17 ingage 0x000d9518 ingage + 25880
4.打开xcode-window-organizer-archives ,找到发布时候的包,右键 show in finder,文件名格式是 应用名+发布时间.xcarchive格式的,右键-显示简介,找到路径,用terminal工具进入,
一直用cd命令进入到 xxx.xcarchive/dSYMs/ingage.app.dSYM/Contents/Resources/DWARF
执行命令
atos -arch armv7 -o ingage 0x001ff421 ,出现错误的代码行就出来了。
2.系统再次启动时,向服务器发送错误信息。
3.从服务器记录中获取错误信息列表
4.根据内存找到错误代码行
1) 错误堆栈存储到文件中
appDelegate.m 在@interface -@end 之后增加全局方法
NSUncaughtExceptionHandler * uncaughtExceptionHandler =nil;
void UncaughExceptionHandler(NSException * exception) {
NSLog(@"CRASH: %@",exception);
NSLog(@"Stack Trace: %@",[exceptioncallStackSymbols]);
//异常出现时的版本信息
NSString *version = [[[NSBundlemainBundle]infoDictionary]objectForKey:@"CFBundleVersion"];
//异常的堆栈信息
NSArray * stackArray = [exceptioncallStackSymbols];
//出现异常的原因
NSString * reason = [exceptionreason];
//异常名称
NSString * name = [exceptionname];
NSString * errorReason = [NSStringstringWithFormat:@"Error
Detail:<br>version:%@<br>------<br>%@<br>-----------<br>%@<br>-----------<br>%@",version,name,reason,[stackArraycomponentsJoinedByString:@"<br>"]];
NSString * filePath = [NSHomeDirectory()stringByAppendingPathComponent:@"Documents/stackError.txt"];
[errorReason writeToFile:filePathatomically:YESencoding:NSUTF8StringEncodingerror:nil];
return ;
}
2)注册异常方法
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary
*)launchOptions
{
//系统再次启动后把异常文件取出来,传给服务器
NSString * filePath = [NSHomeDirectory()stringByAppendingPathComponent:@"Documents/stackError.txt"]];
//这里写传给服务器的请求代码 略。。
//保存系统处理异常的Handler
uncaughtExceptionHandler =NSGetUncaughtExceptionHandler();
//设置处理异常的handler
NSSetUncaughtExceptionHandler(&UncaughExceptionHandler);
}
3. 服务器获取到的传上来的错误信息是这个样子的,目测只能看出来是数组越界了,但是根本不知道是哪一行.找到自己应用名称后的内存地址。 0x001ff421
Error Detail:<br>version:2.30<br>------<br>NSRangeException<br>-----------<br>*** -[__NSArrayM objectAtIndex:]:
index 5 beyond bounds [0 .. 4]<br>-----------<br>0 CoreFoundation 0x2df93f9b <redacted> + 154<br>1 libobjc.A.dylib 0x38717ccf objc_exception_throw + 38<br>2 CoreFoundation 0x2deca7cb <redacted> + 230<br>3 ingage 0x001ff421 ingage + 1229857<br>4 ingage 0x00200b09
ingage + 1235721<br>5 UIKit 0x308cf03f <redacted> + 1078<br>6 UIKit 0x30981357 <redacted> + 214<br>7 UIKit 0x308306d5 <redacted> + 316<br>8 UIKit 0x307a953b <redacted> + 430<br>9 CoreFoundation 0x2df5f255 <redacted> + 20<br>10 CoreFoundation 0x2df5cbf9 <redacted>
+ 284<br>11 CoreFoundation 0x2df5cf3b <redacted> + 730<br>12 CoreFoundation 0x2dec7ebf CFRunLoopRunSpecific + 522<br>13 CoreFoundation 0x2dec7ca3 CFRunLoopRunInMode + 106<br>14 GraphicsServices 0x32dcd663 GSEventRunModal + 138<br>15 UIKit 0x3081414
97f2
d UIApplicationMain
+ 1136<br>16 ingage 0x000e6b21 ingage + 80673<br>17 ingage 0x000d9518 ingage + 25880
4.打开xcode-window-organizer-archives ,找到发布时候的包,右键 show in finder,文件名格式是 应用名+发布时间.xcarchive格式的,右键-显示简介,找到路径,用terminal工具进入,
一直用cd命令进入到 xxx.xcarchive/dSYMs/ingage.app.dSYM/Contents/Resources/DWARF
执行命令
atos -arch armv7 -o ingage 0x001ff421 ,出现错误的代码行就出来了。
相关文章推荐
- ios查找分析友盟统计闪退日志,代码错误位置的方法闪退分析CrashAnalyze
- iOS程序崩溃日志收集
- iOS 查找友盟错误日志代码位置 —— HERO博客
- iOS 原生的崩溃日志收集与发送一
- ios 崩溃日志收集
- iOS Bugly定位收集真机崩溃日志信息
- iOS-崩溃日志收集(Bugly&BugHD)
- iOS app 崩溃日志符号化及代码定位
- iOS 崩溃日志 收集与发送服务器
- iOS 崩溃日志收集及分析
- iOS崩溃日志收集
- iOS 原生的崩溃日志收集与发送二
- iOS中使用Bugly定位收集真机崩溃日志信息
- iOS崩溃日志收集
- iOS_崩溃日志分析(定位崩溃代码)
- ios 崩溃日志收集
- 用Crashlytics收集ios崩溃日志
- iOS 崩溃日志 收集与发送服务器
- iOS应用崩溃日志揭秘2
- iOS开发中程序崩溃邮件通知代码