trace(what, tracer=T, exit=<<see below>>, at=1, print=T,signature) untrace(what=<<see below>>)
trace
adds the functions to the list of those whose calls are traced and
untrace
removes them from that list.
This may be the unquoted name of a function if there is only one.
This argument is required for
trace, but not for
untrace.
TRUE, the standard tracing function,
std.trace, is used,
which prints a line
giving the function call itself before
fun is called.
TRUE or a function to be used as the exit tracing function.
If
TRUE, then
std.xtrace is used as the exit tracing function.
By default, there is no exit tracing.
TRUE,
the tracing code prints a message (e.g.,
"On entry") to identify
the location of the trace, before calling the tracing function.
Usually this is helpful, but you can set the option to
FALSE if you
want silent tracing.
what should be traced.
what is returned invisibly.
trace creates, for each function named in
what, a new version
on the session database, and
trace also updates
.Tracelist.
untrace removes the altered functions from the session database.
If there is no argument to
untrace, all functions are removed
from
.Tracelist.
If
signature is supplied, the
traceMethod function is called to
trace the appropriate method.
Tracing is accomplished by putting a revised version of the functions
into the session database.
Each call to
trace for a given function replaces any previous
tracing for that function.
An object called
.Tracelist on the session database lists the functions
that are currently being traced.
The
.Traceon object in the session database tells whether tracing is
on or off (see
trace.on).
You can perform:
tprint(myfun)
to see where the
at argument will put the tracing.
This prints the body of the function
myfun, with each subexpression
numbered.
Tracing will only be performed during the current session of S-PLUS.
Each call to
trace for a given function replaces any previous
tracing for that function.
The
inspect function now provides a more
general interactive debugging environment, including browsing and tracing,
together with most of the functionality of the
debugger function.
ALWAYS
untrace a function before attempting to modify a traced function.
Because tracing inserts a modified version of the traced function
in the session database, it is frustrating and confusing to attempt to edit the
traced function while tracing is in effect.
(If you forget to untrace a function before editing it, you will end up with
the tracing being part of your permanent function; eventually,
you will need to edit this out.)
trace(parse) # record all calls to the parse function
trace(c("sum", "cumsum"), exit=T)
untrace() # remove tracing from all functions