Debugging with GDB Manual The GNU Source-Level Debugger (769148-001, March 2014)

Breakpoint 1 at 0x23f8: file sum.c, line 11.
5. Run the program:
(gdb) run
Starting program: /tmp/hmc/mysum
Breakpoint 1, main () at sum.c:11
11 int num = 10;
6. When the program stops at the break point, use the edit command to make changes to the
source file.
Because you are going to edit the current file, you do not need to specify a source file name.
(gdb) edit
The edit command opens 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 uses 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; statement 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.
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 and later support the inline debugging feature
in Integrity systems.
106 HP-UX Configuration-Specific Information