国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 網(wǎng)站 > 建站經(jīng)驗(yàn) > 正文

I_OSXcode調(diào)試攻略

2019-11-02 14:51:03
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友

  1. Xcode內(nèi)置GDB,可以使用GDB調(diào)試,調(diào)試命令:

  1.1 po 命令:為 print object 的縮寫(xiě),顯示對(duì)象的文本描述

  (lldb) po [$eax class]:輸出異常對(duì)象的地址


  (lldb) po [$eax name]:輸出這個(gè)異常的名字


  (lldb) po [$eax reason]:這個(gè)將會(huì)輸出錯(cuò)誤消息:


  (lldb) “po $eax”:對(duì)這個(gè)對(duì)象調(diào)用“description”方法和打印出來(lái)

  “$eax”是cup的一個(gè)寄存器。在一個(gè)異常的情況下,這個(gè)寄存器將會(huì)包含一個(gè)異常對(duì)象的指針。注意:$eax只會(huì)在模擬器里面工作,假如你在設(shè)備上調(diào)試,你將需要使用”$r0″寄存器

  1.2 print 命令:有點(diǎn)類(lèi)似于格式化輸出,可以輸出對(duì)象的不同信息

  比如:print (char*)[[dic description] cString]、(lldb) print (int)[label retainCount]

  1.3 info 命令:我們可以查看內(nèi)存地址所在信息

  1.4 info line *內(nèi)存地址:可以獲取內(nèi)存地址所在的代碼行相關(guān)信息

  1.5 show 命令:顯示 GDB 相關(guān)的信息。如:show version 顯示GDB版本信息

  1.6 bt: 顯示當(dāng)前進(jìn)程的函數(shù)調(diào)用棧的情況;"up num":查看調(diào)用的詳細(xì)信息;down:返回棧列表;l:顯示詳細(xì)代碼信息;p:輸出數(shù)值。

  2. 添加全局?jǐn)帱c(diǎn)(Add Exception BreakPoint):

  2.1 添加步驟:

  1. In the bottom-left corner of the breakpoints navigator, click the Add button.

  2. Choose Add Exception Breakpoint.

  3. Choose the type of exception from the Exception pop-up menu.

  4. Choose the phase of the exception handling process at which you want program execution to stop.

  5. Click Done.

  2.2 使用場(chǎng)景:

  程序因?yàn)镾IGABRT而crash,想要定位到導(dǎo)致crash的行。

  3. 添加符號(hào)斷點(diǎn)(Add Symbolic BreakPoint):

  3.1 斷點(diǎn)執(zhí)行的時(shí)機(jī):Symbolic breakpoints stop program execution when a specific function or method starts executing

  3.2 添加步驟:

  1. Steps In the bottom-left corner of the breakpoint navigator, click the Add button.

  2. Choose Add Symbolic Breakpoint.

  3. Enter the symbol name in the Symbol field.

  4. Click Done.

  3.3 使用場(chǎng)景:

  當(dāng)想讓系統(tǒng)在某個(gè)指定條件處中斷時(shí),設(shè)置相應(yīng)的斷點(diǎn)。

  比如:

  objc_exception_throw:在系統(tǒng)拋出異常處設(shè)置斷點(diǎn)。

  -[NSException raise]:

  4. 設(shè)置NSZombieEnabled、MallocStackLogging、NSAutoreleaseFreedObjectCheckEnabled、NSDebugEnabled:

  4.1 設(shè)置方法:

  1. Product->Edit Scheme...->Run...->EnvironmentVariables.

  2. add NSZombieEnabled,set the value with YES

  3. add MallocStackLogging, set the value with YES.

  4. add NSAutoreleaseFreedObjectCheckEnabled, set the value with YES.

  5. add NSDebugEnabled, set the value with YES.

  4.2 使用場(chǎng)景:

  主要為了解決EXC_BAD_ACCESS問(wèn)題,MallocStackLogging用來(lái)啟用malloc記錄(使用方式 malloc_history ${App_PID} ${Object_instance_addr})。

  4.3 需要注意的問(wèn)題

  NSZombieEnabled只能在調(diào)試的時(shí)候使用,千萬(wàn)不要忘記在產(chǎn)品發(fā)布的時(shí)候去掉,因?yàn)镹SZombieEnabled不會(huì)真正去釋放dealloc對(duì)象的內(nèi)存。

  5. 重寫(xiě)respondsToSelector方法

  5.1 實(shí)現(xiàn)方式

發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 边坝县| 遂川县| 青州市| 武宁县| 泸溪县| 南郑县| 兰考县| 班戈县| 六枝特区| 佛山市| 绍兴市| 阿图什市| 于田县| 祁门县| 海淀区| 玉山县| 那曲县| 米泉市| 和龙市| 漳平市| 澄迈县| 湘潭市| 钟祥市| 舞钢市| 滕州市| 游戏| 酒泉市| 共和县| 东宁县| 乌兰浩特市| 永康市| 德阳市| 防城港市| 玉林市| 井冈山市| 嘉峪关市| 河曲县| 克什克腾旗| 临颍县| 铜山县| 游戏|