LLDB調試

常用指令

continue /? c? ? 執行到下一個斷點

next / n? ? ? ? ? ?單步運行 把子函數當作整體

step / s???????????單步運行 遇到函數會進去

memory read / x? ?讀取內存地址中的值


增加斷點的方法

@implementation?ViewController

- (void)lldbDemo:(id)parame {}

void test() {}

breakpoint set -n?

$breakpoint set -n test

breakpoint set -n?

$breakpoint set -n "-[ViewController lldbDemo:]"

b -n??

$b -n? "-[ViewController?lldbDemo:]"

b -[ViewController touchesBegan:withEvent:]

$b -[ViewController lldbDemo:]

breakpoint set --selector? /? b? ? ?

將所有的同名方法都加斷點

$breakpoint set --selector?lldbDemo

$b?lldbDemo

breakpoint set --file ?--selector?

$breakpoint set --file??ViewController.m?--selector?lldbDemo:

breakpoint list? ?/? ?break list

$break list

Current breakpoints:1: file = '~/ViewController.m', line = 27, exact_match = 0, locations = 1, resolved = 1, hit count = 1?

1.1: where = lldbDemo`-[ViewController touchesBegan:withEvent:] + 80 at ViewController.m:28, address = 0x00000001087b1730, resolved, hit count = 1?2: name = '-[ViewController lldbDemo:]', locations = 1, resolved = 1, hit count = 0?

2.1: where = lldbDemo`-[ViewController lldbDemo:] + 47 at ViewController.m:24, address = 0x00000001087b16cf, resolved, hit count = 0?

breakpoint disable? /? ?break dis? ? ?breakpoint enable? /??break en

$break dis 1.1

$break en 2.1

Current breakpoints:1: file = '~/ViewController.m', line = 27, exact_match = 0, locations = 1 ??

1.1: where = lldbDemo`-[ViewController touchesBegan:withEvent:] + 80 at ViewController.m:28, address = 0x00000001087b1730, unresolved, hit count = 1?2: name = '-[ViewController lldbDemo:]', locations = 1, resolved = 1, hit count = 0? Options:?disabled

2.1: where = lldbDemo`-[ViewController lldbDemo:] + 47 at ViewController.m:24, address = 0x00000001087b16cf, resolved, hit count = 0? Options: enabled

breakpoint delete

只能刪除整個大類,刪除分類時只是將分類設為disable

$breakpoint delete

About to delete all breakpoints, do you want to do that?: [Y/n]

$breakpoint delete 1.1??

1.1: where = lldbDemo`-[ViewController touchesBegan:withEvent:] + 80 at ViewController.m:28, address = 0x00000001087b1730, unresolved, hit count = 1?2: name = '-[ViewController lldbDemo:]', locations = 1, resolved = 1, hit count = 0??Options:?disabled

breakpoint set -r? ?

遍歷滿足項目中所有方法的關鍵字

?$breakpoint set -r touches

Breakpoint 5: 359 locations.



修改參數值

expression /? p

#import "Person.h"

@implementation ViewController

- (void)viewDidLoad {

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

? ? [self.personModels addObject:p];

}

$p (Person *)self.personModels.firstObject? ? //獲取參數內存地址

(Person *) $1 = 0x000060000002fe20

$p $1 .name = @""? ?//修改屬性

$p &person->_name? //查看屬性



斷點軌跡調試

backTrack? ?/? ?bt

查看斷點歷史軌跡

$bt

* thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1 ? * frame #0: 0x000000010b43e730 lldbDemo`-[ViewController touchesBegan:withEvent:](self=0x00007fdc3f60d7c0, _cmd="touchesBegan:withEvent:", touches=1 element, event=0x000060800011c170) at ViewController.m:28?

frame #1: 0x000000010c8077c7 UIKit`forwardTouchMethod + 340? ??

frame #2: 0x000000010c807662 UIKit`-[UIResponder touchesBegan:withEvent:] + 49 ? ?

frame #3: 0x000000010c64fe7a UIKit`-[UIWindow _sendTouchesForEvent:] + 2052 ? ?

frame #4: 0x000000010c651821 UIKit`-[UIWindow sendEvent:] + 4086 ? ?

frame #5: 0x000000010c5f5370 UIKit`-[UIApplication sendEvent:] + 352 ? ?

frame #6: 0x000000010cf3657f UIKit`__dispatchPreprocessedEventFromEventQueue + 2796 ? ?

frame #7: 0x000000010cf39194 UIKit`__handleEventQueueInternal + 5949 ? ?

frame #8: 0x000000010eec7bb1 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17 ? ?

frame #9: 0x000000010eeac4af CoreFoundation`__CFRunLoopDoSources0 + 271 ? ?

frame #10: 0x000000010eeaba6f CoreFoundation`__CFRunLoopRun + 1263 ? ?

