Tru64 UNIX
Ladebug Debugger Manual


Previous Contents Index

1.8.1 Quick Help Panel

Under the Help: menu in the Main Window is a Display Quick Help toggle. When the Display Quick Help toggle is enabled, the Quick Help Panel appears at the bottom of the Main Window. The Quick Help Panel displays one line of context-sensitive help when you drag the pointer over a menu item or pop-up menus.

When customization options are saved (using the Options:Save Options... on the Main Window), the state of the Display Quick Help toggle is saved in the Ladebug resource file. For more information about the Ladebug resource file, Chapter 4.

When Ladebug is run as part of the DEC FUSE environment, the Quick Help Panel is displayed by default.

1.8.2 Displaying Context-Sensitive Help

Context-sensitive help is information about an area or object in a window or a dialog box.

To display context-sensitive help:

  1. Choose Help:On Context in a debugger window. The pointer shape changes to a question mark (?).
  2. Place the question mark on an object or area in a debugger window or dialog box.
  3. Click on MB1. Help for that area or object is displayed in a Help window.

To display context-sensitive help for a dialog box, you can also click on the Help button in the dialog box.

1.8.3 Displaying Command-Oriented Help

You can display help about debugger commands using the following methods:

1.9 Support for International Users

Ladebug's international support is dependent on the support available in the underlying system. International support is provided through the global locale of the debugger, which is set automatically from the external user environment when you invoke the debugger.

The locale information can be printed using the debugger variable $lc_ctype. This (read-only) variable specifies the value of the current LC_CTYPE locale category in the debugger, which is used for all data interpretations.

Ladebug's international support provides the features described in Section 1.9.1 through Section 1.9.3.

1.9.1 Support for Input of Local Language Characters in User Commands

Ladebug supports the input of local language characters in user commands. It analyzes user input commands to recognize and process locale-based text (including multibyte characters) in language specific expressions: file names, function names, variable names and values, debugger variable names and values, alias names and parameters, and the debugger prompt.

This support is based on the specific capabilities of the programming language of the debugged unit and of the global debugger locale.

1.9.2 Support for Output of Local Language Characters

Ladebug prints all character data according to the current global locale set in the debugger.

Ladebug checks the character to be printed to see if it is a special character that is printed as an escaped expression (for example, (char)8 is printed as \\t). Ladebug then checks the XPG4 appropriate functions to find out if the character is a printable character in the current locale. If it is, the character is printed as is. Otherwise, the character is printed in octal notation (for example, (char)1 is printed as \\001).

1.9.3 Support for Wide Character Type (wchar_t) in C and C++ Programs

Ladebug prints wcharacters of type wchar_t and wide strings of type wchar_t * in readable format, similar to their literals L'X' and L"XYZ" (where X, Y ,Z are character codes encoded in the current global locale).

Wide character/string input is accomplished by entering literals in the forms accepted by C and C++ compilers.

The display of these entities is made available through extensions to the following debugger commands:

Specify C mode (uppercase) to print each sizeof (wchar_t) as a wide character.

Specify S mode (uppercase) to print the contents of memory as a wide string.

Use the following command to print the result of the expression for wide characters or wide strings:


 
$  print expression [,...]
 

Wide characters in C and C++ are interpreted as unsigned integers by the DIGITAL UNIX compilers and set as such in the symbol tables of object files. As a result, Ladebug can't distinguish between an unsigned int data and a wchar_t in the symbol table. You must specify the debugger variable $wchar_t to determine the user-preferred output format for unsigned integer expressions (either as integers or as wide characters/strings). If $wchar_t has a non-zero value, a wide character is printed in the format of L'X' in accordance with the codeset of the current locale. A wide string is printed in an L"XXXX" format.

Using the following form,


 
$  printf [format [expression,...]]
 

specify format specifier %C (uppercase) to print a wide character and format specifier %S (uppercase) to print a wide string.

Nonprintable wide characters (as determined by XPG4 library iswprint() function) will be printed as escaped character expressions.


Part 2
Basic Debugging

This part explains how to prepare programs for debugging, how to start and end a debugging session, how to examine program information, and other basic debugging techniques.


Chapter 2
Examining Program Information

This chapter explains how to:

The chapter describes window actions and window menu choices, but you can perform most common debugger operations by choosing items from context-sensitive pop-up menus. To access these menus, click on MB3 while the mouse pointer is in the window area.

In addition to selecting debugger menu items, you can enter Ladebug commands at the debugger prompt (ladebug) or in the Command Message View of the GUI.

For more information on specific Ladebug commands mentioned in this chapter, see Part 5.

