ang*_*man 3 objective-c llvm lldb
我想知道是否可以从bt命令中获取所选项目.例如,找到某个函数的调用函数.这个想法基本上是在有问题的函数中添加一个不间断的断点,然后打印callstack,例如调用函数,也许是调用函数.最后,这可能归结为过滤bt命令的结果.过滤将是必要的,以排除其间的框架和运行时方法.
你今天需要使用一些Python脚本来做到这一点 - 它还不错.
(lldb) br se -n mach_msg
(lldb) br comm add -s python 1
Enter your Python command(s). Type 'DONE' to end.
> thread = frame.GetThread()
> frnum = 0
> for fr in thread.frames:
> print '% 2d %s' % (frnum, fr.GetFunctionName())
> frnum = frnum + 1
> frame.GetThread().GetProcess().Continue()
> DONE
Run Code Online (Sandbox Code Playgroud)
我设置了断点(mach_msg在这个例子中为on ()),我向断点添加一个命令(-s python意味着它是用脚本语言python编写的;我将这个命令添加到断点#1).
python代码自动提供当前断点对象和帧对象(参见help break command addlldb中的" ").我从帧对象获取当前线程,然后迭代该线程的堆栈帧.
lldb有很多关于你可以对这些python对象做什么操作的内置信息.例如
(lldb) script help (lldb.SBFrame)
(lldb) script help (lldb.SBThread)
Run Code Online (Sandbox Code Playgroud)
另见http://lldb.llvm.org/python-reference.html