Locating source

When you debug an application, the debug engine finds the source for the application - or you can specify the source location through the debugger user interface. If the application does not have debug information, the debugger will not display the source for it and the editor will display a Disassembly view of the source. If the application does have debug information, but the debugger is unable to locate source, you have a variety of options for locating it.

About this task

One of the easiest ways to ensure that the debugger can locate the source for your C/C++ program is to compile it with the -qfullpath compiler option. For more information about debug compiler options, see the related topic.

When the debugger cannot find source, the debugger editor opens without source - however, right inside the editor, you are provided with options for locating the source. One of these options, the Edit Source Lookup push button, opens the Edit Source Lookup Path dialog in which you can select the type of source location to add. Alternatively, you can alter the source location list by right-clicking on a stack frame or thread in the Debug view and selecting the Edit Source Lookup action.

Altering the source location list

About this task

After you have launched a debug session, you can modify or add to the source location list by completing these steps:

Procedure

  1. Right-click the debug target (or one of its threads or stack frames) and choose Edit Source Lookup from the pop-up menu.
  2. In the Edit Source Lookup Path dialog box, perform any of these tasks:
    • To add a source location, click Add. This will invoke the Add Source dialog box, in which you can select the type of source location to add. From the selection list in the Add Source dialog box:
      • Choosing File System Directory will add a local file system directory to the source location list. If desired, subdirectories of this directory will be recursively searched if you select the Search subfolders check box.
      • Choosing Debug engine will cause the debug engine to be added to the source location list.
      • Choosing Debug engine path will cause the path specified on the debug engine to be added to the source location list. When specifying multiple paths, separate them with a colon (:).
        Note: Changes to the Debug engine path setting will take effect in subsequent debug sessions.
    • To remove an existing entry, select a source location and click Remove.
    • To set the order of existing entries, select a source location and click Up or Down to alter that location's placement.
  3. If you want to search for all instances of the source file name in the source location list, 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.
  4. After you have changed the path, click OK to close the dialog box and have the new path used to find source.

Changing the editor source file

About this task

If your program was not compiled with -qfullpath, your source has moved, or you are debugging on a system other than the one on which your program was built, the debugger may locate the incorrect source for the current stack frame. When this happens, you can change the text file that opens in the editor by completing the following steps:

Procedure

  1. Right-click inside the editor and select Change Text File from the pop-up menu.
  2. In the Change Text File dialog box field, enter or browse for the path and name of the file that you want to open.
    Note: If you are specifying a file on your local workstation, the fully-qualified path and filename must be entered in this field.
  3. Click OK to load the specified source file in the editor and close the Change Text File dialog box. Alternatively, if you do not want to change the source file, click Cancel.

Source file not found

About this task

When source cannot be found, the editor opens without source. In the editor, you are provided with these options:

  • You can specify a different editor source file name. To do this, choose the Change Text File push button to enter or browse for the path and name of the file that you want to open.
    Note: If you are specifying a file on your local workstation, the fully-qualified path and filename must be entered in this field.
  • You can edit the source lookup path so that it points to the location of the source file. To edit the source lookup path, select the Add Source Location push button. This will invoke the Edit Source Lookup Path dialog box. Instructions for using this dialog box are provided in the preceding altering the source location list section.
  • You can select Show Disassembly to open a Disassembly view of the source.

Feedback