2.1 Displaying the Source Code of Your Program

By default, the debugger's Main Window displays the source code of your program.

Figure 2-1 Default Main Window Configuration


Whenever execution is suspended (at a breakpoint for example), the debugger updates the source display by displaying the code that surrounds the point at which execution is paused. The current-location pointer to the left of the source code marks the line whose code will execute next. (A source line corresponds to one or more programming-language statements, depending on the language and coding style.)

By default, the debugger displays line numbers to the left of the source code. These numbers help you identify breakpoints that are listed in the Breakpoint View (see Section 3.3.1). You can choose not to display line numbers. To hide or display line numbers, choose File:Display Line Numbers on the Main Window.

The current-location pointer is normally filled in. The current-location pointer is cleared if the displayed code is not that of the routine in which execution is paused.

You can use the scroll bars to show more of the source code. However, you can scroll vertically through only one module of your program at a time.

The following sections explain how to display source code for other parts of your program so that you can set breakpoints in various modules. Section 2.1.2 explains what to do if the debugger cannot find source code for display. Section 2.5 explains how to display the source code associated with routines that are currently active on the call stack.

After you navigate the Main Window, you can redisplay the location at which execution is paused by clicking on the top item in the Call Stack menu.

If your program was optimized during compilation, the source code displayed might not reflect the actual contents of some program locations.

You can also display source code from the command interface by entering the list command and specifying the following arguments:

Example 2-1 uses the list command to display the lines of a COBOL program source file numbered 43 through 50.

Example 2-1 Listing Source Code in a Number Range

(ladebug) list 43,50
     43     PERFORM LOOK-BACK  VARYING SUB-1 FROM 20 BY -1 
     44         UNTIL TEMP-CHAR (SUB-1) NOT = SPACE. 
     45     MOVE SUB-1 TO CHARCT. 
     46     PERFORM MOVE-IT    VARYING SUB-2 FROM 1 BY 1   UNTIL SUB-1 = 0. 
     47     MOVE HOLD-WORD TO TEMP-WORD. 
     48 MOVE-IT. 
     49     MOVE TEMP-CHAR (SUB-1) TO HOLD-CHAR (SUB-2). 
     50     SUBTRACT 1 FROM SUB-1. 
(ladebug) 

Example 2-2 uses the list command to display the first 25 lines of an Ada program.

Example 2-2 Listing Source Code By Counting from a Starting Line

(ladebug) list 1:25
     1  with TEXT_IO; use TEXT_IO; 
     2  with INTEGER_TEXT_IO; use INTEGER_TEXT_IO; 
     3  with FLOAT_TEXT_IO; use FLOAT_TEXT_IO; 
     4  procedure TEST is 
     5 
     6     procedure P (I : INTEGER); 
     7     procedure P (F : FLOAT); 
     8 
     9     procedure P (I : INTEGER) is 
    10        TWO : constant := 2; 
    11     begin 
    12        PUT (I * TWO); 
    13        NEW_LINE; 
    14     end; 
    15 
    16     procedure P (F : FLOAT) is 
    17     begin 
    18        PUT(F); 
    19        NEW_LINE; 
    20     end; 
    21 
    22  begin 
    23     P(5); 
    24     P(6.0); 
    25  end; 
(ladebug) 

If the source file is not in the current directory, you can enter a use command to add directories to the list of directories the debugger will search.

2.1.1 Displaying Source Code Contained in Another Module

To display source code contained in another module or source file:

  1. Choose File:Browse Source... on the Main Window. The Browse Source dialog box appears listing your program file. See Figure 2-2.
  2. Double click on the image to get a list of modules.
  3. Double click on the name of the module or source file containing the routine of interest. The names of the program's modules are displayed (indented) under the file name, and the Display Source button is now highlighted.
  4. Click on the name of the module whose source code you want to display.
  5. Click on Display Source. The source display in the Main Window now displays the module's source code.

Section 2.5 describes an alternative way to display routine source code for routines currently active on the call stack using the Call Stack menu.

The Browse Source dialog box displays information in a hierarchical form about all the binary files in your application. For each binary file, it displays information about the modules contained in the binary. For each module, a list of routines in that module can be displayed.

You can manipulate the Browse Source display by clicking on menu items in the Browse Source pop-up menus.

Figure 2-2 Displaying Source Code in Another Routine


2.1.2 Making Source Code Available for Display

In certain cases, the debugger cannot display source code. Possible causes are:

If the debugger cannot find source code for a display, it tries to display the source code for the next routine on the call stack for which source code is available. If the debugger can display source code for such a routine, the current-location pointer is cleared. The pointer then marks the source line to which execution returns in the calling routine.

