To create a debug launch configuration that will attach
to a compiled language application, complete the steps in this topic.
Procedure
- Select File > New launch > Attach to process from
the debugger main menu.
- In the Name field, enter a name
of your choice for the configuration that you are creating.
- Select the Main tab to bring it
to the foreground.
- If you know the process ID of the program that you want
to debug, enter it in the Process Identifier field.
Alternatively, select the Browse push button
to invoke the Select Process dialog box, from
which you can choose the program that you want to debug and its system
Process ID. If you do not see the program that you want to debug in
the process list, you can scroll the list or click Refresh to
refresh the list with programs that have recently started. Once you
have selected the program that you want to attach to, click OK.
Note: - If the name of the process to which you want to attach is unique,
you can specify the name instead of the Process ID.
- The Browse action cannot be used when debugging
remotely. It only supports browsing the machine that is running the
user interface client.
- Select the Advanced tab, in which
you can make the following settings:
- To set the Source Lookup Path, select the Source tab
and perform any of the following tasks:
If you want to search for all instances of the source file
name in the source search path, select the Search for
duplicate source files on the path check box. If you select
this check box and the debugger finds multiple instances of the file
name, you will be prompted by a dialog box to choose the correct source
file.
- Select the Environment tab to bring
it to the foreground. In the Environment page,
you can set environment variables for your debug session. Settings
that you make in this page will only affect your debug session.
Note: Changes made in this tab will only affect the debug engine
and not the process to be debugged. The process to be
debugged is already running and its environment cannot be altered
through this tab.
You might need to set environment variables
for a variety of factors, for example, to specify the location of
the executable for an application that is required for the debug session.
To set environment variables in this page, perform any of these tasks:
- By default, the environment variables that are set for your debug
session are as follows:
- If you launched the workbench from a command line or batch file
with environment variables set, these will be the default environment
variables used for the debug session.
- To add an environment variable for the debug session, click the
New button and then complete the New
Environment Variable dialog box with the appropriate values.
The environment variable will be added to the default environment
variables.
- To remove an environment variable for the debug session, select
it from the Environment variables to set list
and then choose the Remove button.
- Click Select to open a dialog box that
allows you to add any variable that is currently in the environment.
- If all information mandatory to the launch configuration
has been provided, the Debug and Apply push
buttons will be enabled. Clicking Apply will
save the launch configuration, at which point you can choose to close
the dialog box without launching the debug session or you can click
Debug to launch a debug session using the
new launch configuration. If you click Debug,
any changes to the launch configuration will be saved and a debug
session will be launched.
Note: When you save a launch
configuration for attaching to a running process, the process ID that
you enter is saved, however, will not likely be valid the next time
you use the launch configuration. Edit the configuration to again
choose a process ID.
Tip: If you have not yet saved
launch configuration settings and if you have made entries in the
launch configuration settings that you want to remove or change, clicking
Revert will remove all changes that you have
made.
- If information mandatory to the launch configuration has
not been provided or if there are errors in the information that you
have provided, messages at the top of the dialog box will indicate
what is missing.
- If you did not use the dialog box to launch a debug session
(for example, you used it instead to create and save a launch configuration,
click Close to exit the dialog box when you
are finished working in it.
Results
To delete a launch configuration, select File
> Launches > Delete Launches from the debugger main menu.
This will open a dialog box, in which you can select the launch or
launches that you want to remove.
To launch a debug session
with a launch configuration that you have already created, select File
> Launches > <launch>, where <launch> is
the launch configuration name that you specified when creating the
launch configuration. This will open the launch configuration dialog
box with the saved settings for the launch configuration. You can
edit these settings before using the launch configuration again.
Attention: Unexpected results might occur if an incorrect process
ID is entered or if you try to attach to a system process.