Xcode调试之LLDB(2)

2020-04-22  本文已影响0人  天山童姥张奶奶

断点和调试器交互

help命令

print

expression

流程控制

断点管理

在LLDB执行C/Objective-C/C++/Swift

在调试器中直接更行UI

(lldb) e id $myView = (id)0x7f82b1d01fd0
(lldb) e (void)[$myView setBackgroundColor:[UIColor blueColor]]
(lldb) e (void)[CATransaction flush]

查找Button的target

查看按钮按下后谁会接收到按钮发出的action

(lldb) po [$myButton allTargets]
{(
<MagicEventListener: 0x7fb58bd2e240>
)}
(lldb) po [$myButton actionsForTarget:(id)0x7fb58bd2e240 forControlEvent:0]
<__NSArrayM 0x7fb58bd2aa40>(
_handleTap:
)

观察实例变量变化

想监视vMain变量什么时候被重写了,监视这个地址什么时候被写入

(lldb) p (ptrdiff_t)ivar_getOffset((struct Ivar *)class_getInstanceVariable([MyView class], "vMain"))
(ptrdiff_t) $0 = 8
(lldb) watchpoint set expression -- (int *)$myView + 8
Watchpoint created: Watchpoint 3: addr = 0x7fa554231340 size = 8 state = enabled type = w
new value: 0x0000000000000000
上一篇下一篇

猜你喜欢

热点阅读