简体   繁体   中英

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) . 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.

I know I can directly insert a breakpoint at SomeBlock::new , but I was curious if there was a cleaner way of doing it.

According to the GDB documentation on Rust :

The Rust expression evaluator does not support “statement-like” expressions such as if or match , or lambda expressions.

It seems that you cannot step into anything that is inside a match expression. Note that you can step into fnA as it is evaluated before its output gets matched inside the match block.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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