2.2 Accessing Program Variables

This section provides some general information about accessing program variables while debugging.

If your program was optimized during compilation, you might not have access to certain variables while debugging. When you compile a program for debugging, it is best to disable optimization if possible (see Section 1.6.1).

Before you check on the value of a variable, always execute the program beyond the point where the variable is declared and initialized. The value contained in any uninitialized variable should be considered invalid.

In most cases, the debugger resolves symbol ambiguities automatically, using the scope and visibility rules of the source programming language.

2.2.1 How the Debugger Searches for Variables and Other Symbols

Symbol ambiguities can occur when a symbol is defined in more than one routine or other program unit.

In most cases, the debugger automatically resolves symbol ambiguities. First, it uses the scope and visibility rules of the currently set language. The debugger uses the ordering of routine calls on the call stack to resolve symbol ambiguities.

In some cases, however, the debugger might respond as follows when you specify a symbol that is defined multiple times:

To resolve such problems, you must specify a scope where the debugger searches for the declaration of the symbol you want:

2.2.2 GUI Options for Selecting and Changing Variables and Values

Table 2-1 describes the options available in the GUI that you can use for selecting and changing variables and values.

Table 2-1 GUI Options for Selecting and Changing Variables and Values
Option Attributes
Local Variables View
  • Local variables monitored automatically by debugger. You do not have to select names as with the Print button or Monitor View.
  • Cannot monitor global variables.
  • Can expand aggregates into their components.
  • Can assign new values directly in the Local Variables View.
Print button
  • Must select a variable name.
  • Can display values of global names or local variables.
  • Must select name and press the Print button each time you want to see the updated value.
  • Shows output of the debugger in the Command Message View.
Monitor View
  • Must select a variable name.
  • Can monitor global or local variables (when selected local variables are active).
  • Shows output in the Monitor View.
  • Can expand aggregates into their components.
  • Can assign new values directly in the Monitor View.
Print Dialog Box Allows for typecasting.
Assign Dialog Box Allows for typecasting.

You can also enter commands in the command interface to select variables and change their values.

2.2.3 Selecting Variable Names from Windows

Use the following techniques to select variable names from windows.

When selecting names, follow the syntax of the source programming language:

Select character strings from windows in one of the following ways:

2.2.4 Listing and Displaying Variables

You can use the dump command in the command interface to list an active function's local variables and parameters.

Example 2-3 shows how to obtain a dump of all active functions.

Example 2-3 Displaying Information on Each Activation Level

(ladebug) dump
>0  0x120001224 in factorial(i=1) sample.c:13 
i=1 
f=0 
(ladebug) 

The function factorial has the parameter i but it has no local variables. The function main has two local variables, i and f.

Your program may declare a particular symbol more than once. For example, in the program sample.c the symbol i is declared in the function main and again in the function factorial.

Because the debugger extends the visibility and scope rules of the programming language, the debugger may have access to more than one declaration of a symbol name. You can use the which command in the command interface to determine which declaration exists in the current context. The which command displays the variable with its scope information fully qualified.

The whereis command lists all declarations of a variable together with each declaration's scope information fully qualified. Example 2-4 shows how to use the whereis and which commands to determine a variable's scope.

Example 2-4 Displaying a Variable's Scope

(ladebug) where
>0  0x120001230 in factorial(i=1) sample.c:14 
#1  0x12000124c in factorial(i=2) sample.c:16 
#2  0x120001194 in main() sample.c:5 
(ladebug) print i
1 
(ladebug) which i
"sample.c"`factorial.i 
(ladebug) whereis i
"sample.c"`factorial.i 
"sample.c"`main.i 
(ladebug) func main
main in sample.c line No. 5: 
      5         f = factorial(i); 
(ladebug) print i
2 
(ladebug) which i
"sample.c"`main`i 
(ladebug) 

The whereis command is useful for obtaining information needed to differentiate overloaded identifiers that are in different units, or within different routines in the same unit.

Example 2-5 shows how to set breakpoints in two Ada program routines, both named DO_PRINT.

Example 2-5 Determining Overloaded Identifiers

(ladebug) whereis do_print
"overload.ada"`OVERLOAD`DO_PRINT 
"overload.ada"`OVERLOAD`INNER`DO_PRINT 
(ladebug) stop in "overload.ada"`OVERLOAD`DO_PRINT
[#1: stop in DO_PRINT ] 
(ladebug) stop in "overload.ada"`OVERLOAD`INNER`DO_PRINT
[#2: stop in DO_PRINT ] 
(ladebug) 


Previous Next Contents Index