常用指令
continue /? c? ? 執(zhí)行到下一個斷點
next / n? ? ? ? ? ?單步運行 把子函數(shù)當(dāng)作整體
step / s???????????單步運行 遇到函數(shù)會進去
memory read / x? ?讀取內(nèi)存地址中的值
增加斷點的方法
@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
只能刪除整個大類袜香,刪除分類時只是將分類設(shè)為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? ?
遍歷滿足項目中所有方法的關(guān)鍵字
?$breakpoint set -r touches
Breakpoint 5: 359 locations.
修改參數(shù)值
expression /? p
#import "Person.h"
@implementation ViewController
- (void)viewDidLoad {
? ? Person *p = [[Person alloc] init];
? ? [self.personModels addObject:p];
}
$p (Person *)self.personModels.firstObject? ? //獲取參數(shù)內(nèi)存地址
(Person *) $1 = 0x000060000002fe20
$p $1 .name = @""? ?//修改屬性
$p &person->_name? //查看屬性
斷點軌跡調(diào)試
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
斷點執(zhí)行到上一個胳赌,但是結(jié)束斷點之后不會在執(zhí)行之后的代碼
觀察內(nèi)存斷點
watchpoint set variable
$watchpoint set variable p->_name? ? ?//當(dāng)name屬性的值發(fā)生變化時,斷點自動執(zhí)行到當(dāng)前函數(shù)中
watchpoint set expression
通過內(nèi)存地址添加觀察斷點
$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? ?// 輸入要執(zhí)行的代碼
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"