Debugging with GDB (February 2008)

Table Of Contents
122 Debugging with GDB
If you change the name of a function and there was a breakpoint set to the old function,
WDB does not move the breakpoint to the new function. The old breakpoint is still
valid.
If the number of lines of the modified file is different from that of the original file, the
placement of breakpoints may not be correct.
When the program resumes, the program counter is moved to the beginning of the
same line in the modified function. The program counter may be at the wrong line.
14.7.3 Using Fix and Continue
When WDB recompiles a fixed source file, it uses the same compiler and the same options
that were used to create the original executable. If the compiler generates any syntax errors
or it encounters any of the restrictions, WDB does not patch the changes into the executable
image being debugged.
After you successfully recompile the changes, WDB uses the fixed version of the code
when you use any of the execution commands such as step, run, or continue.
When you use the edit command, WDB then monitors any edited source files for addi-
tional changes. After you enter the initial fix command, WDB checks for additional saved
changes to a source file each time you enter a program execution command. If a saved
source file has been changed, WDB asks if you want to fix the changed source, allowing you
to apply repeated fixes without explicitly entering the fix command.
The Fix and Continue facility enables you to make the following changes:
Change existing function definitions.
Disable, reenable, save, and delete redefinitions
Adding global and file static variables.
Add new structure fields to the end of a structure type object.
Set breakpoints in and single-step within redefined code.
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 if you load a different executable and are not reflected in
the original executable when you exit the debugger.
14.7.4 Example Fix and Continue session
This example shows how you can make and test changes to a function without leaving
the debugger session.
Here is a short sample C program with an error:
int sum (num) int num;
{
int j, total = 0;
for (j = 0; j <= num; j++)
total += num;