I've been using Xcode for a years now and it has stopped providing information in the gdb window when my iOS app receives any kind of SIGABRT or EXEC_BAD_ACCESS etc. Now when I run the app and it generates any kind of SIGABRT I get a:
Thread 1: Program received signal: "SIGABRT"
But, in the debug output window where the error description and stack trace would normally be I get no output. This makes debugging really difficult - I have to set random breakpoints till I step through the program and find the line that caused the SIGABRT and fixing the problem can be very tedious without any debugging info.
When I enter "info signals" in the gdb window I get:
SIGABRT Yes Yes Yes Aborted
for the signal settings, which I think is correct.
The only way to get any info that I have found is to set a break point using:
(gdb) fb -[NSException raise]
(gdb) fb objc_exception_throw
(gdb) fb malloc_error_break
and then when the sigabrt happens i use
(gdb) set $exception = *(id *)($ebp + 8)
(gdb) po $exception
(gdb) po [$exception name]
(gdb) po [$exception reason]
I should mention I'm using Xcode 4.2 and iOS SDK
Try putting these 3 in your ~/.gdbinit
file:
fb -[NSException raise]
fb -[NSAssertionHandler handleFailureInFunction:file:lineNumber:description:]
fb -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:]
My entire .gdbinit
if it helps:
#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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.