我最近升级到Xcode 4,还没有弄清楚如何将异常和错误消息记录到运行控制台.
示例:在Xcode 3中,[[NSArray array] objectAtIndex:1]导致以下结果记录到控制台.
2011-08-10 10:27:22.061 App[28662:40b] *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[NSArray objectAtIndex:]: index 1 beyond bounds for empty array'
*** Call stack at first throw:
(
0 CoreFoundation 0x015babe9 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x0170f5c2 objc_exception_throw + 47
2 CoreFoundation 0x015b080c -[__NSArrayI objectAtIndex:] + 236
3 App 0x00002514 -[AppDelegate application:didFinishLaunchingWithOptions:] + 357
4 UIKit 0x003fc1fa -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 1163
5 UIKit 0x003fe55e -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 439
6 UIKit 0x00408db2 -[UIApplication handleEvent:withNewEvent:] + 1533
7 UIKit 0x00401202 -[UIApplication sendEvent:] + 71
8 UIKit 0x00406732 _UIApplicationHandleEvent + 7576
9 GraphicsServices 0x01c24a36 PurpleEventCallback + 1550
10 CoreFoundation 0x0159c064 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
11 CoreFoundation 0x014fc6f7 __CFRunLoopDoSource1 + 215
12 CoreFoundation 0x014f9983 __CFRunLoopRun + 979
13 CoreFoundation 0x014f9240 CFRunLoopRunSpecific + 208
14 CoreFoundation 0x014f9161 CFRunLoopRunInMode + 97
15 UIKit 0x003fdfa8 -[UIApplication _run] + 636
16 UIKit 0x0040a42e UIApplicationMain + 1160
17 App 0x00002393 main + 85
Run Code Online (Sandbox Code Playgroud)
此异常不会在Xcode 4中将任何内容记录到控制台.
我能够通过添加一个异常断点来查看调用堆栈-然而,持续过去异常断点不会记录到控制台(甚至不是一个模糊SIGABRT或EXC_BAD_ACCESS消息).
我在"编辑方案"窗口的"诊断"选项卡中选中了"日志例外"和"启用僵尸对象",但它没有帮助.还有其他可能缺少的设置吗?
非常感谢.
请考虑使用以下内容增强您的 gdbinit 文件:
fb -[NSException raise]
fb -[NSAssertionHandler handleFailureInFunction:file:lineNumber:description:]
fb -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:]
#define NSZombies
# this will give you help messages. Set to NO to turn them off.
set env MallocHelp=YES
# might also be set in launch arguments.
set env NSZombieEnabled=YES
set env NSDeallocateZombies=NO
set env MallocCheckHeapEach=100000
set env MallocCheckHeapStart=100000
set env MallocScribble=YES
set env MallocGuardEdges=YES
set env MallocCheckHeapAbort=1
set env CFZombie 5
fb -[_NSZombie init]
fb -[_NSZombie retainCount]
fb -[_NSZombie retain]
fb -[_NSZombie release]
fb -[_NSZombie autorelease]
fb -[_NSZombie methodSignatureForSelector:]
fb -[_NSZombie respondsToSelector:]
fb -[_NSZombie forwardInvocation:]
fb -[_NSZombie class]
fb -[_NSZombie dealloc]
fb szone_error
Run Code Online (Sandbox Code Playgroud)
正如 Kendal 在这篇原始文章中的评论中所述:如果您还没有 gdbinit 文件,您需要创建一个名为 .gdbinit 的新文件 - 将其放在您的主目录中并用提供的内容填充它。现在,每次 gdb 启动时,它都会执行该文件中的命令。
希望这可以帮助。
| 归档时间: |
|
| 查看次数: |
1420 次 |
| 最近记录: |