0

I'm debugging an iOS app with Xcode 4.5.1 in Mountain Lion 10.8.2 using lldb.

Sometimes I'll try to examine an iVar in the debugger window when at a breakpoint using:

po _currentSale

and will receive the reply:

Printing description of self->_currentSale: (Sale *) _currentSale = 0x081cd7e0

and other times I'll receive this reply (which is what I want):

Printing description of self->_currentSale: '<'Sale: 0x81cd7e0'>' (entity: Sale; id: 0x81dd670 ; data: { cardNumber = "\U2022\U2022\U2022\U2022\U2022\U2022\U2022\U2022\U2022\U2022\U2022\U20220001"; cvv = 222; emailAddress = "k@w.com"; expirationDate = 0413; lastStatus = approved; purchaseNumber = 00000008; saleAmount = 230; saleDate = "2012-10-20 08:06:45 +0000"; sectionIdentifier = 20121020; tipPercentage = 15; transactions = ( "0x75df620 '<'x-coredata://4A0DEB78-C770-4CE2-8A5D-878F51294D6D/Transaction/p11'>'" ); zipCode = 33333; })

Why does the reply vary between giving me the object address sometimes and the complete description others? My Sale object is a Core Data object (if it makes any difference).

codiac
  • 71
  • 8

1 Answers1

0

I'm not positive but I don't think this is from lldb. po is a thin veneer over a call to char *_NSPrintForDebugger(id), you can test where the text is coming from easily enough by calling _NSPrintForDebugger directly yourself, 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 Molenda
  • 14,835
  • 1
  • 59
  • 61
  • Thanks for that Jason - interesting piece of information. I still haven't figured out why "print description" sometimes prints out only the object address and other times prints out the complete object info (even though in each case, all the info is there - as determined by NSLog statements). Randy – codiac Oct 22 '12 at 07:52
  • Try calling _NSPrintForDebugger() next time you see this - if _NSPrintForDebugger() can print a proper description but lldb's po isn't, that's likely an lldb problem and interesting to look into. – Jason Molenda Oct 22 '12 at 09:50