Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Jun 14, 2012, 03:26 PM   #1
Maury
macrumors 6502
 
Join Date: Mar 2008
Better debugging "po" info?

I'm trying to debug a problem with one of my NSDictionary's containing junk. I'm stepping though trying to figure out where it happens - so far no clue.

I think I know the general area, but when I try to see what data I've already got, everything's just references...

(lldb) po dict
(NSMutableDictionary *) $37 = 0x00000001001afee0 {
"table_cat" = <6d797371 6c>;
}

Is there any way to know what that thing inside the <>'s is? It's supposed to be an NSData, shouldn't the contents just print out? Shouldn't it at *least* say it's an NSData?
Maury is offline   0 Reply With Quote
Old Jun 14, 2012, 03:43 PM   #2
chown33
macrumors 603
 
Join Date: Aug 2009
It is "printing out". It's showing the first 5 bytes in hex:
Code:
<6d797371 6c>
i.e.
Code:
mysql
You should try an NSLog with a %@ format on the NSData before dropping into the debugger. So you know what NSData's -description method is likely to produce.
chown33 is offline   0 Reply With Quote
Old Jun 15, 2012, 09:29 AM   #3
Maury
Thread Starter
macrumors 6502
 
Join Date: Mar 2008
Quote:
Originally Posted by chown33 View Post
It is "printing out". It's showing the first 5 bytes in hex:
Code:
<6d797371 6c>
i.e.
Code:
mysql
You should try an NSLog with a %@ format on the NSData before dropping into the debugger. So you know what NSData's -description method is likely to produce.
Oh, well this is very good news then. But shouldn't this be decoded by default? I seem to recall it did that under gdb, that is, you got a string instead of hex.
Maury is offline   0 Reply With Quote
Old Jun 15, 2012, 10:28 AM   #4
chown33
macrumors 603
 
Join Date: Aug 2009
Quote:
Originally Posted by Maury View Post
Oh, well this is very good news then. But shouldn't this be decoded by default?
I don't see why. The debugger has no way of knowing what the text-encoding is. It could guess, but how? A plausible explanation for 'po' is that it calls the -description method, the same way %@ does in a format string.

Quote:
I seem to recall it did that under gdb, that is, you got a string instead of hex.
I'm not in a position to check this, but it seems unlikely to me. There's no way of knowing what the bytes in the NSData represent. It's just bytes. They could represent anything.

If gdb is guessing it's a string, and showing it that way, it's some special feature of gdb, because it would have to look at the bytes, guess an encoding, and then show the text. There may be other ways of printing arbitrary bytes as text in gdb, but 'po' doesn't seem like it (assuming it's implemented as %@ or -description). The NSData object certainly doesn't know if the bytes it holds are a string. It could be anything.
chown33 is offline   0 Reply With Quote
Old Jun 15, 2012, 11:53 AM   #5
Maury
Thread Starter
macrumors 6502
 
Join Date: Mar 2008
Quote:
Originally Posted by chown33 View Post
I'm not in a position to check this, but it seems unlikely to me. There's no way of knowing what the bytes in the NSData represent. It's just bytes. They could represent anything..
Oh geez, now I get it. Yes, you are right, this is indeed what I should be getting back. For some reason I had convinced myself the data inside was NSString, even though it was clear even as I wrote that message that it wasn't. Duh!
Maury is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 03:19 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC