简体   繁体   English

Xcode lldb 错误:无法打印出 Swift 变量 - 改为获取“$__lldb_injected_self.$__lldb_wrapped_expr_x”

[英]Xcode lldb error: can't print out Swift variable - get "$__lldb_injected_self.$__lldb_wrapped_expr_x" instead

Sometimes, when trying to print out a variable in the debugger, the following error message is displayed:有时,当试图在调试器中打印出一个变量时,会显示以下错误消息:

error: warning: <EXPR>:12:9: warning: initialization of variable '$__lldb_error_result' was never used; consider replacing with assignment to '_' or removing it
    var $__lldb_error_result = __lldb_tmp_error
    ~~~~^~~~~~~~~~~~~~~~~~~~
    _

error: <EXPR>:18:5: error: use of unresolved identifier '$__lldb_injected_self'
    $__lldb_injected_self.$__lldb_wrapped_expr_120(     
    ^~~~~~~~~~~~~~~~~~~~~

This is a known lldb bug ( https://bugs.swift.org/browse/SR-6156 ), but perhaps someone knows a workaround that can be used until that bug is fixed?这是一个已知的lldb错误 ( https://bugs.swift.org/browse/SR-6156 ),但也许有人知道在修复该错误之前可以使用的解决方法?

As a workaround you can print it in the lldb debugger using:作为一种解决方法,您可以使用以下命令在lldb调试器中打印它:

frame variable variablename

Also possible using shortened syntax for quicker typing也可以使用缩短的语法来更快地打字

fr v variablename

Since XCode 10.2 an ever simpler lldb syntax is supported:从 XCode 10.2 开始,支持更简单的lldb语法:

v variable

Update - new workarounds:更新- 新的解决方法:

Print stack addresses:打印堆栈地址:

v -L variablename

po like on stack frame variable.property po像堆栈框架 variable.property

 v -o variablename.property

Swift like pp一样迅捷

e unsafeBitCast(address, to: ClassName.self)

Update2 - new workaround applicable for Swift classes being wrappers of objc classes. Update2 - 适用于作为 objc 类包装器的 Swift 类的新解决方法

Example:示例:

v response
(HTTPURLResponse) response = 0x0000000283ba7640 {

if v works^:如果v有效^:

e -l objc -- (int)[0x0000000283ba7640 statusCode]
(int) $2 = 404

I'd appreciate reports what is actually helpful and works.我很感激报告什么是真正有用和有效的。 Thanks.谢谢。

More information on this kind of capabilities can be found here: https://developer.apple.com/library/content/documentation/General/Conceptual/lldb-guide/chapters/C5-Examining-The-Call-Stack.html有关此类功能的更多信息,请访问: https : //developer.apple.com/library/content/documentation/General/Conceptual/lldb-guide/chapters/C5-Examing-The-Call-Stack.html

清理项目并删除派生数据为我解决了这个问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM