迅速将LLDB中的po [英] po in LLDB with swift

查看:127
本文介绍了迅速将LLDB中的po的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在带有LLDB的Swift App中绘制变量的值?

How can I plot out variable's value in a Swift App with LLDB?

以前就像po variable_name

现在我通常会遇到一些讨厌的错误,例如:

Now I usually get some nasty error, like:

(lldb) po a
error: <EXPR>:11:5: error: use of unresolved identifier '$__lldb_injected_self'
    $__lldb_injected_self.$__lldb_wrapped_expr_2(     
    ^

推荐答案

该错误听起来像是因为DWARF没有告诉LLDB在哪里可以找到自我"对象.鉴于Swift的本质,LLDB需要知道self的类型,以便能够在本地范围内插入表达式 找出这是否是您的问题的一种方法是在LLDB提示符下进行:

That error sounds like it might be because DWARF is not telling LLDB where to find your "self" object. Given the nature of Swift, LLDB needs to know the type of self in order to be able to inject an expression inside your local scope One way to find out if that is your problem is to do at the LLDB prompt:

(lldb)框架变量-L self

(lldb) frame variable -L self

您可能会看不到它的位置.值得提交错误报告,仅用于跟踪您的特定再现案例

You are probably going to not see a location for it. Worth filing a bug report for, just to track your specific repro case

无论如何,要解决大部分问题.在Swift中,没有像ObjC这样的语言认可的用于打印描述"的机制,因此尽管您可以键入"po self",除非self是Objective-C类型,您几乎会看到与"p self"相同的内容甚至帧变量self"会告诉您-这完全基于LLDB数据格式化程序机制.如果您想通过它自定义Swift对象的外观,则强制性引用为: http://lldb.llvm.org/varformats.html

Anyway, to get to the bulk of your question. In Swift, there is no language-sanctioned mechanism for "print description" like for ObjC, so while you can type "po self", unless self is an Objective-C type, you will pretty much see the same thing that "p self" or even "frame variable self" would tell you - which is entirely based on the LLDB data formatters mechanism. If you want to hook into that to customize the way your Swift objects look, the obligatory reference is: http://lldb.llvm.org/varformats.html

这篇关于迅速将LLDB中的po的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