Chapter Contents

Previous

Next
Command Directory

trace

Trace Program Flow

ABBREVIATION
t{race}

FORMATS

Format 1: trace
Format 2: trace HOOK-TYPE [when (EXPRESSION)] [count N

DESCRIPTION
The trace command traces program flow at specified hooks.

Format 1: Format 1 is used without arguments only within an on command because you specify the hooks as part of the on command syntax.

Format 2: Format 2 of the trace command traces program flow at the hooks you request with the HOOK-TYPE argument. See Using Debugger Commands for details about the HOOK-TYPE argument.

When a hook is reached, program execution proceeds automatically after the trace. You cannot enter other debugger commands.

You determine the type of line that the trace command writes by using the auto command. The default is a source line that contains, in addition to a listing of the source code, the line number and the location of the line (the section name and function name where the line is located).

The arguments: A when clause can be used to trace conditionally, that is, to trace a line when a hook is reached if the when clause is true.

The argument count N is optional. If count N is specified, the first N-1 times the hook is reached, the count is decremented. The Nth time it is hit, the command is executed. After the Nth time, the command is executed every time the hook is hit.

If a when clause is present, a hit is counted only if the when expression is true.

A query command, issued before the count drops to 1, displays the current value of count. The word count can be abbreviated to cou{nt}.

Identical requests: If a trace request is made that is identical to an existing one, the identical request is not installed. This is true whether the request to be installed is within an on command or typed in at the command line.

If an identical request is issued and the original request is disabled, the identical request is discarded and the original request is automatically enabled.

If count N is used, the count is ignored in identical requests. If an identical request with a different count is entered, the count field of a query is updated with the new count, and a message is produced.

EXAMPLES

trace *
traces program flow at all line-number hooks in all functions.

trace entry
traces program flow at entry to all functions.

trace main 45
traces program flow at line 45 in the main function.

trace 53
traces program flow at line 53 of the current function.

trace (comp23) entry
traces program flow upon entry into the comp23 compilation.

trace func1 entry
traces program flow at entry to the func1 function.

trace func 23:46
traces program flow at lines 23 through 46 in the func function.

SYSTEM DEPENDENCIES
none

COMMAND CAN BE ISSUED FROM

PROFILE yes
configuration file no
Source window prefix t

SCOPE
The trace command uses command scope to supply default identifiers, function names, and section names.

RETURN CODES SET
Successful: number of the action from the list produced by query
Unsuccessful: 0

SEE ALSO


Chapter Contents

Previous

Next

Top of Page

Copyright © 2001 by SAS Institute Inc., Cary, NC, USA. All rights reserved.