Guardian Programmer's Guide

Table Of Contents
Fault-Tolerant Programming in C
Guardian Programmer’s Guide 421922-014
27 - 50
Example With Debugging Options
initialize_backup ();
primary_processing ();
}
}
Debugging Modifications to Function initialize_backup
The name of the terminal for the backup process must be communicated to the backup
process through the C function __ns_start_backup. Code is added to the
initialize_backup function to test the number of parameters, get the terminal
name, and pass it to __ns_start_backup. To get the terminal name,
initialize_backup calls the user-written function get_terminal_name.
Two optional debugging parameters are added to the call to the C function
__ns_start_backup. Note that they are intended for the PROCESS_CREATE_
procedure, which is called by __ns_start_backup to create the backup process.
terminal_name, an input parameter that points to the string naming the home
terminal for the backup process.
debug_options, an input parameter that specifies debugging options. The
parameter is set to 11, which indicates the following when it is passed to
PROCESS_CREATE_:
Use the Inspect tool as the debugger.
Enter the Inspect tool at the first executable instruction in the main procedure.
If the program traps, do not create a save file.
See the C/C++ Programmer’s Guide for details on the function parameters.
Function initialize_backup is as follows, with new code shown in boldface print:
void initialize_backup (void)
{
short backup_phandle [PHANDLESIZE];
char process_name [MAXNAMELEN];
short process_name_len;
short error; /*value not used*/
short error_detail;
char *terminal_name;
short debug_options = 11;
/*Start the backup process*/
if (arg_num >= 3)
{
/*Terminal names provided for debugging*/
get_terminal_name (&terminal_name);
error = __ns_start_backup (&error_detail, (short) -1,
backup_phandle, terminal_name, debug_options);
}
else /*Debug option not requested*/
error = __ns_start_backup (&error_detail, (short) -1,