From 003ab0c7de83498070d2c7c4efad3f8f5fd1414f Mon Sep 17 00:00:00 2001 From: Ralf Stubner Date: Fri, 6 Sep 2024 20:40:14 +0200 Subject: [PATCH] Add support for debugging C++ from Positron See https://github.com/posit-dev/positron/discussions/4534 On Linux I also needed to run sudo sysctl -w kernel.yama.ptrace_scope=0 --- .Rbuildignore | 2 ++ .vscode/launch.json | 28 ++++++++++++++++++++++++++++ debug/debug.R | 7 +++++++ 3 files changed, 37 insertions(+) create mode 100644 .vscode/launch.json create mode 100644 debug/debug.R diff --git a/.Rbuildignore b/.Rbuildignore index 3b7432e..653b8ab 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -21,3 +21,5 @@ ^\.cache$ ^compile_commands\.json$ ^touchstone$ +^\.vscode$ +^debug$ diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..fefcb14 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,28 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "name": "(lldb) Launch R", + "type": "lldb", + "request": "launch", + "program": "/Library/Frameworks/R.framework/Resources/bin/exec/R", + "args": [ + "--vanilla", + "-e", + "source('debug/debug.R')" + ], + "env": { + "R_HOME" : "/Library/Frameworks/R.framework/Resources" + }, + "terminal": "console", + "stopOnEntry": false + }, + { + "name": "(lldb) Attach to R", + "type": "lldb", + "request": "attach", + "pid": "${command:pickMyProcess}", + "stopOnEntry": false + } + ] +} diff --git a/debug/debug.R b/debug/debug.R new file mode 100644 index 0000000..ee74905 --- /dev/null +++ b/debug/debug.R @@ -0,0 +1,7 @@ +devtools::clean_dll() +devtools::load_all() +Sys.getpid() + +dqrng::dqrunif(10) + +dqrng::dqRNGkind("pcg64")