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

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
主站蜘蛛池模板: 屯昌县| 定边县| 达州市| 观塘区| 丹阳市| 长寿区| 兴安县| 信宜市| 驻马店市| 石渠县| 义马市| 兴城市| 寿阳县| 泌阳县| 永泰县| 秀山| 凤冈县| 上杭县| 永嘉县| 荥经县| 大丰市| 都安| 罗山县| 汾阳市| 习水县| 湖口县| 亚东县| 鄂托克旗| 社旗县| 那曲县| 平湖市| 平邑县| 民勤县| 福建省| 雷波县| 保山市| 洱源县| 马尔康县| 应用必备| 长春市| 漳浦县|