Windows上用VS Code调试Rust 程序 : Parity源代码

https://blog.csdn.net/weixin_33709219/article/details/92672559

 

以前看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参考:

 

 
  1. rustup self update

  2.  
  3. rustup update nightly

  4.  
  5. rustup component add rls --toolchain nightly

  6.  
  7. rustup component add rust-analysis --toolchain nightly

  8.  
  9. rustup component add rust-src --toolchain nightly

  10.  
  11. rustup component add rust-src --toolchain stable

  12.  
  13. 添加环境变量

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

  16.  
  17. 使用Cargo包管理器安装

  18.  
  19. cargo install racer

  20.  
  21. cargo install rustfmt

  22.  
  23. cargo install rustsym

  24.  
  25. WASM编译: 安装

  26.  
  27. rustup target add wasm32-unknown-emscripten stable

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

这是我的Launch.json

 
  1. {

  2. // 使用 IntelliSense 了解相关属性。

  3. // 悬停以查看现有属性的描述。

  4. // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387

  5. "version": "0.2.0",

  6. "configurations": [

  7. {

  8. "name": "(Windows) Launch",

  9. "type": "cppvsdbg",

  10. "request": "launch",

  11. "program": "C:/dev/Coins/parity-master/target/debug/parity.exe",

  12. "args": [],

  13. "stopAtEntry": false,

  14. "cwd": "${workspaceFolder}",

  15. "environment": [],

  16. "externalConsole": true

  17. }

  18. ]

  19. }

然后,编译RUST程序

     Cargo Build

Windows上用VS Code调试Rust 程序 : Parity源代码

 

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

Windows上用VS Code调试Rust 程序 : Parity源代码

 

转载于:https://my.oschina.net/gavinzheng731/blog/1580801