2015-03-02 46 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在調試導航器中選擇最上面的「機器代碼」框架後爲我工作。