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:
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:|
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.:
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:
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.
This dialog box provides you with a list of the source files that your executable file can use, including any files in linked libraries.
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.
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.
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 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.
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.
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:
Create a new directory in your_home_directory:
% mkdir jellodemos
Change to the new directory:
% cd jellodemos
Copy the Jello demo files from the Workshop demo directory into your new directory:
% cp /usr/demos/WorkShop/jello/* .
Enter the following to ensure that the jello executable contains the jello demos source path:
% make clobber % make
Create another new directory in your jellodemos directory:
% mkdir ./newdir
Move the Jello source files to a new location:
% mv ./*.c newdir
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
Choose the following from the menu bar in the Main View window: Admin -> Remap Paths.... The Path Remapping window displays.
In the Substitution Set for '.': dialog box:
Select your_home_directory /jellodemos/newdir/jello.c
The path/filename appears in the Value: field.
Enter the following:
Enter the following in the Value: field below the Substitution Set for '.': dialog box:
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.