\Header{debug}{Debug a function}
\alias{undebug}{debug}
\keyword{programming}{debug}
\keyword{environment}{debug}
\begin{Usage}
\begin{verbatim}
debug(fun)
undebug(fun)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\texttt{fun}] any interpreted \R\ function.
\end{ldescription}
\end{Arguments}
\begin{Description}
These functions set and unset the debugging flag on a function.
When a function flagged for debugging is entered, normal execution
is suspended and the body of function is executed one statement at a time.
A new browser context is initiated for each step (and the previous one
destroyed).
Currently you can only debug functions that have bodies enclosed in braces.
This is a bug and will be fixed soon.
You take the next step by typing carriage return, \texttt{n} or \texttt{next}.
You can see the values of variables by typing their names.
Typing \texttt{c} or \texttt{cont} causes the debugger to continue to the
end of the function.
You can \texttt{debug} new functions before you step in to them from inside
the debugger.
If you have variables with names that are identical to the controls
(eg. \texttt{c} or \texttt{n} ) then you need to use \texttt{print(c)} and
\texttt{print(n)} to evaluate them.\end{Description}
\begin{SeeAlso}
\texttt{\Link{browser}}, \texttt{\Link{traceback}} to see the stack after
an \texttt{Error: ...} message.\end{SeeAlso}

