LLDB 斷點(diǎn)調(diào)試

斷點(diǎn)


1.添加斷點(diǎn)

1.給test1函數(shù)添加斷點(diǎn)(C函數(shù))set 是子命令, -n 是選項(xiàng),是--name 的縮寫(xiě):????????

????????????breakpoint set -n test1

2.給系統(tǒng)所有這個(gè)方法加斷點(diǎn): ???????????????????

??????????breakpoint set --selector touchesBegan:withEvent:

3.指定文件 的某個(gè)方法添加斷點(diǎn): ??????????????

? ? ? ? ? ?breakpoint set --file ViewController.m --selector touchesBegan:withEvent:

4.給ViewController類(lèi)里面的三個(gè)方法添加斷點(diǎn) ? ??????????

????????breakpoint?set -n "-[ViewController save:]" -n "-[ViewController pauseGame:]" -n "-[ViewController continueGame:]"

5.遍歷整個(gè)項(xiàng)目中滿足Game:這個(gè)字符的所有方法添加斷點(diǎn):???????

?????????breakpoint set -r Game:

6.遍歷整個(gè)項(xiàng)目中滿足?hank?這個(gè)字符的所有方法:????????

?????????breakpoint set -r hank

????????b ?hank

7.給指定類(lèi)添加方法 ? 敲 ? ? ? ? b hankT ? ? ? ?就會(huì)出現(xiàn)提示,回車(chē)即可

????????b -[ViewController hankTest1:]

2.刪除斷點(diǎn)(只能刪除某一組)

刪除第1組斷點(diǎn):????breakpoint delete 1

刪除所有斷點(diǎn):????breakpoint delete

breakpoint delete 1.1????輸出:0 breakpoints deleted; 1 breakpoint locations disabled. ?沒(méi)有斷點(diǎn)被刪除,只是被禁用

3.啟用/禁用斷點(diǎn) ?enable/disable ?en/dis

啟用第1組斷點(diǎn):breakpoint enable 1????????????????????簡(jiǎn)寫(xiě):break? en?1 ? ?

啟用 第1組的第1個(gè)斷點(diǎn):breakpoint enable 1.1

?禁用所有斷點(diǎn):breakpoint disable ? ??? ? ? ? ????????? 簡(jiǎn)寫(xiě):break? dis ??

4.查看斷點(diǎn)列表

breakpoint list

5.流程控制

繼續(xù)執(zhí)行(continue的簡(jiǎn)寫(xiě)) ??c ? ? ??

單步運(yùn)行,將子函數(shù)當(dāng)做整體一步執(zhí)行(next的簡(jiǎn)寫(xiě))? ?n

單步運(yùn)行,遇到子函數(shù)會(huì)進(jìn)去????????s

6.查看幫助

breakpoint help


p/expression 用法



????????????expression self.view.subviews

????????????po self.view.subviews?? ?

????????????p self.view.subviews

????????????p 是?expression 的簡(jiǎn)寫(xiě)

po? ?調(diào)用oc的description方法

更改背景顏色????????????p self.view.backgroundColor = [UIColor redColor]

調(diào)出斷點(diǎn)函數(shù)調(diào)用棧????????????bt

斷點(diǎn)回退指令 ?回到調(diào)用這個(gè)方法的地方????????????????up ? ? ?down

?代碼回退到上一個(gè)調(diào)用的地方,然后return掉 ? ? ? ? ? ? ? thread return

//可以設(shè)置成功

p (Person*)self.models.lastObject

p $7.name = @“hnak"


調(diào)出斷點(diǎn)函數(shù)調(diào)用棧????????????????bt

斷點(diǎn)回退/前進(jìn)指令 ,回到調(diào)用這個(gè)方法的地方 ????????????? ?up ????????down

回到函數(shù)調(diào)用棧的某一個(gè) ? ?定位到某個(gè)方法的具體調(diào)用位置 ???frame select 3

打印出整個(gè)函數(shù)的參數(shù) ? ?frame variable


demo地址

https://github.com/shuyangxiaobao/LLDB


command + shift + M ?可查看內(nèi)存存儲(chǔ)情況

breakpoint set --file ViewController.m --selector? touchesBegan:withEvent:

Breakpoint 1: where = 001--LLDB`-[ViewController touchesBegan:withEvent:] + 92 at ViewController.m:86, address = 0x0000000104bee3b0

?po self.models

p [self.models addObject:[[Person alloc]init]]

po self.models

p (Person*)self.models[3]?

????????????????(Person *) $2 = 0x00000001c0220d80

p $2.name

????????????????(NSString *) $3 = nil

p $2.name = @"xiaoming"

????????????????(NSTaggedPointerString *) $4 = 0xa006412031812da8 @"xiaoming"

po $2.name

????????????????xiaoming ? ?????????

po $2.age =? 254

????????????????254 ? ?????

po $2

????????????????<Person:?0x1c0220d80>

po sizeof($2)

????????????????8 ? ?????

?control + 回車(chē)。可以代碼換行

p Person *p5 = [[Person alloc]init];

p5.name = @"我是p5";

p5.age = 31;

[self.models addObject:p5];

p (Person *)self.models[4]

? ??????????????(Person *) $14 = 0x00000001c0221ac0

p (Person *)self.models.lastObject

????????????????(Person *) $5 = 0x00000001c0224ba0

? 打印對(duì)象地址 ? p $5

????????????????(Person *) $5 = 0x00000001c0224ba0 ? ?????????

p $5.age

????????????????(int) $6 = 256

po $6

????????????????256

設(shè)置對(duì)象屬性值 ?p $5.age = 19

獲取對(duì)象字節(jié)大小 ? ? ? po sizeof($6)

????????????????4

取地址 ? ? ? ? ? ? ??p &($6)

????????????????0x00000001034b46f0 ? ?????


添加斷點(diǎn),當(dāng)改變p1的value值時(shí)斷住

watchpoint set variable p1->_name

打印出內(nèi)存存儲(chǔ)的值

po 0x0000000100620198

給第一組斷點(diǎn)添加代碼 ? ?????????break command add 1

查看command列表 ? ? ? ? ? ? ? ? ?breakpoint command list 1


調(diào)試數(shù)組越界奔潰


調(diào)用[self test2];函數(shù)。

image lookup -a 0x183c53fd8

可打印 出異常的棧調(diào)用

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

友情鏈接更多精彩內(nèi)容