admin管理员组文章数量:1202391
I am using vscode+rust-analyzer+codelldb to debug rust code on Ubuntu server 24.04. I want to easily see values in a Dataframe or Series like what we usually do when debugging python pandas programs, but I can only get in vscode 'variable' window: enter image description here How can I see the values hold in a dataframe or series while debugging?
I tried use dbg! in debug console , only get msg: dbg!(amount) error: 'dbg' is not a valid command.
I posted an issue in polars project, I got the reply: This is really not a Polars specific problem. LLDB has long had problems pretty printing Rust structures. Rust provides a custom script to add pretty printing but I have never really had success with that.
I also tried rustrover, it do not provide the wanted feature.
Here is my test code:
use polars::prelude::*;
use rand::Rng;
fn main() -> Result<(), PolarsError> {
// Generate sample data with length 15
let mut rng = rand::thread_rng();
let amount: Vec<i32> = (0..15).map(|_| rng.gen_range(100..600)).collect();
let cond: Vec<bool> = (0..15).map(|_| rng.gen_bool(0.3)).collect();
let amount_series = Series::new("amount", amount);
let cond_series = Series::new("cond", cond);
let df = DataFrame::new(vec![
amount_series,
cond_series,
])?;
// I know this prints out df, but when debug hit breakpoints here, I can't see the data from vscode debug "variable" window
println!("{}", df);
Ok(())
}
I am using vscode+rust-analyzer+codelldb to debug rust code on Ubuntu server 24.04. I want to easily see values in a Dataframe or Series like what we usually do when debugging python pandas programs, but I can only get in vscode 'variable' window: enter image description here How can I see the values hold in a dataframe or series while debugging?
I tried use dbg! in debug console , only get msg: dbg!(amount) error: 'dbg' is not a valid command.
I posted an issue in polars project, I got the reply: This is really not a Polars specific problem. LLDB has long had problems pretty printing Rust structures. Rust provides a custom script to add pretty printing https://github.com/rust-lang/rust/blob/master/src/etc/rust-lldb but I have never really had success with that. https://github.com/pola-rs/polars/issues/20803
I also tried rustrover, it do not provide the wanted feature.
Here is my test code:
use polars::prelude::*;
use rand::Rng;
fn main() -> Result<(), PolarsError> {
// Generate sample data with length 15
let mut rng = rand::thread_rng();
let amount: Vec<i32> = (0..15).map(|_| rng.gen_range(100..600)).collect();
let cond: Vec<bool> = (0..15).map(|_| rng.gen_bool(0.3)).collect();
let amount_series = Series::new("amount", amount);
let cond_series = Series::new("cond", cond);
let df = DataFrame::new(vec![
amount_series,
cond_series,
])?;
// I know this prints out df, but when debug hit breakpoints here, I can't see the data from vscode debug "variable" window
println!("{}", df);
Ok(())
}
Share
Improve this question
asked Jan 21 at 7:44
Swamp RagerSwamp Rager
1
1 Answer
Reset to default 0lldb does not have native support for the Rust language or the Rust typesystem. That prohibits access to some of lldb's powerful features. For instance, it looks like dbg!
is some Rust construct that you want to call. Normally, the way you would access some printing function for values in your program would be to use the lldb expression parser
to actually call this function in the debugee:
(lldb) expr dbg!(amount)
However, because there isn't first-class Rust language support for lldb, there isn't a Rust expression parser. To the extent there is Rust support in lldb, it's limited to "telling lldb that Rust is close enough to C++ that you can use the C++ expression parser for Rust types". From what I hear that doesn't work terribly well.
The other support provided - as you mentioned - is that someone has provided some lldb "data formatters" which know how traverse the actual ivars of Rust datatypes and present them in some useful way.
In the current state of things, the data formatters (summary or synthetic child providers) are the main way to augment your view of your Rust datatypes. However, it doesn't seem like there are data formatters for the types you want to view. Depending on how hard the data structures you are interested in are to grok, it might not be too hard to write a formatter for them. That process is described here:
https://lldb.llvm.org/use/variable.html
本文标签: lldbHow can I see the values in dataframe or series when debug rust polars programStack Overflow
版权声明:本文标题:lldb - How can I see the values in dataframe or series when debug rust polars program? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1738647872a2104694.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论