Chapter 4. Fix and Continue Reference

This chapter describes in detail the function of each window, menu, and display in the Fix and Continue utility's graphical user interface (GUI). In addition, the chapter describes the Fix and Continue commands available on the Debugger command line (see “Command-Line Interface”). Most commands are available from either interface. You can move from one to the other as you prefer. For a task-oriented introduction to commonly-used functions, see Chapter 3, “Using Fix and Continue: A Sample Session.”

With Fix and Continue, the Debugger is in the “Edit” state by default. This means that you may select a function for editing, redefine, check syntax, and run the program. You can work with several redefinitions, selectively enabled or disabled.

This chapter contains the following sections:

Graphical User Interface

The Fix and Continue GUI affects several WorkShop windows and provides three more. The Debugger and Source View access the Fix and Continue utility from the menu bar. The results of running redefined code are displayed in the Debugger Execution View. Special line numbers (decimal notation) applied to redefined functions appear in several WorkShop views (refer to “Changes to Debugger Views”). Fix and Continue comes with three windows devoted entirely to Fix and Continue: Status, Message, and Build Environment. This section describes Fix and Continue menu selections and these windows.

The Fix and Continue menu is available from the Debugger Main View menu bar, as shown in Figure 4-1. The menu selections operate on the selected function or on the file shown in the source view. The Fix and Continue menu is also available from Source View and from the Fix and Continue Status window.

Figure 4-1. Fix+Continue Menu Selections


Fix and Continue Menu Operations

Figure 4-2. Fix+Continue Menu


The Fix and Continue menu (see Figure 4-2) offers the following menu selections:

“Edit“ 

Allows you to edit functions using the Debugger editor.

“External Edit“ 

Allows you to edit functions using an external editor. The default editor is vi, but can be changed by using the “Set Edit Tool...” popup menu in the Admin menu of the Status window. See “Fix+Continue Status Window” for further information.

“Parse and Load“ 


Parses your modified function and loads it for execution. You can execute the modified function by clicking on the Run or Continue buttons in the Debugger main view.

“Cancel Edit” 

Takes you out of edit mode.

“Show Difference“ submenu 


Allows you to see the difference between the original code and your modifications. See “Show Difference Submenu” for further information.

“Edited<-->Compiled“ 


Enables or disables your changes. This switch allows you to see how your application executed before and after the changes you made.

“Delete All Edits“ 


Deletes any changes that you made to functions.

“Save File+Fixes As...“ 


Allows

Figure 4-3. ”Save File+Fixes As...” Popup Window


you to save your changes to a file (see Figure 4-3). You can save the changes to the current source file (the default), or to a separate file.

“Update All Files...”  


Launches the “Save File+Fixes As...” dialog (see Figure 4-3), which allows you to update the current session, saving all the modified functions to the appropriate files.

“View“ submenu 


Allows you to change to different views. Fix and Continue supports status, message, and build environment windows. See “View Submenu” for further information.

“Preferences” submenu 


Allows you to set your Fix+Continue preferences. See “Preferences Submenu” for further information.

Show Difference Submenu

Figure 4-4. Show Difference Submenu


This submenu(see Figure 4-4) allows you to see the difference between the original and your modified code. It contains the following options:

“For Function” 


Opens a window that shows you the differences between the original function source and your modified source.

“For File” 

Opens a window that shows you the differences between the original source file and your modified version.

“Set Diff Tool ...” 


Launches the Preference dialog (see Figure 4-7), which allows you to set the tool that displays the differences between the two sets of code. The default is xdiff. For further information on the Preference dialog, see “Preferences Submenu”.

View Submenu

Figure 4-5. View Submenu


This submenu(see Figure 4-5) allows you to open different Fix+Continue view windows. It contains the following options:

“Status Window” 


Launches the Fix+Continue Status window. See “Fix+Continue Status Window” for more information.

“Message Window” 


Launches the Fix+Continue Message window. See “Fix+Continue Message Window” for more information.

“Build Environment Window” 


Launches the Fix+Continue Build Environment window. See “Fix+Continue Build Environment Window” for more information.

Preferences Submenu

Figure 4-6. Preferences Submenu


The PreferenceMenu (see Figure 4-6) allows you to set various options for Fix and Continue environment, such as the difference tool, the external editor command, and so on. The menu contains the following options:

“Show Preferences” 


Launches the Preference dialog (see Figure 4-7), which displays the preferences that are currently enabled for the session, and allows you to change the settings.

Figure 4-7. Preferences Dialog


“Reset Factory Defaults” 


Sets the preferences to the installed defaults.

“Save Preferences” 


Allows you to save your preferences to a file. This item brings up the File dialog. See Figure 4-16.

