Debug rust program as root in Vscode

Hi,

I know this in not a Rust programming language question but much probably you would use Vscode as Rust IDE.
Can anyone debug rust program as root in Vscode ?
I'm using the following configuration but doesn't work.

Tasks.json

{
    "tasks": [
        {
            "label": "Debug as root",
            "type": "shell",
            "command": "${workspaceFolder}/remote_debug.sh",
            "args": [ "${workspaceFolder}/target/debug/prova", "localhost", "17777" ],
            "group": "none",
        },
    ]
}

remote_debug.sh

#!/bin/sh

VSCODE_WS="$1"
SSH_REMOTE="$2"
GDBPORT="$3"
TARGET_USER="root"

ssh "${TARGET_USER}@${SSH_REMOTE}" "killall gdbserver"
ssh -f "${TARGET_USER}@${SSH_REMOTE}" "sh -c 'gdbserver *:${GDBPORT} ${VSCODE_WS} > /dev/null 2>&1 &'"

launch.json

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "lldb",
            "request": "custom",
            "name": "Debug 'prova' as root",
            "preLaunchTask": "Debug as root",
            "targetCreateCommands": ["target create ${workspaceFolder}/target/debug/prova"],
            "processCreateCommands": ["gdb-remote localhost:17777"]
        },
        {
            "type": "lldb",
            "request": "launch",
            "name": "Debug executable 'prova'",
            "cargo": {
                "args": [
                    "build",
                    "--bin=prova",
                    "--package=prova"
                ],
                "filter": {
                    "name": "prova",
                    "kind": "bin"
                }
            },
            "args": [],
            "cwd": "${workspaceFolder}"
        },
        {
            "type": "lldb",
            "request": "launch",
            "name": "Debug unit tests in executable 'prova'",
            "cargo": {
                "args": [
                    "test",
                    "--no-run",
                    "--bin=prova",
                    "--package=prova"
                ],
                "filter": {
                    "name": "prova",
                    "kind": "bin"
                }
            },
            "args": [],
            "cwd": "${workspaceFolder}"
        }
    ]
}

I am able to connect to the debug session but i cannot watch the source code.
Any advices?
Thanks in advance.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.