【问题标题】:Cannot debug Rust in Visual Studio Code?无法在 Visual Studio Code 中调试 Rust?
【发布时间】:2022-01-15 17:27:36
【问题描述】:

https://imgur.com/a/Xv5y23Z 单击确定后,它向我显示了这个 https://imgur.com/a/zJwt4dw 我的扩展 https://imgur.com/a/CF8mRRV 代码很简单,hello world

【问题讨论】:

    标签: visual-studio-2010 visual-studio-code rust


    【解决方案1】:

    不幸的是 VS Code 不能开箱即用地调试 Rust :(但不用担心,只需几个配置步骤即可完成工作:)

    步骤

    1. 如果您在 Windows 上安装 C/C++ extension,如果在 OS X/Linux 上安装 CodeLLDB

    2. 点击Debug -> Add Configuration,应该会打开一个launch.json文件,你需要在此处手动更改program名称

       {
           "version": "0.2.0",
           "configurations": [
               {
                   "name": "(Windows) Launch",
                   "type": "cppvsdbg",
                   "request": "launch",
                   "program": "${workspaceRoot}/target/debug/foo.exe",
                   "args": [],
                   "stopAtEntry": false,
                   "cwd": "${workspaceRoot}",
                   "environment": [],
                   "externalConsole": true
               },
               {
                   "name": "(OSX) Launch",
                   "type": "lldb",
                   "request": "launch",
                   "program": "${workspaceRoot}/target/debug/foo",
                   "args": [],
                   "cwd": "${workspaceRoot}",
               }
           ]
       }
      
    3. 确保 Allow setting breakpoints in any fileFile -> Preferences -> Settings

      下勾选

    详细步骤和更多可以参考the article我曾经回答过这个

    学分-福雷斯特·史密斯

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-10-23
      • 2017-12-18
      • 1970-01-01
      • 2021-02-01
      • 1970-01-01
      • 2020-06-09
      • 1970-01-01
      • 2022-06-24
      相关资源
      最近更新 更多