用Swift开发时,使用LLDB的po和print命令在控制台输出变量报错。
- let a = 1
-
- (lldb) po a
- (lldb) print a
错误信息
error: expression failed to parse:
warning:
var $__lldb_error_result = __lldb_tmp_error
~~~~^~~~~~~~~~~~~~~~~~~~
_
error:
$__lldb_injected_self.$__lldb_wrapped_expr_78(
^~~~~~~~~~~~~~~~~~~~~
1. 使用frame variable variablename打印
frame variable可以简写成fr v或v
- (lldb) frame variable a
- (Int) a = 1
-
- (lldb) fr v a
- (Int) a = 1
-
- (lldb) v a
- (Int) a = 1
- (lldb) frame variable this.dataArray[0]
- (hdjlm.HDGoodsModel) [0] = {
- id = "0nOzwPbqBkS7t8GY7QudKUGU6-m9adjRUWqx3VGaGCYb"
- name = "奥克斯家用小型速干衣烘衣机风干机"
- tag = "天猫"
- image = "https://img.alicdn.com/bao/uploaded/i4/2794532420/O1CN01qlZ1D01TkPH6irS2s_!!0-item_pic.jpg"
- originPrice = "489"
- actualPrice = "484"
- sales = "10000"
- couponAmount = "5"
- rebateAmount = "10.45"
- src = "1"
- buyEconomy = ""
- shopName = "奥克斯赵记专卖店"
- couponLink = ""
- created = ""
- couponExpire = "1669391999"
- isCollect = false
- }
2. 使用frame variable -L veriablename打印堆栈地址
- (lldb) po this.dataArray[0]
- Fatal error: Call of deleted method
- 2022-11-21 18:20:20.401060+0800 hdjlm[7124:293069] Fatal error: Call of deleted method
- error: Execution was interrupted, reason: signal SIGABRT.
- The process has been returned to the state before expression evaluation.
-
-
- (lldb) frame variable -L this.dataArray[0]
- 0x00007f8928e38370: (hdjlm.HDGoodsModel) [0] = {
- 0x00007f8928e38370: id = "0nOzwPbqBkS7t8GY7QudKUGU6-m9adjRUWqx3VGaGCYb"
- 0x00007f8928e38380: name = "奥克斯家用小型速干衣烘衣机风干机"
- 0x00007f8928e38390: tag = "天猫"
- 0x00007f8928e383a0: image = "https://img.alicdn.com/bao/uploaded/i4/2794532420/O1CN01qlZ1D01TkPH6irS2s_!!0-item_pic.jpg"
- 0x00007f8928e383b0: originPrice = "489"
- 0x00007f8928e383c0: actualPrice = "484"
- 0x00007f8928e383d0: sales = "10000"
- 0x00007f8928e383e0: couponAmount = "5"
- 0x00007f8928e383f0: rebateAmount = "10.45"
- 0x00007f8928e38400: src = "1"
- 0x00007f8928e38410: buyEconomy = ""
- 0x00007f8928e38420: shopName = "奥克斯赵记专卖店"
- 0x00007f8928e38430: couponLink = ""
- 0x00007f8928e38440: created = ""
- 0x00007f8928e38450: couponExpire = "1669391999"
- 0x00007f8928e38460: isCollect = false
- }
3. 使用frame variable -o veriablename打印
- (lldb) print this.dataArray[0]
- Fatal error: Call of deleted method
- 2022-11-21 18:22:53.338750+0800 hdjlm[7124:293069] Fatal error: Call of deleted method
- error: Execution was interrupted, reason: signal SIGABRT.
- The process has been returned to the state before expression evaluation.
-
-
- (lldb) frame variable -o this.dataArray[0]
- (hdjlm.HDGoodsModel) [0] = ▿ HDGoodsModel
- - id : "0nOzwPbqBkS7t8GY7QudKUGU6-m9adjRUWqx3VGaGCYb"
- - name : "奥克斯家用小型速干衣烘衣机风干机"
- - tag : "天猫"
- - image : "https://img.alicdn.com/bao/uploaded/i4/2794532420/O1CN01qlZ1D01TkPH6irS2s_!!0-item_pic.jpg"
- - originPrice : "489"
- - actualPrice : "484"
- - sales : "10000"
- - couponAmount : "5"
- - rebateAmount : "10.45"
- - src : "1"
- - buyEconomy : ""
- - shopName : "奥克斯赵记专卖店"
- - couponLink : ""
- - created : ""
- - couponExpire : "1669391999"
- - isCollect : false