下斷點的方法
1.下符號斷點
br set -n "-[YBRWebViewController viewWillDisappear:]"
2.下地址斷點
breakpoint set --address 0x1013d9e34
3.下方法斷點
b NSLog
繼續(xù)執(zhí)行
c
打印命令
p/t 二進制打印
p/o 八進制打印
p/d 十進制打印
p/x 十六進制打印
更多打印說明
https://sourceware.org/gdb/onlinedocs/gdb/Output-Formats.html
//打印對象指針
(lldb) p object
(LGPerson *) $15 = 0x0000000101120ba0
//打印對象指針和p命令差不多
(lldb) p/x object
(LGPerson *) $16 = 0x0000000101120ba0
檢查內(nèi)存
//打印內(nèi)存信息
(lldb) x object
0x101120ba0: 31 11 00 00 01 80 1d 00 00 00 00 00 00 00 00 00 1...............
0x101120bb0: 02 00 00 00 00 00 00 00 98 e8 64 9e ff 7f 00 00 ..........d.....
//格式化打印內(nèi)存信息
(lldb) x/4gx object
0x101120ba0: 0x001d800100001131 0x0000000000000000
0x101120bb0: 0x0000000000000002 0x00007fff9e64e898
//更多說明
//https://sourceware.org/gdb/onlinedocs/gdb/Memory.html#Memory
讀取寄存器
實際上入?yún)?id obj,SEL _cmd)
register read
Xcode11
register read x0 類
register read x1 函數(shù)(方法)
Xcode10
register read x9 類
register read x8 函數(shù)(方法)
匯編中打印參數(shù)
po $arg3
-
arg1是消息接受者 -
arg2是發(fā)送的消息SEL -
arg3才是OC中的參數(shù)
frame info
會告訴你當前的行數(shù)和源碼文件
(lldb) frame info
frame #0: 0x000000010a53bcd4 DebuggerDance`main + 68 at main.m:17
frame select 斷點跳到frame
frame select 1 # 斷點跳到frame 1
查看當前幀中局部變量的屬性
(lldb) frame variable # 查看當前幀中局部變量的屬性
(lldb) pinternals 0x0000000282decbb0 # 查看自己想看的屬性
如何打印+load 列表
(lldb) br s -r "\+\[.+ load\]$"
/*
輸出:Breakpoint 6: 27 locations.
*/
//再通過,打印列表
(lldb) br list
- 原理:使用了lldb的breakpoint命令,通過正則下符號斷點
UIView中的私有方法打印信息
1. 打印視圖結構recursiveDescription
1.1 recursiveDescription
-[UIView recursiveDescription]
recursiveDescription這是一個私有方法, 用來打印任意的視圖結構, 并按視圖層次排列, 它會遞歸地做這件事, 對每個子視圖, 再去找它們的子視圖(比用Reveal查看視圖結構更完整)。
1.2 _autolayoutTrace
-[UIView _autolayoutTrace]
recursiveDescription的簡化版,去掉了UIView的一些描述
2. 檢查視圖控制器
-[UIViewController _printHierarchy]
來檢查視圖控制器
3. 檢查對象中的實例變量和值
-[NSObject _ivarDescription]
4. 檢查對象中的實例變量和值
-[NSObject _shortMethodDescription]
打印指定對象的所有屬性,實例方法和類方法
查找要斷點類中所有方法
5. 根據(jù)對象地址查看對象屬性
(lldb) pinternals 0x280fb3b00 # 根據(jù)對象地址查看對象屬性
(RTCPeerConnection) $18 = {
NSObject = {
isa = RTCPeerConnection
}
_factory = 0x0000000281474420
_localStreams = 0x0000000281445500 @"0 elements"
_hasStartedRtcEventLog = false
_delegate = 0x0000000282decbb0
}