【问题标题】:Debugging using the PO command使用 PO 命令进行调试
【发布时间】:2013-10-25 14:27:59
【问题描述】:

为什么这个调试器命令有效:

(lldb) **po indexPath**
<NSIndexPath: 0x1c0711b0> {length = 2, path = 3 - 0}

但事实并非如此:

(lldb) **po [indexPath section]**
[no Objective-C description available]

?

【问题讨论】:

    标签: ios objective-c xcode debugging lldb


    【解决方案1】:

    对于原始类型,您必须使用 'p' , 'po' 用于对象

    p = 打印

    po = 打印对象

    例如

    (lldb) p [indexPath section]
    

    【讨论】:

    • 使用这个时,我收到错误消息:error: no known method '-section'; cast the message send to the method's return type。有什么想法吗?
    • 当调试器无法识别输入类型时,只需将其转换为 'p [(NSIndexPath*)indexPath section]'
    • 奇怪...而不是尝试转换返回值 'p (NSInteger)[(NSIndexPath*)indexPath section]
    • 现在可以使用了。如果有更用户友好的方式来调试它会很棒:-)
    • 使用 lldb 你实际上可以调用方法 ot 函数并打印返回值,不仅打印变量,例如'po NSHomeDirectory()',但你必须注意嵌套断点和递归函数,在这种情况下,调试器将打印错误
    【解决方案2】:

    因为部分不是对象,it is an integer

    【讨论】:

    • 太棒了!我没有在意这件事。整数是否有 PO 的等效命令?
    • 只是“p”,它是“print”的缩写。 Good tutorial on LLVM debugging
    猜你喜欢
    • 2012-11-18
    • 2019-08-26
    • 2014-10-07
    • 2019-11-08
    • 2015-06-01
    • 1970-01-01
    • 2021-02-17
    • 1970-01-01
    • 2010-09-22
    相关资源
    最近更新 更多