XBXSlagHeap
XBXSlagHeap

Reputation: 174

How can I navigate stack frames to track down the original line called in xCode using the LLDB

I'm getting an error very rarely in my game and I'm trying to determine which runAction is conflicting with an action already in progress. I know I just need to stop a previous action, but can't determine which action is trying to run.

Can anyone give me advice on how to see earlier in the backtrace or navigate to a more useful area since most of the backtrace is just throwing the error and I want to see what is happening before the error gets thrown?

Here is my error and backtrace to help give some context.

NOTE: I'm a noob when it comes to 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

Here is the backtrace which doesn't show back far enough or I just don't know how to navigate to the right place?

(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

I've seen people talking about "moving up a couple stacks to get to the root item" and have no idea how to move up stacks?

Any help, suggestions, or pointers would be greatly appreciated! Thanks in advance!

Upvotes: 1

Views: 913

Answers (2)

Tommie C.
Tommie C.

Reputation: 13181

Problem

How can I navigate stack frames to track down the original line called in xCode using the LLDB

Solution

Within Xcode after you break on the exception you can navigate up/down the stack frames by typing the word "up" or "down" (no quotes) followed by the [enter] key. The debugger will navigate to the appropriate frame one step at a time. You may also want to review the Log Navigator to see a complete history of your debug session (⌘ + 8).

Upvotes: 0

Jason Molenda
Jason Molenda

Reputation: 15395

Try having Xcode put an Exception breakpoint in your program - you should be able to catch the exception when it is thrown. In Xcode, View > Navigators > Show Breakpoint Navigator, hit the + button to add a new breakpoint and you can choose between "Add Exception Breakpoint" and "Add Symbolic Breakpoint" (the latter being a breakpoint on main() or whatever).

Upvotes: 2

Related Questions