Debugger not showing/offering variables?

⚓ Rust    📅 2026-04-21    👤 surdeus    👁️ 2      

surdeus

Hard to tell if this is a DEBUGGER problem? I am using JetBrains RUST ROVER.

Or is this a COMPILER problem? Not generating a debug record for the variable.

Or is it due to a test case problem? ie: neither of the above.

The code in question (a snippit) reads as follows its part of a MUCH larger set of unit test things, my goal is to step through the unit test with the debugger {rustrover}

if (code & 2) != 0 {
    n = get_string(2, true);
    v = get_string(2, false);
    result = result - n.len() - v.len() - 2;
    let mut actual = dut.space_remain();
    if  actual != result {
        println!("fail -CODE: {}", code );
        dump_env( dut );
        dut.bb2.hexdump(128);
        assert!(false);
    }
}

The if( actual != result ) was originally a simple inline assert - that failed. To figure out what is going on, I want to step through it in the debugger.

In the debugger, I can not easily see the result "dut.space_remain()' - duh...

This has happened before, the solution is to assign it to a variable.

One of two things happen -(A) it works and shows up or (B) it does not show up

If that simple assignment does not produce a debugger variable, then if I change the variable to a MUT variable - it shows up [sometimes] in the debugger.

Well as you might guess, it still does not show up.

Having done compiler things in my past life, I would think there is a micro optimization going on between that assignment that drops the variable in debug/test mode.

As you can guess this is not a simple thing to reduce to a smaller reproducible problem :-(.

So suggestions would be helpful.

1 post - 1 participant

Read full topic

🏷️ Rust_feed