此问题是远远过时,因为它要求的XCode 3,请不要考虑它的XCode有用4+。 =)


我的应用崩溃时(貌似)随机事件。所以,我想添加NSZombieEnabled调试我iPhone应用程序。我克隆我的目标和设置其的Info.plist到相同的原始目标和设定NSZombieEnabled为YES。

在我运行应用程序,它与...

的堆栈跟踪崩溃
#0  0x3025db0c in ___forwarding___ ()
#1  0x30239db2 in __forwarding_prep_0___ ()
#2  0x304f5105 in NSPopAutoreleasePool ()
#3  0x308ee452 in _UIApplicationHandleEvent ()
#4  0x32031425 in PurpleEventCallback ()
#5  0x30235253 in CFRunLoopRunSpecific ()
#6  0x302343c8 in CFRunLoopRunInMode ()
#7  0x308e6209 in -[UIApplication _run] ()
#8  0x308eef81 in UIApplicationMain ()
#9  0x000023ef in main (argc=1, argv=0xbffff0bc) at /Users/tomen/Documents/MIB-Sprint4/main.m:26

当NSZombieEnabled设置为YES这只发生。如果它没有被设置,该应用只是运行(和在不同的时间崩溃)

我想添加断点喜欢“ - [_ NSZombie:]方法”等人,但他们在调试过程中得到激活。我尝试这两种方法与接通和断开“加载延迟加载符号”

我还试图在我〜/ .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

其产生这样的结果在控制台:

The Debugger has exited with status 0.
[Session started at 2009-09-08 13:48:40 +0200.]
Loading program into debugger…
GNU gdb 6.3.50-20050815 (Apple version gdb-966) (Tue Mar 10 02:43:13 UTC 2009)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i386-apple-darwin".warning: Unable to read symbols for "/System/Library/Frameworks/UIKit.framework/UIKit" (file not found).
warning: Unable to read symbols from "UIKit" (not yet mapped into memory).
warning: Unable to read symbols for "/System/Library/Frameworks/CoreGraphics.framework/CoreGraphics" (file not found).
warning: Unable to read symbols from "CoreGraphics" (not yet mapped into memory).
Pending breakpoint 1 - "-[NSException raise]" resolved
Pending breakpoint 2 - "-[NSAssertionHandler handleFailureInFunction:file:lineNumber:description:]" resolved
Pending breakpoint 3 - "-[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:]" resolved
Pending breakpoint 14 - "szone_error" resolved
Program loaded.
sharedlibrary apply-load-rules all
Attaching to program: `/Users/tomen/Library/Application Support/iPhone Simulator/User/Applications/F77D9D82-0B34-4B8D-9076-AE883A2714F4/MIB.app/MIB', process 279.
Re-enabling shared library breakpoint 1
Re-enabling shared library breakpoint 2
Re-enabling shared library breakpoint 3
Re-enabling shared library breakpoint 14
Re-enabling shared library breakpoint 16
Re-enabling shared library breakpoint 17
Re-enabling shared library breakpoint 18
warning: Couldn't raise load state for requested objfile: "/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation" for breakpoint 1/

warning: Couldn't raise load state for requested objfile: "/System/Library/Frameworks/Foundation.framework/Versions/C/Foundation" for breakpoint 2/

warning: Couldn't raise load state for requested objfile: "/System/Library/Frameworks/Foundation.framework/Versions/C/Foundation" for breakpoint 3/

为什么我的断点得到停用?

有帮助吗?

解决方案

,我一直尝试这种方法也具有相同的结果。我的理解是NSZombie断点不再Leopard和Snow Leopard有效。

一些替代:

1)转储上obj_msg_send eax寄存器。我没有亲自试过这一个,但我发现很多关于这个主题的帖子: 如何调试EXC_BAD_ACCESS只发生在公布目标的iPhone应用程序?

2)使用信息的malloc历史。作品很好在模拟器中但我有一点运气获得注销设备。的查找释放的对象的解除分配的情况下

3)可能是最好的事情是运行仪器您的应用程序。需要注意的是NSZombie模式不可用在设备上。这可能会有所帮助: iPhone存储器调试NSZombie

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top