![]() Chapter Contents |
![]() Previous |
![]() Next |
| Using the Debugger |
| Running Your Program |
The go command starts
(or resumes) program execution under the
debugger. The program then executes until the next requested breakpoint or
action. PF12 is the default PF key assignment for the go
command. See go for details.
| Stepping Through Your Program |
step [INTEGER]
The optional INTEGER is a nonnegative decimal integer.
Use the INTEGER argument to specify the number of times that you want the step command to be performed. The step
command is usually used without an optional INTEGER argument. This is the
most common form of the step command and it causes the debugger to continue
execution to the next hook. In other words, it is used to single step through
your program. PF11 is the default PF key assignment for the step command. See step for more
details.
continue [INTEGER]
The optional INTEGER is a nonnegative decimal integer.
Use the INTEGER argument to specify the number of times that you want the continue command to be performed. When a continue command is
issued at a function call, the function
is not stepped into. Execution proceeds to the next line hook in the current
function, provided that there are no other breakpoints requested before the
next hook. PF10 is the default PF key assignment for the continue command. See continue for more
details.
| Stopping in Your Program |
break HOOK-TYPE
Values for the HOOK-TYPE argument are explained in Using Debugger Commands. The
HOOK-TYPE argument can be one of several possible formats. Another format
of the break command is
break FUNCTION-NAME entry
This format sets a breakpoint at entry to the function
that is specified by the FUNCTION-NAME argument. See break for a complete discussion
of all the formats for the break command.
break *break entrybreak callsbreak func1 entry when (parm ==5) func1 function when the value of parm1
is 5.
break 66
The prefix-area command B
breaks on line 66 in Prefix-Area Command B Example and is entered from the prefix area of the line number field. This command
can be issued only between the lines that contain the opening and closing
braces of a function.
See Prefix-Area Commands for a comprehensive listing of the prefix-area commands.
runto HOOK-TYPE [when (EXPRESSION)]
Breakpoints that are set by the runto command are
temporary and are removed the first time the
program execution stops. This occurs even if execution stops at another breakpoint
before reaching the breakpoint that is specified in the runto command. Issuing a runto
command causes the program to run until it hits the breakpoint that is specified,
unless execution stops before reaching the breakpoint. See runto for more details. The
following are examples of the runto command:
runto main
52runto 75 count 5
| Changing Program Execution |
SIGSEGV. SIGSEGV
is the illegal memory access signal.
SIGFPE class of signals: SIGIDIV, SIGFPDIV, SIGFPOFL,
and SIGFPUFL.
abort which
is identified by the signal SIGABRT.
SIGABRT or
SIGABND.
See the SAS/C Library Reference, Volume 1 for a discussion of the characteristics of signals.
resume [FUNCTION-NAME][LINENO]
math_a()
{
stmt1; /* lines of code */
stmt2;
.
.
.
p = 0;
27 if (a == b) *p = d; /* This line causes a SIGSEGV signal */
.
.
.
59 strncpy(p, "XYZ",4); /* Call strcmp, passing p--which is */
/* bad, and a string "XYZ". This line */
/* would cause a SIGSEGV signal to */
/* occur in the library strncpy */
/* function */
Suppose a SIGSEGV occurs
at line 27. Depending on how math_a
is supposed to work, several different errors could be the reason for the SIGSEGV. Perhaps p
should not have been set to 0, or perhaps a and b should
have been equal. If the problem is that p should not have been 0, you can use assign to give
p
a correct value and then use resume to try
the assignment again. Execution starts at the last hook that was encountered
before the code that caused the error condition. So, when the first SIGSEGV is encountered at line 27, resume
moves back to the closing parenthesis of if
(a == b) and retries the rest of the line.
Execution is resumed at the first hook in the source
line that is identified by LINENO in the abending function. The command resume 27 retries line 27 from the beginning of the
if statement.
Suppose p
is 0, and a and b are not supposed to be equal. You could
use assign to change the value of a or b,
and use resume 27 to reexecute the if statement, thereby avoiding the bad assignment
to *p.
Suppose that a SIGSEGV
occurs at line 59 in strncpy. resume FUNCTION-NAME resumes execution at the last hook that
was executed before the error in the active function (specified by FUNCTION-NAME).
In this example, you cannot resume strncpy because strncpy
is a library routine. Therefore, resume math_a
restarts execution at the last hook in math_a before the call to strncpy.
Use resume with a LINENO
argument for an error that occurs in a function call that takes several lines. resume with no arguments only reexecutes the last line of
the call; you must issue a resume command with
the first line in order to reexecute the entire statement. This is important
if you correct the problem by changing a parameter in a line of the call other
than the last: for example, if math_a
contains the lines
15 longsub(a,b[i],c, 16 d,e,f);
If you have a failure in longsub that is due to a problem with b, and if you
change [i]
and then issue resume math_a, the same old b[i] values are still passed to
longsub because b[i] is not reexecuted. You have to issue resume math_a 15
to correct it.
go. This lets you get a dump, for instance.
terminate function, which calls the abort
function.
See resume for more details on the resume
command.
| Displaying, Disabling, Dropping, and Ignoring Breakpoints Requests |
The
query command generates a query list, which is a numbered
list of break, catch, trace, ignore, on, and
monitor command requests
that are currently in effect. When issued with no arguments, the query command produces the numbered list of all requests.
See query for more details on the query command.
disable ACTION-RANGE
Once you have disabled a request, the request is not
honored until you enable it again. See enable for more information. Disabled requests
are marked with an asterisk next to the request number in the query list.
See disable for more details on the disable command.
drop ACTION-RANGE
drop all
The first format of
the drop command allows you to drop requests
from the query list by number. The ACTION-RANGE
argument specifies either a single request number or a range of request numbers.
The second form of the drop command allows
you to drop all request for the entire program. See drop for details about the drop command.
ignore HOOK-TYPE
Values for the HOOK-TYPE argument are explained in HOOK-TYPE Argument. As discussed in that section, this can be one of several possible formats. One commonly used format is
FUNCTION-NAME line-num1:line-num2
This means to ignore requests at source line range in the specified function (FUNCTION-NAME).
The ignore command is
helpful if you want to ignore requests only at a specific line number or line
number range. In other words, you can leave a request in effect except for
a line range. You can drop the ignore command
using drop. See ignore for a description of all
the formats for the ignore command.
| Displaying Variables and Data |
print EXPRESSION
EXPRESSION Argument discusses the types of expressions that can be used with the print command and option formats.
The print command enables
you to determine the contents of a scalar or aggregate, inspect function return
values, print function parameters, and look at other program elements and
objects. PF16 is the default PF key assignment for the print command. See print for details on all the
formats that you can use. The whatis command displays the type information that is associated
with its argument. One format of the whatis
command is
whatis EXPRESSION
EXPRESSION is a valid expression or macro. See EXPRESSION Argument for more
information. Used with this argument, whatis
displays the type and length of the expression. To display information about
macro names, you must compile with dbgmacro.
The auto command keyword cmacros does not need to be set.
For example, assume the following declaration for
the whatis EXPRESSION:
struct ABC {
int x;
double d;
} new_struct;
whatis new_struct::x
displays:
int x
| Modifying Variables and Data |
assign SCALAR-TYPE-EXPRESSION = VALUE
The assign command assigns
the value that is specified by the VALUE argument to the object identified
by SCALAR-TYPE-EXPRESSION. As described in SCALAR-TYPE-EXPRESSION Argument, SCALAR-TYPE-EXPRESSION is an expression
whose type is arithmetic, pointer, or bit-field. VALUE is an expression whose
type is one of the following:
#define A_MIN 9 int avalue; assign avalue = 9 + A_MIN
See assign for a description of all formats for the assign command.
| Exiting Your Program |
The exit command immediately terminates program execution under
the debugger, after closing all program and debugger files. PF3 is the default
PF key assignment for the exit command. See exit for details.
![]() Chapter Contents |
![]() Previous |
![]() Next |
![]() Top of Page |
Copyright © 2001 by SAS Institute Inc., Cary, NC, USA. All rights reserved.