Skip to content

Commit 1caee02

Browse files
author
Alex J Lennon
committed
feat(board_test): rsgdb.env + run_rsgdb_proxy for Cursor target overrides
Wire VS Code remote_ssh task to run_rsgdb_proxy.sh; source optional gitignored rsgdb.env for RSGDB_TARGET_HOST and friends. Add rsgdb.env.example; document. Made-with: Cursor
1 parent f861781 commit 1caee02

6 files changed

Lines changed: 72 additions & 6 deletions

File tree

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Example board test binary (built locally)
22
examples/board_test_app/board_test_app
3+
# Optional env overrides for Cursor/tasks (copy from rsgdb.env.example)
4+
examples/board_test_app/rsgdb.env
35

46
# Rust
57
/target/

.vscode/tasks.json

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,7 @@
2525
{
2626
"label": "rsgdb: remote_ssh proxy",
2727
"type": "shell",
28-
"command": "\"${workspaceFolder}/target/release/rsgdb\"",
29-
"args": [
30-
"--config",
31-
"${workspaceFolder}/examples/board_test_app/rsgdb.remote.toml"
32-
],
28+
"command": "\"${workspaceFolder}/examples/board_test_app/run_rsgdb_proxy.sh\"",
3329
"options": {
3430
"cwd": "${workspaceFolder}"
3531
},

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ rsgdb/
309309
├── src/ # Library + CLI
310310
├── tests/ # Integration tests
311311
├── .vscode/ # shared VS Code / Cursor: launch + tasks (board_test_app remote debug)
312-
├── examples/board_test_app/ # remote Linux target smoke (Makefile, rsgdb.remote.toml, helper scripts)
312+
├── examples/board_test_app/ # remote Linux target smoke (Makefile, rsgdb.remote.toml, rsgdb.env.example, run_rsgdb_proxy.sh)
313313
├── CHANGELOG.md
314314
├── RELEASING.md
315315
├── scripts/validate_local.sh

examples/board_test_app/README.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,47 @@ Before debugging with **`transport = remote_ssh`** (so `scp` + `ssh` work withou
1616
2. Confirm **`ssh`** to the target works without a password.
1717
3. Continue with **Build** and **Debug** below. See the main README **Setting up a Linux target for `remote_ssh` debugging** for the full project-wide checklist.
1818

19+
## Configure target IP, deploy, and debug
20+
21+
**Remote deploy + debug** is driven by [`rsgdb.remote.toml`](rsgdb.remote.toml): **`rsgdb`** **`scp`**s your built ELF to the board, **`ssh`** starts **`gdbserver`** there, then **GDB** (CLI or Cursor) talks to **`127.0.0.1:<listen_port>`** on your PC while the proxy forwards to the board.
22+
23+
### 1. Point at your board (IP, user, ports)
24+
25+
Edit **`examples/board_test_app/rsgdb.remote.toml`** (paths are relative to the **repo root** when you run **`rsgdb`** from there):
26+
27+
| Setting | Meaning |
28+
|--------|--------|
29+
| **`[proxy] target_host`** | Board **IP or hostname** (SSH and TCP target when **`[backend.remote_ssh] host`** is unset). |
30+
| **`[proxy] target_port`** | Port **`gdbserver`** listens on **on the board** (must match **`{port}`** in **`program`**). |
31+
| **`[proxy] listen_port`** | Port **on your PC** where **GDB** attaches (**`127.0.0.1:this`**). Default **3333** — if you change it, update [`.vscode/launch.json`](../../.vscode/launch.json) **`miDebuggerServerAddress`**. |
32+
| **`[backend.remote_ssh] user`** | SSH login on the target. |
33+
| **`upload_local` / `upload_remote`** | Host path → path on the board for **`scp`** before **`gdbserver`**. |
34+
| **`program`** | Remote command; must include **`{port}`** (same value as **`target_port`**). |
35+
36+
**Override IP/port without committing edits to the TOML** (applied after the file is loaded): create **`examples/board_test_app/rsgdb.env`** from [`rsgdb.env.example`](rsgdb.env.example) (that file is **gitignored**). Set **`RSGDB_TARGET_HOST`**, optional **`RSGDB_TARGET_PORT`**, **`RSGDB_PORT`**, or **`RSGDB_SSH_PASSWORD`**. Cursor’s preLaunch task runs [`run_rsgdb_proxy.sh`](run_rsgdb_proxy.sh), which **`source`**s **`rsgdb.env`** if present, then starts **`rsgdb`**.
37+
38+
```bash
39+
cp examples/board_test_app/rsgdb.env.example examples/board_test_app/rsgdb.env
40+
# edit IP / password in rsgdb.env
41+
```
42+
43+
### 2. Start debugging from Cursor
44+
45+
1. **`make`** / build **`board_test_app`** (the preLaunch task does this).
46+
2. Run **`rsgdb: board_test_app (build, start proxy, debug)`** — it starts **`rsgdb`** with this TOML, which **deploys** the binary and **starts gdbserver** on the target, then attaches **gdb-multiarch** to **localhost:3333** (or whatever **`listen_port`** / **`RSGDB_PORT`** you use).
47+
48+
If **`rsgdb`** is already running in a terminal with the right env/config, use **`rsgdb: board_test_app (proxy already running)`** instead.
49+
50+
### 3. Same flow on the CLI
51+
52+
```bash
53+
cd /path/to/rsgdb
54+
./examples/board_test_app/run_rsgdb_proxy.sh
55+
# or: export RSGDB_TARGET_HOST=… && ./target/release/rsgdb --config examples/board_test_app/rsgdb.remote.toml
56+
```
57+
58+
In another terminal: **`gdb-multiarch`****`target extended-remote 127.0.0.1:3333`** with **`file`** set to the ELF (see **Automated** debug section below).
59+
1960
## Build (aarch64 default)
2061

2162
The Makefile defaults to **`aarch64-linux-gnu-gcc`**:
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Copy to `rsgdb.env` in this directory (gitignored) and adjust.
2+
# Sourced by `run_rsgdb_proxy.sh` before starting rsgdb; overrides `rsgdb.remote.toml`
3+
# after load (see `Config::merge_env` in the rsgdb crate).
4+
#
5+
# cp examples/board_test_app/rsgdb.env.example examples/board_test_app/rsgdb.env
6+
7+
RSGDB_TARGET_HOST=192.168.2.139
8+
# RSGDB_TARGET_PORT=2345
9+
# RSGDB_PORT=3333
10+
# RSGDB_SSH_PASSWORD=
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/usr/bin/env bash
2+
# Start rsgdb with examples/board_test_app/rsgdb.remote.toml, optionally after
3+
# sourcing examples/board_test_app/rsgdb.env (gitignored). Used by .vscode/tasks.json.
4+
set -euo pipefail
5+
6+
ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
7+
cd "$ROOT"
8+
9+
ENV_FILE="${ROOT}/examples/board_test_app/rsgdb.env"
10+
if [[ -f "$ENV_FILE" ]]; then
11+
# shellcheck source=/dev/null
12+
set -a
13+
source "$ENV_FILE"
14+
set +a
15+
fi
16+
17+
exec "${ROOT}/target/release/rsgdb" --config "${ROOT}/examples/board_test_app/rsgdb.remote.toml"

0 commit comments

Comments
 (0)