在XCode中调试程序时,我有几个CFStringRef
变量指向长度大约为200个字符的字符串。
在调试器中,它只显示这些字符串的值达到一定长度,然后将它们省略。我真的很想看到字符串的全部价值。
我可以配置一些选项,以便它不会以任意长度终止它们吗?
答案 0 :(得分:32)
在调试控制台中,您可以通过执行以下操作来获取字符串值:
(gdb) print (void)CFShow(myCFString)
或:
(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.
print
命令。
答案 1 :(得分:3)
要显示非常长的字符串,请使用print long string in xcode 6 debugging console
中的方法setting set target.max-string-summary-length 10000
print
或po
命令打印字符串print my_string
答案 2 :(得分:1)
如果您在xcode中编译c ++项目,请使用此命令
po string_name