周末闲来无事就来公司逛逛,想到还有个UI问题没弄懂,就打开了我的电脑,开始调试起来我的程序。
于是就开始打断点
发现栈中居然调用了-[UIView initWithFrame:]方法。
于是就向上查找
发现上面调用了-[UIView init]方法。
由此可见-[UIView init]内部其实是调用了-[UIView initWithFrame:]来实现的。
那么问题又来了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
发现了想看的直存在x8寄存器里
虽然看到了,但是还是想通过命令打印出来。于是各种打印命令都试了试都看不出来。只有下面的成功了。
(lldb) x/4xg 0x00000001981863c8
0x1981863c8: 0x0000000000000000 0x0000000000000000
0x1981863d8: 0x0000000000000000 0x0000000000000000
虽然看出来都是0了但是感觉还是不好,于是求助了万能的群,最后得出
(lldb) po NSStringFromCGRect($x8)
{{0, 0}, {0, 0}}
完美!
但是群里有人发出了下面的消息,不明白什么意思。
po $arg3
$arg1 self $arg2 _cmd
后来在lldb里试了试
(lldb) po $arg0
error: :1:1: use of undeclared identifier '$arg0'
$arg0
^
(lldb) po $arg1
(lldb) po $arg2
7713067954
(lldb) po $arg3
(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: :1:2: use of undeclared identifier 'x3'
&x3
^
(lldb) po $arg3
(lldb)
这个结果也不知道怎么总结了...