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

Viewing Code

» 

Technical documentation

Complete book in PDF

 » Table of Contents

The WDB GUI offers two main views for looking at your code: the Source view and the Disassembly view. Use the Source view to see the contents of a file, and use the Disassembly view to see the corresponding assembly code.

The dwell feature allows you to quickly view the value of a variable or expression. It is available from both the Source view and Disassembly view.

Viewing source code

Before you can view your source code, you must have an executable loaded and running in the WDB GUI. Once you have loaded a file, you can use the Source view to see and manipulate your source code. Specifically, you can use the Source view to:

  • See the current file’s source path.

  • See the source file contents.

  • See the current location of the program counter. The program counter is set to the point in your program where the debugger will begin executing.

  • See the location and status of breakpoints.

  • See a stack marker that indicates the current context, determined by the stack frame selected in the Call Stack view.

  • Access the pop-up menu to perform actions that will affect how the code executes.

  • Use dwell to quickly view the value of a variable or expression.

To view your source code in the source view

  1. In the main window, click the Source tab.

  2. View the file’s source path by looking below the Source tab label.

  3. View the source code content in the right column of the Source view.

  4. View the location of the program counter, breakpoints, and the stack marker in the left column of the Source view.

NOTE: You cannot display the Source view in a separate window.

To use the pop-up menu in the Source View

In the Source view, click the right mouse button to display a pop-up menu that contains the following commands:

  • Show Next Statement

  • Quick Watch

  • Insert/Remove Breakpoint

  • Enable/Disable Breakpoint

  • Edit Breakpoint

  • Run to Cursor

  • Set Next Statement

  • Edit File

  • Open File in $EDITOR

Viewing assembly code

Before you can use the Disassembly view, your executable must be running. You can use the Disassembly view to:

  • See the assembly code associated with the currently executing function.

  • See the instruction that corresponds to the current location of the program counter. The program counter is set to the point in your program where the debugger will begin executing.

  • See the location and status of breakpoints.

  • See a stack marker that indicates the current context, determined by the stack frame selected in the Call Stack view.

  • Access the pop-up menu to perform actions that will affect how the code executes.

  • Perform debug actions, such as stepping through a program and setting breakpoints.

  • Use dwell to quickly view the value of a variable, register, or expression.

To view code in the Disassembly View

  1. In the main window, click the Disassembly tab.

  2. View the assembly code content in the right column of the Disassembly view.

  3. View the location of the program counter, breakpoints, and the stack marker in the left column of the Disassembly view.

To see the Disassembly View in a separate window

  • Click the right mouse button, then click Open Separate View. The separate window behaves the same as the tabbed Disassembly view.

  • To close the separate window, click the right mouse button, then click Close.

To use the pop-up menu in the Disassembly View

In the Disassembly view, click the right mouse button to display a pop-up menu that contains the following commands:

  • Show Next Statement

  • Quick Watch

  • Insert/Remove Breakpoint

  • Enable/Disable Breakpoint

  • Edit Breakpoint...

  • Run to Cursor

  • Set Next Statement

  • Open Separate View

  • Close

Viewing variables using Dwell

The dwell feature displays the value of the variable or expression on which the mouse pointer is paused. Dwell works in both the Source view and the Disassembly view.

Dwell gives you quick information about a variable. For more detailed information, use Quick Watch, Watch view, or Local Variables view.

To view the value of a variable or expression

  1. Use the mouse to position the pointer over a variable. For an expression (such as a+b), highlight the expression to select it, then point to the highlighted text.

  2. Do not move the pointer. After a short time (about a half-second), a window appears that displays the value of the variable or expression.

  3. Move the mouse or press a key or button to close the dwell window.

  4. You can view the decimal and hexadecimal value of a numeric variable or expression by changing the preference in the Source View section of the Edit > Preferences dialog box. See Setting Debugger Preferences. The displayed decimal and hexadecimal values are separated by a semicolon(;)

Limitations of Dwell

Dwell does not display the value of certain types of variables and expressions. It will not display the value of complex variables such as arrays and structs, but it will display the value of elements in an array, fields in a struct, and pointers.

Expressions are not displayed if there may be a potential side effect on the program being debugged (such as i++ or exit(1)). Expressions containing ), =, ++, and -- are not displayed with dwell.

Examples of complex variables

Dwell displays the value of fields as well as variables. Dwelling on bar of foo->bar displays the value of foo->bar, while dwelling on foo displays only the value of foo.

In the expression a[i] there are several places to use dwell:

  • If a is a pointer, dwelling on a displays the value of variable a.

  • If a is an array, dwelling on a displays the text [...]. This indicates that the variable is an array and cannot be viewed with dwell. You can use dwell to view the value of individual elements within an array.

  • Dwelling on i displays the value of i.

  • Dwelling on [ displays the value of a[i].

In the expression *p, you can use dwell in the following ways:

  • Dwelling on the * displays the value of *p

  • Dwelling on the p displays the value of p

Tips
  • Use the function browser to view source for a particular function. See Browsing Functions for detais .

  • Click the toolbar button to open and close the Disassembly view in a separate window.

  • On the View menu, click Source or Disassembly to quickly bring that view to the top.

  • You can customize the WDB GUI to display line numbers in the Source view. On the Edit menu, click Preferences and use the Display Line Numbers check box to set whether line numbers are displayed in the Source view.

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