“Load Preferences...” 


Allows you to load preferences from a file. This item brings up the File dialog. See Figure 4-16.

Fix+Continue Status Window

This section describes the Fix+Continue Status window (see Figure 4-8). The Status window provides you with a summary of the modifications that you have made during your session. It also allows you quick access to your modified functions, and a somewhat expanded Fix+Continue menu.

Figure 4-8. Fix+Continue Status Window


The function ID number, status, name, and filename are displayed in the Status window. Double-clicking a line item in the status window brings up the corresponding source in the Debugger main window.

The menus and submenus that provide you with extra functionality through the Status window (see Figure 4-9) are described below.

Figure 4-9. Fix+Continue Status Window Menus


Admin Menu

Figure 4-10. Status Window Admin Menu


The Admin menu (see Figure 4-10) contains an option for closing the window.

“Close” 

Closes the Status window.

View Menu

Figure 4-11. Status Window View Menu


The View menu (see Figure 4-11) contains options for sorting the information in the window, and displaying filenames.

“Sort Status View” 


Sorts the information in the status view according to the field currently selected.

“Show Long Filenames” 


A toggle that allows you to show the absolute (long) pathnames, relative pathnames, or base names.

Fix+Continue Menu

Figure 4-12. Status Window Fix+Continue Menu


The Fix+Continue menu (see Figure 4-12) that is available from the Status view is somewhat different from that available through the Debugger main view. It contains a number of options and submenus, which are all described below. These options and submenus are active on the function that you select in the Source view. You can select a function by clicking on it.

“External Editor” 


Allows you to edit with an external editor such as vi, rather than the Debugger's default editor.

“Parse And Load” 


Parses your modified function and loads it for execution. You can execute the modified function by clicking on the Run or Continue buttons in the Debugger main view.

Update All Files...” 


Launches the “Save File+Fixes As...” dialog (see Figure 4-3), which allows you to update the current session, saving all the modified functions to the appropriate files.

Figure 4-13. Show Difference Submenu


“Show Difference” submenu (see Figure 4-13) 


Allows you to show the difference between the original source and your modified code. You can show the difference in the code in one of the two following ways:

  • “For Function” shows the differences for the current function only.

  • “For File” shows the differences for the entire file that contains the current function.

    Figure 4-14. Enable Submenu


“Enable” submenu (see Figure 4-14) 


Allowsyou to enable the changes in your modified code in one of the three following ways:

  • “Function” enables the changes in the current function.

  • “Functions in File” enables the changes to the current function in its own file.

  • “All Functions” enables the changes to all functions in the modified code.

“Disable” submenu (see Figure 4-14) 


Has the same menu choices as the “Enable” submenu, but disables rather than enables.

Figure 4-15. Save Submenu


“Save” submenu (see Figure 4-15) 


Allowsyou to save your code changes to a file. You can save the changes in one of the three following ways:

  • “Function...” launches the File dialog (see Figure 4-16), allowing you to save only the current function to a file.

  • “File...” launches the “Save File+Fixes As...” popup window (see Figure 4-3), allowing you to save the entire file that contains the current function.

    Figure 4-16. File Dialog


“Delete” submenu (see Figure 4-14) 


has the same menu choices as the “Enable” submenu, but deletes rather than enables.

Figure 4-17. Show Submenu


“Show” submenu (see Figure 4-17) 


Allowsyou to launch any of the following three different Fix and Continue windows:

Fix+Continue Message Window

The Fix+Continue Message window (see Figure 4-18) contains a list of any errors and other system messages that pertain to your source modifications, parses, and attempts to run your modified source.

Figure 4-18. Fix+Continue Message Window


You can highlight the source line where the error occurred by double-clicking the appropriate line in the Message window. The window contains the following buttons:

Clear 

Clears all the parsing errors and warnings.

Next 

Puts a tick mark on the next unticked error warning entry in the parse messages. It displays the corresponding file and line in the Source view, highlighting it according to the type of error or warning. Next doesn't function after all the entries in the messages are ticked.

Rescan 

Erases all the ticks, so that you can rescan all the error warnings from the beginning.

The added functionality available through the Message window's Admin and View menus is described below.

Admin Menu

The Admin menu allows you to perform either of the following two operations:

“Clear All” 

Clears all messages in the Message window.

“Close” 

Closes the window.

View Menu

The View menu allows you to set any of the following three toggles:

“Show Warnings” 


Causes compile warnings to be displayed in the parse errors list.

“Append Parse Messages” 


Causes parse messages to be appended to the parse errors list.

“Append Load Messages” 


Causes load messages to be appended to the load errors list.

Fix+Continue Build Environment Window

