Running Your Application with Diagnostics
During the test and debug phases of your product development, configure a scheme to run your application with various memory management diagnostics and logging options enabled. Schemes have a Run action with a Diagnostics pane that allows you to choose from a selection of runtime diagnostic tools.
From the Scheme toolbar menu, choose a scheme.
From the same menu, choose Edit Scheme to display the scheme dialog.
In the left column, select Run.
To specify runtime diagnostics, click the Diagnostics tab.
Click the Run button or choose Product > Run.
Select the tools that you want Xcode to use. You can view output from these tools in the debug area console and in the debug log in the reports navigator, excepting the address sanitizer (see below).
Some diagnostic tools can be used in combination with others; the options available on the Diagnostics pane are enabled and disabled as different options are chosen to help you select option combinations. For example, enable the address sanitizer and other, incompatible tools are disabled and cannot be chosen:
Memory Management options:
Enable Malloc Scribble. Fill allocated memory with
0xAAand deallocated memory with
Enable Malloc Guard Edges. Add guard pages before and after large allocations.
Enable Guard Malloc. Use
libgmallocto catch common memory problems such as buffer overruns and use-after-free.
Enable Zombie Objects. Replace deallocated objects with a “zombie” object that traps any attempt to use it. When you send a message to a zombie object, the runtime logs an error and crashes. You can look at the backtrace to see the chain of calls that triggered the zombie detector.
Enable Address Sanitizer. Halts your app and displays the location in the debugger when memory corruption happens. Address sanitizer, working together with the Xcode debugger when it is triggered, helps you find and fix memory problems caused that are otherwise elusive to track down.
Enabling this option forces a recompilation the next time you Run your app for debugging.
Distributed Objects. Enable logging for distributed objects (
Malloc Stack. Record stack logs for memory allocations and deallocations.
Log Dynamic API Usage. Log dynamic-linker API calls (for example,
Log Library Loads. Log dynamic-linker library loads.
Stop on Debugger() and DebugStr(). Enable Core Services routines that enter the debugger with a message. These routines send a SIGINT signal to the current process.