[Rcpp-devel] Debugging an Rcpp/RCppArmadillo program?

Davor Cubranic cubranic at stat.ubc.ca
Tue Apr 9 06:37:11 CEST 2013


On 13-04-08 07:57 AM, Dirk Eddelbuettel wrote:
>
> On 8 April 2013 at 16:37, Stefano Calza wrote:
> | 1) open R in emacs (M-x R) and load the *.so. At developement stage it might be
> | useful to use sourceCpp
> | 2) open gdb (M-x gdb) in emacs
> | 3) look for R session id (see "ps" command), let's assume it's 1234
> | 4) In the gdb shell:
> |     a) attach 1234
> |     b) set breakpoints
> |     c) signal 0
> | 5) now run R commands and you'll get the debugger stop once into you code
>
> Right -- there is a write-up by Doug Bates "somewhere". Might have an older R
> News / R Journal that documents this but have the gist of it here: find the
> process, attach to it, be merry.

I run "R -d gdb" instead. From the terminal

1. type "R -d gdb" at the shell prompt
2. when gdb starts, type "r"
3. R will start -- at the R prompt load your package: "library(yourpackage)"
4. type Ctrl-C to drop back into the debugger
5. set breakpoints ("break file.cpp:123" or "break MyFunction")
6. type "c" to continue executing R
7. invoke the relevant functions in your package.

Davor



More information about the Rcpp-devel mailing list