Debug with RCPP #4534
-
I went to posit::conf(2024) and was impressed by Positron's support for debugging from R into C. I am trying to re-produce the behavior locally but did not have success: I have two files in the folder:
Then I do:
The debugging point does not seem to go into C code as I click on "step over", as @DavisVaughan showed in his demo. Is there anything I can do to reproduce this behavior? My team is super interested. Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 3 replies
-
Do you actually use Also what OS are you on? We've only heavily tested this on a Mac. Here is a longform video of me getting this to work. The files used here are here https://github.com/DavisVaughan/testrcppdebug Screen.Recording.2024-08-30.at.11.42.07.AM.movIt's a little more complex than what I showed in my talk - we had to greatly trim for time. But it still isn't horrible, you just need a little setup. We definitely need some real documentation for this, but here are the steps.
{
"version": "0.2.0",
"configurations": [
{
"name": "(lldb) Attach to R",
"type": "lldb",
"request": "attach",
"pid": "${command:pickMyProcess}",
"stopOnEntry": false
}
]
}
|
Beta Was this translation helpful? Give feedback.
-
Our other tip is that for syntax highlighting, go to definition, and other C++ related language server features, you will also want the clangd extension (also shown in my screenshot). clangd typically requires you to make a
This is all still experimental, hence the |
Beta Was this translation helpful? Give feedback.
-
Hey @DavisVaughan thanks for the example and I am able to go into C code now. As I look into the "Debug Variables", it seems native C objects can show properly (see
|
Beta Was this translation helpful? Give feedback.
-
Thanks @DavisVaughan and @lionel- for your reply! This is a really exciting feature for my team to try out! If possible, we would love to have more straightforward ways of debugging RCPP objects in Positron. |
Beta Was this translation helpful? Give feedback.
-
Just watched the "Introducing Positron, a new data science IDE - posit conf 2024" video on Youtube, so excited about the debugging capability of Positron. Looking forward to the coming document! Great job you guys! |
Beta Was this translation helpful? Give feedback.
Do you actually use
sourceCpp()
like this in your "real" code? Or do you use Rcpp in a package? It is much easier to do this debugging if its inside an actual package. When you usesourceCpp()
, your C++ file gets copied to a cache directory (that you typically can't see) and gets built from there. So if you set any breakpoints in yourfind_max.cpp
C++ file, they won't be activated. I was able to workaround this by forcing the cache directory to be inside my project, and then I could go set a breakpoint in the copied C++ file and that fixed things.Also what OS are you on? We've only heavily tested this on a Mac.
Here is a longform video of me getting this to work. The files used here are …