Windows上用VS Code调试Rust程序

以前看Parity源代码的时候,一直用GDB调试跟踪。幸亏以前有Unix/Linux编程的底子,否则用GDB想死的心都有。最近发现Microsoft的VS Code,非常不错。把过程记下来,备查

首先下载VSCode    

如果没有visual Studio的话,要下载Visual Studio Build Tool 2015  

其次,启动VS Code,安装Extension

  1. ext install C++  -- 安装C++(Windows)
  2. ext install Debug  -- 安装GDB,llDB
  3. ext install vscode-rust

然后,安装ToolChain

安装RLS参考:

 

rustup self update

rustup update nightly

rustup component add rls --toolchain nightly

rustup component add rust-analysis --toolchain nightly

rustup component add rust-src --toolchain nightly

rustup component add rust-src --toolchain stable

添加环境变量

set RUST_SRC_PATH=%USERPROFILE%.rustup\toolchains\stable-x86_64-pc-windows-gnu\lib\rustlib\src\rust\src

使用Cargo包管理器安装

cargo install racer

cargo install rustfmt

cargo install rustsym

WASM编译: 安装

rustup target add wasm32-unknown-emscripten stable

在VS Code中点击选择“Add Configuration", 这回自动在 .vscode目录下生成一个Launch.json。进行相应的修改,于本地环境相配。

这是我的Launch.json

{
    // 使用 IntelliSense 了解相关属性。 
    // 悬停以查看现有属性的描述。
    // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "(Windows) Launch",
            "type": "cppvsdbg",
            "request": "launch",
            "program": "C:/dev/Coins/parity-master/target/debug/parity.exe",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": true
        }
    ]
}

然后,编译RUST程序

     Cargo Build

114034_tOJa_2981977.png

 

点击绿色的"play"按钮,Hola...

112108_X9oy_2981977.png

 

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值