如何使用 LLDB 导航堆栈帧以跟踪 xCode 中调用的原始行



我在游戏中很少收到错误,我正在尝试确定哪个 runAction 与正在进行的操作冲突。我知道我只需要停止上一个操作,但无法确定哪个操作正在尝试运行。

任何人都可以给我建议如何在回溯中查看前面或导航到更有用的区域,因为大多数回溯只是抛出错误,我想在抛出错误之前看看发生了什么?

这是我的错误和回溯,以帮助提供一些上下文。

注意:在LLDB方面,我是一个菜鸟!

2012-10-01 19:44:27.000 Game Name[19255:907] *** Assertion failure in -[CCActionManager addAction:target:paused:], /Users/username/Documents/Development/Sandbox/Game Name/libs/cocos2d/CCActionManager.m:177
2012-10-01 19:44:27.004 Game Name[19255:907] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'runAction: Action already running'
*** First throw call stack:
(0x392b83e7 0x354b6963 0x392b829d 0x356647b3 0x2799d 0x497d7 0xb732d 0xede1b 0x3569ce67 0x3928d857 0x3928d503 0x3928c177 0x391ff23d 0x391ff0c9 0x313fb33b 0x39380289 0xaf0a1 0x12ee0)
libc++abi.dylib: terminate called throwing an exception

这是回溯,它显示得不够远,或者我只是不知道如何导航到正确的位置?

(lldb) thread list
Process 19255 stopped
* thread #1: tid = 0x2403, 0x39bf9350 libsystem_kernel.dylib`__pthread_kill + 8, stop reason = signal SIGABRT
  thread #4: tid = 0x2903, 0x39bf9d98 libsystem_kernel.dylib`__workq_kernreturn + 8
  thread #9: tid = 0x2c03, 0x39bf9d98 libsystem_kernel.dylib`__workq_kernreturn + 8
  thread #7: tid = 0x2d03, 0x39bf96a4 libsystem_kernel.dylib`__semwait_signal + 24
  thread #8: tid = 0x2e03, 0x39be95d0 libsystem_kernel.dylib`kevent64 + 24
  thread #10: tid = 0x2f03, 0x39be8e30 libsystem_kernel.dylib`mach_msg_trap + 20
  thread #11: tid = 0x3003, 0x39be8e30 libsystem_kernel.dylib`mach_msg_trap + 20
  thread #12: tid = 0x3103, 0x39bf9594 libsystem_kernel.dylib`select$DARWIN_EXTSN + 20
  thread #13: tid = 0x3203, 0x39be8e30 libsystem_kernel.dylib`mach_msg_trap + 20
  thread #14: tid = 0x3303, 0x39be8e30 libsystem_kernel.dylib`mach_msg_trap + 20
  thread #15: tid = 0x233f, 0x39bf9d98 libsystem_kernel.dylib`__workq_kernreturn + 8
(lldb) thread backtrace
* thread #1: tid = 0x2403, 0x39bf9350 libsystem_kernel.dylib`__pthread_kill + 8, stop reason = signal SIGABRT
    frame #0: 0x39bf9350 libsystem_kernel.dylib`__pthread_kill + 8
    frame #1: 0x39a4ffb6 libsystem_c.dylib`pthread_kill + 58
    frame #2: 0x39a8c36a libsystem_c.dylib`abort + 94
    frame #3: 0x3504edde libc++abi.dylib`abort_message + 74
    frame #4: 0x3504c098 libc++abi.dylib`default_terminate() + 24
    frame #5: 0x354b6a5a libobjc.A.dylib`_objc_terminate() + 146
    frame #6: 0x3504c11a libc++abi.dylib`safe_handler_caller(void (*)()) + 78
    frame #7: 0x3504c1b4 libc++abi.dylib`std::terminate() + 20
    frame #8: 0x3504d62a libc++abi.dylib`__cxa_rethrow + 94
    frame #9: 0x354b69b4 libobjc.A.dylib`objc_exception_rethrow + 12
    frame #10: 0x391ff2a0 CoreFoundation`CFRunLoopRunSpecific + 456
    frame #11: 0x391ff0c8 CoreFoundation`CFRunLoopRunInMode + 104
    frame #12: 0x313fb33a GraphicsServices`GSEventRunModal + 74
    frame #13: 0x39380288 UIKit`UIApplicationMain + 1120
    frame #14: 0x000af0a0 Game Name`main + 100 at main.m:14

我见过有人谈论"向上移动几个堆栈以到达根项目",但不知道如何向上移动堆栈?

任何帮助,建议或指示将不胜感激!提前感谢!

尝试让 Xcode 在程序中放置一个 Exception 断点 - 您应该能够在抛出异常时捕获异常。 在 Xcode 中,查看>导航器>显示断点导航器,点击 + 按钮添加新断点,您可以在"添加异常断点"和"添加符号断点"之间进行选择(后者是 main() 上的断点或其他)。

问题

如何使用 LLDB 导航堆栈帧以跟踪 xCode 中调用的原始行

溶液

在 Xcode 中,在异常中断后,您可以通过键入单词"up"或"down"(无引号)后跟 [enter] 键来向上/向下导航堆栈帧。调试器将一次一步导航到相应的帧。您可能还需要查看日志导航器以查看调试会话的完整历史记录 (⌘ + 8)。

最新更新