Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode debugger: display long strings

While debugging a program in Xcode I have several CFStringRef variables that point to strings with lengths around the 200 character mark.

In the debugger, it only shows the value of these strings up to a certain length and then just ellipses them away. I'd really like to see the full value of the strings.

Is there some option I can configure so it doesn't terminate them at arbitrary length?

like image 953
mcccclean Avatar asked Feb 10 '09 05:02

mcccclean


1 Answers

In the debugging console you can get the string value by doing something like:

(gdb) print (void)CFShow(myCFString) 

or:

(gdb) po (NSString*)myCFString 

Either of those will display the entire string's contents to the debugging console. It's probably the easiest way to deal with large, variable-length strings or data structures of any kind.

For more information, the print command in the debugger basically dumps some data structure to the console. You can also call any functions or whatever, but since print doesn't have access to the function declarations, you have to make sure you provide them implicitly (as shown in the example above), or the print command will complain.

po is a shortcut for print-object and is the same as print except for Objective-C objects. It basically functions like this:

(gdb) print (const char *)[[theObject debugDescription] UTF8String] 

This is really useful for examining things like NSData object and NSArray/NSDictionary objects.

For a lot more information on debugging topics, see Technical Note TN2124 - Mac OS X Debugging Magic and (from the debugger console) you can issue the help command as well.

like image 195
Jason Coco Avatar answered Sep 29 '22 21:09

Jason Coco