我在-[CALayer setSpeed:]
上设置了一个符号断点,我希望断点仅在特定函数调用函数时触发
-[UIPercentDrivenInteractiveTransition _updateInteractiveTransition:percent:isFinished:didComplete:]
有没有办法做到这一点?
我可以通过执行bt 2
来手动查看调用函数的值。是否有某种方法可以在断点条件中与此输出执行字符串比较?
谢谢!
你可以在断点上使用一些 python 脚本来做到这一点。 这意味着每次命中断点时,lldb 都会停止进程并恢复它 - 对于像 objc_msgSend 这样非常热门的函数,这将极大地影响性能。
在你的 homedir 中创建一个 python 函数,就像~/lldb/stopifcaller.py
这些内容一样
import lldb
def stop_if_caller(current_frame, function_of_interest):
thread = current_frame.GetThread()
if thread.GetNumFrames() > 1:
if thread.GetFrameAtIndex(1).GetFunctionName() != function_of_interest:
thread.GetProcess().Continue()
然后把
command script import ~/lldb/stopifcaller.py
在您的~/.lldbinit
文件中。
在 lldb 中像这样使用它:
(lldb) br s -n bar
Breakpoint 1: where = a.out`bar + 15 at a.c:5, address = 0x0000000100000e7f
(lldb) br comm add --script-type python -o "stopifcaller.stop_if_caller(frame, 'foo')" 1
您已完成 - 断点 1(在 bar()
上)仅在调用方帧foo()
时停止。 或者换句话说,如果调用方帧未foo()
,它将继续