2015-03-02 43 views
7

我的应用程序崩溃了,它好像被捕获到异常断点(这是有道理的),但我无法找到崩溃的原因。如何在Xcode 6的异常断点处打印异常?

这是我已经试过:

  • po $eax
  • po $rax
  • po $r0
  • po *(id *)($esp + 4)

对于所有试图在上面,我发现了以下错误:

error: use of undeclared identifier '$<register name>' error: 1 errors parsing expression

我也发现了这个LLDB Command Guide,但没有发现任何有用的东西(有点混乱它,你不知道你在找什么)。

如何打印碰撞原因?

我运行iOS 8,LLDB和Xcode的6

编辑

现在我明白为什么都没有发现这些寄存器。下面是我得到的,当我运行register read

General Purpose Registers: 
x0 = 0x0000000000000001 
x1 = 0x0000000000000000 
x2 = 0x0000000000000000 
x3 = 0x0000000195531a74 libsystem_malloc.dylib`nano_free_definite_size 
x4 = 0x0000000000000000 
x5 = 0x0000000000000000 
x6 = 0x676e697274534643 
x7 = 0x0000000000000f80 
x8 = 0x00000001569d5a10 
x9 = 0x0000000000000000 
x10 = 0x000001a574056051 
x11 = 0x0000000000000001 
x12 = 0x000000000000003d 
x13 = 0x0000000000000000 
x14 = 0x0000000000000001 
x15 = 0x0000000000000052 
x16 = 0x0000000194d6e510 libobjc.A.dylib`object_setClass 
x17 = 0x0000000000000000 
x18 = 0x0000000000000000 
x19 = 0x00000001702823f0 
x20 = 0x0000000174038eaa 
x21 = 0x000000019130a778 "release" 
x22 = 0x0000000000000000 
x23 = 0x0000000174246d20 
x24 = 0x0000000174038ea0 
x25 = 0x00000001895d22fa "forwardingTargetForSelector:" 
x26 = 0x00000001745186a0 
x27 = 0x0000000000000000 
x28 = 0x00000000a40008ff 
fp = 0x0000000105757720 
lr = 0x000000018462a440 CoreFoundation`___forwarding___ + 968 
sp = 0x00000001057576c0 
pc = 0x000000018462a440 CoreFoundation`___forwarding___ + 968 
cpsr = 0x20000000 

正如你可以看到这些都是使用不含有任何我以前试过的那些的寄存器。但是,我仍然无法找到例外。

xcode view

+0

[Xcode/GDB:如何获得刚才抛出的异常信息?](http://stackoverflow.com/questions/3327828/xcode-gdb-how-to-get-information-about -an-exception-that-just-thrown) – 2015-06-12 18:38:28

回答

4

你应该只需要输入:

po $arg1

更多信息看:How to replace NSUncaughtExceptionHandler with definition in Breakpoint navigator?

+0

在这个问题中没有'$ arg1'的选项。因此,请检查您在异常断点内定义的内容。我的意思是你定义了什么行动?你能附上一个屏幕吗? – 2015-07-22 08:34:18

+0

好吧,它不在这里工作:http://stackoverflow.com/questions/31403719/using-of-symbolic-breakpoints-for-child-classes-in-xcode/31527538?noredirect=1#comment51049128_31527538 和这里: http://natashatherobot.com/xcode-debugging-trick/ 一般来说 - 它甚至找不到'$ arg1',所以它总是不能正常工作,你总是试图访问它 – 2015-07-22 09:43:29

+0

你是对的,他们正在工作为Xcode 7。 – 2015-07-22 09:46:29

0

从以前的答案强调Rickster的评论:

确保你选择正确的框架。

po $arg1在调试导航器中选择最上面的“机器代码”框架后为我工作。