frame #11: 0x000000010eeab30b CoreFoundation`CFRunLoopRunSpecific + 635 ? ?

frame #12: 0x0000000111813a73 GraphicsServices`GSEventRunModal + 62 ? ?

frame #13: 0x000000010c5da0b7 UIKit`UIApplicationMain + 159 ? ?

frame #14: 0x000000010b43e7bf lldbDemo`main(argc=1, argv=0x00007ffee47c1060) at main.m:14 ? ?

frame #15: 0x0000000110102955 libdyld.dylib`start + 1

up? down

更改斷點位置

frame select

直接跳到指定斷點

$frame select?2

frame variable

打印斷點所在位置的所有屬性

$frame variable

(ViewController *) self = 0x00007fdc3f60d7c0

(SEL) _cmd = "touchesBegan:withEvent:"

(__NSSetM *) touches = 0x000060400002b940 1 element

(UITouchesEvent *) event = 0x000060800011c170

thread return

斷點執行到上一個,但是結束斷點之后不會在執行之后的代碼



觀察內存斷點

watchpoint set variable

$watchpoint set variable p->_name? ? ?//當name屬性的值發生變化時,斷點自動執行到當前函數中

watchpoint set expression

通過內存地址添加觀察斷點

$watchpoint set expression 0x000060400003c808?

watchpoint list

watchpoint delete

使用方法參考breakpoint



添加指令

break command add

$break list

1.1 ...

2.1...

$break command add 1.1

Enter your debugger command(s).? Type 'DONE' to end.

>? frame variable? ?// 輸入要執行的代碼

break command list

break command delete?

$break command list 1.1

Breakpoint 1.1: ? ?

Breakpoint commands: ? ? ?

frame variable

target stop-hook add? ? /? ?target stop-hook add -o

將所有斷點都添加指令

$target stop-hook add -o "frame variable"

target stop-hook list

target stop-hook delete? ?/??undisplay

target stop-hook disable



查看異常指針

'NSRangeException', reason: '*** -[__NSArray0 objectAtIndex:]: index 0 beyond bounds for empty NSArray'

*** First throw call stack:

( 0 ? CoreFoundation? ? ? ? ? ? ? ? ? ? ? 0x00000001068711e6 __exceptionPreprocess + 294

1 ? libobjc.A.dylib ? ? ? ? ? ? ? ? ? ? 0x0000000105f06031 objc_exception_throw + 48

2 ? CoreFoundation? ? ? ? ? ? ? ? ? ? ? 0x0000000106889e3d -[__NSArray0 objectAtIndex:] + 93

3 ? lldbDemo? ? ? ? ? ? ? ? ? ? ? ? ? ? 0x00000001056066d1 -[ViewController touchesBegan:withEvent:] + 129

4 ? UIKit ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 0x0000000106f1b7c7 forwardTouchMethod + 340

5 ? UIKit ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 0x0000000106f1b662 -[UIResponder touchesBegan:withEvent:] + 49

6 ? UIKit ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 0x0000000106d63e7a -[UIWindow _sendTouchesForEvent:] + 2052

7 ? UIKit ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 0x0000000106d65821 -[UIWindow sendEvent:] + 4086

8 ? UIKit ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 0x0000000106d09370 -[UIApplication sendEvent:] + 352

9 ? UIKit ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 0x000000010764a57f __dispatchPreprocessedEventFromEventQueue + 2796

10? UIKit ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 0x000000010764d194 __handleEventQueueInternal + 5949

11? CoreFoundation? ? ? ? ? ? ? ? ? ? ? 0x0000000106813bb1 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17

12? CoreFoundation? ? ? ? ? ? ? ? ? ? ? 0x00000001067f84af __CFRunLoopDoSources0 + 271

13? CoreFoundation? ? ? ? ? ? ? ? ? ? ? 0x00000001067f7a6f __CFRunLoopRun + 1263

14? CoreFoundation? ? ? ? ? ? ? ? ? ? ? 0x00000001067f730b CFRunLoopRunSpecific + 635

15? GraphicsServices? ? ? ? ? ? ? ? ? ? 0x000000010b9dba73 GSEventRunModal + 62

16? UIKit ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 0x0000000106cee0b7 UIApplicationMain + 159

17? lldbDemo? ? ? ? ? ? ? ? ? ? ? ? ? ? 0x000000010560679f main + 111

18? libdyld.dylib ? ? ? ? ? ? ? ? ? ? ? 0x000000010a2ca955 start + 1

19? ??? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 0x0000000000000001 0x0 + 1 )

image lookup -a?

查看異常指針

$image lookup -a 0x00000001056066d1

