LLDB的Xcode默認(rèn)的調(diào)試器,它與LLVM編譯器一起,帶給我們更豐富的流程控制和數(shù)據(jù)檢測(cè)的調(diào)試功能。平時(shí)用Xcode運(yùn)行程序,實(shí)際走的都是LLDB。熟練使用LLDB,可以讓你debug事半功倍
LLDB基礎(chǔ)知識(shí)
LLDB控制臺(tái)
Xcode中內(nèi)嵌了LLDB控制臺(tái),在Xcode中代碼的下方,我們可以看到LLDB控制臺(tái)。
LLDB控制臺(tái)平時(shí)會(huì)輸出一些log信息。如果我們想輸入命令調(diào)試,必須讓程序進(jìn)入暫停狀態(tài)。讓程序進(jìn)入暫停狀態(tài)的方式主要有2種:
- 斷點(diǎn)或者watchpoint: 在代碼中設(shè)置一個(gè)斷點(diǎn)(watchpoint),當(dāng)程序運(yùn)行到斷點(diǎn)位置的時(shí)候,會(huì)進(jìn)入stop狀態(tài)
- 直接暫停,控制臺(tái)上方有一個(gè)暫停按鈕,上圖紅框已標(biāo)出,點(diǎn)擊即可暫停程序
LLDB語(yǔ)法
在使用LLDB之前,我們來(lái)先看看LLDB的語(yǔ)法,了解語(yǔ)法可以幫助我們清晰的使用LLDB:
<command> [<subcommand> [<subcommand>...]] <action> [-options [option-value]] [argument [argument...]]
一眼看上去可能比較迷茫,給大家解釋一下:
-
<command>
(命令)和<subcommand>
(子命令):LLDB調(diào)試命令的名稱。命令和子命令按層級(jí)結(jié)構(gòu)來(lái)排列:一個(gè)命令對(duì)象為跟隨其的子命令對(duì)象創(chuàng)建一個(gè)上下文,子命令又為其子命令創(chuàng)建一個(gè)上下文,依此類推。 -
<action>
:執(zhí)行命令的操作 -
<options>
:命令選項(xiàng) -
<arguement>
:命令的參數(shù) -
[]
:表示命令是可選的,可以有也可以沒(méi)有
舉個(gè)例子,假設(shè)我們給main方法設(shè)置一個(gè)斷點(diǎn),我們使用下面的命令:
breakpoint set -n main
這個(gè)命令對(duì)應(yīng)到上面的語(yǔ)法就是:
-
command
:breakpoint
表示斷點(diǎn)命令 -
action
:set
表示設(shè)置斷點(diǎn) -
option
:-n
表示根據(jù)方法name設(shè)置斷點(diǎn) -
arguement
:mian
表示方法名為mian
原始(raw)命令
LLDB支持不帶命令選項(xiàng)(options)的原始(raw)命令,原始命令會(huì)將命令后面的所有東西當(dāng)做參數(shù)(arguement)傳遞。不過(guò)很多原始命令也可以帶命令選項(xiàng),當(dāng)你使用命令選項(xiàng)的時(shí)候,需要在命令選項(xiàng)后面加--
區(qū)分命令選項(xiàng)和參數(shù)。
e.g: 常用的expression
就是raw命令,一般情況下我們使用expression
打印一個(gè)東西是這樣的:
(lldb) expression count
(int) $2 = 4
當(dāng)我們想打印一個(gè)對(duì)象的時(shí)候。需要使用-O
命令選項(xiàng),我們應(yīng)該用--
將命令選項(xiàng)和參數(shù)區(qū)分:
(lldb) expression -O -- self
<ViewController: 0x7f9000f17660>
唯一匹配原則
LLDB的命令遵循唯一匹配原則:假如根據(jù)前n個(gè)字母已經(jīng)能唯一匹配到某個(gè)命令,則只寫前n個(gè)字母等效于寫下完整的命令。
e.g: 前面提到我設(shè)置斷點(diǎn)的命令,我們可以使用唯一匹配原則簡(jiǎn)寫,下面2條命令等效:
breakpoint set -n main
br s -n main
~/.lldbinit
LLDB有了一個(gè)啟動(dòng)時(shí)加載的文件~/.lldbinit
,每次啟動(dòng)都會(huì)加載。所以一些初始化的事兒,我們可以寫入~/.lldbinit
中,比如給命令定義別名等。但是由于這時(shí)候程序還沒(méi)有真正運(yùn)行,也有部分操作無(wú)法在里面玩,比如設(shè)置斷點(diǎn)。
LLDB命令
expression
expression命令的作用是執(zhí)行一個(gè)表達(dá)式,并將表達(dá)式返回的結(jié)果輸出。expression的完整語(yǔ)法是這樣的:
expression <cmd-options> -- <expr>
-
<cmd-options>
:命令選項(xiàng),一般情況下使用默認(rèn)的即可,不需要特別標(biāo)明。 -
--
: 命令選項(xiàng)結(jié)束符,表示所有的命令選項(xiàng)已經(jīng)設(shè)置完畢,如果沒(méi)有命令選項(xiàng),--
可以省略 -
<expr>
: 要執(zhí)行的表達(dá)式
說(shuō)expression
是LLDB里面最重要的命令都不為過(guò)。因?yàn)樗軐?shí)現(xiàn)2個(gè)功能。
-
執(zhí)行某個(gè)表達(dá)式。
我們?cè)诖a運(yùn)行過(guò)程中,可以通過(guò)執(zhí)行某個(gè)表達(dá)式來(lái)動(dòng)態(tài)改變程序運(yùn)行的軌跡。
假如我們?cè)谶\(yùn)行過(guò)程中,突然想把self.view顏色改成紅色,看看效果。我們不必寫下代碼,重新run,只需暫停程序,用expression
改變顏色,再刷新一下界面,就能看到效果// 改變顏色 (lldb) expression -- self.view.backgroundColor = [UIColor redColor] // 刷新界面 (lldb) expression -- (void)[CATransaction flush]
將返回值輸出。
也就是說(shuō)我們可以通過(guò)expression
來(lái)打印東西。
假如我們想打印self.view:
(lldb) expression -- self.view
(UIView *) $1 = 0x00007fe322c18a10
p & print & call
一般情況下,我們直接用expression還是用得比較少的,更多時(shí)候我們用的是p
、print
、call
。這三個(gè)命令其實(shí)都是expression --
的別名(--
表示不再接受命令選項(xiàng),詳情見(jiàn)前面原始(raw)命令
這一節(jié))
-
print
: 打印某個(gè)東西,可以是變量和表達(dá)式 -
p
: 可以看做是print
的簡(jiǎn)寫 -
call
: 調(diào)用某個(gè)方法。
表面上看起來(lái)他們可能有不一樣的地方,實(shí)際都是執(zhí)行某個(gè)表達(dá)式(變量也當(dāng)做表達(dá)式),將執(zhí)行的結(jié)果輸出到控制臺(tái)上。所以你可以用p
調(diào)用某個(gè)方法,也可以用call
打印東西
e.g: 下面代碼效果相同:
(lldb) expression -- self.view
(UIView *) $5 = 0x00007fb2a40344a0
(lldb) p self.view
(UIView *) $6 = 0x00007fb2a40344a0
(lldb) print self.view
(UIView *) $7 = 0x00007fb2a40344a0
(lldb) call self.view
(UIView *) $8 = 0x00007fb2a40344a0
(lldb) e self.view
(UIView *) $9 = 0x00007fb2a40344a0
根據(jù)唯一匹配原則,如果你沒(méi)有自己添加特殊的命令別名。
e
也可以表示expression
的意思。原始命令默認(rèn)沒(méi)有命令選項(xiàng),所以e
也能帶給你同樣的效果
po
我們知道,OC里所有的對(duì)象都是用指針表示的,所以一般打印的時(shí)候,打印出來(lái)的是對(duì)象的指針,而不是對(duì)象本身。如果我們想打印對(duì)象。我們需要使用命令選項(xiàng):-O
。為了更方便的使用,LLDB為expression -O --
定義了一個(gè)別名:po
(lldb) expression -- self.view
(UIView *) $13 = 0x00007fb2a40344a0
(lldb) expression -O -- self.view
<UIView: 0x7fb2a40344a0; frame = (0 0; 375 667); autoresize = W+H; layer = <CALayer: 0x7fb2a4018c80>>
(lldb) po self.view
<UIView: 0x7fb2a40344a0; frame = (0 0; 375 667); autoresize = W+H; layer = <CALayer: 0x7fb2a4018c80>>
還有其他很多命令選項(xiàng),不過(guò)我們一般用得比較少,所以我就不具體的一一介紹了,如果想了解,在LLDB控制臺(tái)上輸入:
help expression
即可查到expression所有的信息
thread
thread backtrace
& bt
有時(shí)候我們想要了解線程堆棧信息,可以使用thread backtrace
thread backtrace
作用是將線程的堆棧打印出來(lái)。我們來(lái)看看他的語(yǔ)法
thread backtrace [-c <count>] [-s <frame-index>] [-e <boolean>]
thread backtrace
后面跟的都是命令選項(xiàng):
-c
:設(shè)置打印堆棧的幀數(shù)(frame)
-s
:設(shè)置從哪個(gè)幀(frame)開(kāi)始打印
-e
:是否顯示額外的回溯
實(shí)際上這些命令選項(xiàng)我們一般不需要使用。
e.g: 當(dāng)發(fā)生crash的時(shí)候,我們可以使用thread backtrace
查看堆棧調(diào)用
(lldb) thread backtrace
* thread #1: tid = 0xdd42, 0x000000010afb380b libobjc.A.dylib`objc_msgSend + 11, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=EXC_I386_GPFLT)
frame #0: 0x000000010afb380b libobjc.A.dylib`objc_msgSend + 11
* frame #1: 0x000000010aa9f75e TLLDB`-[ViewController viewDidLoad](self=0x00007fa270e1f440, _cmd="viewDidLoad") + 174 at ViewController.m:23
frame #2: 0x000000010ba67f98 UIKit`-[UIViewController loadViewIfRequired] + 1198
frame #3: 0x000000010ba682e7 UIKit`-[UIViewController view] + 27
frame #4: 0x000000010b93eab0 UIKit`-[UIWindow addRootViewControllerViewIfPossible] + 61
frame #5: 0x000000010b93f199 UIKit`-[UIWindow _setHidden:forced:] + 282
frame #6: 0x000000010b950c2e UIKit`-[UIWindow makeKeyAndVisible] + 42
我們可以看到crash發(fā)生在-[ViewController viewDidLoad]
中的第23行,只需檢查這行代碼是不是干了什么非法的事兒就可以了。
LLDB還為backtrace專門定義了一個(gè)別名:bt
,他的效果與thread backtrace
相同,如果你不想寫那么長(zhǎng)一串字母,直接寫下bt
即可:
(lldb) bt
thread return
Debug的時(shí)候,也許會(huì)因?yàn)楦鞣N原因,我們不想讓代碼執(zhí)行某個(gè)方法,或者要直接返回一個(gè)想要的值。這時(shí)候就該thread return
上場(chǎng)了。
thread return [<expr>]
thread return
可以接受一個(gè)表達(dá)式,調(diào)用命令之后直接從當(dāng)前的frame返回表達(dá)式的值。
e.g: 我們有一個(gè)someMethod
方法,默認(rèn)情況下是返回YES。我們想要讓他返回NO
我們只需在方法的開(kāi)始位置加一個(gè)斷點(diǎn),當(dāng)程序中斷的時(shí)候,輸入命令即可:
(lldb) thread return NO
效果相當(dāng)于在斷點(diǎn)位置直接調(diào)用return NO;
,不會(huì)執(zhí)行斷點(diǎn)后面的代碼
c & n & s & finish
一般在調(diào)試程序的時(shí)候,我們經(jīng)常用到下面這4個(gè)按鈕:
用觸摸板的孩子們可能會(huì)覺(jué)得點(diǎn)擊這4個(gè)按鈕比較費(fèi)勁。其實(shí)LLDB命令也可以完成上面的操作,而且如果不輸入命令,直接按Enter鍵,LLDB會(huì)自動(dòng)執(zhí)行上次的命令。按一下Enter就能達(dá)到我們想要的效果,有木有頓時(shí)感覺(jué)逼格滿滿的!!!
我們來(lái)看看對(duì)應(yīng)這4個(gè)按鈕的LLDB命令:
-
c
/continue
/thread continue
: 這三個(gè)命令效果都等同于上圖中第一個(gè)按鈕的。表示程序繼續(xù)運(yùn)行 -
n
/next
/thread step-over
: 這三個(gè)命令效果等同于上圖第二個(gè)按鈕。表示單步運(yùn)行 -
s
/step
/thread step-in
: 這三個(gè)命令效果等同于上圖第三個(gè)按鈕。表示進(jìn)入某個(gè)方法 -
finish
/step-out
: 這兩個(gè)命令效果等同于第四個(gè)按鈕。表示直接走完當(dāng)前方法,返回到上層frame
thread其他不常用的命令
thread 相關(guān)的還有其他一些不常用的命令,這里就簡(jiǎn)單介紹一下即可,如果需要了解更多,可以使用命令help thread
查閱
-
thread jump
: 直接讓程序跳到某一行。由于ARC下編譯器實(shí)際插入了不少retain,release命令。跳過(guò)一些代碼不執(zhí)行很可能會(huì)造成對(duì)象內(nèi)存混亂發(fā)生crash。 -
thread list
: 列出所有的線程 -
thread select
: 選擇某個(gè)線程 -
thread until
: 傳入一個(gè)line的參數(shù),讓程序執(zhí)行到這行的時(shí)候暫停 -
thread info
: 輸出當(dāng)前線程的信息
frame
前面我們提到過(guò)很多次frame(幀)。可能有的朋友對(duì)frame這個(gè)概念還不太了解。隨便打個(gè)斷點(diǎn)
我們?cè)诳刂婆_(tái)上輸入命令bt
,可以打印出來(lái)所有的frame。如果仔細(xì)觀察,這些frame和左邊紅框里的堆棧是一致的。平時(shí)我們看到的左邊的堆棧就是frame。
frame variable
平時(shí)Debug的時(shí)候我們經(jīng)常做的事就是查看變量的值,通過(guò)frame variable
命令,可以打印出當(dāng)前frame的所有變量
(lldb) frame variable
(ViewController *) self = 0x00007fa158526e60
(SEL) _cmd = "text:"
(BOOL) ret = YES
(int) a = 3
可以看到,他將self
,_cmd
,ret
,a
等本地變量都打印了出來(lái)
如果我們要需要打印指定變量,也可以給frame variable
傳入?yún)?shù):
(lldb) frame variable self->_string
(NSString *) self->_string = nil
不過(guò)frame variable
只接受變量作為參數(shù),不接受表達(dá)式,也就是說(shuō)我們無(wú)法使用frame variable self.string
,因?yàn)?code>self.string是調(diào)用string
的getter
方法。所以一般打印指定變量,我更喜歡用p
或者po
。
其他不常用命令
一般frame variable
打印所有變量用得比較多,frame還有2個(gè)不怎么常用的命令:
frame info
: 查看當(dāng)前frame的信息
(lldb) frame info
frame #0: 0x0000000101bf87d5 TLLDB`-[ViewController text:](self=0x00007fa158526e60, _cmd="text:", ret=YES) + 37 at ViewController.m:38
frame select
: 選擇某個(gè)frame
(lldb) frame select 1
frame #1: 0x0000000101bf872e TLLDB`-[ViewController viewDidLoad](self=0x00007fa158526e60, _cmd="viewDidLoad") + 78 at ViewController.m:23
20
21 - (void)viewDidLoad {
22 [super viewDidLoad];
-> 23 [self text:YES];
24 NSLog(@"1");
25 NSLog(@"2");
26 NSLog(@"3");
當(dāng)我們選擇frame 1的時(shí)候,他會(huì)把frame1的信息和代碼打印出來(lái)。不過(guò)一般我都是直接在Xcode左邊點(diǎn)擊某個(gè)frame,這樣更方便
breakpoint
調(diào)試過(guò)程中,我們用得最多的可能就是斷點(diǎn)了。LLDB中的斷點(diǎn)命令也非常強(qiáng)大
breakpoint set
breakpoint set
命令用于設(shè)置斷點(diǎn),LLDB提供了很多種設(shè)置斷點(diǎn)的方式:
<b>使用-n
根據(jù)方法名設(shè)置斷點(diǎn):<b>
e.g: 我們想給所有類中的viewWillAppear:
設(shè)置一個(gè)斷點(diǎn):
(lldb) breakpoint set -n viewWillAppear:
Breakpoint 13: 33 locations.
<b>使用-f
指定文件<b>
e.g: 我們只需要給ViewController.m
文件中的viewDidLoad
設(shè)置斷點(diǎn):
(lldb) breakpoint set -f ViewController.m -n viewDidLoad
Breakpoint 22: where = TLLDB`-[ViewController viewDidLoad] + 20 at ViewController.m:22, address = 0x000000010272a6f4
這里需要注意,如果方法未寫在文件中(比如寫在category文件中,或者父類文件中),指定文件之后,將無(wú)法給這個(gè)方法設(shè)置斷點(diǎn)。
<b>使用-l
指定文件某一行設(shè)置斷點(diǎn)<b>
e.g: 我們想給ViewController.m
第38行設(shè)置斷點(diǎn)
(lldb) breakpoint set -f ViewController.m -l 38
Breakpoint 23: where = TLLDB`-[ViewController text:] + 37 at ViewController.m:38, address = 0x000000010272a7d5
<b>使用-c
設(shè)置條件斷點(diǎn)<b>
e.g: text:
方法接受一個(gè)ret
的參數(shù),我們想讓ret == YES
的時(shí)候程序中斷:
(lldb) breakpoint set -n text: -c ret == YES
Breakpoint 7: where = TLLDB`-[ViewController text:] + 30 at ViewController.m:37, address = 0x0000000105ef37ce
<b>使用-o
設(shè)置單次斷點(diǎn)<b>
e.g: 如果剛剛那個(gè)斷點(diǎn)我們只想讓他中斷一次:
(lldb) breakpoint set -n text: -o
'breakpoint 3': where = TLLDB`-[ViewController text:] + 30 at ViewController.m:37, address = 0x000000010b6f97ce
breakpoint command
有的時(shí)候我們可能需要給斷點(diǎn)添加一些命令,比如每次走到這個(gè)斷點(diǎn)的時(shí)候,我們都需要打印self
對(duì)象。我們只需要給斷點(diǎn)添加一個(gè)po self
命令,就不用每次執(zhí)行斷點(diǎn)再自己輸入po self
了
breakpoint command add
breakpoint command add
命令就是給斷點(diǎn)添加命令的命令。
e.g: 假設(shè)我們需要在ViewController
的viewDidLoad
中查看self.view
的值
我們首先給-[ViewController viewDidLoad]
添加一個(gè)斷點(diǎn)
(lldb) breakpoint set -n "-[ViewController viewDidLoad]"
'breakpoint 3': where = TLLDB`-[ViewController viewDidLoad] + 20 at ViewController.m:23, address = 0x00000001055e6004
可以看到添加成功之后,這個(gè)breakpoint
的id為3,然后我們給他增加一個(gè)命令:po self.view
(lldb) breakpoint command add -o "po self.view" 3
-o
完整寫法是--one-liner
,表示增加一條命令。3
表示對(duì)id為3
的breakpoint
增加命令。
添加完命令之后,每次程序執(zhí)行到這個(gè)斷點(diǎn)就可以自動(dòng)打印出self.view
的值了
如果我們一下子想增加多條命令,比如我想在viewDidLoad
中打印當(dāng)前frame的所有變量,但是我們不想讓他中斷,也就是在打印完成之后,需要繼續(xù)執(zhí)行。我們可以這樣玩:
(lldb) breakpoint command add 3
Enter your debugger command(s). Type 'DONE' to end.
> frame variable
> continue
> DONE
輸入breakpoint command add 3
對(duì)斷點(diǎn)3增加命令。他會(huì)讓你輸入增加哪些命令,輸入'DONE'表示結(jié)束。這時(shí)候你就可以輸入多條命令了
多次對(duì)同一個(gè)斷點(diǎn)添加命令,后面命令會(huì)將前面命令覆蓋
breakpoint command list
如果想查看某個(gè)斷點(diǎn)已有的命令,可以使用breakpoint command list
。
e.g: 我們查看一下剛剛的斷點(diǎn)3已有的命令
(lldb) breakpoint command list 3
'breakpoint 3':
Breakpoint commands:
frame variable
continue
可以看到一共有2條命令,分別為frame variable
和continue
breakpoint command delete
有增加就有刪除,breakpoint command delete
可以讓我們刪除某個(gè)斷點(diǎn)的命令
e.g: 我們將斷點(diǎn)3中的命令刪除:
(lldb) breakpoint command delete 3
(lldb) breakpoint command list 3
Breakpoint 3 does not have an associated command.
可以看到刪除之后,斷點(diǎn)3就沒(méi)有命令了
breakpoint list
如果我們想查看已經(jīng)設(shè)置了哪些斷點(diǎn),可以使用breakpoint list
e.g:
(lldb) breakpoint list
Current breakpoints:
4: name = '-[ViewController viewDidLoad]', locations = 1, resolved = 1, hit count = 0
4.1: where = TLLDB`-[ViewController viewDidLoad] + 20 at ViewController.m:23, address = 0x00000001055e6004, resolved, hit count = 0
我們可以看到當(dāng)前只有一個(gè)斷點(diǎn),打在-[ViewController viewDidLoad]
上,id是4
breakpoint disable/enable
有的時(shí)候我們可能暫時(shí)不想要某個(gè)斷點(diǎn),可以使用breakpoint disable
讓某個(gè)斷點(diǎn)暫時(shí)失效
e.g: 我們來(lái)讓剛剛的斷點(diǎn)4失效
(lldb) breakpoint disable 4
1 breakpoints disabled.
輸入完命令之后,顯示斷點(diǎn)已經(jīng)失效
當(dāng)我們又需要這個(gè)斷點(diǎn)的時(shí)候,可以使用breakpoint enable
再次讓他生效
e.g: 重新啟用斷點(diǎn)4
(lldb) breakpoint enable 4
1 breakpoints enabled.
breakpoint delete
如果我們覺(jué)得這個(gè)斷點(diǎn)以后再也用不上了,可以用breakpoint delete
直接刪除斷點(diǎn).
e.g: 刪除斷點(diǎn)4
(lldb) breakpoint delete 4
1 breakpoints deleted; 0 breakpoint locations disabled.
如果我們想刪除所有斷點(diǎn),只需要不指定breakpoint delete
參數(shù)即可
(lldb) breakpoint delete
About to delete all breakpoints, do you want to do that?: [Y/n] y
All breakpoints removed. (1 breakpoint)
刪除的時(shí)候他會(huì)提示你,是不是真的想刪除所有斷點(diǎn),需要你再次輸入Y
確認(rèn)。如果想直接刪除,不需要他的提示,使用-f
命令選項(xiàng)即可
(lldb) breakpoint delete -f
All breakpoints removed. (1 breakpoint)
實(shí)際平時(shí)我們真正使用
breakpoint
命令反而比較少,因?yàn)閄code已經(jīng)內(nèi)置了斷點(diǎn)工具。我們可以直接在代碼上打斷點(diǎn),可以在斷點(diǎn)工具欄里面查看編輯斷點(diǎn),這比使用LLDB命令方便很多。不過(guò)了解LLDB相關(guān)命令可以讓我們對(duì)斷點(diǎn)理解更深刻。
如果你想了解怎么使用Xcode設(shè)置斷點(diǎn),可以閱讀這篇文章《Xcode中斷點(diǎn)的威力》
watchpoint
breakpoint
有一個(gè)孿生兄弟watchpoint
。如果說(shuō)breakpoint
是對(duì)方法生效的斷點(diǎn),watchpoint
就是對(duì)地址生效的斷點(diǎn)
如果我們想要知道某個(gè)屬性什么時(shí)候被篡改了,我們?cè)撛趺崔k呢?有人可能會(huì)說(shuō)對(duì)setter方法打個(gè)斷點(diǎn)不就行了么?但是如果更改的時(shí)候沒(méi)調(diào)用setter方法呢?
這時(shí)候最好的辦法就是用watchpoint
。我們可以用他觀察這個(gè)屬性的地址。如果地址里面的東西改變了,就讓程序中斷
watchpoint set
watchpoint set
命令用于添加一個(gè)watchpoint
。只要這個(gè)地址中的內(nèi)容變化了,程序就會(huì)中斷。
watchpoint set variable
一般情況下,要觀察變量或者屬性,使用watchpoint set variable
命令即可
e.g: 觀察self->_string
(lldb) watchpoint set variable self->_string
Watchpoint created: Watchpoint 1: addr = 0x7fcf3959c418 size = 8 state = enabled type = w
watchpoint spec = 'self->_string'
new value: 0x0000000000000000
watchpoint set variable
傳入的是變量名。需要注意的是,這里不接受方法,所以不能使用watchpoint set variable self.string
,因?yàn)閟elf.string調(diào)用的是string的getter方法
watchpoint set expression
如果我們想直接觀察某個(gè)地址,可以使用watchpoint set expression
e.g: 我們先拿到_model的地址,然后對(duì)地址設(shè)置一個(gè)watchpoint
(lldb) p &_model
(Modek **) $3 = 0x00007fe0dbf23280
(lldb) watchpoint set expression 0x00007fe0dbf23280
Watchpoint created: Watchpoint 1: addr = 0x7fe0dbf23280 size = 8 state = enabled type = w
new value: 0
watchpoint command
跟breakpoint類似,在watchpoint中也可以添加命令
watchpoint command add
我們來(lái)看看怎么給watchpoint
添加命令:
首先,我們?cè)O(shè)置一個(gè)watchpoint:
(lldb) watchpoint set variable _string
Watchpoint created: Watchpoint 1: addr = 0x7fe4e1444760 size = 8 state = enabled type = w
watchpoint spec = '_string'
new value: 0x0000000000000000
可以看到這個(gè)watchpoint的id是1。我們可以用watchpoint command add -o
添加單條命令
watchpoint command add -o 'bt' 1
我們?cè)趙atchpoint停下來(lái)的時(shí)候,打印了他的線程信息。
我們也可以一次添加多條命令:
(lldb) watchpoint command add 1
Enter your debugger command(s). Type 'DONE' to end.
> bt
> continue
> DONE
可以看到watchpoint
的使用方法跟breakpoint
幾乎一模一樣。
watchpoint command list
我們可以用watchpoint command list
列出某個(gè)watchpoint
所有的command
(lldb) watchpoint command list 1
Watchpoint 1:
watchpoint commands:
bt
continue
watchpoint command delete
我們也可以用watchpoint command delete
刪除某個(gè)watchpoint
所有的command
(lldb) watchpoint command delete 1
(lldb) watchpoint command list 1
Watchpoint 1 does not have an associated command.
watchpoint list
如果我們想看當(dāng)前所有watchpoint,可以使用watchpoint list
:
(lldb) watchpoint list
Number of supported hardware watchpoints: 4
Current watchpoints:
Watchpoint 1: addr = 0x7fe9f9f28e30 size = 8 state = enabled type = w
watchpoint spec = '_string'
old value: 0x0000000000000000
new value: 0x000000010128e0d0
可以看到,只有一個(gè)watchpoint。
watchpoint disable
當(dāng)我們不想讓某個(gè)watchpoint生效的時(shí)候,可以用watchpoint disable
:
(lldb) watchpoint disable 1
1 watchpoints disabled.
再次查看這個(gè)watchpoint,可以看到他的state已經(jīng)變?yōu)榱薲isabled
(lldb) watchpoint list
Number of supported hardware watchpoints: 4
Current watchpoints:
Watchpoint 1: addr = 0x7fe9f9f28e30 size = 8 state = disabled type = w
watchpoint spec = '_string'
old value: 0x0000000000000000
new value: 0x000000010128e0d0
watchpoint enable
過(guò)了一會(huì),我們又要用這個(gè)watchpoint
了,這時(shí)候可以使用watchpoint enable
:
(lldb) watchpoint enable 1
1 watchpoints enabled.
watchpoint delete
如果我們覺(jué)得再也用不著這個(gè)watchpoint
了,可以用watchpoint delete
將他刪除:
(lldb) watchpoint delete 1
1 watchpoints deleted.
(lldb) watchpoint list
Number of supported hardware watchpoints: 4
No watchpoints currently set.
刪除之后,我們可以看到watchpoint list
里面已經(jīng)沒(méi)有watchpoint1
了
如果有很多個(gè)watchpoint,我們想全都干掉,只需要不指定具體哪個(gè)watchpoint即可:
(lldb) watchpoint delete
About to delete all watchpoints, do you want to do that?: [Y/n] y
All watchpoints removed. (2 watchpoints)
target
target modules lookup(image lookup)
對(duì)于target這個(gè)命令,我們用得最多的可能就是target modules lookup
。由于LLDB給target modules
取了個(gè)別名image
,所以這個(gè)命令我們又可以寫成image lookup
。
image lookup --address
當(dāng)我們有一個(gè)地址,想查找這個(gè)地址具體對(duì)應(yīng)的文件位置,可以使用image lookup --address
,簡(jiǎn)寫為image lookup -a
e.g: 當(dāng)我們發(fā)生一個(gè)crash
2015-12-17 14:51:06.301 TLLDB[25086:246169] *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArray0 objectAtIndex:]: index 1 beyond bounds for empty NSArray'
*** First throw call stack:
(
0 CoreFoundation 0x000000010accde65 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x000000010a746deb objc_exception_throw + 48
2 CoreFoundation 0x000000010ac7c395 -[__NSArray0 objectAtIndex:] + 101
3 TLLDB 0x000000010a1c3e36 -[ViewController viewDidLoad] + 86
4 UIKit 0x000000010b210f98 -[UIViewController loadViewIfRequired] + 1198
5 UIKit 0x000000010b2112e7 -[UIViewController view] + 27
我們可以看到是由于-[__NSArray0 objectAtIndex:]:
超出邊界而導(dǎo)致的crash,但是objectAtIndex:
的代碼到底在哪兒呢?
(lldb) image lookup -a 0x000000010a1c3e36
Address: TLLDB[0x0000000100000e36] (TLLDB.__TEXT.__text + 246)
Summary: TLLDB`-[ViewController viewDidLoad] + 86 at ViewController.m:32
根據(jù)0x000000010a1c3e36 -[ViewController viewDidLoad]
里面的地址,使用image lookup --address
查找,我們可以看到代碼位置在ViewController.m
里面的32行
image lookup --name
當(dāng)我們想查找一個(gè)方法或者符號(hào)的信息,比如所在文件位置等。我們可以使用image lookup --name
,簡(jiǎn)寫為image lookup -n
。
e.g: 剛剛遇到的真問(wèn)題,某個(gè)第三方SDK用了一個(gè)我們項(xiàng)目里原有的第三方庫(kù),庫(kù)里面對(duì)NSDictionary添加了category。也就是有2個(gè)class對(duì)NSDictionary添加了名字相同的category,項(xiàng)目中調(diào)用自己的category的地方實(shí)際走到了第三方SDK里面去了。最大的問(wèn)題是,這2個(gè)同名category方法行為并不一致,導(dǎo)致出現(xiàn)bug
現(xiàn)在問(wèn)題來(lái)了,怎么尋找到底是哪個(gè)第三方SDK?方法完全包在.a里面。
其實(shí)只需使用image lookup -n
即可:
(lldb) image lookup -n dictionaryWithXMLString:
2 matches found in /Users/jiangliancheng/Library/Developer/Xcode/DerivedData/VideoIphone-aivsnqmlwjhxapdlvmdmrubbdxpq/Build/Products/Debug-iphoneos/BaiduIphoneVideo.app/BaiduIphoneVideo:
Address: BaiduIphoneVideo[0x00533a7c] (BaiduIphoneVideo.__TEXT.__text + 5414908)
Summary: BaiduIphoneVideo`+[NSDictionary(SAPIXmlDictionary) dictionaryWithXMLString:] at XmlDictionary.m
Module: file = "/Users/jiangliancheng/Library/Developer/Xcode/DerivedData/VideoIphone-aivsnqmlwjhxapdlvmdmrubbdxpq/Build/Products/Debug-iphoneos/BaiduIphoneVideo.app/BaiduIphoneVideo", arch = "armv7"
CompileUnit: id = {0x00000000}, file = "/Users/jiangliancheng/Development/Work/iOS_ShareLib/SharedLib/Srvcs/BDPassport4iOS/BDPassport4iOS/SAPI/Extensive/ThirdParty/XMLDictionary/XmlDictionary.m", language = "Objective-C"
Function: id = {0x23500000756}, name = "+[NSDictionary(SAPIXmlDictionary) dictionaryWithXMLString:]", range = [0x005a6a7c-0x005a6b02)
FuncType: id = {0x23500000756}, decl = XmlDictionary.m:189, clang_type = "NSDictionary *(NSString *)"
Blocks: id = {0x23500000756}, range = [0x005a6a7c-0x005a6b02)
LineEntry: [0x005a6a7c-0x005a6a98): /Users/jiangliancheng/Development/Work/iOS_ShareLib/SharedLib/Srvcs/BDPassport4iOS/BDPassport4iOS/SAPI/Extensive/ThirdParty/XMLDictionary/XmlDictionary.m
Symbol: id = {0x0000f2d5}, range = [0x005a6a7c-0x005a6b04), name="+[NSDictionary(SAPIXmlDictionary) dictionaryWithXMLString:]"
Variable: id = {0x23500000771}, name = "self", type = "Class", location = [sp+32], decl =
Variable: id = {0x2350000077e}, name = "_cmd", type = "SEL", location = [sp+28], decl =
Variable: id = {0x2350000078b}, name = "string", type = "NSString *", location = [sp+24], decl = XmlDictionary.m:189
Variable: id = {0x23500000799}, name = "data", type = "NSData *", location = [sp+20], decl = XmlDictionary.m:192
Address: BaiduIphoneVideo[0x012ee160] (BaiduIphoneVideo.__TEXT.__text + 19810016)
Summary: BaiduIphoneVideo`+[NSDictionary(XMLDictionary) dictionaryWithXMLString:] at XMLDictionary.m
Module: file = "/Users/jiangliancheng/Library/Developer/Xcode/DerivedData/VideoIphone-aivsnqmlwjhxapdlvmdmrubbdxpq/Build/Products/Debug-iphoneos/BaiduIphoneVideo.app/BaiduIphoneVideo", arch = "armv7"
CompileUnit: id = {0x00000000}, file = "/Users/wingle/Workspace/qqlive4iphone/iphone_4.0_fabu_20150601/Common_Proj/mobileTAD/VIDEO/Library/Third Party/XMLDictionary/XMLDictionary.m", language = "Objective-C"
Function: id = {0x79900000b02}, name = "+[NSDictionary(XMLDictionary) dictionaryWithXMLString:]", range = [0x01361160-0x0136119a)
FuncType: id = {0x79900000b02}, decl = XMLDictionary.m:325, clang_type = "NSDictionary *(NSString *)"
Blocks: id = {0x79900000b02}, range = [0x01361160-0x0136119a)
LineEntry: [0x01361160-0x01361164): /Users/wingle/Workspace/qqlive4iphone/iphone_4.0_fabu_20150601/Common_Proj/mobileTAD/VIDEO/Library/Third Party/XMLDictionary/XMLDictionary.m
Symbol: id = {0x0003a1e9}, range = [0x01361160-0x0136119c), name="+[NSDictionary(XMLDictionary) dictionaryWithXMLString:]"
Variable: id = {0x79900000b1e}, name = "self", type = "Class", location = r0, decl =
Variable: id = {0x79900000b2c}, name = "_cmd", type = "SEL", location = r1, decl =
Variable: id = {0x79900000b3a}, name = "string", type = "NSString *", location = r2, decl = XMLDictionary.m:325
Variable: id = {0x79900000b4a}, name = "data", type = "NSData *", location = r2, decl = XMLDictionary.m:327
東西有點(diǎn)多,我們只需關(guān)注里面的file這一行:
CompileUnit: id = {0x00000000}, file = "/Users/jiangliancheng/Development/Work/iOS_ShareLib/SharedLib/Srvcs/BDPassport4iOS/BDPassport4iOS/SAPI/Extensive/ThirdParty/XMLDictionary/XmlDictionary.m", language = "Objective-C"
CompileUnit: id = {0x00000000}, file = "/Users/wingle/Workspace/qqlive4iphone/iphone_4.0_fabu_20150601/Common_Proj/mobileTAD/VIDEO/Library/Third Party/XMLDictionary/XMLDictionary.m", language = "Objective-C"
可以清晰的看到,LLDB給我們找出來(lái)了這個(gè)方法的位置。
當(dāng)然這個(gè)命令也可以找到方法的其他相關(guān)信息,比如參數(shù)等.
image lookup --type
當(dāng)我們想查看一個(gè)類型的時(shí)候,可以使用image lookup --type
,簡(jiǎn)寫為image lookup -t
:
e.g: 我們來(lái)看看Model的類型:
(lldb) image lookup -t Model
Best match found in /Users/jiangliancheng/Library/Developer/Xcode/DerivedData/TLLDB-beqoowskwzbttrejseahdoaivpgq/Build/Products/Debug-iphonesimulator/TLLDB.app/TLLDB:
id = {0x30000002f}, name = "Model", byte-size = 32, decl = Modek.h:11, clang_type = "@interface Model : NSObject{
NSString * _bb;
NSString * _cc;
NSString * _name;
}
@property ( getter = name,setter = setName:,readwrite,nonatomic ) NSString * name;
@end
"
可以看到,LLDB把Model這個(gè)class的所有屬性和成員變量都打印了出來(lái),當(dāng)我們想了解某個(gè)類的時(shí)候,直接使用image lookup -t
即可
target stop-hook
我們知道,用LLDB debug,大多數(shù)時(shí)候需要讓程序stop,不管用breakpoint
還是用watchpoint
。
target stop-hook
命令就是讓你可以在每次stop的時(shí)候去執(zhí)行一些命令
target stop-hook
只對(duì)breakpoint
和watchpoint
的程序stop生效,直接點(diǎn)擊Xcode上的pause
或者debug view hierarchy
不會(huì)生效
target stop-hook add & display
假如我們想在每次程序stop的時(shí)候,都用命令打印當(dāng)前frame的所有變量。我們可以添加一個(gè)stop-hook:
(lldb) target stop-hook add -o "frame variable"
Stop hook #4 added.
target stop-hook add
表示添加stop-hook,-o
的全稱是--one-liner
,表示添加一條命令。
我們看一下,當(dāng)執(zhí)行到一個(gè)斷點(diǎn)的時(shí)候會(huì)發(fā)生什么?
- Hook 1 (frame variable)
(ViewController *) self = 0x00007fd55b12e380
(SEL) _cmd = "viewDidLoad"
(NSMutableURLRequest *) request = 0x00007fd55b1010c0
在程序stop的時(shí)候,他會(huì)自動(dòng)執(zhí)行frame variable
,打印出了所有的變量。
大多情況下,我們?cè)趕top的時(shí)候可能想要做的是打印一個(gè)東西。正常情況我們需要用target stop-hook add -o "p xxx"
,LLDB提供了一個(gè)更簡(jiǎn)便的命令display
。
e.g: 下面2行代碼效果相同
(lldb) target stop-hook add -o "p self.view"
(lldb) display self.view
也可以用
display
來(lái)執(zhí)行某一個(gè)命令。p
,e
,expression
是等效的。
target stop-hook list
當(dāng)添加完stop-hook之后,我們想看當(dāng)前所有的stop-hook
怎么辦呢?使用stop-hook list
(lldb) target stop-hook list
Hook: 4
State: enabled
Commands:
frame variable
Hook: 5
State: enabled
Commands:
expression self.view
Hook: 6
State: enabled
Commands:
expr -- self.view
我們可以看到,我們添加了4個(gè)stop-hook
,每個(gè)stop-hook
都有一個(gè)id,他們分別是4,5,6
target stop-hook delete & undisplay
有添加的命令,當(dāng)然也就有刪除的命令。使用target stop-hook delete
可以刪除stop-hook
,如果你覺(jué)得這個(gè)命令有點(diǎn)長(zhǎng),懶得敲。你也可以用undisplay
(lldb) target stop-hook delete 4
(lldb) undisplay 5
我們用target stop-hook delete
和undisplay
分別刪除了id為4和5的stop-hook
target stop-hook disable/enable
當(dāng)我們暫時(shí)想讓某個(gè)stop-hook
失效的時(shí)候,可以使用target stop-hook disable
(lldb) target stop-hook disable 8
如果我們想讓所有的stop-hook
失效,只需不傳入stop-hook
id即可:
(lldb) target stop-hook disable
有disable
就有enable
,我們又想讓stop-hook
生效了。可以使用target stop-hook enable
(lldb) target stop-hook enable 8
同理,不傳入?yún)?shù)表示讓所有stop-hook
生效
(lldb) target stop-hook enable
Extension
前幾天@兔be南玻1在微博上給出一個(gè)小技巧。LLDB中@import UIKit
即可打印frame等變量(默認(rèn)情況下打不出來(lái))微博鏈接。
(lldb) p self.view.frame
error: property 'frame' not found on object of type 'UIView *'
error: 1 errors parsing expression
(lldb) e @import UIKit
(lldb) p self.view.frame
(CGRect) $0 = (origin = (x = 0, y = 0), size = (width = 375, height = 667))
由于每次run Xcode,LLDB的東西都會(huì)被清空。所以每次run你都需要在LLDB中輸入e @import UIKit
才能使用這個(gè)方便的功能,有點(diǎn)麻煩呀!
之后有人提出了比較方便的一個(gè)辦法。給UIApplicationMain設(shè)置一個(gè)斷點(diǎn),在斷點(diǎn)中添加執(zhí)行e @import UIKit
。
這種方法非常方便,不用自己輸入了,但是斷點(diǎn)我們可能會(huì)誤刪,而且斷點(diǎn)是對(duì)應(yīng)工程的。換一個(gè)工程又得重新打一個(gè)這樣的斷點(diǎn)。還是有點(diǎn)麻煩。有沒(méi)有更簡(jiǎn)便的方法呢?
我們首先想到的是LLDB在每次啟動(dòng)的時(shí)候都會(huì)load '~/.lldbinit'文件。在這里面執(zhí)行e @import UIKit
不就行了么?不會(huì)被誤刪,對(duì)每個(gè)工程都有效!
然而想法是美好的,現(xiàn)實(shí)卻是殘酷的!因?yàn)?code>UIKit這個(gè)庫(kù)是在target中。而load '~/.lldbinit'的時(shí)候target還沒(méi)創(chuàng)建。所以無(wú)法import UIKit
。stackoverflow詳細(xì)解釋
這時(shí)候我們又想到,可不可以在'~/.lldbinit'中給UIApplicationMain設(shè)置一個(gè)斷點(diǎn),在斷點(diǎn)中添加執(zhí)行e @import UIKit
呢?
答案是不行。原因跟前面一樣,load '/.lldbinit'執(zhí)行時(shí)間太早。斷點(diǎn)是依賴target的,target還未創(chuàng)建,斷點(diǎn)加不上去。好事多磨,道路坎坷呀~~
后來(lái)我們又想到用stop-hook
行不行呢?stop-hook
不依賴target。一般我們p frame
的時(shí)候,都需要先stop,理論上是可行的
事實(shí)證明stop-hook
的方法完全ok。只需要在'~/.lldbinit'中添加這2條命令即可:
display @import UIKit
target stop-hook add -o "target stop-hook disable"
- 命令1:使用
display
表示在stop的時(shí)候執(zhí)行@import UIKit
- 命令2:由于我們只需要執(zhí)行一次
@import UIKit
,所以執(zhí)行完成之后,執(zhí)行target stop-hook disable
,使原有的所有stop-hook
失效
這個(gè)命令有個(gè)缺陷,直接點(diǎn)擊Xcode上的
pause
和debug view hierarchy
,stop-hook
不會(huì)生效。正在探索有沒(méi)有更好的辦法完成@import UIKit
,如果你想到了,可以聯(lián)系我~
target symbols add(add-dsym)
說(shuō)這個(gè)命令之前,先簡(jiǎn)單解釋一下dSYM文件。程序運(yùn)行的時(shí)候,都會(huì)編譯成二進(jìn)制文件。因?yàn)橛?jì)算機(jī)只識(shí)別二進(jìn)制文件,那為什么我們還能在代碼上打斷點(diǎn)?
這主要是因?yàn)樵诰幾g的時(shí)候Xcode會(huì)生成dSYM文件,dSYM文件記錄了哪行代碼對(duì)應(yīng)著哪些二進(jìn)制,這樣我們對(duì)代碼打斷點(diǎn)就會(huì)對(duì)應(yīng)到二進(jìn)制上。dSYM詳細(xì)資料
當(dāng)Xcode找不著dSYM文件的時(shí)候,我們就無(wú)法對(duì)代碼打斷點(diǎn),進(jìn)行調(diào)試。target symbols add
命令的作用就是讓我們可以手動(dòng)的將dSYM文件添加上去。LLBD對(duì)這個(gè)命令起了一個(gè)別名: add-dsym
e.g: 當(dāng)我們對(duì)接framework的時(shí)候,如果只有framework代碼,沒(méi)有工程代碼,能不能debug呢?其實(shí)我們只需要拿到工程的ipa和dSYM文件,就可以debug了,通過(guò)Attach to Process,使用命令add-dsym
將dSYM文件加入target,即可只debug framework,不需要工程的代碼
add-dsym ~/.../XXX.dSYM
詳細(xì)細(xì)節(jié)可以查看iOS中framework的聯(lián)調(diào)
help & apropos
LLDB的命令其實(shí)還有很多,很多命令我也沒(méi)玩過(guò)。就算玩過(guò)的命令,我們也非常容易忘記,下次可能就不記得是怎么用的了。還好LLDB給我們提供了2個(gè)查找命令的命令:help
& apropos
help
直接在LLDB中輸入help。可以查看所有的LLDB命令
(lldb) help
Debugger commands:
apropos -- Find a list of debugger commands related to a particular
word/subject.
breakpoint -- A set of commands for operating on breakpoints. Also see
_regexp-break.
help -- Show a list of all debugger commands, or give details
about specific commands.
script -- Pass an expression to the script interpreter for
evaluation and return the results. Drop into the
interactive interpreter if no expression is given.
settings -- A set of commands for manipulating internal settable
debugger variables.
source -- A set of commands for accessing source file information
target -- A set of commands for operating on debugger targets.
thread -- A set of commands for operating on one or more threads
within a running process.
type -- A set of commands for operating on the type system
version -- Show version of LLDB debugger.
watchpoint -- A set of commands for operating on watchpoints.
....(東西太多,只截取了一部分)
如果我們想看具體某一個(gè)命令的詳細(xì)用法,可以使用help <command-name>
e.g: 我們查看watchpoint
命令
(lldb) help watchpoint
The following subcommands are supported:
command -- A set of commands for adding, removing and examining bits of
code to be executed when the watchpoint is hit (watchpoint
'commmands').
delete -- Delete the specified watchpoint(s). If no watchpoints are
specified, delete them all.
disable -- Disable the specified watchpoint(s) without removing it/them.
If no watchpoints are specified, disable them all.
enable -- Enable the specified disabled watchpoint(s). If no watchpoints
are specified, enable all of them.
ignore -- Set ignore count on the specified watchpoint(s). If no
watchpoints are specified, set them all.
list -- List all watchpoints at configurable levels of detail.
modify -- Modify the options on a watchpoint or set of watchpoints in
the executable. If no watchpoint is specified, act on the
last created watchpoint. Passing an empty argument clears the
modification.
set -- A set of commands for setting a watchpoint.
apropos
有的時(shí)候,我們可能并不能完全記得某個(gè)命令,如果只記得命令中的某個(gè)關(guān)鍵字。這時(shí)候我們可以使用apropos
搜索相關(guān)命令信息。
e.g: 我們想使用stop-hook
的命令,但是已經(jīng)不記得stop-hook
命令是啥樣了
(lldb) apropos stop-hook
The following built-in commands may relate to 'stop-hook':
_regexp-display -- Add an expression evaluation stop-hook.
_regexp-undisplay -- Remove an expression evaluation stop-hook.
target stop-hook -- A set of commands for operating on debugger
target stop-hooks.
target stop-hook add -- Add a hook to be executed when the target stops.
target stop-hook delete -- Delete a stop-hook.
target stop-hook disable -- Disable a stop-hook.
target stop-hook enable -- Enable a stop-hook.
target stop-hook list -- List all stop-hooks.
可以看到使用apropos stop-hook
搜索一下,即可將所有stop-hook
相關(guān)命令搜索出來(lái)
常用的Debug快捷鍵
debug的時(shí)候,使用快捷鍵是一個(gè)很好的習(xí)慣,我簡(jiǎn)單列舉了幾個(gè)debug的快捷鍵
功能 | 命令 |
---|---|
暫停/繼續(xù) | cmd + ctrl + Y |
斷點(diǎn)失效/生效 | cmd + Y |
控制臺(tái)顯示/隱藏 | cmd + shift + Y |
光標(biāo)切換到控制臺(tái) | cmd + shift + C |
清空控制臺(tái) | cmd + K |
step over | F6 |
step into | F7 |
step out | F8 |
End
東西有點(diǎn)多,感謝大家耐心看完這篇文章。LLDB命令非常多,有很多LLDB命令我也沒(méi)玩過(guò)。這些命令我們不一定要完全記住,只要有個(gè)印象LLDB可以實(shí)現(xiàn)哪些功能就可以了。具體用的時(shí)候再用help
或者apropos
查找
Reference
The LLDB Debugger
與調(diào)試器共舞 - LLDB 的華爾茲
LLDB調(diào)試器使用簡(jiǎn)介
Xcode中斷點(diǎn)的威力
dSYM詳細(xì)資料
About me
微博 QQ群:159974494