XCode调试器:显示长字符串

mcc*_*ean 28 string debugging macos xcode

在XCode中调试程序时,我有几个CFStringRef变量指向长度在200个字符左右的字符串.

在调试器中,它只显示这些字符串的值达到一定长度,然后将它们省略.我真的很想看到字符串的全部价值.

有没有我可以配置的选项,所以它不会以任意长度终止它们?

Jas*_*oco 33

在调试控制台中,您可以通过执行以下操作来获取字符串值:

(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

poprint-object 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.

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

This is really useful for examining things like NSData is a shortcut for (gdb) print (void)CFShow(myCFString) and is the same as print except for Objective-C objects. It basically functions like this:

(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

poprint-object

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

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

(gdb) print (void)CFShow(myCFString) 命令也是.

  • 对我来说,打印变体并没有抑制字符串“缩短”,所以我仍然看不到整个字符串。 (2认同)

Ale*_*kov 5

在 xcode 6 调试控制台中打印长字符串显示真正的长字符串使用方法

  1. 在 lldb 控制台中增加max-string-summary-length
setting set target.max-string-summary-length 10000
Run Code Online (Sandbox Code Playgroud)
  1. printpo命令打印你的字符串
print my_string
Run Code Online (Sandbox Code Playgroud)