This section describes the Fix+Continue Build Environment window (see Figure 4-19). The Build Environment window provides you with the build information for your source code in your current environment. It displays the command that was used to build your executable and the name of the file that contains the function that you currently have selected.

Figure 4-19. Fix+Continue Build Environment Window


The compiler and associated flags that were used to compile the file are normally gathered from the target. You can use the Build Environment window to make any changes to these flags.

The Build Environment window allows you to select your build environment setting through the “Build Environment Setting” toggle, which contains the two options described below:

“Default” 

Sets the build environment to default that is displayed in the Build Environment window.

“File Specific” 

Sets the build environment to that of the file that contains the currently selected function. You can change the file by clicking the Select File button, which launches the File dialog (see Figure 4-16).

The Build Environment window also contains the following buttons:

Select File 

Launches the File dialog and allows you to select a file from which to set the build environment.

Clear 

Clears the window.

Set 

Sets the build environment to what is displayed in the window.

Unset 

Unsets the build environment.

Done 

Dismisses the window.

Keyboard Accelerators

Use the accelerators in Table 4-1 to issue Fix+Continue commands directly from the keyboard.The accelerators are listed alphabetically by command.

Table 4-1. Fix and Continue Keyboard Accelerators

Command

Ctrl + key

Cancel Edit

U

Edit

E

External Edit

X

Parse And Load

P


Changes to Debugger Views

When you use Fix and Continue, Debugger views change to show redefined functions or stopped lines containing redefined functions.

Main View

When you open the Debugger after installing Fix and Continue, you'll notice several changes to the environment. All Fix and Continue functions are available through the Fix+Continue menu. See Figure 4-20 for details.

Figure 4-20. Debugger Main View


You select Fix and Continue commands from the Fix+Continue menu or enter them at the Debugger command line. The source code status is Read Only. Color coding shows the differences between editable code, enabled redefinitions, disabled definitions, and breakpoints. Line numbers in redefined functions have decimal notation that is used for every reference to the line number. The integer portion of the decimal is the same as the first line of the function. This ensures that compiled source code line numbers remain unchanged.

Command-Line Interface

The Debugger command-line interface accepts Fix and Continue commands and reports status involving redefined functions or files. Figure 4-21 shows a function successfully redefined using the command line. Change id 1 was previously redefined and assigned the number 1.

Figure 4-21. Command-Line Interface With Redefined Function


Call Stack

The Call Stack View recognizes redefined functions. It uses the decimal notation for line numbers, as shown in Figure 4-22.

Figure 4-22. Call Stack


Trap Manager

The Trap Manager recognizes redefined functions. It uses the decimal notation for line numbers, as shown in Figure 4-23.

Figure 4-23. Trap Manager With Redefined Function


Command-Line Interface

The commands in this section let you work with Fix and Continue from the Debugger command line. Command arguments that are used for more than one command are grouped and documented separately in the next section. They are listed in alphabetical order for quick lookup.

Common Fix and Continue Command Arguments

This section contains descriptions of some Fix and Continue flags and variables that are common to more than one command.

[-all] 

Specifies existing changes.

[change_id] 

A unique identifier (ID number) returned on the Debugger command line the first time you redefine a function. From then on, you can use the ID to refer to the function. Disabling or enabling the ID undoes or redoes the cumulative changes performed on the function.

[-file]  

Specifies the following source file (filename); for example: -file fmain.c

[filename] 

Specifies a filename with an extension such as .h, .c, or .CC

[func_spec] 

Specifies a function using the following syntax:

[change_id | [“filename”:] function_signature]

where function_signature is the name of the function. A C++ member function includes the class name and scope resolution operator (::). For example:

3
“fmain.c”: getNumbers
getNumbers
A::bingo

[line_number] 


Specifies the number of the line in the source code.

Fix and Continue Commands

add_source {“filename”:line_number} 


Prompts you to add source code lines (for example, add_source “fmain.c”:15.2). line_number must be within the body of a function. Entering a period (.) specifies the end of your input. The source lines you provide are added after the specified line. This command returns an ID existing or new, depending on whether the function affected has already been changed or not. The resulting new definition of the function is executed on its entry next time. See also delete_source, replace_source.

delete_changes {func_spec | -all | {-file filename}} 


Undoes the changes corresponding to the selected functions (for example, delete_changes getNumbers -file fmain.c). Once deleted, you won't be able to use the IDs again, since the IDs associated with the selected functions are released. The default is -all. See also save_changes.

delete_source {“filename”:line_number[,line_number]} 


Deletes the given line(s) if line_number or ,line_number (range) is within the body of a function. An example is: delete_source “fmain.c”:8.6,8.7. This command eturns an ID existing or new, depending on whether the function affected has already been changed or not. The resulting new definition of the function is executed on its entry next time.

