Skip to content

VSCode调试Rust #141

@jht6

Description

@jht6

场景

Remote SSH 连接到 Ubuntu, 远程开发调试

步骤

安装CodeLLDB插件

https://github.com/vadimcn/codelldb/releases 下载离线插件包, 由于目标环境是Ubuntu, 需选择 linux 版

在插件面板的右上角的三个点按钮中, 选择 "从VSIX安装"

launch.json

{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "Debug Rust",
      "type": "lldb",
      "request": "launch",
      "program": "${workspaceFolder}/target/debug/anvil",
      "args": [],
      "cwd": "${workspaceFolder}",
      "preLaunchTask": "cargo-build-debug"
    }
  ]
}

tasks.json

{
  "version": "2.0.0",
  "tasks": [
    {
      "label": "cargo-build-debug",
      "type": "shell",
      "command": "cargo",
      "args": [
        "build",
        "--message-format=json"
      ],
      "group": {
        "kind": "build",
        "isDefault": true
      },
      "problemMatcher": [
        "$rustc"
      ],
      "presentation": {
        "reveal": "silent",
        "focus": false,
        "panel": "shared"
      },
      "options": {
        "cwd": "${workspaceFolder}"
      }
    }
  ]
}

Cargo.toml

确保dev时的debug配置:

[profile.dev]
debug = true

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions