NextGen TotalView for HPC User Guide : PART II Debugging Tools and Tasks : Chapter 5 Setting and Managing Action Points (Breakpoints) : Evalpoints : Patching Programs : Branching Around Code
Branching Around Code
The following example contains a logic error in which the program dereferences a null pointer:
1 int check_for_error (int *error_ptr)
2 {
3 *error_ptr = global_error;
4 global_error = 0;
5 return (global_error != 0);
6 }
The error occurs because the routine that calls this function assumes that the value of error_ptr can be 0. The check_for_error()function, however, assumes that error_ptr isn’t null, which means that line 3 can dereference a null pointer.
Correct this error by setting an evalpoint on line 3 and entering:
if (error_ptr == 0) goto 4;
If the value of error_ptr is null, line 3 isn’t executed. Note that you are not naming a label used in your program. Instead, you are naming one of the line numbers generated by TotalView.