Dear Folks--
I am a moderately experienced, self-employed R programmer who spends a great deal of time in debugging, in continuing education, and in otherwise trying to figure out what my $*!# code is doing. I often find the current R debugging tools with which I am familiar do not suffice to let me quickly identify where and why a bug or unanticipated outcome occurs, and I keep a running wish list of imaginary debugging features. Note that these do not generally come from experience with debuggers from other languages, of which I have little. Instead they are usually of the form "If only I had a tool which would do 'X'." Every six months or so, I spend a few hours of internet search in the hopes that some of my debugging fantasy tools for R will appear. Sometimes this has been quite productive, but more usually not.
Recently I was doing this, and accidentally came across the C/C++ debugger called "rr". The rr debugger implements my number one fantasy for a debugging tool (albeit not for R): it lets you single-step backwards. Once you reproduce a bug a single time, it contains a complete recording of all the intermediate values and states that a program passed through on the way to your bug. This includes things that are not part of the program being debugged itself -- interactions with the OS, the file system, other system calls, etc. This seems to me like a really valuable capacity and I wonder if there is anything like it that I have overlooked that now exists in RStudio, in R itself, or in the tidyverse or the R package universe more broadly.
It seems to me like this system could also impliment my number two fantasy, though I do not know if it actually does. That is to trace the value of a particular variable backwards, showing the value at each step. Imagine MS-Excels visual formula tracing combined with RStudio's object display and Environment pane. I frequently find when looking at a traceback that is eight to 12 lines long that I am not able to understand how the final function got called starting from my original code, or that I am not sure where the offending function argument came from. My carefully honed informitive names are not as much help as one might wish when they have been shed by two or three steps up the call stack.
There is a nice description of using rr at this blog post: http://fitzgeraldnick.com/2015/11/02/back-to-the-futurre.html I was especially impressed by the author's assertion that he would boot from his normal, non-linux OS into fedora just to use the rr debugger. Plainly, he likes this debugger a lot. The main documentation site is here: https://rr-project.org/.
Thoughts, anyone?
andrewH