Qt Creator does not include a debugger. It provides a debugger plugin that acts as an interface between the Qt Creator core and external native debuggers such as the GNU Symbolic Debugger (gdb), the Microsoft Console Debugger (CDB), and an internal Java Script debugger. You can use the native debuggers to debug the C++ language.
You can use the Qt Creator Debug mode to inspect the state of your Qt projects while debugging.
In the Debug mode you can interact with the debugger in several ways, including the following:
- Go through a program line-by-line or instruction-by-instruction.
- Interrupt running programs.
- Set breakpoints.
- Examine the contents of the call stack.
- Examine and modify registers and memory contents of the debugged program.
- Examine and modify registers and memory contents of local and global variables.
- Examine the list of loaded shared libraries.
- Create snapshots of the current state of the debugged program and re-examine them later.
Qt Creator displays the raw information provided by the native debuggers in a clear and concise manner with the goal to simplify the debugging process as much as possible without losing the power of the native debuggers.
In addition to the generic IDE functionality provided by stack view, views for locals and watchers, registers, and so on, Qt Creator includes features to make debugging Qt-based applications easy. The debugger plugin understands the internal layout of several Qt classes, for example, QString, the Qt containers, and most importantly QObject (and classes derived from it), as well as most containers of the C++ Standard Library and some gcc and Symbian extensions. This deeper understanding is used to present objects of such classes in a useful way.
For an example of how to debug applications in the Debug mode, see Debugging the Example Application.
For more information about the functions available in the Debug mode, see Interacting with the Debugger.
If you install Qt Creator as part of a Qt SDK, the GNU Symbolic Debugger is installed automatically and you should be ready to start debugging after you create a new project. If you want a special setup, such as using debugging tools for Windows, see Setting Up Debugger.
Modes of Operation
The debugger plugin runs in different operating modes depending on where and how the process is started and run. Some of the modes are only available for a particular operating system or platform.
You can launch the debugger in the following modes:
- Plain to debug locally started applications, such as a Qt based GUI application.
- Terminal to debug locally started processes that need a console, typically without a GUI.
- Attach to debug local processes started outside Qt Creator.
- Remote to debug a process running on a different machine.
- Core to debug crashed processes on Unix.
- Post-mortem to debug crashed processes on Windows.
- TRK to debug processes running on a Symbian device.
When you click the Start Debugging button, the debugger is launched in the appropriate operating mode (plain, terminal, or TRK), based on the build and run settings for the active project. Select Debug menu options to launch the debugger in the other modes.
To launch the debugger in the plain mode, click the Start Debugging button for the active project, or choose Debug > Start Debugging > Start and Debug External Application... and specify an executable.
To launch the debugger in the terminal mode, select Projects > Run Settings and select the Run in terminal check box. Then click the Start Debugging button for the active project.
To launch the debugger in the attach mode, select Debug > Start Debugging > Attach to Running External Application..., and then select a process by its name or process ID to attach to.
The remote mode uses a gdbserver daemon that runs on the remote machine.
To launch the debugger in the remote mode, select Debug > Start Debugging > Start and Attach to Remote Application....
The core mode is available only in Unix. It debugs crashed processes using the core files (crash dumps) that are generated if the setting is enabled in the shell.
To enable the dumping of core files, enter the following command in the shell from which the application will be launched:
ulimit -c unlimited
To launch the debugger in the core mode, select Debug > Start Debugging > Attach to Core....
The post-mortem mode is available only on Windows, if you have installed the debugging tools for Windows.
The Qt Creator installation program asks you whether you want to register Qt Creator as a post-mortem debugger. To change the setting, select Tools > Options... > Debugger > Common > Use Creator for post-mortem debugging.
You can launch the debugger in the post-mortem mode if an application crashes on Windows. Click the Debug in Qt Creator button in the error message that is displayed by the Windows operating system.
The TRK mode is a special mode available only for Symbian. It debugs processes running on a Symbian device using the App TRK application that runs on the device.
To launch the debugger in the TRK mode, open the project, select Symbian as the target, and click the Start Debugging button.
For more information on setting up Symbian projects, see Setting Up Development Environment for Symbian.