ios - lldb 断点命令在 XCode 8 中不起作用

标签 ios xcode lldb

编辑:现在看来,它不仅限于 frame info,但实际上,breakpoint command add 命令都不起作用。只有在 (lldb) 命令提示符下手动输入它们才会起作用

我通过 XCode 控制台在 LLDB 中设置了一些断点,以检查一个类及其在代码中的使用方式。

(lldb) breakpoint set --func-regex "DVLayer"

断点 7:73 个位置。

(lldb) breakpoint command add 7

输入您的调试器命令。输入“DONE”结束。

 frame info

 continue

 DONE

这在 XCode 4 之前的所有 XCode 版本中都运行良好。但是现在,我得到的只是控制台中的这些语句,没有帧信息。 我已经在 5 个不同的类上尝试了断点命令,但它对它们都不起作用......总是这个输出。

命令#2“继续”继续目标。

命令#2“继续”继续目标。

命令#2“继续”继续目标。

命令#2“继续”继续目标。

命令#2“继续”继续目标。

命令#2“继续”继续目标。

命令#2“继续”继续目标。

命令#2“继续”继续目标。

命令#2“继续”继续目标。

另请注意,THIS ONLY FAILS TO WORK INSIDE A breakpoint command add 语句

如果我只是在 (lldb) 命令提示符处停在 LLDB 的断点处,我可以键入 frame info 并且它按预期工作,但是,如上所述,添加 frame info 作为断点命令完全失败,输出如上。

最佳答案

以下解决方法在 Xcode 8.0 中对我有效:

(lldb) breakpoint set --func-regex "setTitle"
Breakpoint 2: 296 locations.
(lldb) breakpoint command add --script-type python 2
Enter your Python command(s). Type 'DONE' to end.
def function (frame, bp_loc, internal_dict):
    """frame: the lldb.SBFrame for the location at which you stopped
       bp_loc: an lldb.SBBreakpointLocation for the breakpoint location information
       internal_dict: an LLDB support object not to be used"""
    print str(frame)
    frame.GetThread().GetProcess().Continue()
    DONE
(lldb) 
frame #0: 0x00000001879ca4b8 UIKit`-[UIButton _setTitleShadowOffset:]
frame #0: 0x00000001879ca4b8 UIKit`-[UIButton _setTitleShadowOffset:]
frame #0: 0x00000001879ca4b8 UIKit`-[UIButton _setTitleShadowOffset:]
frame #0: 0x000000018781ef68 UIKit`-[UIButton setTitleColor:forState:]
frame #0: 0x000000018781efb4 UIKit`-[UIButtonContent setTitleColor:]
frame #0: 0x000000018781ef68 UIKit`-[UIButton setTitleColor:forState:]
frame #0: 0x000000018781efb4 UIKit`-[UIButtonContent setTitleColor:]
frame #0: 0x000000018781ef68 UIKit`-[UIButton setTitleColor:forState:]
frame #0: 0x000000018781efb4 UIKit`-[UIButtonContent setTitleColor:]
frame #0: 0x000000018781edec UIKit`-[UIButton setTitle:forState:]
frame #0: 0x000000018781ee6c UIKit`-[UIButtonContent setTitle:]

编辑:更多信息:我无法让外部 python 脚本进入 Xcode 8。

编辑:链接到 LLDB python 命令:https://lldb.llvm.org/python-reference.html

关于ios - lldb 断点命令在 XCode 8 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40593039/

相关文章:

ios - 向 NSMutableArray 添加对象不起作用

ios - Twitter 库错误 : Undefined symbols for architecture x86_64:

ios - UITest用例处理位置服务警报

python - 使用 lldb 和 python 捕获 `UIImageView` 属性

stringByReplacingOccurrencesOfString 后调试器中的 Objective-C 奇怪外观

ios - 有人能告诉我为什么我在 CGColorCreateCopy 上得到 "Potential leak of an object"吗?

ios - 如何将我的当前位置分享给 UIActivityViewController?

objective-c - 如何使用 Objective C 检测击键?

objective-c - 加载包含在框架中的 Nib

ios - 在 lldb 中切换到 Objective-C 模式