【问题标题】:Sometimes the lldb po command returns only the object address有时 lldb po 命令只返回对象地址
【发布时间】:2012-10-20 09:28:27
【问题描述】:

我正在使用 lldb 在 Mountain Lion 10.8.2 中使用 Xcode 4.5.1 调试 iOS 应用程序。

有时我会尝试在调试器窗口中在断点处检查 iVar:

po _currentSale

并会收到回复:

self->_currentSale 的打印说明: (销售 *) _currentSale = 0x081cd7e0

其他时候我会收到这个回复(这是我想要的):

self->_currentSale 的打印说明: ''(实体:销售;ID:0x81dd670;数据:{ cardNumber = "\U2022\U2022\U2022\U2022\U2022\U2022\U2022\U2022\U2022\U2022\U2022\U20220001"; cvv = 222; 电子邮件地址 = "k@w.com"; 过期日期 = 0413; 最后状态 = 已批准; 购买编号 = 00000008; 销售额 = 230; saleDate = "2012-10-20 08:06:45 +0000"; 部分标识符 = 20121020; 小费百分比 = 15; 交易 = ( “0x75df620''” ); 邮编 = 33333; })

为什么有时给我对象地址和其他人的完整描述之间的回复会有所不同? My Sale 对象是一个 Core Data 对象(如果有任何区别的话)。

【问题讨论】:

    标签: ios command lldb po


    【解决方案1】:

    我不肯定,但我认为这不是来自 lldb。 po 是对char *_NSPrintForDebugger(id) 的调用的薄薄的一层,您可以通过自己直接调用_NSPrintForDebugger 来轻松测试文本的来源,v.

    Process 10842 stopped
    * thread #1: tid = 0x1f03, 0x00000001000018f9 a.out`main + 153 at objc-prog.m:88, stop reason = step over
        #0: 0x00000001000018f9 a.out`main(argc=1, argv=0x00007fff5fbffb18) + 153 at objc-prog.m:88
       85   
       86       NSString *a = @"hi there";
       87   
    -> 88       [object randomFunc];
    
    (lldb) p a
    (NSString *) $1 = 0x0000000100002470 @"hi there"   // lldb's built-in NSString summary formatter
    
    (lldb) po a
    (NSString *) $2 = 0x0000000100002470 hi there
    
    (lldb) p (char*)_NSPrintForDebugger(a)
    (char *) $4 = 0x000000010010f400 "hi there"
    
    (lldb) p (char*)_NSPrintForDebugger(0x0000000100002470)
    (char *) $3 = 0x0000000100114c60 "hi there"
    

    【讨论】:

    • 感谢 Jason - 有趣的信息。我仍然没有弄清楚为什么“打印描述”有时只打印出对象地址而其他时候打印出完整的对象信息(即使在每种情况下,所有信息都在那里 - 由 NSLog 语句确定)。兰迪
    • 下次看到这个时尝试调用 _NSPrintForDebugger() - 如果 _NSPrintForDebugger() 可以打印正确的描述但 lldb 的 po 不是,这可能是一个 lldb 问题并且值得研究。
    猜你喜欢
    • 1970-01-01
    • 2021-03-07
    • 1970-01-01
    • 1970-01-01
    • 2017-03-18
    • 2012-11-14
    • 2014-11-21
    • 2016-06-06
    • 2012-05-11
    相关资源
    最近更新 更多