Debug a S-PLUS Expression

DESCRIPTION:

Use the S-PLUS command line debugger to debug an expression.

USAGE:

Debug(x, breakpoints=list(), types=rep("n", length(breakpoints)), entryStop=F)

REQUIRED ARGUMENTS:

x
a S-PLUS expression to debug.

OPTIONAL ARGUMENTS:

breakpoints
a named list of line number vectors. Each name can be a file name, a string containing the function definition, or a function name.
types
a character vector denoting the type of each entry in the list given by breakpoints. Allowed values are: "n", a function name; "f", a file name; "t", a string containing the function definition. This vector should have the same length as the breakpoints list.
entryStop
a logical value. If TRUE, a breakpoint is added at the entry to expression that is being debugged. The default value is FALSE.

VALUE:

The value returned is the result of evaluating the S-PLUS expression given by x .

SIDE EFFECTS:

The debugger's prompt will appear on the S-PLUS command line allowing the user to enter debugger commands.

DETAILS:

A call to Debug causes execution of the S-PLUS expression given by x to stop at the first breakpoint specified by breakpoints or on entry to the expression if entryStop=T. The debugger's prompt, "my debug>" will appear on the S-PLUS command line. Type "?" or "h" to see the list of debugger commands.

SEE ALSO:

For more functionality, flexibility and a GUI interface use the debugger in S-PLUS Workbench. Refer to the chapter about debugging in the S-PLUS Workbench User's Guide.

EXAMPLES:

# Debug a call to lm() with breakpoints at lines 10, 14 and 23 in lm.
Debug(lm(Mileage ~ Weight - 1, data = fuel.frame), 
    breakpoints = list(lm = c(10, 14, 23)), type = "n")

# Debug a user defined function, with breakpoints at lines 2 and 3
Debug(foo(2), breakpoints=list("foo<-function(x) {\ny <- x+4\ny\n}"=c(2,3)),
    type="t")

# Create a file named "foo.q" containing this:
foo <- function(x) {
   y <- x+4
   y
}
# Debug a call to a function in file "foo.q"
Debug(foo(2), breakpoints=list("foo.q"=c(2,3)), type="f")