首页 > 解决方案 > 使用 vscode 调试 rust 程序时发生错误(仅限 Windows)

问题描述

我正在尝试使用 vscode 调试下面的代码,但出现错误。

开发环境

// Cargo.toml
//[dependencies]
//datafusion = "3.0.0"
//arrow = "3.0.0"
//tokio = { version = "0.2", features = ["macros", "blocking", "rt-core", "rt-threaded", "sync"] }


use std::time::{Duration, Instant};
use arrow::util::pretty;
use datafusion::error::Result;
use datafusion::prelude::*;

/// This example demonstrates executing a simple query against an Arrow data source (CSV) and
/// fetching results

#[tokio::main]
async fn main() -> Result<()> {
    println!("======== Start Program ========");
    let start = Instant::now();

    // let res_path = r"/root/workspace/project/hello_arrow/res/sample_01.csv";

    // http://insideairbnb.com/get-the-data.html
    // listing_id,id,date,reviewer_id,reviewer_name,comments
    // Boston, Massachusetts, United States
    let res_path = r"D:\workspace\vscode\arrow_rust\res\review.01.csv";

    // create local execution context
    let mut ctx = ExecutionContext::new();
    // register csv file with the execution context
    ctx.register_csv("datatable_01", res_path, CsvReadOptions::new())?;

    // execute the query
    let sql = "SELECT count(id) from datatable_01";
    let df = ctx.sql(sql)?;
    let results = df.collect().await?;

    // print the results
    pretty::print_batches(&results)?;

    let duration = start.elapsed();

    println!("Time elapsed in expensive_function() is: {:?}", duration);
    println!("======== End Program ========");
    Ok(())
}

错误代码

configuration: {
  type: 'lldb',
  request: 'launch',
  name: 'Debug Window',
  program: '${workspaceRoot}/target/debug/arrow_rust.exe',
  args: [],
  cwd: '${workspaceRoot}',
  sourceLanguages: [ 'rust' ],
  __configurationTarget: 5,
  relativePathBase: 'd:\\workspace\\vscode\\arrow_rust'
}
Listening on port 8541
error: arrow_rust.exe :: Class 'arrow::datatypes::DataType' has a member '__0' of type 'alloc::vec::Vec<arrow::datatypes::Field>' which does not have a complete definition.
Debug adapter exit code=3221225620, signal=null.

程序正常运行。在 Linux 上调试相同的代码。

有没有其他方法可以在 Windows 上进行调试?

标签: visual-studio-coderustvscode-debuggerapache-arrow

解决方案


我也有同样的问题。
受下面链接的启发,我已经解决了。

https://github.com/vadimcn/vscode-lldb/issues/410#issuecomment-786791796

原因是我安装了NVIDIA Nsight
如下图,Nsight的msdia140.dll已经被codelldb加载了。

msdia140.dll

以管理员身份运行 PowerShell。执行以下命令注册组件。然后 codelldb 工作。

regsvr32.exe C:\Users\【user name】\.vscode\extensions\vadimcn.vscode-lldb-1.6.8\lldb\bin\msdia140.dll

电源外壳


推荐阅读