How do you change the display format of floats & doubles in Xcode debug window?

醉酒当歌 提交于 2019-12-01 08:56:18

问题


Im debugging C in Xcode and setting breakpoints in functions to examine the value of various doubles. Xcode insists on displaying them using scientific notation, which is a real pain. I need to see a decimal representation. The right click "View Value" menu option of Decimal, does weird things. Anyone have any idea how to get this to play nice short of printf'n everything I want to see??


回答1:


Check out the LLDB Variable Formatting documentation, specifically the Type Format section near the top.

You can use the type format command to change the default output.

From the link above

Type formats enable you to quickly override the default format for displaying primitive types (the usual basic C/C++/ObjC types: int, float, char, ...).

If for some reason you want all int variables in your program to print out as hex, you can add a format to the int type.

This is done by typing

(lldb) type format add --format hex int

To change the default display of your jDate objects you should be able to do something like

type format add -f float jDate

You can get more info from the debugger itself with help <format> but the above linked page reads quite well.

If that doesn't solve your problem, you may need to read further down on Type Summaries. I can't remember what Xcode displays, be it the format or the summary.

Additionally, the WWDC2012 session # 415 "Debugging with LLDB" shows methods to change these display formats and add your own. The relevant bits are around the 35 minute mark, but the whole session is great.

Hope that helps!



来源:https://stackoverflow.com/questions/11488028/how-do-you-change-the-display-format-of-floats-doubles-in-xcode-debug-window

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!