Chapter Contents |
Previous |
Next |
Using the Debugger |
Displaying a Traceback |
where
list readin*
However, the command does not display the readin
function in the Source window if readin
is not currently in the
calling sequence identified by your
command scope. You can only access variables in functions and sections that
are listed in the traceback (that is, active functions). An external variable
is accessed from any function whose context contains a declaration for it.
See where for more details on the where
command.
Viewing and Searching Source Code |
list LINENO
Then, to move back to your current position in your source code use the format
list
The window find
subcommand
is used to search for strings and is supported in the following
windows:
The following format is used with the window find
subcommand:
window find WINDOW-NAME
The WINDOW-NAME argument can be any of the following:
If
the <> WINDOW-NAME argument is used, the position
of the cursor determines the window to which the command is applied. See Find Window for more
details on the window find
subcommand.
Changing Scope |
Command scope identifies a second location in your source
code that can be used to resolve variable references. Normally, command scope
is the same as run scope; however, it can be changed with the scope
command. Certain commands use command scope in order
to resolve variable references and to supply default function and section
names. As described in Run Scope and Command Scope,
both command and run scope are displayed in the Status window. Some formats
of the scope
command are as follows:
scope
FUNCTION-NAMEscope
+ INTEGERscope
- INTEGERscope
See
scope for details on the scope
command.
Stopping Execution When a Value Changes |
monitor EXPRESSION [LENGTH] [print]
The arguments and option for this form of the monitor command are as follows:
print
p
.)
With the print
option, the debugger displays
the new value of the object. If the object is no more than 256 bytes in length,
the debugger also displays the old value. The values are formatted appropriately
for the type of the object. If the object is an aggregate and less than 256
bytes, then only those fields that change are displayed.
Arguments can follow the EXPRESSION in any order. See
monitor for more
details on the monitor
command.
Performing One or More Debugger Commands at Various Locations |
The on
command enables you to perform one or more debugger commands
at a specific location in your program. You can issue a list of commands
{CMD-LIST} to be performed at locations that are specified with the HOOK-TYPE
argument when a certain condition is met (EXPRESSION). Values for the HOOK-TYPE
argument are described in HOOK-TYPE Argument.
Use the following format for the on
command.
on HOOK-TYPE [when (EXPRESSION)] {CMD-LIST}
on stats c {break; print lengthsum, totcnt}
Issuing this command interrupts
program execution at calls from stats
and at
returns to stats
, and prints the value of lengthsum
and totcnt
.
on lookup e when (strcmp(arg, "testid") == 0) { on lookup * {dump var str; break;}print}
on main 15 {dump &p; dump &g}
go; print z; print w;
The debugger executes the go
command and reaches line 15. As this point, the command buffer is
go; print z; print w; ↑
go; dump &p; dump &q; implied go; print z; print w; ↑
The debugger executes the inserted commands and then
executes the added go
. This means that the
two print commands are not executed at line 15. In fact, they are not executed
until the next breakpoint. See on for more details about the on
command.
Setting Different Debugger Modes |
auto KEYWORD KEYWORD . . .
#define MAXLEN 15
Then at the command line you would type:
Cdebug: auto cmacro
And to print the value of MAXLEN you would type:
Cdebug: print MAXLEN
which prints a value of 15 to the Log window.
See auto for a detailed discussion of these keywords and other
auto
command keywords.
Viewing Memory |
dump EXPRESSION
dump EXPRESSION str
The EXPRESSION argument is either a pointer, an address, or an array.
An absolute address must be specified with a leading 0p, for example, 0p00001234.
For the first format of the dump
command,
the number of bytes dumped is determined as follows:
The second form of the command dumps the contents of storage that is pointed to by the EXPRESSION until the null terminator, \0, is encountered.
In the following example, because str
is specified, the entire string test
is dumped:
Cdebug: dump wordstrg str
wordstrg
0002b1d0 a385a2a3 *test *
In the next example, inword
is an int
, so 4 bytes are dumped (int
type has a size of 4 bytes):
Cdebug: dump &inword
&inword
0002b1cc 00000001 *.... *
See dump for more details on the dump
command.
Defining Macros |
define DMACRO "REPLACEMENT TEXT"
The DMACRO argument is any valid identifier. The REPLACEMENT
TEXT argument is the debugger command that is substituted for the macro when
you invoke the macro. The REPLACEMENT TEXT argument can contain double quotation
marks, but you must escape the quotation marks with a backslash. Drop debugger
macro definitions with the undef
command when
you no longer need them. See undef for a discussion of the undef
command.
Cdebug: define dmp "dump wordarry str"
See define for more details on the define
command.
Executing Operating Environment Commands |
system OPERATING-SYSTEM-COMMAND
The
system
command uses full command resolution as if the command were entered in response
to the CMS prompt. See Command Directory,
for more information on the system under CMS.
Displaying Storage Analysis |
Cdebug: storage
The following output is an example of a report:
At SUB1(PGM1) entry ------ SIZE: FREE/USED SIZE: FREE/USED SIZE: FREE/USED SIZE: FREE/USED 24: 0/116 32: 0/118 40: 0/18 48: 0/69 56: 0/10 64: 0/7 72: 0/59 80: 0/10 88: 0/9 96: 0/4 104: 0/3 120: 0/2 144: 0/5 152: 0/1 160: 0/1 280: 0/1 512: 1/0 792: 1/0 1152: 1/0 1472: 1/1 1792: 0/2 8192: 0/1 No corruptions found in heap. SIZE NUMBER SIZE NUMBER SIZE NUMBER SIZE NUMBER SIZE NUMBER 152: 1 168: 1 208: 1 248: 1 256: 1 296: 2 672: 1 Total unused space in stack (bytes): 1768 No corruptions found in stack.
Halting Your Running Program |
attn
You generate the SIGINT
signal
under TSO by pressing the attention (PA1) key, and under CMS by using the
immediate command IC. However, when you are using the debugger, pressing
the attention key under TSO, IC under CMS, or CTRL+C under UNIX System Services
gives control back to the debugger. To actually send a SIGINT
signal to the executing program under the debugger, you must
use the attn
command.
Note:
When using the debugger in full-screen mode under CMS, you might not be able
to issue an immediate command. Another method of interrupting the debugger
under CMS is to press the attention key to give control to the VM control
program CP, and then issue the CP command EXTERNAL DB. This sends an external
interrupt of the debugger, which interprets it as an attention.
See attn for more details on the attn
command. See the
discussion of signal handling in the SAS/C Library Reference, Volume 1 for details on the characteristics
of signals.
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright © 2001 by SAS Institute Inc., Cary, NC, USA. All rights reserved.