Skip to content

internal and external debugging [was: [R] step by step debugger in R?]

2 messages · Mark Bravington, Romain Francois

#
Hello all

I'm coming late to this discussion, and my comments may now be beside the point-- but I have been intending to ask what people think of the pros & cons of internal and external (e.g. 'debug' package) debuggers. When I wrote 'debug', the internal debugger just didn't do what I wanted, but maybe things have changed-- hence this email, to find out. The particular facilities in 'debug' that I'm thinking of, are

   - Graceful error trapping. In 'debug', I can just run til it crashes, then figure out what's up and carry on if desired-- often in conjunction with...
   
   - 'skip', to move the execution point around. I use this all the time, often after a graceful error trap, to replace a dodgy bit of code with the correct version, and then skip round the bad version to carry on.
   
   - the conditional breakpoint facilities, including debugging of on-exit code.
 
Can these be done with internal debugging?
 
The main negative issues I have seen with 'debug' are:

   - very clunky tcl/tk interface, and inability to see proper source code;

   - (occasionally) speed-- although this can often be gotten round with a bit of ingenuity;

   - some more "special cases" that I should add, e.g. to trace into 'try' statements;

   - a few maggots in the code barrel due to changes in R over the years.
   
I try to catch up with the 3rd & 4th from time to time, and would be very happy if anyone can help with the 1st (Romain did already offer as part of summer-of-code, though the project didn't get up).

If anyone has other thoughts on bad things in, or good things not in, 'debug', then I would consider adding them.
   
Finally, my 2c from experience with 'debug': writing it was very hard work. Debugger-writing seems to be a case where one can one can get *something* working quite quickly-- and then get sucked in to a very long and painful process. The effort I spent has been repaid many times over, but...

Mark Bravington

CSIRO, Hobart, Australia
#
Hi,

Thank you for these comments. I think it does indeed add to the 
discussion and provides a good reference. I have added a few comments below.
Mark.Bravington at csiro.au wrote:
options( error = recover ) lets you examine what did cause the crash. 
AFAIK, it does not let you carry on.
I am not sure I understand completely here, but I think the new 
facilities implemented by Robert Gentleman are going in this direction. 
once in a browser, you can use browserSetDebug to jump up one or more 
frames in the stack.
browser now (in R-devel) has a "expr" argument that I think controls 
whether to actually enter the browser or not.

Also, with the work Duncan Murdoch has been doing recently on keeping 
the srcref records as part of the stack, we are not too far from the 
ability to create breakpoints without actually typing in "browser()" in 
the code, i.e. something similar to trace(...,at=) where at would not be 
a step in the list of expressions of the function but a srcref record. 
This would great from a visual debugger point of view.

Romain