-
Notifications
You must be signed in to change notification settings - Fork 18
Feature : Enable LLDB Debugging for R Dev Container #260
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 12 commits
b686781
5200db3
7131f53
0aafb3d
12e95fd
8d169f3
ecd644a
13a94cd
e31cb45
10bb76e
0ded05f
aa3881d
c511d20
6ff6e5b
c6e3c74
3023bdb
16aab2e
8449b16
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| { | ||
| "version": "0.2.0", | ||
| "configurations": [ | ||
| { | ||
| "name": "Debug R (C debugging)", | ||
| "type": "cppdbg", | ||
| "request": "launch", | ||
| "program": "/workspaces/r-dev-env/scripts/launch_r.sh", | ||
| "args": [], | ||
| "stopAtEntry": false, | ||
| "cwd": "${workspaceFolder}", | ||
| "environment": [ | ||
| { | ||
| "name": "R_RPATH_LINUX", | ||
| "value": "${config:r.rpath.linux}" | ||
| } | ||
| ], | ||
|
||
| "externalConsole": false, | ||
| "MIMode": "lldb" | ||
| } | ||
| ] | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| #include <sys/prctl.h> | ||
|
|
||
| __attribute__((constructor)) | ||
| static void allow_ptrace(void) { | ||
| prctl(PR_SET_PTRACER, PR_SET_PTRACER_ANY); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| #!/usr/bin/env bash | ||
| # Preload helper for ptrace | ||
| export LD_PRELOAD="$(dirname "$0")/allow_ptrace.so" | ||
|
|
||
| # VS Code sets the env var R_RPATH_LINUX to the path from r.rpath.linux | ||
| if [ -n "${R_RPATH_LINUX:-}" ] && [ -x "$R_RPATH_LINUX" ]; then | ||
| R_BINARY="$R_RPATH_LINUX" | ||
| else | ||
| R_BINARY="/usr/bin/R" | ||
| fi | ||
|
|
||
| exec "$R_BINARY" "$@" | ||
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,21 +9,21 @@ local_script(){ | |
| WORK_DIR=$PWD | ||
| VSCODE_DIR="$WORK_DIR/.vscode" | ||
| DEVCONTAINER_JSON="$WORK_DIR/.devcontainer/devcontainer.json" | ||
| SCRIPTS_DIR="$WORK_DIR/scripts" | ||
|
|
||
| # Create patch directory in workspace root ($PWD at start) | ||
| PATCHDIR="$WORK_DIR/patches" | ||
| mkdir -p $PATCHDIR | ||
| mkdir -p $VSCODE_DIR | ||
|
|
||
| # Copy the which_r and set_build_r function definitions to .bashrc | ||
| cat $WORK_DIR/scripts/which_r.sh >> ~/.bashrc | ||
| cat $WORK_DIR/scripts/set_build_r.sh >> ~/.bashrc | ||
| cat $SCRIPTS_DIR/which_r.sh >> ~/.bashrc | ||
| cat $SCRIPTS_DIR/set_build_r.sh >> ~/.bashrc | ||
|
|
||
| # Copy over the welcome message script to be run when bash terminal starts | ||
| cat $WORK_DIR/scripts/welcome_msg.sh >> ~/.bashrc | ||
| cat $SCRIPTS_DIR/welcome_msg.sh >> ~/.bashrc | ||
|
|
||
| #bash ~/.bashrc | ||
|
|
||
| # Remove git directory if it exists | ||
| rm -rf .git | ||
|
|
||
|
|
@@ -38,3 +38,13 @@ fi | |
|
|
||
| # Run the main function | ||
| local_script | ||
|
|
||
| # Remove the .vscode/settings.json file if it exists so that | ||
| # it does not interfere with the devcontainer.json | ||
| rm -f "$WORK_DIR/.vscode/settings.json" | ||
|
||
|
|
||
| # 1. Build the ptrace helper library | ||
| gcc -shared -fPIC -o "$SCRIPTS_DIR/allow_ptrace.so" "$SCRIPTS_DIR/allow_ptrace.c" | ||
|
|
||
| # 2. Mark the wrapper executable | ||
| chmod +x "$SCRIPTS_DIR/launch_r.sh" | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please only change what is necessary in this file: edit line 63 so it only changes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think you need this, see below for getting the current version of R.