| Line 1... |
Line 1... |
| 1 |
% File src/library/base/man/debug.Rd
|
1 |
% File src/library/base/man/debug.Rd
|
| 2 |
% Part of the R package, https://www.R-project.org
|
2 |
% Part of the R package, https://www.R-project.org
|
| 3 |
% Copyright 1995-2014 R Core Team
|
3 |
% Copyright 1995-2019 R Core Team
|
| 4 |
% Distributed under GPL 2 or later
|
4 |
% Distributed under GPL 2 or later
|
| 5 |
|
5 |
|
| 6 |
\name{debug}
|
6 |
\name{debug}
|
| 7 |
\title{Debug a Function}
|
7 |
\title{Debug a Function}
|
| 8 |
\alias{debug}
|
8 |
\alias{debug}
|
| Line 33... |
Line 33... |
| 33 |
%% can we describe what happens when it is turned off *inside* debugging ??
|
33 |
%% can we describe what happens when it is turned off *inside* debugging ??
|
| 34 |
}
|
34 |
}
|
| 35 |
\description{
|
35 |
\description{
|
| 36 |
Set, unset or query the debugging flag on a function.
|
36 |
Set, unset or query the debugging flag on a function.
|
| 37 |
The \code{text} and \code{condition} arguments are the same as those
|
37 |
The \code{text} and \code{condition} arguments are the same as those
|
| 38 |
that can be supplied via a call to \code{browser}. They can be retrieved
|
38 |
that can be supplied via a call to \code{\link{browser}}. They can be retrieved
|
| 39 |
by the user once the browser has been entered, and provide a mechanism to
|
39 |
by the user once the browser has been entered, and provide a mechanism to
|
| 40 |
allow users to identify which breakpoint has been activated.
|
40 |
allow users to identify which breakpoint has been activated.
|
| 41 |
}
|
41 |
}
|
| 42 |
\details{
|
42 |
\details{
|
| 43 |
When a function flagged for debugging is entered, normal execution
|
43 |
When a function flagged for debugging is entered, normal execution
|
| 44 |
is suspended and the body of function is executed one statement at a
|
44 |
is suspended and the body of function is executed one statement at a
|
| 45 |
time. A new browser context is initiated for each step (and the
|
45 |
time. A new \code{\link{browser}} context is initiated for each step
|
| 46 |
previous one destroyed).
|
46 |
(and the previous one destroyed).
|
| 47 |
|
47 |
|
| 48 |
At the debug prompt the user can enter commands or \R expressions,
|
48 |
At the debug prompt the user can enter commands or \R expressions,
|
| 49 |
followed by a newline. The commands are described in the
|
49 |
followed by a newline. The commands are described in the
|
| 50 |
\code{\link{browser}} help topic.
|
50 |
\code{\link{browser}} help topic.
|
| 51 |
|
51 |
|
| 52 |
To debug a function which is defined inside another function,
|
52 |
To debug a function which is defined inside another function,
|
| 53 |
single-step though to the end of its definition, and then call
|
53 |
single-step through to the end of its definition, and then call
|
| 54 |
\code{debug} on its name.
|
54 |
\code{debug} on its name.
|
| 55 |
|
55 |
|
| 56 |
If you want to debug a function not starting at the very beginning,
|
56 |
If you want to debug a function not starting at the very beginning,
|
| 57 |
use \code{\link{trace}(..., at = *)} or \code{\link{setBreakpoint}}.
|
57 |
use \code{\link{trace}(..., at = *)} or \code{\link{setBreakpoint}}.
|
| 58 |
|
58 |
|
| 59 |
Using \code{debug} is persistent, and unless debugging is turned off
|
59 |
Using \code{debug} is persistent, and unless debugging is turned off
|
| 60 |
the debugger will be entered on every invocation (note that if the
|
60 |
the debugger will be entered on every invocation (note that if the
|
| 61 |
function is removed and replaced the debug state is not preserved).
|
61 |
function is removed and replaced the debug state is not preserved).
|
| 62 |
Use \code{debugonce} to enter the debugger only the next time the
|
62 |
Use \code{debugonce()} to enter the debugger only the next time the
|
| 63 |
function is invoked.
|
63 |
function is invoked.
|
| 64 |
|
64 |
|
| 65 |
To debug an S4 method by explicit signature, use
|
65 |
To debug an S4 method by explicit signature, use
|
| 66 |
\code{signature}. When specified, signature indicates the method of
|
66 |
\code{signature}. When specified, signature indicates the method of
|
| 67 |
\code{fun} to be debugged. Note that debugging is implemented slightly
|
67 |
\code{fun} to be debugged. Note that debugging is implemented slightly
|
| Line 88... |
Line 88... |
| 88 |
}
|
88 |
}
|
| 89 |
\value{
|
89 |
\value{
|
| 90 |
\code{debug} and \code{undebug} invisibly return \code{NULL}.
|
90 |
\code{debug} and \code{undebug} invisibly return \code{NULL}.
|
| 91 |
|
91 |
|
| 92 |
\code{isdebugged} returns \code{TRUE} if the function or method is
|
92 |
\code{isdebugged} returns \code{TRUE} if the function or method is
|
| - |
|
93 |
|
| 93 |
marked for debugging, and \code{FALSE} otherwise.
|
94 |
marked for debugging, and \code{FALSE} otherwise.
|
| 94 |
}
|
95 |
}
|
| 95 |
\seealso{
|
96 |
\seealso{
|
| 96 |
\code{\link{debugcall}} for conveniently debugging methods,
|
97 |
\code{\link{debugcall}} for conveniently debugging methods,
|
| 97 |
\code{\link{browser}}, \code{\link{trace}};
|
98 |
\code{\link{browser}} notably for its \sQuote{\emph{commands}}, \code{\link{trace}};
|
| 98 |
\code{\link{traceback}} to see the stack after an \code{Error: \dots}
|
99 |
\code{\link{traceback}} to see the stack after an \code{Error: \dots}
|
| 99 |
message; \code{\link{recover}} for another debugging approach.
|
100 |
message; \code{\link{recover}} for another debugging approach.
|
| 100 |
}
|
101 |
}
|
| 101 |
|
102 |
|
| 102 |
\examples{
|
103 |
\examples{
|