Entering Commands (cont.) [ Symbolic Debugger/iX User's Guide ] MPE/iX 5.0 Documentation
Symbolic Debugger/iX User's Guide
Entering Commands (cont.)
Entering Procedure Calls (cont.)
Data Viewing and Modification Commands
Data viewing and modification commands allow you to view program data in
a variety of formats and change the values of variables. The data
viewing and modification commands are:
* disp (display)
* l (list)
* lc (list common)
* lg (list globals)
* ll (list labels)
* lm (list macros)
* lp (list procedures)
* lr (list registers)
* ls (list specials)
* mov (move)
* p (print)
disp (display)
{disp } expression
{display}
Used only with HP COBOL II programs to print COBOL variables or
expressions. Simple items, fields, array elements, and expressions can
be displayed. Items displayed can be of type "edited" or "non-edited".
For example:
>disp z of y of x of w(3,7,11)
0x40003028 345.67
This command is equivalent to the p (print) command for other source
languages.
l (list)
{l } [proc[:depth]]
{list}
Lists all parameters and local variables of the current procedure. You
can optionally specify any active procedure and its depth on the stack.
If a procedure name is given without a depth, then the most recent
invocation of that procedure is used. If an invocation of that procedure
other than the most recent is desired, then a depth must be specified.
The following illustrates the use of this command.
If the current stack trace (generated with the command t 5) is:
0 groucho( ) [marx.c:23]
1 harpo( ) [marx.c:70]
2 chico( ) [marx.c:55]
3 harpo( ) [marx.c:73]
4 main( ) [marx.c:16]
and groucho is the procedure currently viewed (where execution is
currently suspended), then:
l Lists the local variables and parameters of
groucho.
l harpo Lists the local variables and parameters of harpo
at level 1 on the stack.
l harpo:3 Lists the local variables and parameters of harpo
at level 3 on the stack.
The \n (normal) format is used to display the procedures, parameters, and
local data except for arrays and pointers, which are displayed as
addresses.
lc (list common)
{lc } [string]
{list common}
Used when debugging an HP FORTRAN 77 program, this command displays HP
FORTRAN 77 common blocks and their associated variables. If a string is
specified, only those common blocks whose names begin with that string
are printed; otherwise, all common blocks within the current subroutine
or function are printed.
Sample output is:
>lc
COMMON /COM1/
BR4 = 0
INT1 = 0
BR8 = 0
BI4 = -2097152000
BI2 = -32000
BCX8 = 0
BC1 = '\000'
BL4 = .FALSE.
lg (list globals)
{lg } [string]
{list globals}
Lists all global variables and their values. If a string is specified,
only those global variables whose names begin with this string are
listed.
ll (list labels)
{ll } [string]
{list labels}
Lists all labels and program entry points known to the linker. If a
string is specified, only those symbolic addresses with this prefix are
used.
lm (list macros)
{lm } [string]
{list macros}
Displays all user-defined macros and their definitions. If a string is
specified, only those macros whose names begin with this string are
listed.
Sample output is:
>lm
pheadtuti ==> p flavor:list->head.tutifruti
unS ==> bu\t {}; c
Overall macros state: ACTIVE
lp (list procedures)
{lp } [string]
{list procedures}
Lists all procedure names and their aliases as well as their locations in
memory. If a string is specified, only those procedures whose names
begin with this string are listed.
Sample output is:
0: main 0x00001218 to 0x000013c0
0: _MAIN_
1: proc1 0x000013c8 to 0x00001438
2: proc2 0x00001440 to 0x0000148c
3: _end_ 0x000047e8 to 0x000047fc
NOTE The following notes apply to when using the lp (list procedures
command):
* Only subprograms are shown when using this command with HP
COBOL II subprograms.
* The procedure name main is used as the alias name for the
main program in all supported languages. Do not use it for
any debuggable procedures.
* For code that is not debuggable or does not have a
corresponding source file, the debugger displays unknown for
the unknown file and procedure names. The debugger cannot
show code locations or interpret parameter lists and so on.
However, procedure names are provided for most procedures,
even if not debuggable.
lr (list registers)
{lr } [string]
{list registers}
Lists all registers and their contents. This command displays all
general and floating point registers, as well as the program counter,
stack pointer registers, and other registers. If a string is specified,
only those registers beginning with this string are listed (the $ is
significant). All register values are printed in hexadecimal.
ls (list specials)
{ls } [string]
{list specials}
Lists all special variables and their values. Registers are not listed.
If a string is specified, only those special variables whose names begin
with this string are listed.
Sample output is:
$lang = COBOL (default)
$line = 49
$signal = 0
$malloc = 43008
$step = 100
$long = 0
$short = 0
$result = 0
$result is normally interpreted to be the same type as the last procedure
call (if the call returns a structured type, $result defaults to
integer). Note that there are two alternate ways of looking at $result,
as a 32 bit integer ($long) or as a 16 bit integer ($short).
You can also list special variables defined by usage. For example:
p $var = 10
defines the variable $var to be equal to 10. The ls (list specials)
command will also display $var and its current value.
mov (move)
{mov } expr1 to expr2
{move}
Used only with HP COBOL II programs to modify variables. The first
expression is the source; the second is the destination. The source and
destination cannot be an edited field. The source can be any non-edited
COBOL field, a string literal, a number, or a named constant (such as
SPACES or BLANKS). The destination can be any non-edited COBOL field.
For example:
>mov zeros to n-comp-03-u
N-COMP-03-U = .000
This command is equivalent to print expr2=expr1 in other source
languages.
p (print)
{expr [?format] }
{p }{[+] [[\]format]}
{print}{[-] }
Displays and optionally modifies program data. You can choose to display
data in one of the formats shown in tables 4-3 and 4-4. The p (print)
command is also used to evaluate arbitrary expressions involving
constants and/or program data.
A format has the syntax:
[count] {formchar} [size]
Formchar, which is required, specifies the actual format in which you
choose to display the data. Count is the number of times to apply the
format. Size is the number of bytes that are formatted for each data
item, and overrides the default size for the given format. The count
must be a decimal, octal, or hexadecimal number. The size must be a
decimal number or the letters b, s, and l which are predefined sizes of 1
byte (8 bits), 2 bytes (short), and 4 bytes (long) respectively. For
example:
>p abc\4x2
prints four two-byte numbers in hexadecimal starting at the address
designated by the variable abc. If abc is an array, you need to specify
a subscript if you want to see the contents of consecutive array
elements. For example:
>p abc[5]\4n
will display four elements of array abc starting with element 5.
Table 4-3 lists the possible data formats and corresponding formchars.
Note that there is usually a difference between a lowercase and uppercase
character.
For example, the d and D formats print in short and long decimal:
d Displays 16 bits
D Displays 32 bits
Short and long form apply only to the following formats:
Short Long
---------------------------------------------------------------------------------------
d D
e E
f F
g G
o O
u U
x X
Many of the the data formats have a default size if the size is not
given. For example, X has a default size of four bytes. There are also
some shorthand notations for size. These shorthand notations are shown
in table 4-4. Shorthand notations can be appended to formchar instead of
a numeric size. For example:
xb
prints one byte in hexadecimal.
There is also a default for the format, if the format is not specified.
For example: D is the default for a long integer variable or field, X is
the default for a pointer or array variable or field, and S is the
default for a structure variable. The n format specifies the default.
In general, if the expression describes a named data object, the debugger
will display its value in a manner consistent with the object's declared
type, even if it is a structured type. if the debugger cannot determine
the type of an expression or data object, X is used.
The following example prints a dynamically allocated C structure that is
local to procedure flavor.
>p *flavor:list->head
0x68023004 struct {
chocolate = 1597845365;
tutifruti = 2.21414e-10;
}
Table 4-3. Data Viewing Formats
--------------------------------------------------------------------------------------------
| | |
| Formchar | Description |
| | |
--------------------------------------------------------------------------------------------
| | |
| a | Prints a string using the expression as the address of the first byte. |
| | |
--------------------------------------------------------------------------------------------
| | |
| (b|B) | Prints a byte in decimal. |
| | |
--------------------------------------------------------------------------------------------
| | |
| (c|C) | Prints a character. |
| | |
--------------------------------------------------------------------------------------------
| | |
| (d|D) | Prints in decimal as an integer or long integer, respectively. |
| | |
--------------------------------------------------------------------------------------------
| | |
| (e|E) | Prints in e floating point notation as a float or double, respectively. |
| | (4 bytes, 8 bytes) |
| | |
--------------------------------------------------------------------------------------------
| | |
| (f|F) | Prints in f floating point notation as a float or double, respectively. |
| | |
--------------------------------------------------------------------------------------------
| | |
| (g|G) | Prints in g floating point notation as a float or double, respectively. |
| | |
--------------------------------------------------------------------------------------------
| | |
| n | Prints in normal (default) format, based on the type. (if known) |
| | |
--------------------------------------------------------------------------------------------
| | |
| (o|O) | Prints the expression (expr) in octal as an integer or long integer, |
| | respectively. |
| | |
--------------------------------------------------------------------------------------------
| | |
| p | Prints the name of the procedure containing the given address. (expr) |
| | |
--------------------------------------------------------------------------------------------
| | |
| s | Prints a string using an expression as the address of a pointer to the |
| | first byte. In HP C, this is the same as specifying *expr\a. |
| | |
--------------------------------------------------------------------------------------------
| | |
| S | Prints a formatted dump of structures, fields and their values. The |
| | expression (expr) must be the address of a structure, not the address of |
| | a pointer to a structure. |
| | |
--------------------------------------------------------------------------------------------
| | |
| t | Shows the type of the expression (expr), usually a variable or procedure |
| | name. |
| | |
--------------------------------------------------------------------------------------------
| | |
| (u|U) | Prints the expression (expr) in unsigned decimal as an integer or long |
| | integer. If the quantity is known to be a full word, u gives the same |
| | result as U. |
| | |
--------------------------------------------------------------------------------------------
| | |
| (x|X) | Prints in short and long hexadecimal, respectively. If the quantity is |
| | known to be a full word, x gives the same result as X. |
| | |
--------------------------------------------------------------------------------------------
Table 4-4. Shorthand Notation for Size
--------------------------------------------------------------------------------------------
| | |
| Mnemonic | Actual Size |
| | |
--------------------------------------------------------------------------------------------
| | |
| b | 1 byte (8 bits) |
| | |
--------------------------------------------------------------------------------------------
| | |
| s | 2 bytes (16 bits) |
| | |
--------------------------------------------------------------------------------------------
| | |
| l | 4 bytes (32 bits) |
| | |
--------------------------------------------------------------------------------------------
Use the \format option to display the value of the expression in a
specific format. For example:
>print abc\x
prints the contents of abc in hexadecimal. If a format is not given, the
expression is displayed in a format consistent with the type of the
expression. For example:
>print (abc*3/25)+2
prints the results of evaluating the given expression using the current
value of abc in decimal. Use the ?format option to print the address of
the evaluated expression in the selected format. For example:
>print abc?o
prints the address of abc in octal. If the expression is not a named
data item, ? is equivalent to \.
Display absolute addresses with the p (print) command when you are
debugging a program with no debugger information. For example:
>p *0xC0000348
or
>p *($sp-36)\x)
p+ prints the next element. Based on the size of the last item
displayed, p+ increments the current data address by the size of the
previous format and then displays the contents of memory starting at the
new address, using the format if it is supplied, or the previous format,
if not supplied. This command is useful for displaying successive
elements of an array. The initial p (print) command can determine the
array's format by its type.
p- prints the previous element. Based on the size of the last item
displayed, p- decrements the current data address by the size of the
previous format and then displays the contents of memory starting at the
new address, using the format if it is supplied, or the previous format,
if not supplied.
The p (print) command is also used to modify the value of a variable.
Modification of variables is done by using the assignment operator in the
expression (= in HP C, HP FORTRAN 77, and HP COBOL II, or := in HP
Pascal). For example:
>p fob=7
In the case of an assignment, the debugger will also show the name of the
variable being modified or the address used if the expression is not a
simple name.
Here are some symbol table dependencies:
1. When you try to display a variable which is an HP FORTRAN 77
format label, an HP Pascal file-of-text, or an HP Pascal set, with
no display format or with normal format (\n), the value is shown
as {format-label}, {file-of-text}, or {set}, respectively. You
can use other formats, such as \x, to display the contents of such
variables.
2. When a compiler does not know array dimensions, such as for some
HP FORTRAN 77 and HP C array parameters, it uses 0:MAXINT or
1:MAXINT as appropriate. The \t format shows such cases with []
(no bounds specified), and subscripts from 0 (or 1) to MAXINT are
allowed in expressions.
3. Even though the symbol table supports C structure, union, and
enumeration tags, C typedefs, and Pascal types, the debugger does
not know how to search for them, even for the \t format. They are
"invisible".
4. Some variables are indirect, so a child process must exist in
order for the debugger to know their addresses. When there is no
child process, the address of any such variable is shown as
0xfffffffe.
Stack Viewing Commands
Stack viewing commands trace the stack of a program. The stack viewing
commands are:
* t (trace)
* T (Trace)
Figure 4-1 illustrates the stack depth of a program and shows that A
called B, B called C, C called D, D called E, E called F, and program
execution is currently suspended in F. The procedure at which the program
is currently stopped is always at depth zero.
Figure 4-1. Stack Depth
t (trace)
{t } [depth]
{trace}
Prints a stack trace. You can optionally specify a depth. The default
depth is 20 levels. If an optional depth is supplied, only the
procedures up to this depth in the stack are displayed. For each
procedure in the stack trace, the following is displayed:
* Stack depth
* Name of procedure at that depth
* Name of procedure parameters and their values (printed in normal
(\n) format)
* Source file and line number where it is suspended (depth 0) or
where a call to the next procedure (at the next lowest depth)
occurred.
The following example is a NON-COBOL trace.
>t
0 icecream (i = 7) [ice.c: 8]
1 flavor (year = 1988) [flavors.c: 19]
2 main () [main.c: 59]
The following example is an HP COBOL II trace. Note that this trace
shows both stacked subprograms as well as paragraphs.
>t 3
0 PROGRAM-9 () [LCBTST21.V.JOE: 74]
0 Paragraph PARA-9x2
1 Paragraph PARA-2y
1 PROGRAM-8 () [LCBTST21.V.JOE: 48]
0 Paragraph PARA-1C
2 PROGRAM-7 () [LCBTST21.V.JOE: 43]
0 Paragraph EVAL-CK
T (Trace)
{T } [depth]
{Trace}
Prints a stack trace. You can optionally specify a depth. The default
depth is 20 levels. If an optional depth is supplied, only the
procedures up to this depth in the stack are displayed. For each
procedure in the stack trace, the following is displayed:
* Stack depth
* Name of procedure at that depth
* Name of procedure parameters and their values (printed in normal
(\n) format)
* All local variables and their values (printed in normal (\n)
format)
* Source file and line number where execution is suspended (depth 0)
or where a call to the next procedure (at the next lowest depth)
occurred.
All arrays, structures, and pointers are shown as addresses. Only the
first word of a structure is shown.
The following example is a NON-COBOL Trace.
>T
0 icecream (i = 7) [ice.c: 8]
c = 00000000
1 flavor (year = 1988) [flavors.c: 19]
harpo = 1995
list = 0x680235bc
2 main () [main.c: 59]
i = 3
j = 2987
k = 1988
icecream = 0x00000000
buff = 0x6802377e
When displaying a Trace of an HP COBOL II program, paragraph "stacking"
is shown within the subprograms called (if any). Variables local to a
given subprogram are shown. For example:
>T
0 PROGRAM-9 () [LCBTST21.V.JOE: 74]
0 Paragraph PARA-9x2
1 Paragraph PARA-2y
TALLY = 0
Y = 427
1 PROGRAM-8 () [LCBTST21.V.JOE: 48]
0 Paragraph PARA-1C
2 PROGRAM-7 () [LCBTST21.V.JOE: 43]
0 Paragraph EVAL-CK
CK-LBL = 6536-A
Status Viewing Command
The status viewing commands display the state of the debugger and the
program being debugged. Various list commands can be used. Refer to the
section on Data Viewing and Modification for further information about
list commands. The other major status viewing command is:
* Inquire
I (Inquire)
{I }
{Inquire}
Prints the current status of the debugger. The output contains
information such as the version number of the debugger, program name,
number of source files and procedures, process ID of the child process,
number of breakpoints, record and playback information and so on. A
sample output is displayed:
Version .......... HP31508 A.02.03 HP SYMBOLIC DEBUGGER (XDB)
Program .......... "tree"
Core File ........ None
Procedures ....... 10
Child process .... None
Breakpoints ...... 4 (Active)
Assertions ....... 3 (Suspended)
Macros ........... 9 (Active)
Recording ........ Suspended
Record file ...... None
Record-all ....... Active
Record-all file .. mysession
Playback file .... None
Searches ......... NOT case sensitive
Address format ... "%#10.81x"
Bytes malloc'd ... 7168
Run arguments .... ""
Job Control Commands
The job control commands let you control execution of the program. The
parent (HP Symbolic Debugger) and child (objectfile) processes take turns
running. The debugger is only active while the child process is stopped,
due to encountering a signal or a breakpoint, or by terminating.
The job control commands are:
* c (continue)
* C (Continue)
* k (kill)
* r (run)
* R (Run)
* s (step)
* S (Step)
c (continue)
{c } [location]
{continue}
Resumes execution after a breakpoint has been encountered, ignoring the
signal, if any. If a location is specified, a temporary breakpoint is
set at that location. See "Breakpoint Commands" in this chapter for more
information.
C (Continue)
{C } [location]
{Continue}
Resumes execution after a breakpoint has been encountered, allowing the
signal, if any, to be received by the child process. If a location is
specified, a temporary breakpoint is set at that location. See
"Breakpoint Commands" in this chapter for more information.
NOTE Since signals are currently unsupported on the MPE/iX operating
system, this command will operate exactly as the c (continue)
command.
k (kill)
{k }
{kill}
Terminates the current child process, if any. You are asked to confirm
this command; this guards against accidental termination of the child
process.
r (run)
{r } [;info='info-string'] [;parm='number']
{run}
Lets you run a program as a new child process with an optional info
string and run parm. If a child process already exists, the debugger
asks if you want to terminate the child process first.
If you do not enter an info string, the debugger uses those supplied with
the last r (run) command (if any). info string can contain a "<" and/or
a ">" for redirecting standard input and standard output ($STDIN) and
($STDOUT).
R (Run)
{R }
{Run}
Lets you run a program as a new child process with no argument list. If
a child process already exists, the debugger asks if you want to
terminate the child process first. Use this command to explicitly
indicate no arguments.
s (step)
{s } [number]
{step}
Single steps through a program, executing one source statement or machine
instruction at a time before pausing and prompting for another command.
In source mode, one source statement is executed (or one step of a
multiple step statement in HP Pascal or HP C); in disassembly mode, one
machine instruction is executed (several machine instructions might be
equivalent to one source statement). If a procedure call is encountered,
the procedure is single stepped in the same manner (stepped "into").
NOTE One s (step) is required to go from the calling statement to the
first statement of the called procedure.
To execute more than one statement or instruction, enter that number as
the number parameter. The debugger executes this number of statements or
instructions before stopping unless it encounters a breakpoint.
NOTE Single stepping through a procedure for which there is no debugger
information (for example, printf) can be slow. You might prefer to
use the c (continue) or S (Step) command instead.
If you accidentally step down into a procedure you don't care
about, use the bu command to set a temporary "uplevel" breakpoint,
and then continue using a continue command.
You can press RETURN to repeat this command.
S (Step)
{S } [number]
{Step}
Single steps through a program. In source mode, one source statement (or
one step of a multiple step statement in HP Pascal or HP C) is executed;
in disassembly mode, one machine instruction is executed (several machine
instructions might be equivalent to one source statement). If a
procedure call is encountered, it is not "stepped into". Instead,
execution steps to the statement following the call. The procedure call
is treated as a single statement. If a breakpoint is encountered in the
procedure or any that is called, its commands are executed.
NOTE Using a continue command in a breakpoint command list within a
procedure will cause the program to keep executing through the
procedure! If the breakpoint does not explicitly continue, the
current act of stepping "over" the procedure ceases. The command
list
>bu\t {}; c
continues back to the calling statement, effectively completing the
S (Step) command.
The S (Step) command does not step "over" PERFORM statements in HP
COBOL II programs, only CALL statements.
To execute more than one statement or instruction, enter that number as
the number parameter. The debugger executes this number of statements or
instructions unless it encounters a breakpoint.
You can press RETURN to repeat this command as a single step.
MPE/iX 5.0 Documentation