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

后端 未结 2 1163
花落未央
花落未央 2020-12-15 03:50

What is the most productive and quickest way to debug shared objects that are loaded into R, in particular on OS X Mavericks? I\'m primarily interested in debugging compile

相关标签:
2条回答
  • 2020-12-15 04:14

    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.

    0 讨论(0)
  • 2020-12-15 04:18

    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.

    0 讨论(0)
提交回复
热议问题