• [Error]Swift开发调试时使用LLDB的po和print命令无法输出变量


    问题:

    Swift开发时,使用LLDB的po和print命令在控制台输出变量报错。

    1. let a = 1
    2. (lldb) po a
    3. (lldb) print a

    错误信息

    error: expression failed to parse:
    warning: :11:7: 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: :19:5: error: cannot find '$__lldb_injected_self' in scope
        $__lldb_injected_self.$__lldb_wrapped_expr_78(
        ^~~~~~~~~~~~~~~~~~~~~

    解决:

    1. 使用frame variable variablename打印

    frame variable可以简写成fr v或v

    1. (lldb) frame variable a
    2. (Int) a = 1
    3. (lldb) fr v a
    4. (Int) a = 1
    5. (lldb) v a
    6. (Int) a = 1
    1. (lldb) frame variable this.dataArray[0]
    2. (hdjlm.HDGoodsModel) [0] = {
    3. id = "0nOzwPbqBkS7t8GY7QudKUGU6-m9adjRUWqx3VGaGCYb"
    4. name = "奥克斯家用小型速干衣烘衣机风干机"
    5. tag = "天猫"
    6. image = "https://img.alicdn.com/bao/uploaded/i4/2794532420/O1CN01qlZ1D01TkPH6irS2s_!!0-item_pic.jpg"
    7. originPrice = "489"
    8. actualPrice = "484"
    9. sales = "10000"
    10. couponAmount = "5"
    11. rebateAmount = "10.45"
    12. src = "1"
    13. buyEconomy = ""
    14. shopName = "奥克斯赵记专卖店"
    15. couponLink = ""
    16. created = ""
    17. couponExpire = "1669391999"
    18. isCollect = false
    19. }

     2. 使用frame variable -L veriablename打印堆栈地址

    1. (lldb) po this.dataArray[0]
    2. Fatal error: Call of deleted method
    3. 2022-11-21 18:20:20.401060+0800 hdjlm[7124:293069] Fatal error: Call of deleted method
    4. error: Execution was interrupted, reason: signal SIGABRT.
    5. The process has been returned to the state before expression evaluation.
    6. (lldb) frame variable -L this.dataArray[0]
    7. 0x00007f8928e38370: (hdjlm.HDGoodsModel) [0] = {
    8. 0x00007f8928e38370: id = "0nOzwPbqBkS7t8GY7QudKUGU6-m9adjRUWqx3VGaGCYb"
    9. 0x00007f8928e38380: name = "奥克斯家用小型速干衣烘衣机风干机"
    10. 0x00007f8928e38390: tag = "天猫"
    11. 0x00007f8928e383a0: image = "https://img.alicdn.com/bao/uploaded/i4/2794532420/O1CN01qlZ1D01TkPH6irS2s_!!0-item_pic.jpg"
    12. 0x00007f8928e383b0: originPrice = "489"
    13. 0x00007f8928e383c0: actualPrice = "484"
    14. 0x00007f8928e383d0: sales = "10000"
    15. 0x00007f8928e383e0: couponAmount = "5"
    16. 0x00007f8928e383f0: rebateAmount = "10.45"
    17. 0x00007f8928e38400: src = "1"
    18. 0x00007f8928e38410: buyEconomy = ""
    19. 0x00007f8928e38420: shopName = "奥克斯赵记专卖店"
    20. 0x00007f8928e38430: couponLink = ""
    21. 0x00007f8928e38440: created = ""
    22. 0x00007f8928e38450: couponExpire = "1669391999"
    23. 0x00007f8928e38460: isCollect = false
    24. }

     3. 使用frame variable -o veriablename打印

    1. (lldb) print this.dataArray[0]
    2. Fatal error: Call of deleted method
    3. 2022-11-21 18:22:53.338750+0800 hdjlm[7124:293069] Fatal error: Call of deleted method
    4. error: Execution was interrupted, reason: signal SIGABRT.
    5. The process has been returned to the state before expression evaluation.
    6. (lldb) frame variable -o this.dataArray[0]
    7. (hdjlm.HDGoodsModel) [0] = ▿ HDGoodsModel
    8. - id : "0nOzwPbqBkS7t8GY7QudKUGU6-m9adjRUWqx3VGaGCYb"
    9. - name : "奥克斯家用小型速干衣烘衣机风干机"
    10. - tag : "天猫"
    11. - image : "https://img.alicdn.com/bao/uploaded/i4/2794532420/O1CN01qlZ1D01TkPH6irS2s_!!0-item_pic.jpg"
    12. - originPrice : "489"
    13. - actualPrice : "484"
    14. - sales : "10000"
    15. - couponAmount : "5"
    16. - rebateAmount : "10.45"
    17. - src : "1"
    18. - buyEconomy : ""
    19. - shopName : "奥克斯赵记专卖店"
    20. - couponLink : ""
    21. - created : ""
    22. - couponExpire : "1669391999"
    23. - isCollect : false
  • 相关阅读:
    二、初识FreeRTOS之FreeRTOS入门
    uniapp小程序之一键使用手机号登录
    软考-系统开发基础
    一文带你看透短信验证码
    gatk4中的interval是什么??
    Java设计模式_适配器模式
    基于微信小程序和安卓的二手车查询平台APP
    [Java反序列化]—Shiro反序列化(二)
    Python接口自动化测试之post请求详解
    剑指offer 04. 替换空格
  • 原文地址:https://blog.csdn.net/u012881779/article/details/127969615