# Debugging a program

To debug a program, a debug launch configuration is used. The debug configuration contains information such as the executable being debugged, how to run the executable, and parameters for the debugger itself (in this case: gdb). Once a launch configuration is created, it can be used again (e.g. relaunching the executable after the debug session is terminated). By default, the Stand-alone Debugger creates a debug launch configuration for you when you specify an executable on the command-line or if you use the New Executable... dialog.

There are multiple debug launch configuration types. The most common, is the Local C/C++ Application configuration which is for running local applications and this is the configuration that the Stand-alone Debugger will set up for you when you specify an executable in either of the aforementioned ways. A local C/C++ launch configuration is normally tied to an Eclipse project which contains the executable you wish to debug. You do not have to create an Eclipse project because the Stand-alone debugger also creates the Eclipse project on your behalf as part of importing your executable. By default, this is usually the special Executablesproject which is set aside for this purpose, but if you have imported multiple executables at the same time, additional ExecutablesNNNN projects will be created to keep each executable in a separate project. This is done to help the indexer keep track of the executable and all its associated source fiels.

There are other C/C++ debug configuration types that you may wish to use such as:

- C/C++ Attach to Application
- C/C++ Postmortem Debugger

These additional launch configurations require that you create them manually. To do this:

1. In C/C++ Projects view, select a project. The C/C++ Projects view is not visible by default when you start the Stand-alone debugger. You can access it by using Window > Show View > C/C++ > C/C++ Projects. As mentioned, in most cases, you will only see the Executables project.
2. Click Run > Debug Configurations....
3. In the Debug Configurations dialog box, select a desired debug configuration type from the Configurations list.

4. Click the New button in the top left.

5. In the Name box, type a descriptive name for this debug configuration.
6. In the Project box, type the name of the project containing the application you want to debug. If you had selected a project, this project will be filled in for you. In almost all cases, this will be the Executables project.
7. In the C/C++ Application box, type the name of the executable that you want to run. This must be an application that has been imported into the project or in the case of an Attach to Application configuration, this field can be empty.
8. Click Debug.

   The debug perspective is opened and the application window opens on top. In the case of an attach configuration, a dialog will pop up to allow you to select a running application.

For more information:

- To specify the execution arguments an application uses and the working directory for a run configuration, see Specifying execution arguments.
- To set the environment variables and values to use when an application runs, see Setting environment variables
- To select a debugger to use when debugging an application, see Selecting a debugger
- To specify the location of source files used when debugging a C or C++ application, see Specifying the location of source files
- To specify where the run configuration is stored, how you access it and what perspective to open when running an application, see Specifying the location of the run configuration

To use a debug configuration:

You can reuse a previously created debug launch configuration to debug your program.

1. Click Run > Debug.
2. In the Debug dialog box, select a debug configuration from the Configurations list.
3. Click Debug.

Debug overview
Debug information

Debugging

Run and Debug dialog box