[R] debugging R

Douglas Bates bates at stat.wisc.edu
Tue Sep 30 15:11:21 CEST 2003


Francisco J Molina <fjmolina at ams.ucsc.edu> writes:

> To debug R "from within Xemacs" I have tried two different things: 
> 
> C-u M-x R RET - d SPC gdb RET to start an inferior R process with arguments
> @option{-d gdb}
> 
> This is the way described in the official documentation of R.
> 
> and also 
> 
> M-x R and then start GUD (M-x gdb) giving the R binary (using its full path
> name: /usr/bin/R ) as the program to debug. Use the program @command{ps} to find the
> process number of the currently running R process then use the attach
> command in gdb to attach it to that process.
> 
> I have had problems with the last way: R freezes.

That is because gdb has interrupted the R process.  At this point I
usually set a breakpoint at the function of interest, go to the gdb
window and restart R by sending the 0 signal

gdb> sig 0

Then you are able to get a response in the ESS window with R.

This technique is particularly useful if you have compiled code in a
package because you can attach the package and load the shared object
before invoking the debugger.

> Has anyone been succesfull in debugging R in last way?

Yes - more times than I would care to count.




More information about the R-help mailing list