debug                  package:base                  R Documentation

_D_e_b_u_g _a _F_u_n_c_t_i_o_n

_D_e_s_c_r_i_p_t_i_o_n:

     Set, unset or query the debugging flag on a function.

_U_s_a_g_e:

     debug(fun)
     undebug(fun)
     isdebugged(fun)

_A_r_g_u_m_e_n_t_s:

     fun: any interpreted R function.

_D_e_t_a_i_l_s:

     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).

     At the debug prompt the user can enter commands or R expressions.
     The commands are


     '_n' (or just return).  Advance to the next step.

     '_c' continue to the end of the current context: e.g. to the end of
          the loop if within a loop or to the end of the function.

     '_c_o_n_t' synonym for 'c'.

     '_w_h_e_r_e' print a stack trace of all active function calls.

     '_Q' exit the browser and the current evaluation and return to the
          top-level prompt.

     (Leading and trailing whitespace is ignored, except for return).

     Anything else entered at the debug prompt is interpreted as an R
     expression to be evaluated in the calling environment: in
     particular typing an object name will cause the object to be
     printed, and 'ls()' lists the objects in the calling frame.  (If
     you want to look at an object with a name such as 'n', print it
     explicitly.)

     If a function is defined inside a function, single-step though to
     the end of its definition, and then call 'debug' on its name.

     In order to debug S4 methods (see 'Methods'), you need to use
     'trace', typically calling 'browser', e.g., as 
      'trace("plot", browser, exit=browser, signature = c("track",
     "missing"))'

_S_e_e _A_l_s_o:

     'browser', 'trace'; 'traceback' to see the stack after an 'Error:
     ...' message; 'recover' for another debugging approach.

