What are productive ways to debug Rcpp compiled code loaded in R (on OS X Mavericks)?

回眸只為那壹抹淺笑 提交于 2019-11-29 01:05:00

To debug simple Rcpp scripts like this, one thing you can do is create a .cpp application (with a main) that embeds R. This way you can debug it directly with Xcode which will give you a good debugging experience.

It gets more complicate when you start to want to debug packages.

This is tough. I tried Xcode and Eclipse with a standalone C++ application, but it was so difficult to get all the headers and libraries working. Furthermore, the RcppExport code calls your real R function through a pointer which seemed to really confuse Xcode, and I couldn't step into my function.

I ended up with (gdb or lldb): In R: R -d lldb In debugger, set breakpoint: b functionName run In R: .Call(etc) # or just call your R code which invokes compiled C/C++ code Then back in debugger once break happens, you can step, examine frames, etc.

This lldb/gdb command quick reference helped a lot.

Forget about trying to do this in a GUI at this point. Hopefully Rstudio will get this going.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!