官术网_书友最值得收藏!

Debugger and debug gauges

Debugging with Xcode 5 has been greatly improved thanks to many new features added to the debugger. Apple has completely switched from the previous GDB engine to the much more powerful LLDB engine. This allows breakpoint flexibility, inline variable previews, and the finding of variable values more easily.

If you have ever debugged a project using breakpoints, you will notice some changes in the way Xcode 5 manages its breakpoints. Breakpoints are still created by clicking directly on the required line number. These breakpoints can then be enabled or disabled by clicking on them directly or using the breakpoints button that has been moved to the debug toolbar found at the bottom of the Xcode window.

Each breakpoint may also be configured to respond conditionally. By default, code will stop once it reaches a breakpoint. Once you set conditions, however, breakpoints will be ignored unless these conditions are met. You can edit these conditions by right-clicking on an individual breakpoint and selecting Edit Breakpoint. From here, set your conditions and resultant actions. These actions can include logging a message to the console, running an AppleScript or Shell Script, and even playing a sound.

Another great feature of Xcode 5's debugger is the ability to preview variables and objects during debugging using data tips. While debugging your application, hover your mouse over a variable and its value will automatically appear below your cursor. This works for standard data types, such as strings, numeric types, and Boolean types.

Data tips are very powerful when it comes to objects as well. For instance, while in debug mode, hover your mouse over an image, and a summary of information will appear about this object. Selecting the eye-shaped icon will allow you to preview the actual image right in code, as shown in the following screenshot:

Debugger and debug gauges

Properly debugging any application also involves monitoring system resources to ensure your code is as optimized as possible. Xcode 5 introduces debug gauges, a lightweight and embedded version of some useful instruments' tools. Because debug gauges are integrated into Xcode 5, they are able to run alongside the application at all times while allowing you to observe CPU, Memory, iCloud, Energy, and OpenGL ES resources.

Debug gauges can be found through the debug navigator and will begin running automatically once you run a project. The previously mentioned resources are displayed in an easy-to-read visual graph so that you can monitor your application's performance at a glance and in real time. Additionally, access to the complete instruments software is just a single click away, which is achieved by clicking on the Profile in Instruments button shown in the following screenshot:

Debugger and debug gauges
主站蜘蛛池模板: 蒙自县| 化德县| 景泰县| 延寿县| 榆树市| 玛曲县| 龙山县| 乌拉特后旗| 通渭县| 烟台市| 巴里| 南投市| 凤庆县| 奉化市| 彭阳县| 炉霍县| 芮城县| 陇川县| 白朗县| 皮山县| 米泉市| 陵川县| 山阴县| 丽水市| 阿拉善右旗| 宁河县| 沁水县| 油尖旺区| 周至县| 花垣县| 南丰县| 宁化县| 乌鲁木齐县| 和田市| 灵川县| 金华市| 洛扎县| 大足县| 建德市| 个旧市| 五寨县|