gpt4 book ai didi

ios - Xcode 4 : Exceptions not being logged to the console

转载 作者:技术小花猫 更新时间:2023-10-29 11:09:02 24 4
gpt4 key购买 nike

我最近升级到 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

此异常不会将任何内容记录到 Xcode 4 的控制台。

我可以通过添加异常断点来查看调用堆栈 - 然而,继续越过异常断点不会将任何内容记录到控制台(甚至不是模糊的 SIGABRTEXC_BAD_ACCESS 消息)。

我在“编辑方案”窗口的“诊断”选项卡中选中了“记录异常”和“启用僵尸对象”,但没有帮助。是否还有其他我可能遗漏的设置?

非常感谢。

最佳答案

请考虑使用以下内容增强您的 gdbinit 文件:

How do I set these break points in ~/.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

正如 Kendal 在这篇原始帖子的评论中所述:如果您还没有 gdbinit 文件,您需要创建一个名为 .gdbinit 的新文件 - 将其放入您的主目录并使用提供的内容填充它。现在每次 gdb 启动时都会执行这个文件中的命令。

希望这对您有所帮助。

关于ios - Xcode 4 : Exceptions not being logged to the console,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6860646/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com