Debugging with GDB (September 2007)

124 Debugging with GDB
Because you are going to edit the current file, you do not need to specify a source file
name.
(gdb) edit
The edit command ope ns a new terminal session using your environment variable
settings for terminal and editor. The debugger automatically loads the source file.
7. Make the necessary changes. In this case, add:
return total;
to the function named num.
8. Save the edited source file and exit the editor. This saves the changes in the actual
source file for the program.
9. Use the fix command to recompile the program to see the results of the changes:
(gdb) fix
Compiling /dev/src/sum.c...
Linking...
Applying code changes to sum.c.
Fix succeeded.
The fix command creates a new executable that includes the changes you made to the
source file.
The debugger automatically use s the new executable and picks up the debugging session
where you stopped before using the edit command.
For example, you can continue stepping through the program and you will find the new
return total; state ment in the source view. You can print the value of total, and
see that the result is 110.
10. When you finish with the debugging session, you can exit the debugger normally:
(gdb) q
The following modules in /dev/src/mysum have been fixed:
/dev/src/sum.c
Remember to remake the program.
The debugger message lists the source files that you have changed during the debugging
session.
Note:
You must rebuild the program after you use the fix command because
the changes you make are temporarily patched into the executable image.
The changes are lost when you exit the debugger or you load a different
executable.
14.8 Inline Support
HP WDB enables you to debug inline functions in applications compiled with -g option.
To enable inline debugging in HP 9000 systems, the applications must be compiled with
the +inline_debug option (introduced in the A.03.65 and later versions of the HP aC++
compiler). In Integrity systems, the applications that are compiled with -g option support
inline debugging by default and require no additional options. Compiler versions A.06.02