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 or unset the debugging flag on a function.

_U_s_a_g_e:

     debug(fun)
     undebug(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.

