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:\rustc\b8cedc00407a4c56a3bda1ed605c6fc166655447的目录,并将用户目录下的.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\src\rust\src拷到前面的目录下。这样就能跟踪到内部代码了。
相关推荐
Yvettre 2020-09-15
gsl 2020-08-15
fushilin 2020-07-05
80296630 2020-07-04
shangs00 2020-06-09
小焊猪web前端 2020-11-04
changcongying 2020-11-02
azhedashuaibi 2020-09-15
zhongfuyu 2020-08-16
lichuanlong00 2020-08-15
mmwalker 2020-08-11
山有木兮卿有意 2020-08-03
Java编程语言学习 2020-07-29
举 2020-07-28
sshong 2020-07-19
风雨断肠人 2020-06-14
ningningmingming 2020-06-14
hualala 2020-06-13
choupiaoyi 2020-06-13