disable_changes {func_spec | -all | {-file filename}} 


Undoes changes specified for the selected functions (for example, disable_changes getNumbers -file fmain.c. Nothing happens if the selected function is already disabled. The compiled definition of the function is executed on its next entry. You can invoke this command when the process is stopped or on a running process when a function entry breakpoint is set.

enable_changes {func_spec | -all | {-file filename}} 


Redoes changes specified for the selected functions (for example, enable_changes getNumbers -file fmain.c. Nothing happens if the selected function is already enabled. The latest accepted definition of the function is redefined on its next entry. You can invoke this command when the process is stopped or on a running process when a function entry breakpoint is set.

list_changes [func_spec | -all | {-file filename}] 


Lists one or more lines using the following syntax:

change_id isEnabled filename function_spec

For example:

4 enabled foo.c foo
8 disabled A.c++ A::bingo

The default is list_changes -all.

redefine func_spec 


[-edit |
{ -read
filename[line_number,line_number]}]
Specifies a new body for a function. The new definition is checked, and errors (if any) are printed. The new function body is redefined on the next function entry. Breakpoints (if set) on the old definition are put on the new definition based on their relative line number position from the beginning of the function definition. (Note that some breakpoints may not make it to the new definition.) You can invoke this command when the process is stopped or on a running process when a function entry breakpoint is set. There are three ways to provide a new definition:

  • -edit pops up an editor of your choice containing the current definition of the function. The specification of the new definition is complete when you exit the editor. You may not leave the editor open. Figure 4-24 shows the vi editor.

    Figure 4-24. Editing a Function in the vi Editor


  • -read takes the contents of the file specified (within the line numbers if given) as the new function definition.

  • No option allows you to type in replacement code from the next line. A period in the first column on a fresh line terminates the definition. For example:

    redefine getNums
    “/usr/fmain.c”:8.1> {
    “/usr/fmain.c”:8.2> printf(“In getNums.\n”);
    “/usr/fmain.c”:8.3> }
    “/usr/fmain.c”:8.4> .
    

    You can use a combination of characters (yet to be determined) to open an editor of your choice containing the lines typed. The specification of the new definition is complete when you exit the editor.

replace_source {“filename”:line_number[,line_number]} 


Prompts you to type in replacement source if line_number or ,line_number (range) is within the body of a function. The source lines you provide replace the specified line(s). An example is replace_source “fmain.c”:12. This command returns an existing or new id depending on whether the function affected has already been changed or not. The resulting new definition of the function is executed on its entry next time. See also add_source and delete_source.

save_changes {func_spec | {-file filename}}  


[-[w|a]] filename_to_save
Saves (enabled or disabled) function redefinitions or an entire file to a separate file (filename_to_save). An example of saving a function definition is the following:

save_changes getNumbers getNumbersFunc

If you specify the -file option, then before saving to filename_to_save, all function changes are applied to the compiled source of the file (with the condition that the file has had only its functions redefined, and has not been edited since the last build). An example of saving an entire file is the following:

save_changes -file fmain.c fmain.c

-w replaces the filename_to_save. -a appends to the file_to_save. An example of adding a function to a file is the following:

save_changes getNumbers -a newFuncs

See also delete_changes.

setbuildenv [“filename”] compiler-flag-list 


Overrides default build environment flags (compiler options). Without filename, the flags are passed along with -c -g flags to the compiler for any function in any file except those set separately with setbuildenv. An example is the following:

setbuildenv -DnameA -Idir
If filename is given, this command sets separate flags specifically for that file. For example, consider the following: 
setbuildenv “fermat.c” -DnameB -Ianotherdir

See also unsetbuildenv.

showbuildenv [“filename”] 


Lists all the build environment flags set so far. showbuildenv “filename” lists any build environment specs set separately with setbuildenv filename.

show_changes [func_spec | -all | {-file filename}] 


Prints the code of all enabled redefinitions of the specified function(s). The default is show_changes -all. See also enable_changes and disable_changes.

show_diff {func_spec | {-file filename}} 


Launches a xdiff comparing the compiled source and its latest redefinition for the specified function. If -file filename is specified, xdiff shows the difference between the compiled file and the file with all redefinitions applied to the compiled source of the file (with the condition that the file has had only its functions redefined, and has not been edited since the last build).

unsetbuildenv [“filename”] 


Disregards the default build environment flags if specified earlier. For all functions in files that don't have an overriding build environment, unsetbuildenv passes only the -c and -g flags.

If filename is given, this command disregards the build environment flags specified for the file earlier. Further redefinition of the functions in the file use the default build environment flags, if set. See also setbuildenv.