Cocos2d,iOS和XCode:我怎样才能debugging/理解这个stacktrace?

我正在开发一个Cocos2d 2.0游戏,无法安静地解决为什么我的应用程序崩溃。

控制台输出如下:

2013-02-08 10:52:08.298 AppName[994:15203] cocos2d: CCSpriteBatchNode: resizing TextureAtlas capacity from [29] to [40]. 2013-02-08 10:52:08.299 AppName[994:15203] cocos2d: CCSpriteBatchNode: resizing TextureAtlas capacity from [40] to [54]. 2013-02-08 10:52:08.300 AppName[994:15203] cocos2d: CCSpriteBatchNode: resizing TextureAtlas capacity from [54] to [73]. (lldb) 

“游戏场景”立即加载并崩溃。 我可以看到,这与CCSpriteBatchNode有关,但我完全不知道代码失败的原因。 如果我添加一个断点,那么这个断点并没有多大用处,因为它会在达到失败的确切时刻之前触发很多次。

(lldb)是什么意思? 有没有办法有更明确的stacktrace? 我曾经在Java和Eclipse工作,并有可能在英文阅读完整的stacktrace ..我怀疑它是使用XCode simle。

你可能会得到那些令人讨厌的EXC_BAD_ACCESS搜寻器之一。 不,没有例外。 例如

 @try { // this is caught // NSMutableArray *ar = [NSMutableArray array]; // [ar addObject:nil]; // this is caught // NSMutableDictionary *dic = [NSMutableDictionary dictionary] ; // [dic setObject:@"a" forKey:nil]; // this crashes , no exception // NSLog("21"); // and this will cause a message sent to a dealloced instance (zombie). // no exception, just a bad crash. GEIntEffect *eff = [GEIntEffect intEffectWithString:@"*1.1" withOrder:geEffectOrderFightMagic andImpact:geEffectImpactPositive]; [eff release]; NSLog([eff description]); [[GameSpecs sharedGameSpecs] setupBattlesInitialSpecs]; // with a comment } @catch (NSException *e) { MPLOGERROR(@"*** an exception [%@] occured while writing the game specs, continuing.\n%@\n\n%@", e.description, e.callStackSymbols, e.callStackReturnAddresses); } 

前两个被困,日志语句是明确的,把日志中的堆栈跟踪。 NSLog(“21”)… ooops,忘记了“@”严重崩溃。 第四个例子,在使用之前错误地释放一个对象…呃,你知道那是做什么的。 我只能build议你:

  • 检查所有的警告(我有一个坏的NSLog)
  • 使用乐器为您的僵尸应用程序进行configuration。 发送给被处理对象的消息也将崩溃。
  • 虽然有一个performance的惩罚,即不要过分,一些战略上放置try / catch块可以帮助巨大。 通常情况下,我在Debug中包装了任何'update'方法,删除了Release中的try / catch。
  • 重新检查你所有的警告:)

祝你好运。

ps:这是什么日志看起来像当我陷阱exception。 偏移不是“代码行”,象征性允许这样做。 但是,通常情况下,我从跟踪中获得足够的信息来将其缩小到真正接近的范围。 :

– [MPGameSequencer sequenceInitState]: *在编写游戏规格时发生exception[* – [__ NSArrayM insertObject:atIndex:]:object不可为零],继续。 (

 0 CoreFoundation 0x028de02e __exceptionPreprocess + 206 1 libobjc.A.dylib 0x022bbe7e objc_exception_throw + 44 2 CoreFoundation 0x02891b6a -[__NSArrayM insertObject:atIndex:] + 314 3 CoreFoundation 0x02891a20 -[__NSArrayM addObject:] + 64 4 Battles 0x00221c49 -[MPGameSequencer sequenceInitState] + 809 5 Battles 0x0021e359 -[MPGameSequencer nextFrame:] + 121 6 Battles 0x00067324 -[CCTimer update:] + 308 7 Battles 0x00070444 -[CCScheduler update:] + 772 8 Battles 0x0009dc81 -[CCDirectorIOS drawScene] + 225 9 Battles 0x0009ef44 -[CCDirectorDisplayLink mainLoop:] + 52 10 QuartzCore 0x007c32d2 _ZN2CA7Display11DisplayLink8dispatchEyy + 110 11 QuartzCore 0x007c375f _ZN2CA7Display16TimerDisplayLink8callbackEP16__CFRunLoopTimerPv + 161 12 CoreFoundation 0x0289d376 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 22 13 CoreFoundation 0x0289ce06 __CFRunLoopDoTimer + 534 14 CoreFoundation 0x02884a82 __CFRunLoopRun + 1810 15 CoreFoundation 0x02883f44 CFRunLoopRunSpecific + 276 16 CoreFoundation 0x02883e1b CFRunLoopRunInMode + 123 17 GraphicsServices 0x035e57e3 GSEventRunModal + 88 18 GraphicsServices 0x035e5668 GSEventRun + 104 19 UIKit 0x00e9165c UIApplicationMain + 1211 20 Battles 0x000c2bce main + 270 21 Battles 0x00002a15 start + 53