周末閑來無事就來公司逛逛檬姥,想到還有個(gè)UI問題沒弄懂,就打開了我的電腦从隆,開始調(diào)試起來我的程序歉眷。
于是就開始打斷點(diǎn)
image.png
發(fā)現(xiàn)棧中居然調(diào)用了-[UIView initWithFrame:]方法。
于是就向上查找
image.png
發(fā)現(xiàn)上面調(diào)用了-[UIView init]方法材诽。
由此可見-[UIView init]內(nèi)部其實(shí)是調(diào)用了-[UIView initWithFrame:]來實(shí)現(xiàn)的底挫。
那么問題又來了CGRect的直是什么呢?
猜也能猜出來是CGRectZero脸侥。
但是還是想用什么辦法直觀的看出來建邓。
先打印下寄存器
(lldb) register read
General Purpose Registers:
x0 = 0x000000010cdbd150
x1 = 0x00000001cbbc13b2
x2 = 0x00000002822337c0
x3 = 0x000000010cdbd2c0
x4 = 0x000000010cdbd1c0
x5 = 0x00000001d1ad6fd0 UIKitCore`__block_literal_global.403
x6 = 0x4076800000000000
x7 = 0x000000016b98f240
x8 = 0x00000001981863c8 CoreGraphics`CGRectZero
x9 = 0x77dfe4e875010056
x10 = 0x000000010d46c000
x11 = 0x01ff00010d46c000
x12 = 0x000000010d46db20
x13 = 0x000001a107ef61e5 (0x0000000107ef61e5) (void *)0x01dd132a60000000
x14 = 0x0000000000000100
x15 = 0x0000000000000105
x16 = 0x00000001955590a4 UIKitCore`-[UIView initWithFrame:]
x17 = 0x000000010a298a3c libMainThreadChecker.dylib`__trampolines + 96264
x18 = 0x0000000000000000
x19 = 0x000000010cd0d760
x20 = 0x000000010cd3d560
x21 = 0x00000001dd133000 (void *)0x00000001dd06d270: NSObject
x22 = 0x00000001cbaddd10
x23 = 0x0000000000000000
x24 = 0x0000000000000000
x25 = 0x0000000000000000
x26 = 0x0000000000000740
x27 = 0x00000000000009e8
x28 = 0x00000002822330c0
fp = 0x000000016b98ff70
lr = 0x0000000106b3b34c `-[LSCourseToolListBarControl initWith:] + 96 at LSCourseToolListBarControl.m:37:16
sp = 0x000000016b98ff30
pc = 0x00000001955590a4 UIKitCore`-[UIView initWithFrame:]
cpsr = 0x60000000
發(fā)現(xiàn)了想看的直存在x8寄存器里
image.png
雖然看到了,但是還是想通過命令打印出來睁枕。于是各種打印命令都試了試都看不出來官边。只有下面的成功了沸手。
(lldb) x/4xg 0x00000001981863c8
0x1981863c8: 0x0000000000000000 0x0000000000000000
0x1981863d8: 0x0000000000000000 0x0000000000000000
雖然看出來都是0了但是感覺還是不好,于是求助了萬能的群注簿,最后得出
(lldb) po NSStringFromCGRect($x8)
{{0, 0}, {0, 0}}
完美契吉!
但是群里有人發(fā)出了下面的消息,不明白什么意思诡渴。
po $arg3
$arg1 self $arg2 _cmd
后來在lldb里試了試
(lldb) po $arg0
error: <user expression 24>:1:1: use of undeclared identifier '$arg0'
$arg0
^
(lldb) po $arg1
<LSCourseToolListBarControl: 0x1226d9d40; frame = (0 0; 0 0); transform = [0, 0, 0, 0, 0, 0]; anchorPoint = (0, 0); alpha = 0; opaque = NO; layer = (null)>
(lldb) po $arg2
7713067954
(lldb) po $arg3
<LSCourseVar: 0x2822329a0>
(lldb) po $arg4
4872576688
(lldb) e 0x00000001981863c8
(long) $19 = 6846702536
(lldb) po NSStringFromCGRect($arg8)
{{0, 0}, {0, 0}}
(lldb) po $x3
4872576688
(lldb) po &x3
error: <user expression 39>:1:2: use of undeclared identifier 'x3'
&x3
^
(lldb) po $arg3
<LSCourseVar: 0x2822329a0>
(lldb)
這個(gè)結(jié)果也不知道怎么總結(jié)了...