欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 汽车 > 时评 > rust 如何debug

rust 如何debug

2025/2/23 13:00:36 来源:https://blog.csdn.net/smz8023/article/details/140045603  浏览:    关键词:rust 如何debug

rust如何debug

  1. 如果创建的是一个二进制文件,并不是一个可执行文件
    比如使用napi-rs/cli 创建出来的一个xxxx.node文件
    我们想在vscode 中调试
    1.1 创建launch.json
{"version": "0.2.0","configurations": [{"type": "lldb","request": "launch","sourceLanguages": ["rust"],"name": "Debug example","program": "node","args": ["${workspaceFolder}/xxx.js"],"cwd": "${workspaceFolder}"}]}

1.2 下载vscode插件CodeLLDB
1.3 在vscode 的js文件中打断点就可以了

  1. 我们可以写一个examples文件夹
    文件夹下创建相关测试文件,例如:test.rs
    use xxxx:yyy
    fn main() {yyy()
    }
    
    我们生成一个可执行的文件
    cargo build
    
    此时会生成target/debug/xxx
    会生成一个可执行会见
    2.1 使用vscode 一键debug
    2.1.1 创建launch.json
    2.1.2
{
"version": "0.2.0",
"configurations": [{"name": "Debug Executable","type": "lldb","request": "launch","program": "${workspaceFolder}/target/debug/xxx","args": [],"cwd": "${workspaceFolder}","sourceLanguages": ["rust"]}
]
}

2.1.3 直接f5 执行debug
2.2 命令行 debug

rust-lldb target/debug/xxx
(lldb) breakpoint set --name main
(lldb) run

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

热搜词