[Dwarf-Discuss] Location list entries for caller-saved registers at time of call
david.stenberg at ericsson.com
Thu Dec 6 04:40:02 PST 2018
When GDB and LLDB perform virtual unwinding, they subtract one byte
from the return addresses of the outer frames. This is for example
necessary when unwinding from a non-returning call that is placed last
in the function, as the return address then can point to a different
function. I assume that this is also necessary to get the variables
that were in scope at the time of the call, and the right location
expressions for the variables, etc.
As far as I have understood it, GCC utilizes this fact for location
list entries that are expressed in caller-saved registers, by
subtracting one from the (exclusive) ending address of the entries.
This means that variables in outer frames that are located in caller-
saved registers will be printed out as <optimized out> by GDB.
I have not been able to find anything in the DWARF standard that
describes this. Is this something that is defined by standard, or is it
established praxis between GCC and GDB? If the latter, do you know of
other producers and consumers that behave like this?
The reason why I ask this is because Clang/LLVM at the moment ends
location list entries expressed in caller-saved registers at the first
instruction after the call. This means that variables in outer frames
using such location list entries will incorrectly be evaluated using
the inner-most frame's register values when debugging in GDB.
(As a side note, as far as I have understood it, LLDB has fallback
knowledge of the ABI, so caller-saved registers will be considered
unavailable in outer frames, meaning that such location list entries
are not an issue when combining Clang/LLVM and LLDB.)
More information about the Dwarf-Discuss