(R-lang.info)Debugging


Next: Parser Prev: Exception handling Up: Top
Enter node , (file) or (file)node

9 Debugging
***********

Debugging code has always been a bit of an art.  R provides several
tools that help users find problems in their code.  These tools halt
execution at particular points in the code and the current state of the
computation can be inspected.

   Most debugging takes place either through calls to 'browser' or
'debug'.  Both of these functions rely on the same internal mechanism
and both provide the user with a special prompt.  Any command can be
typed at the prompt.  The evaluation environment for the command is the
currently active environment.  This allows you to examine the current
state of any variables etc.

   There are five special commands that R interprets differently.  They
are,

'<RET>'
     Go to the next statement if the function is being debugged.
     Continue execution if the browser was invoked.
'c'
'cont'
     Continue the execution.
'n'
     Execute the next statement in the function.  This works from the
     browser as well.
'where'
     Show the call stack
'Q'
     Halt execution and jump to the top-level immediately.

   If there is a local variable with the same name as one of the special
commands listed above then its value can be accessed by using 'get'.  A
call to 'get' with the name in quotes will retrieve the value in the
current environment.

   The debugger provides access only to interpreted expressions.  If a
function calls a foreign language (such as *C*) then no access to the
statements in that language is provided.  Execution will halt on the
next statement that is evaluated in R. A symbolic debugger such as 'gdb'
can be used to debug compiled code.

browser
debug/undebug
trace/untrace
traceback

automatically generated by info2www version 1.2.2.9