作者:多米音乐_34176403 | 来源:互联网 | 2023-08-06 15:03
方法一:用visualstudio 步骤:安装msvc工具链 rustuptoolchaininstallstable-x86_64-pc-windows-msvc切换到该工具链
方法一:
用visual studio
步骤:
安装msvc工具链 rustup toolchain install stable-x86_64-pc-windows-msvc
切换到该工具链 rustup default stable-x86_64-pc-windows-msvc
编译代码 F:\rust_test\t1>cargo build
Compiling t1 v0.1.0 (F:\rust_test\t1)
Finished dev [unoptimized + debuginfo] target(s) in 1.71s
调试F:\rust_test\t1>"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\devenv.exe" F:\rust_test\t1\target\debug\t1.exe
然后你就可以下断电了
方法二:用vscode
参考链接 https://www.brycevandyk.com/debug-rust-on-windows-with-visual-studio-code-and-the-msvc-debugger/
步骤
安装拓展
-
C/C++: Brings in support for debugging MSVC applications. Since we're using MSVC behind the scenes, this gives us some debugging support for our Rust programs.
-
Native Debug: Allows us to set breakpoints by clicking next to line numbers.
配置
遗留问题
在debug的时候vscode总是找不到代码
但是goto definition是对的
暂时解决方案: xcopy /c/d/e C:\Users\cutep\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\src\rust g:\rustc\fc50f328b0353b285421b8ff5d4100966387a997