Using the WDB GUI ·
Fixing Code from within the Debugger
Home and Help IconsKeyword IndexHomeUsing Help
Line Graphic
Line Graphic


Contents

Keyword Index

Using the WDB GUI
Starting and Exiting the WDB GUI
Loading a Program and Changing Program Settings
Opening Source Files
Changing the Working Directory
Saving and Restoring Debug Sessions
Setting Source Paths
Setting Object Paths
Viewing Your Code
Browsing Functions
Setting Signal Handling
Finding Specific Text in Your Code
Using the Command View
Using the Watch View
Using Quick Watch
Using the Local Variables View
Using the Call Stack View
Using the Threads View
Using the Registers View
Examining Memory Use
Using the Program Console
Using Breakpoints
Advancing Through Your Program
{short description of image} Fixing Code from within the Debugger
Starting and Stopping the Debug Process
Setting Debugger Preferences
Customizing Colors and Fonts

Reference Information

Troubleshooting

Using Help



Bullet Overview
Bullet Fixing Code and Continuing Your Program
Bullet Explicitly Requesting Files be Monitored or Rebuilt
Bullet Examining Build Errors and Warnings
Bullet Restrictions on Fixing Code from within the Debugger
Bullet See Also

Line Graphic

Overview

HP WDB lets you change the program you are debugging without having to exit the debugger or even restart the executable you are debugging. You have the option of explicitly requesting that a file be rebuilt and patched in, or you can have the debugger monitor source files, rebuilding the executable whenever changes are detected.

NOTES:
  • Changes made to an executable during a debugging session are not saved when you exit the debugger. To apply the changes outside the debugger, you must rebuild your executable.
  • There are a number of restrictions on the changes you can make to your program while it being debugged. See Restrictions on Fixing Code from within the Debugger for details.
Line Graphic

Fixing Code and Continuing Your Program

To edit your source code in the debugger

  1. On the File menu, click Open File.
  2. In the Directories list, double-click to select the appropriate directory.
  3. Select the Open in debugger toggle (this is the default).
    If you prefer, you can choose to open the file in an external editor.
  4. Make changes to the source file or files.
  5. If you're using an external editor, save your changes when you have completed them.
  6. Click on one of the following toolbar buttons:
    • Step Into
    • Step Over
    • Step Out
    • Step Last
    • Go
    • Restart.
  7. WDB GUI asks you if you want to apply the source changes. Click Yes.
    The debugger performs the command you selected using the modified source.

The Build View tab displays any build output and reports when the build has completed.

NOTES:
  • When the debugger starts an external editor, it chooses the editor based on the environment variable EDITOR. If EDITOR is not set, the debugger starts vi.
  • Files you open are monitored for changes (text changes for the debugger editor; modification times for external editors). When you click on a program execution button (such as Step Into), the debugger asks you if you want to rebuild changed files.
Line Graphic

Explicitly Requesting Files be Monitored or Rebuilt

You can explicitly request that the debugger monitor or fix a specific file or files. This is useful, for example, for building dependent files that need to be rebuilt because you change a header file.

To explicitly request that a specific file be monitored for changes

  1. On the Edit menu, click Fix List.... The Add/Delete Fix List Files dialog appears.
  2. Click Browse... to display the Name of File to Fix dialog box.
  3. In the dialog box, choose a file to add to the fix list.
  4. Click OK to close the dialog box.
    The file you selected appears in the Add/Delete Fix List Files dialog.
  5. When you are finished adding files to the fix list, Click OK.
    All files in the list will be monitored for changes.

To request an immediate rebuild of a specific file

  1. On the Edit menu, click Fix List.... The Add/Delete Fix List Files dialog appears.
  2. In the Fix List dialog, highlight any of the files in the fix list that you want rebuilt and patched in immediately.
  3. Click OK in the Fix List dialog. The files you highlighted will be rebuilt and patched in immediately.

Line Graphic

Examining Build Errors and Warnings

Build errors and warnings are posted to the Build View. The debugger displays the Build View automatically when the debugger rebuilds code you have fixed.

To view the source code for an error or warning, double click on the error or warning in the Build View. The source associated with the error or warning will be displayed in the Source View. Line Graphic

Restrictions on Fixing Code from within the Debugger

These types of source code changes cannot be fixed within the debugger:

  • Adding, deleting or reordering the local variables and parameters in a function currently active on the stack.
  • Changing the data type of a local variable, file static, global variable, parameter of a function.
  • Changing a local, file static, or global variable to be a register variable, or vice-versa.
  • Adding any function calls that increase the size of the parameter area.
  • Adding an alloca() function to a frame that did not previously use alloca().
  • Adding fields to a structure anywhere other than at the end of the structure.
  • Changing the order of fields in a structure.

Additionally, the debugger has these limitations in how it handles changed code:

  • With the exception of the routine at the top of the stack, new code will not be executed for a routine currently on the stack until that routine is popped off the stack and program execution reenters that routine.
  • With the exception of the routine at the top of the stack, breakpoints in a routine on the stack will be inactive until that routine is popped off the stack and program execution reenters that routine.
  • If the name of a function is changed and there was a breakpoint set to the old version of the function, the breakpoint is not moved to the new function. Additionally, the old breakpoint is still valid (and can be hit when existing routines call the old function name).
  • 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. It is possible that the program counter may be at the wrong line.

Line Graphic

See Also

Line Graphic

Return to Top