XCode 调试器:显示长字符串
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/531114/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
XCode debugger: display long strings
提问by mcccclean
While debugging a program in XCode I have several CFStringRef
variables that point to strings with lengths around the 200 character mark.
在 XCode 中调试程序时,我有几个CFStringRef
变量指向长度在 200 个字符标记左右的字符串。
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?
有没有我可以配置的选项,所以它不会以任意长度终止它们?
回答by Jason Coco
In the debugging console you can get the string value by doing something like:
在调试控制台中,您可以通过执行以下操作来获取字符串值:
(gdb) print (void)CFShow(myCFString)
(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.
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 Magicand (from the debugger console) you can issue the help
command as well.
For a lot more information on debugging topics, see Technical Note TN2124 - Mac OS X Debugging Magicand (from the debugger console) you can issue the help
命令也是如此。
回答by Shauket Sheikh
If you are compiling c++ project in xcode just use this command
如果您在 xcode 中编译 c++ 项目,请使用此命令
po string_name
po string_name
回答by Alexander Ushakov
To display really long string use method from print long string in xcode 6 debugging console
在 xcode 6 调试控制台中从打印长字符串显示真正的长字符串使用方法
- In lldb console increase max-string-summary-length
- 在 lldb 控制台中增加max-string-summary-length
setting set target.max-string-summary-length 10000
- Print your string with
print
orpo
commands
- 用
print
或po
命令打印你的字符串
print my_string