windows下用vscode调试rust
Posted gelare
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了windows下用vscode调试rust相关的知识,希望对你有一定的参考价值。
1、vscode安装插件 C/C++ (ms-vscode.cpptools),安装后运行Run->Start Debugging会出现C++(GDB/LLDB)与C++(Windows)
2、根据rust用的版本,如果用的是x86_64-pc-windows-msvc,调试时选择C++(Windows), 如果是x86_64-pc-windows-gnu,调试时选择C++(GDB/LLDB)。
选择C++(Windows)时, 会出现如下配置信息(launch.json),自己修改program,设置要调试的程序。(安装visual studio)
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "(Windows) 启动",
"type": "cppvsdbg",
"request": "launch",
"program": "${workspaceFolder}/rust/rust-test/r019echo-async/target/debug/r019echo-async.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false
}
]
}
选择C++(GDB/LLDB)时,会出现下面的信息,自己设置要调试的程序与gdb所在的路径。(安装 mingw64)
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) 启动",
"type": "cppdbg",
"request": "launch",
"program": "输入程序名称,例如 ${workspaceFolder}/a.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"miDebuggerPath": "/path/to/gdb",
"setupCommands": [
{
"description": "为 gdb 启用整齐打印",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}
3、调试过程中,当要跟踪到rust内部代码时,会跳出如下提示框,这时需要建一个C:
ustc8cedc00407a4c56a3bda1ed605c6fc166655447的目录,并将用户目录下的.rustup oolchainsstable-x86_64-pc-windows-msvclib
ustlibsrc
ustsrc拷到前面的目录下。这样就能跟踪到内部代码了。
以上是关于windows下用vscode调试rust的主要内容,如果未能解决你的问题,请参考以下文章
Linux+STM32Linux下用CubeMX+VSCode点亮LED(STM32)
windows下用visual studio code 调试go代码
配置vscode远程免密登入Linux服务器
WINDOWS下用XWin32 连接Linux图形界面
vscode配置python环境-运行调试-windows环境
[日常] windows下使用vscode配合xebug调试php脚本