Chapter 3. Selecting Source Files

This chapter shows you how to select source files for the source pane of the Main View window of the Debugger (see Figure 1-1). It covers the following topics:

How to Load Source Files

The following sections show you the three ways you can load source files for debugging.

Note: For demonstration purposes, before you begin this section, perform the following from your shell:
% mkdir demos
% mkdir demos/jello
% cd demos/jello
% cp /usr/demos/WorkShop/jello/* .
% make
various messages appear
% cvd &

Load Directly into the Main View Window

Perform the following steps to load your source file directly into, or run your executable from, the Debugger Main View window:

  • Enter the source file directly. Enter the name (or full pathname, if necessary) of the source file in the File field.

    For example, enter the following if you launched cvd & from within the jello/demos directory.:

    File: jello.c

  • Enter the executable directly. Enter the name (or full pathname, if necessary) of the executable in the Command field.

    For example, enter the following if you launched cvd & from within the jello/demos directory:

    Command: jello

Load from the File Browser Dialog Box

You can load source files from the File Browser dialog box, available as Views -> File Browser from the menu bar of the Main View window. The File Browser window is shown in Figure 3-1.

Figure 3-1. File Browser Window

File Browser Window

This dialog box provides you with a list of the source files that your executable file can use, including any files in linked libraries.

  • locate a file: to locate a file, enter your desired filename in the Search field.

  • load a file: to load a file directly into the Main View window from the File Browser dialog box, simply double-click on the file name.

You may be unable to locate some files because the source supports system routines. Source for these routines may not be available on your system.

Load from the Open Dialog Box

You can load source files from the Open dialog box, available as Source -> Open from the menu bar of the Main View window. The standard dialog box lists all available files and the currently selected directory in the Selection field. You can change this directory as you wish.

Figure 3-2. Open Dialog Box

Open Dialog Box

There are several ways to load a file. You can:

  • double-click on the file name.

  • type the full pathname of the file in the Selection field and click the OK button.

  • drag the file icon into the drop pocket. (Use an application like fm to produce file icons.)

If you specify a file name without a full path, the Debugger uses the current path remapping information to try to locate the file (see Path Remapping, “Path Remapping”).

Path Remapping

Path remapping allows you to modify mappings to redirect file names, located in your executable file, to their actual source locations on your file system. Because WorkShop uses full (that is, absolute) path names, path remapping generally is not necessary. However, if you have mounted executable files on a different tree from the one on which they were compiled, you need to remap the root prefix to get access to the source 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 by using use/full_path_name(blank) and dir/full_path_name(blank) in the command line.

Open the Path Remapping window ( Admin -> Remap Paths) from the menu bar of the Main View window. The following window is displayed:

Figure 3-3. Path Remapping Dialog Box

Path Remapping Dialog Box

For each prefix listed in the Prefix list, there is an ordered set of substitutions used to find a real file. By default, path remapping is initialized so that “.” is mapped to the current directory. The Substitution Set for '.' list shows the substitution list for the currently highlighted item in the Prefix list. The Prefix list represents where the source file(s) used to be and the Substitution Set indicates where the source file(s) are currently. You can perform the following operations through the Path Remapping dialog box:

  • 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 substitution set is created with the prefix name as the first element. Click on this element to highlight it.

    Next, type the desired substitution in the Value field below the Substitution Set list and insert it by clicking on either the Insert Before button or the Insert After button.

  • 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.

Case Example for Path Remapping

In some cases, if source files have been moved to new locations, path remapping is required to help the Debugger find the source files again.

The following tutorial shows you a case for remapping. It includes demo files bundled with your WorkShop Debugger:

  1. Create a new directory in your_home_directory:

    % mkdir jellodemos

  2. Change to the new directory:

    % cd jellodemos

  3. Copy the Jello demo files from the Workshop demo directory into your new directory:

    % cp /usr/demos/WorkShop/jello/* .

  4. Enter the following to ensure that the jello executable contains the jello demos source path:

    % make clobber
    % make

  5. Create another new directory in your jellodemos directory:

    % mkdir ./newdir

  6. Move the Jello source files to a new location:

    % mv ./*.c newdir

  7. Start the WorkShop Debugger:

    % cvd ./jello &

    The Main View window displays with no source in the source pane. The following message appears:

    Unable to find file <your_home_directory/newdir/jello.c

  8. Choose the following from the menu bar in the Main View window: Admin -> Remap Paths.... The Path Remapping window displays.

  9. In the Substitution Set for '.': dialog box:

    1. Select your_home_directory /jellodemos/newdir/jello.c

      The path/filename appears in the Value: field.

    2. Enter the following:


  10. Enter the following in the Value: field below the Substitution Set for '.': dialog box:


  11. Click on the Insert Before button.

    The directory is inserted before the highlighted empty line in the Substitution Set for '.': dialog box and after the first element, which was not highlighted.

Now, the source appears in the Main View source pane as your_home_directory/newdir/jello.c