Previous | Contents | Index |
The following commands define and delete symbols for addresses, commands, or values:
DEFINE | Defines a symbol as an address, command, or value |
DELETE | Deletes symbol definitions |
(SET,SHOW) DEFINE | (Establishes, displays) the default qualifier for the DEFINE command |
SHOW SYMBOL/DEFINED | Identifies symbols that have been defined with the DEFINE command |
The following commands control keypad mode and key definitions:
SET MODE [NO]KEYPAD | Enables/disables keypad mode |
DEFINE/KEY | Creates key definitions |
DELETE/KEY | Deletes key definitions |
SET KEY | Establishes the key definition state |
SHOW KEY | Displays key definitions |
The following commands are used with command procedures and log files:
@ (execute procedure) | Executes a command procedure |
(SET,SHOW) ATSIGN | (Establishes, displays) the default file specification that the debugger uses to search for command procedures |
DECLARE | Defines parameters to be passed to command procedures |
(SET,SHOW) LOG | (Specifies, identifies) the debugger log file |
SET OUTPUT [NO]LOG | Controls whether or not a debugging session is logged |
SET OUTPUT [NO]SCREEN_LOG | Controls whether or not, in screen mode, the screen contents are logged as the screen is updated |
SET OUTPUT [NO]VERIFY | Controls whether or not debugger commands are displayed as a command procedure is executed |
SHOW OUTPUT | Identifies the current output options established by the SET OUTPUT command |
The following commands establish conditional and looping structures for debugger commands:
FOR | Executes a list of commands while incrementing a variable |
IF | Executes a list of commands conditionally |
REPEAT | Executes a list of commands a specified number of times |
WHILE | Executes a list of commands while a condition is true |
EXITLOOP | Exits an enclosing WHILE, REPEAT, or FOR loop |
The following commands debug multiprocess programs. Note that these commands are specific to multiprocess programs. Many of the commands listed under other categories have qualifiers or parameters that are specific to multiprocess programs (for example, SET BREAK/ACTIVATING, EXIT process-spec, DISPLAY/PROCESS=).
CONNECT | Brings a process under debugger control |
DEFINE/PROCESS_SET | Assigns a symbolic name to a list of process specifications |
SET MODE [NO]INTERRUPT | Controls whether execution is interrupted in other processes when it is paused in some process |
(SET,SHOW) PROCESS | Modifies the multiprocess debugging environment, displays process information |
WAIT | When debugging a multiprocess program, controls whether the debugger waits until all processes have stopped before prompting for another command |
The following commands are used for miscellaneous purposes:
HELP | Displays online help on debugger commands and selected topics |
ANALYZE/CRASH_DUMP | Opens a process dump for analysis with the System Dump Debugger (SDD) |
ANALYZE/PROCESS_DUMP | Opens a process dump for analysis with the System Code Debugger (SCD) |
(DISABLE,ENABLE,SHOW) AST | (Disables, enables) the delivery of ASTs in the program, identifies whether delivery is enabled or disabled |
PTHREAD | Passes a command to the POSIX Threads Debugger |
(SET,SHOW) EVENT_FACILITY | (Establishes, identifies) the current run-time facility for Ada, POSIX Threads, and SCAN events |
(SET,SHOW) LANGUAGE | (Establishes, identifies) the current language |
SET OUTPUT [NO]TERMINAL | Controls whether debugger output, except for diagnostic messages, is displayed or suppressed |
SET PROMPT | Specifies the debugger prompt |
(SET,SHOW) TASK|THREAD | Modifies the tasking environment, displays task information |
SHOW EXIT_HANDLERS | Identifies the exit handlers declared in the program |
SHOW MODE | Identifies the current debugger modes established by the SET MODE command (for example, screen mode, step mode) |
SHOW OUTPUT | Identifies the current output options established by the SET OUTPUT command |
For information about the debugger's DECwindows Motif user interface, see Part 3.
This chapter gives a tutorial introduction to the debugger's command interface.
The way you use the debugger depends on several factors: the kind of program you are working on, the kinds of errors you are looking for, and your own personal style and experience with the debugger. This chapter explains the following basic tasks that apply to most situations:
Several examples are language specific. However, the general concepts are readily adaptable to all supported languages.
The sample debugging session in Section 2.6 shows how to use some of this information to locate an error and correct it.
For information about starting and ending a debugging session, see
Section 1.3.
2.1 Entering Debugger Commands and Accessing Online Help
After you start the debugger as explained in Section 1.3, you can enter debugger commands whenever the debugger prompt (DBG>) is displayed. To enter a command, type it at the keyboard and press Return. For example, the following command sets a watchpoint on the variable COUNT:
DBG> SET WATCH COUNT |
Detailed reference information about debugger commands is available in Part 6 and through the debugger's online help:
Online help is also available on the following topics:
New_Features
Release_Notes
Address_Expressions
Built_in_Symbols
DECwindows_Interface
Keypad_Definitions
Language_Support
Logical_Names
Messages (diagnostic messages)
Path_Names (to qualify symbolic names)
Screen_Mode
SS$_DEBUG condition (to start debugger from program)
System_Management
To display help about any of these topics, type HELP topic. For example, to display information about diagnostic messages, type HELP Messages.
When you start the debugger, a few commonly used command sequences are automatically assigned to the keys on the numeric keypad (to the right of the main keyboard). Thus, you can perform certain functions either by entering a command or by pressing a keypad key.
The predefined key functions are identified in Figure 2-1.
Figure 2-1 Keypad Key Functions Predefined by the Debugger---Command Interface
Most keypad keys have three predefined functions---DEFAULT, GOLD, and BLUE.
In Figure 2-1, the DEFAULT, GOLD, and BLUE functions are listed within each key's outline, from top to bottom, respectively. For example:
Normally, keys KP2, KP4, KP6, and KP8 scroll screen displays down, left, right, or up, respectively. By putting the keypad in the MOVE, EXPAND, or CONTRACT state, indicated in Figure 2-1, you can also use these keys to move, expand, or contract displays in four directions. Enter the command HELP Keypad_Definitions to display the keypad key definitions.
You can redefine keypad key functions with the DEFINE/KEY command.
2.2 Displaying Source Code
The debugger provides two modes for displaying information: noscreen
mode and screen mode. By default, when you start the debugger, you are
in noscreen mode, but you might find that it is easier to view source
code in screen mode. The following sections briefly describe both modes.
2.2.1 Noscreen Mode
Noscreen mode is the default, line-oriented mode of displaying input and output. The interactive examples throughout this chapter, excluding Section 2.2.2, show noscreen mode.
In noscreen mode, use the TYPE command to display one or more source lines. For example, the following command displays line 7 of the module in which execution is currently paused:
DBG> TYPE 7 module SWAP_ROUTINES 7: TEMP := A; DBG> |
The display of source lines is independent of program execution. To display source code from a module (compilation unit) other than the one in which execution is currently paused, use the TYPE command with a path name to specify the module. For example, the following command displays lines 16 to 21 of module TEST:
DBG> TYPE TEST\16:21 |
Path names are discussed in more detail in Section 2.3.2, with the STEP command.
You can also use the EXAMINE/SOURCE command to display the source line for a routine or any other program location that is associated with an instruction.
The debugger also displays source lines automatically when it suspends execution at a breakpoint or watchpoint, after a STEP command, or when a tracepoint is triggered (see Section 2.3).
After displaying source lines at various locations in your program, you can redisplay the location at which execution is currently paused by pressing KP5.
If the debugger cannot locate source lines for display, it issues a diagnostic message. Source lines might not be available for a variety of reasons. For example:
To switch to noscreen mode from screen mode, press PF1 PF3 (or type SET
MODE NOSCREEN). You can use the TYPE and EXAMINE/SOURCE commands in
screen mode as well as noscreen mode.
2.2.2 Screen Mode
Screen mode provides the easiest way to view your source code. To switch to screen mode, press PF3 (or type SET MODE SCREEN). In screen mode, by default the debugger splits the screen into three displays named SRC, OUT, and PROMPT, as shown in Figure 2-2.
Figure 2-2 Default Screen Mode Display Configuration
The SRC display shows the source code of the module in which execution is currently paused. An arrow in the left column points to the source line corresponding to the current value of the program counter (PC). The PC is a register that contains the memory address of the instruction to be executed next. The line numbers, which are assigned by the compiler, match those in a listing file. As you execute the program, the arrow moves down and the source code is scrolled vertically to center the arrow in the display.
The OUT display captures the debugger's output in response to the commands that you enter. The PROMPT display shows the debugger prompt, your input (the commands that you enter), debugger diagnostic messages, and program output.
You can scroll both SRC and OUT to see whatever information might scroll beyond the display window's edge. Press KP3 repeatedly as needed to select the display to be scrolled (by default, SRC is scrolled). Press KP8 to scroll up and KP2 to scroll down. Scrolling a display does not affect program execution.
In screen mode, if the debugger cannot locate source lines for the routine in which execution is currently paused, it tries to display source lines in the next routine down on the call stack for which source lines are available. If the debugger can display source lines for such a routine, it issues the following message:
%DEBUG-I-SOURCESCOPE, Source lines not available for .0\%PC. Displaying source in a caller of the current routine. DBG> |
In such cases, the arrow in the SRC display identifies the line that
contains code following the call statement in the calling routine.
2.3 Controlling and Monitoring Program Execution
This section explains how to perform the following tasks:
With this information you can pick program locations where you can then
test and manipulate the contents of variables as described in
Section 2.4.
2.3.1 Starting or Resuming Program Execution
Use the GO command to start or resume program execution.
After it is started with the GO command, program execution continues until one of the following events occurs:
With most programming languages, when you bring a program under debugger control, execution is initially paused directly at the beginning of the main program. Entering a GO command at this point quickly enables you to test for an infinite loop or an exception.
If an infinite loop occurs during execution, the program does not terminate, so the debugger prompt does not reappear. To obtain the prompt, interrupt execution by pressing Ctrl/C (see Section 1.4). If you are using screen mode, the pointer in the source display indicates where execution stopped. You can also use the SHOW CALLS command to identify the currently active routine calls on the call stack (see Section 2.3.3).
If an exception that is not handled by your program is signaled, the debugger interrupts execution at that point so that you can enter commands. You can then look at the source display and a SHOW CALLS display to find where execution is paused.
The most common use of the GO command is in conjunction with
breakpoints, tracepoints, and watchpoints, as described in
Section 2.3.4, Section 2.3.5, and Section 2.3.6, respectively. If you
set a breakpoint in the path of execution and then enter the GO
command, execution is paused at that breakpoint. Similarly, if you set
a tracepoint, execution is monitored through that tracepoint. If you
set a watchpoint, execution is paused when the value of the watched
variable changes.
2.3.2 Executing the Program by Step Unit
Use the STEP command to execute the program one or more step units at a time.
By default, a step unit is one line of source code. In the following example, the STEP command executes one line, reports the action ("stepped to..."), and displays the line number (27) and source code of the line to be executed next:
DBG> STEP stepped to TEST\COUNT\%LINE 27 27: X := X + 1; DBG> |
Execution is now paused at the first machine-code instruction for line 27 within routine COUNT of module TEST.
When displaying a program symbol (for example, a line number, routine name, or variable name), the debugger always uses a path name. A path name consists of the symbol plus a prefix that identifies the symbol's location. In the previous example, the path name is TEST\COUNT\%LINE 27. The leftmost element of a path name is the module name. Moving toward the right, the path name lists any successively nested routines and blocks that enclose the symbol. A backslash character (\) is used to separate elements (except when the language is Ada, where a period is used to parallel Ada syntax).
A path name uniquely identifies a symbol of your program to the debugger. In general, you need to use path names in commands only if the debugger cannot resolve a symbol ambiguity in your program (see Section 2.5). Usually the debugger can determine the symbol you mean from its context.
When using the STEP command, note that only those source lines for which code instructions were generated by the compiler are recognized as executable lines by the debugger. The debugger skips over any other lines---for example, comment lines.
You can specify different stepping modes, such as stepping by
instruction rather than by line (SET STEP INSTRUCTION). Also, by
default, the debugger steps over called routines---execution is not
paused within a called routine, although the routine is executed. By
entering the SET STEP INTO command, you direct the debugger to suspend
execution within called routines as well as within the routine in which
execution is currently paused (SET STEP OVER is the default mode).
2.3.3 Determining Where Execution Is Paused
Use the SHOW CALLS command when you are unsure where execution is paused during a debugging session (for example, after a Ctrl/C interruption).
The command displays a traceback that lists the sequence of calls leading to the routine in which execution is paused. For each routine (beginning with the one in which execution is paused), the debugger displays the following information:
For example:
DBG> SHOW CALLS module name routine name line rel PC abs PC *TEST PRODUCT 18 00000009 0000063C *TEST COUNT 47 00000009 00000647 *MY_PROG MY_PROG 21 0000000D 00000653 DBG> |
This example indicates that execution is paused at line 18 of routine PRODUCT (in module TEST), which was called from line 47 of routine COUNT (in module TEST), which was called from line 21 of routine MY_PROG (in module MY_PROG).
Previous | Next | Contents | Index |