3 ms·
Could you clarify this comment a bit? Does GDB ever use current register contents to satisfy a request for a variable, or does it only use a value saved to the
by nkurz 8y ago
Could you clarify this comment a bit? Does GDB ever use current register contents to satisfy a request for a variable, or does it only use a value saved to the stack? That is, is the problem that you don't know when the register value is no longer valid, or that GDB doesn't actually associate the value with a register at all?
- DannyBee 8y agoSo, DWARF tries to provide extensive support for all possible options you can think of to do things like say "a variable is live int his range, have this value in this range, and is dead in this range" Over individual ranges, it even supports saying "this piece of the variable is in a register, this piece in memory, etc". Even at the per-bit level. You can evaluate complex turing-complete expressions to produce the value, including calling DWARF expression subroutines (the latter is fairly new) GDB supports them all. The underlying problem is multi-fold. 1. Computations get rewritten and rearranged in ways that do not affect the semantics of the program overall, but do of the intermediate states. IE if you rewrite a = b * 5 c = a * b as a = b * b c = a * 5 assuming b = 3 the intermediate value of a is now 9 but in terms of the original code it was 15 A value of 45 probably would just confuse the programmer. It is possible, with extensive enough tracking to solve the above problem for a significant set of cases However, code movement and rearrangement make it not feasible to solve it in all (particularly around heavy loop optimization). 2. Variables also get partially coalesced/eliminated all the time in other interesting ways. Turning applesauce back into apples is not possible in practice. I admit the theoretical possibility, but ...