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



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值