我已经使用
Xcode多年了,当我的iOS应用程序收到任何类型的SIGABRT或EXEC_BAD_ACCESS等时,它已停止在gdb窗口中提供信息.现在,当我运行应用程序并生成任何类型的SIGABRT时,我得到一个:
Thread 1: Program received signal: "SIGABRT"
但是,在调试输出窗口中,错误描述和堆栈跟踪通常是我没有输出.这使调试变得非常困难 – 我必须设置随机断点,直到我逐步执行程序并找到导致SIGABRT的行并且修复问题可能非常繁琐而没有任何调试信息.
当我在gdb窗口中输入“info signals”时,我得到:
SIGABRT Yes Yes Yes Aborted
对于信号设置,我认为是正确的.
(gdb) fb -[NSException raise] (gdb) fb objc_exception_throw (gdb) fb malloc_error_break
然后当sigabrt发生时,我使用
(gdb) set $exception = *(id *)($ebp + 8) (gdb) po $exception (gdb) po [$exception name] (gdb) po [$exception reason]
我应该提到我正在使用Xcode 4.2和iOS SDK
解决方法
尝试将这3个放在〜/ .gdbinit文件中:
fb -[NSException raise] fb -[NSAssertionHandler handleFailureInFunction:file:lineNumber:description:] fb -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:]
我的整个.gdbinit如果它有帮助:
#define NSZombies fb -[NSException raise] fb -[NSAssertionHandler handleFailureInFunction:file:lineNumber:description:] fb -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] 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 set env MallocHelp=YES set env NSDebugEnabled=YES 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 NSAutoreleaseFreedObjectCheckEnabled=YES set env MallocStackLoggingNoCompact=YES set env MallocStackLogging=YES set env CFZombie 5 tty /dev/ttys000