[Rd] debuggingState() analogous to tracingState() ?

Jonathan McPherson jonathan at rstudio.com
Thu Oct 2 19:56:01 CEST 2014


>
>  > I don't have much of an opinion on these questions.  I've never used the
>  > tracingState() function, though I use trace() all the time (via
>  > setBreakpoint()).  You might want to consult people who write debugger
>  > front-ends.
>
> which I am now doing: I'm including ESS-core,
> Jonathan (RStudio) and Tobias (StatET) which Duncan mentioned as
> being interested and having asked for better debugging support
> functionality in the past, such as
>
>
Some observations from RStudio which may or may not be helpful:

We don't expose any UI that allows the user to modify tracingState(). In
fact, turning off tracingState() will make RStudio's breakpoints stop
working (as they rely on trace()), without any warning or feedback from the
UI. We've never received complaints about this, and so my presumption is
that very few people need to turn off tracing globally, and those who do
know what they're doing and/or aren't using the IDE debugging features.

Some mechanism for globally altering debugging state would be very useful.
Right now we have a problem wherein during debugging the R functions
RStudio calls to e.g. analyze and compose the list of objects in the
workspace are themselves debugged. Today we're solving this by manually
tripping the RDEBUG flag on an environment before we evaluate expressions
in it, which I think we can all agree is less than ideal.

Do you foresee any non-interactive use for debuggingState()? If so, it
might be nice if the state had push/pop rather than on/off semantics, to
make the pattern of disabling locally easier to express.

 > the ability to add a breakpoint to a function that is
 > currently being evaluated.

Yes, this would be useful to us, although unless I'm missing something it
seems pretty orthogonal to the rest of the thread. It's not a common
feature request.

One thing that would be useful is some officially supported way to debug
during source(). Lots of people don't use functions and just have R scripts
full of straight-line statements (sometimes containing references to other
code via source()). RStudio will let you set breakpoints on top-level
statements, and this has proven to be a popular feature, but its
implementation is very messy--we effectively create a function from the
statements in the file and then use the function debugger, which works for
simple scenarios but starts falling apart if you do anything complicated.

Thanks,
Jonathan.

	[[alternative HTML version deleted]]



More information about the R-devel mailing list