From 465fb45c2cbc1f5b840b8d00c186889a8fb52602 Mon Sep 17 00:00:00 2001 From: Heather Turner Date: Wed, 30 Jul 2025 17:07:04 +0100 Subject: [PATCH] example lldb setup that works as expected --- .devcontainer/devcontainer.json | 6 ++++-- .gitignore | 4 ++++ .vscode/launch.json | 12 ++++++++++++ scripts/allow_ptrace.c | 7 +++++++ scripts/launch_r.sh | 5 +++++ scripts/localscript.sh | 2 +- 6 files changed, 33 insertions(+), 3 deletions(-) create mode 100644 .vscode/launch.json create mode 100644 scripts/allow_ptrace.c create mode 100755 scripts/launch_r.sh diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index ca2376a64..691976ccc 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,6 +1,7 @@ { "name": "R-Dev-Env", "image": "ghcr.io/r-devel/r-dev-env:devel", + "runArgs": ["--cap-add=SYS_PTRACE"], "hostRequirements": { "cpus": 4 }, @@ -13,7 +14,7 @@ "r.lsp.diagnostics": false, "r.plot.useHttpgd": true, "r.rpath.linux": "/usr/bin/R", - "r.rterm.linux": "/usr/bin/R", + "r.rterm.linux": "/workspaces/r-dev-env/scripts/launch_r.sh", "terminal.integrated.sendKeybindingsToShell": true, "svn.multipleFolders.enabled": true, "workbench.editorAssociations": { @@ -28,7 +29,8 @@ "johnstoncode.svn-scm", "ms-vscode.cpptools", "MS-vsliveshare.vsliveshare", - "natqe.reload" + "natqe.reload", + "vadimcn.vscode-lldb" ] } }, diff --git a/.gitignore b/.gitignore index 8fce03092..1c5a8e096 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,10 @@ R-4.1.3/ R-4.1.3.tar.gz R-devel/ R-devel.tar.gz +/build +/svn /venv .cache/ .Rproj.user +*.Rproj +**.so diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 000000000..0fa2b45a5 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,12 @@ +{ +"version": "0.2.0", +"configurations": [ + { + "name": "(lldb) Attach to R", + "type": "lldb", + "request": "attach", + "pid": "${command:pickMyProcess}", + "stopOnEntry": false + } + ] +} \ No newline at end of file diff --git a/scripts/allow_ptrace.c b/scripts/allow_ptrace.c new file mode 100644 index 000000000..4deebecc5 --- /dev/null +++ b/scripts/allow_ptrace.c @@ -0,0 +1,7 @@ +#include +#include + +__attribute__((constructor)) void allow_ptrace() { + prctl(PR_SET_PTRACER, PR_SET_PTRACER_ANY); + fprintf(stderr, "allow_ptrace: called\n"); +} diff --git a/scripts/launch_r.sh b/scripts/launch_r.sh new file mode 100755 index 000000000..7988ec571 --- /dev/null +++ b/scripts/launch_r.sh @@ -0,0 +1,5 @@ +#!/bin/bash +export LD_PRELOAD=/workspaces/r-dev-env/scripts/allow_ptrace.so +# which_r.sh needs updating to switch R version here vs in vscode settings +# exec /workspaces/r-dev-env/build/r-devel/bin/R "$@" +exec /usr/bin/R "$@" \ No newline at end of file diff --git a/scripts/localscript.sh b/scripts/localscript.sh index 3797814b7..4aaebeecd 100644 --- a/scripts/localscript.sh +++ b/scripts/localscript.sh @@ -25,7 +25,7 @@ cat $WORK_DIR/scripts/welcome_msg.sh >> ~/.bashrc #bash ~/.bashrc # Remove git directory if it exists -rm -rf .git +# rm -rf .git # copying vscode extension settings from devcontainer json to vscode settings json using jq if [ -f "$DEVCONTAINER_JSON" ]; then