HPlogo HP WDB-GUI Reference Manual: HP-UX 11i v2 > Chapter 3 Debugging with WDB GUI

Advancing Through Your Program

» 

Technical documentation

Complete book in PDF

 » Table of Contents

You can use the commands in this section to advance through your program during the debugging process.

You can use the Step commands to help you locate the section of your program that is causing a problem. For example, you can set a breakpoint at the beginning of a section, step through the code, and examine variables until you isolate the problem.

You can use the other commands in this section to change or show the location of the program counter.

Stepping into functions

The Step Into command provides a single step execution of the current instruction. If the instruction is a function call, Step Into enters the function and single-steps through it.

You can use Step Into to traverse a program in detail by stepping into each instruction as it is called.

To step into a function or instruction

  1. On the Debug menu, click Step Into.

  2. Or, click the Step Into button in the toolbar:

Stepping over functions

The Step Over command provides a single step execution of the current instruction, unless the instruction is a function call. If the instruction is a function call, Step Over executes the entire function, then pauses at the instruction immediately following the function call. Program execution also pauses at breakpoints that are set in a function.

You can use Step Over to traverse the current stack frame without stepping through the detail of each function call.

To step over a function or instruction

  1. On the Debug menu, click Step Over.

  2. Or, click the Step Over button in the toolbar:

Stepping out of functions

The Step Out command executes the program through completion of the current function. Then the debugger pauses at the statement immediately following the function call.

You can use Step Out to return execution to the calling stack frame when you no longer want to look at the detail of a function.

To step out of a function or instruction

  1. On the Debug menu, click Step Out.

  2. Or, click the Step Out button in the toolbar:

Stepping last functions

The Step Last command steps into the function call without stepping into the argument evaluation function calls.

You can use Step Last to step into a function call without stepping through the detail of each of its argument evaluation function calls. If a function call has arguments which further makes function calls, steplast executes all argument evaluation function calls and will step into the function. Program execution also pauses at breakpoints that are set in argument function.

If steplast is not meaningful at the current line, gdb will display the following warning message: “Steplast is not meaningful for the current line; behaviour undefined.”

In C++, the steplast command is helpful while debugging heavy templated functions, because it directly steps into the call, thus skipping the constructor calls, if any. This behaviour is unlike the step command that steps into the constructor itself.

To step last a function

  1. On the Debug menu, click Step Last.

  2. Or, click the Step Last button in the toolbar:

NOTE: Step last feature is supported for both C and C++ languages in WDB-GUI with HP WDB version 3.2 or higher. Step last is not supported on IPF platforms.

Running to the cursor

The Run To Cursor command continues executing the program until it reaches the current cursor location. The program begins execution at the program counter (indicated by a yellow arrow) and pauses at the current cursor location.

You can use the Run To Cursor command to advance to a specific location without having to set a temporary breakpoint.

To run to the current cursor location

  1. In the Source or Disassembly view, place the cursor at the location where you want program execution to pause.

  2. On the Debug menu, click Run to Cursor.

    • Or, in the Source or Disassembly view, click the right mouse button, then click Run to Cursor.

    • Or, click the Run to Cursor button in the toolbar:

Setting the next statement to execute

The Set Next Statement command sets the program counter at the current cursor location. The program begins execution from the newly set statement instead of from the previous program counter location.

You can use the Set Next Statement command to change the flow of execution if you want to re-execute or skip a portion of the program.

To set the next statement to execute

  1. In the Source or Disassembly view, place the cursor on the statement that you want to execute next.

  2. Click the right mouse button, then click Set Next Statement.

Showing the next statement to execute

The Show Next Statement command updates the WDB GUI to show the next statement to be executed. The command updates all applicable views, such as the Source, Disassembly, and Call Stack views.

You can use the Show Next Statement command to return to the current stack frame and instruction when you have been looking at a different source file or stack frame.

To show the next statement to execute

On the Debug menu, click Show Next Statement.

  • Or, in the Source or Disassembly view, click the right mouse button, then click Show Next Statement.

  • Or, click the Show Next button in the toolbar:

© 2004-2005 Hewlett-Packard Development Company, L.P.