News for hackers. Stuff that matters.
Re:How to read variables optimized out in GDB? by stefan_ on Tuesday October 11, 2022 @06:48PM (#33170271)
Having spent some time looking at DWARF data closely, I get the impression that there is an insane amount of information generated and the format can handle way way more complex scenarios than a simple "X is in register Y" - they got a full state machine and all in there. But the tools available.. simply do not consume it? I'm not entirely sure what the disconnect is.
Re:How to read variables optimized out in GDB? by usr1106 on Tuesday October 11, 2022 @07:13PM (#33170492)
I guess the problem is that variable is in the register only in the beginning of the function. It might overwritten later, that's why the author checks the assembly code.

I haven't looked at DWARF for ages. Can it describe the situation that a variable is valid (in some register) in the beginning of a function, but then goes "out of scope " in the middle of the function?

Re:How to read variables optimized out in GDB? by jmorse2 on Tuesday October 11, 2022 @08:13PM (#33171001)
> I haven't looked at DWARF for ages. Can it describe the situation that a variable is valid (in some register) in the beginning of a function, but then goes "out of scope " in the middle of the function?

Yes, with DW_OP_entry_value used in location expressions to indicate that the variable value is in a certain location on entry to the function. However -- debuggers typically don't store all register values on entry to all functions, so usually the stack frame up needs to be instrumented with call site information indicating where the debugger can find longer-term stored copies of the arguments.

In TFA you can see that happening correctly wherever there's a "@entry" annotation from gdb for an argument, in some cases there isn't a longer-term copy of the value further up the stack, in which case the variable remains optimised out.

Re:How to read variables optimized out in GDB? by khuey on Wednesday October 12, 2022 @01:18AM (#33173174)
The tools are perfectly capable of consuming it. Optimizers just don't emit it.