Debugging in the Console

Xcode’s graphical interface for GDB, the GNU debugger, lets you perform most necessary debugging tasks. You may, however, encounter situations—such as working with watchpoints in GDB—that require you to interact directly with the debugger on the command line. Using the console window, you can:

If you are debugging a command-line program that requires input from stdin, you must use the console to communicate with your program when it is running in the debugger. This window is only available when your program is running under the debugger.

Working in the Console

To open the Console window, choose Run > Console.

To enter commands, click in the console window and type at the gdb or JavaBug prompt. To get help with GDB and Java debugging commands, enter help at the console. To learn more about command-line debugging with GDB, see Debugging with GDB.

Changing Text Formatting

To make the Console text easily readable, Xcode lets you choose the text colors and fonts used in the console window. You can use different fonts and colors for the text you type in the console, the text the debugger writes to the console, and the debug console’s prompt. To change the colors used for text in the console window, use the Fonts and Colors group in Xcode > Preferences > Debugging. See Debugging Preferences for more information.

Note that Xcode uses an executable environment to determine how to launch your program. To specify command-line arguments and environment variables to use when launching your program from Xcode, edit the executable environment; you cannot alter this environment from the gdb command-line in the console window. See Configuring Executable Environments to learn more about configuring an executable environment.