简体   繁体   English

使用 rust-gdb 进行调试时,如何进入在返回值中调用的函数?

[英]How do I step into a function called in a return value when debugging with rust-gdb?

In the following code:在以下代码中:

match fnA(size) {
    Some(arr) => SomeBlock::new(size, &arr, false).as_ptr().add(1) as *mut c_void,
    None => ptr::null::<c_void>() as *mut c_void,
}

I want to use rust-gdb to step into SomeBlock::new(size, &arr, false) .我想使用rust-gdb进入SomeBlock::new(size, &arr, false) When I run it normally, I am able to step into fnA , but if I try to step when I'm on the line with Some(arr) , gdb just ends up running the rest of the program and exiting.当我正常运行它时,我能够进入fnA ,但是如果我在与Some(arr)联机时尝试单步执行, gdb只会运行程序的其余部分并退出。

I know I can directly insert a breakpoint at SomeBlock::new , but I was curious if there was a cleaner way of doing it.我知道我可以直接在SomeBlock::new插入断点,但我很好奇是否有更SomeBlock::new方法来做到这一点。

According to the GDB documentation on Rust :根据关于 Rust的 GDB文档

The Rust expression evaluator does not support “statement-like” expressions such as if or match , or lambda expressions. Rust 表达式评估器不支持“类似语句”的表达式,例如ifmatch ,或 lambda 表达式。

It seems that you cannot step into anything that is inside a match expression.似乎您无法进入match表达式中的任何内容。 Note that you can step into fnA as it is evaluated before its output gets matched inside the match block.请注意,您可以在fnA的输出在 match 块内匹配之前对其进行评估,因此您可以进入fnA

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM