Xcode lldb error: can't print out Swift variable - get “$__lldb_injected_self.$__lldb_wrapped_expr_x” instead

為{幸葍}努か 提交于 2019-12-04 09:20:13

问题


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?


回答1:


As a workaround you can print it in the lldb debugger using:

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:

v variable

Update - new workarounds:

Print stack addresses:

fr v -L variablename

po like on stack frame variable.property

 fr v -o variablename.property

Swift like p

e unsafeBitCast(address, to: ClassName.self)

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://stackoverflow.com/questions/48245427/xcode-lldb-error-cant-print-out-swift-variable-get-lldb-injected-self

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!