?Address: lldbDemo[0x00000001000016d1] (lldbDemo.__TEXT.__text + 257) ? ? ? Summary: lldbDemo`-[ViewController touchesBegan:withEvent:] + 129 at ViewController.m:28

image lookup -t

查看一個類信息

$image lookup -t?ViewController

Best match found in ~/lldbDemo.app/lldbDemo: id = {0x10000002b}, name = "ViewController", byte-size = 8, decl = ViewController.h:11, compiler_type = "@interface ViewController : UIViewController @end"

?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。
  • 序言:七十年代末,一起剝皮案震驚了整個濱河市,隨后出現的幾起案子,更是在濱河造成了極大的恐慌,老刑警劉巖,帶你破解...
    沈念sama閱讀 228,443評論 6 532
  • 序言:濱河連續發生了三起死亡事件,死亡現場離奇詭異,居然都是意外死亡,警方通過查閱死者的電腦和手機,發現死者居然都...
    沈念sama閱讀 98,530評論 3 416
  • 文/潘曉璐 我一進店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人,你說我怎么就攤上這事。” “怎么了?”我有些...
    開封第一講書人閱讀 176,407評論 0 375
  • 文/不壞的土叔 我叫張陵,是天一觀的道長。 經常有香客問我,道長,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 62,981評論 1 312
  • 正文 為了忘掉前任,我火速辦了婚禮,結果婚禮上,老公的妹妹穿的比我還像新娘。我一直安慰自己,他們只是感情好,可當我...
    茶點故事閱讀 71,759評論 6 410
  • 文/花漫 我一把揭開白布。 她就那樣靜靜地躺著,像睡著了一般。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發上,一...
    開封第一講書人閱讀 55,204評論 1 324
  • 那天,我揣著相機與錄音,去河邊找鬼。 笑死,一個胖子當著我的面吹牛,可吹牛的內容都是我干的。 我是一名探鬼主播,決...
    沈念sama閱讀 43,263評論 3 441
  • 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場噩夢啊……” “哼!你這毒婦竟也來了?” 一聲冷哼從身側響起,我...
    開封第一講書人閱讀 42,415評論 0 288
  • 序言:老撾萬榮一對情侶失蹤,失蹤者是張志新(化名)和其女友劉穎,沒想到半個月后,有當地人在樹林里發現了一具尸體,經...
    沈念sama閱讀 48,955評論 1 336
  • 正文 獨居荒郊野嶺守林人離奇死亡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內容為張勛視角 年9月15日...
    茶點故事閱讀 40,782評論 3 354
  • 正文 我和宋清朗相戀三年,在試婚紗的時候發現自己被綠了。 大學時的朋友給我發了我未婚夫和他白月光在一起吃飯的照片。...
    茶點故事閱讀 42,983評論 1 369
  • 序言:一個原本活蹦亂跳的男人離奇死亡,死狀恐怖,靈堂內的尸體忽然破棺而出,到底是詐尸還是另有隱情,我是刑警寧澤,帶...
    沈念sama閱讀 38,528評論 5 359
  • 正文 年R本政府宣布,位于F島的核電站,受9級特大地震影響,放射性物質發生泄漏。R本人自食惡果不足惜,卻給世界環境...
    茶點故事閱讀 44,222評論 3 347
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧,春花似錦、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 34,650評論 0 26
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至,卻和暖如春,著一層夾襖步出監牢的瞬間,已是汗流浹背。 一陣腳步聲響...
    開封第一講書人閱讀 35,892評論 1 286
  • 我被黑心中介騙來泰國打工, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留,地道東北人。 一個月前我還...
    沈念sama閱讀 51,675評論 3 392
  • 正文 我出身青樓,卻偏偏與公主長得像,于是被迫代替她去往敵國和親。 傳聞我的和親對象是個殘疾皇子,可洞房花燭夜當晚...
    茶點故事閱讀 47,967評論 2 374

推薦閱讀更多精彩內容

  • [轉]淺談LLDB調試器文章來源于:http://www.cocoachina.com/ios/20150126/...
    loveobjc閱讀 2,541評論 2 6
  • LLDB的Xcode默認的調試器,它與LLVM編譯器一起,帶給我們更豐富的流程控制和數據檢測的調試功能。平時用Xc...
    CoderSC閱讀 1,374評論 0 2
  • 對于LLDB調試相信很多開發者都不陌生但是也僅僅停留在下斷點看數據的階段,使用最多的命令也就是po甚至包括我在內的...
    初光夫閱讀 1,282評論 2 51
  • 一、斷點命令 1、設置斷點,現用斷點卡住程序,然后在輸入 breakpoint set --file 文件名 --...
    海浪萌物閱讀 1,711評論 0 0
  • 不知不覺過了二十幾度春秋,恍惚間長大了,失去稚嫩的臉龐和輕狂的年少。 歲月的行走,悄無聲息,昨日的...
    舊渡頭閱讀 240評論 1 6