Chapter 2. Managing Source Files

This chapter looks at the details of working with source files. It covers these topics:

Accessing Files Used by an Executable

The File Browser, available from the Views menu in the Main View, provides a scrollable list of the source files used by your executable, including files in linked libraries. See Figure 2-1.

Figure 2-1. File Browser Window

Figure 2-1 File Browser Window

The File Browser has a field labeled Search for quickly locating files in the list. File searching is incremental—as you type the string you are searching for in the Search field, the first string that matches the entered string is highlighted.

To load a file directly into Main View from the File Browser window, simply double-click the filename.

Opening a New File

Another way to load a file is to specify it by using the "Open..." selection from the Source menu. The dialog box in Figure 2-2 displays, listing the files in the file list display area and the currently selected directory in the selection field.

Figure 2-2. Open Source File Dialog Box

Figure 2-2 Open Source File Dialog Box

To load a file listed in the file list, double-click the file's name. You can also type the full pathname of the file in the Selection field and click the OK button to load the file. Another alternative is to drag the file's icon into the drop pocket.

If the file you want to load is not in the current directory, enter the appropriate directory in the selection field. The files in the new directory are listed in the file list.

If you specify a filename without a full path, the Debugger will use the current path remapping information to attempt to locate the file.

Another method for opening a file in Main View is to enter its full name in the File field, below the source code display area, and press <Enter>.

Path Remapping

The path remapping option allows you to modify the set of mappings used to redirect filenames located in your executable to their actual locations in your file system. Since WorkShop uses full (absolute) pathnames, path remapping is generally not necessary. However, if you have mounted executable files on a different tree from the one on which they were compiled, you will need to remap the root prefix to get access to the files in that hierarchy.

The most basic remapping is for ".", which allows you to specify the directories to be searched for files. This basic function works just like dbx and can be modified using the use and dir commands in the command line. To open the Path Remapping dialog box, choose "Remap Paths..." from the "Project" submenu in the Main View Admin menu. The Path Remapping dialog box appears (see Figure 2-3).

Figure 2-3. Path Remapping Dialog Box

Figure 2-3 Path Remapping Dialog Box

For each prefix listed in the Prefix list, there is an ordered set of substitutions that are used to find a real file. By default, the path remapping is initialized so that "." is mapped to the current directory. The Substitution Set list shows the substitution list for the currently highlighted item in the Prefix list. Here are some operations you can perform:

  • To view the substitution set for a different prefix, click that prefix.

  • To add a new prefix, enter the new value in the Value field below the Prefix list and click the Add button. A new, empty substitution set is created. Next, type the desired substitution in the Value field below the Substitution Set list.

  • To modify the currently selected prefix, edit the string in the Value field and click the Modify button.

  • To remove the current prefix and its substitution set, select the prefix and click the Remove button.