This is a patch that mimics GCC's behavior for location list entries
that are clobbered by calls. This is introduced in order to stop
variables that are described by call-clobbered registers and reside in
outer frames from being printable when performing virtual unwinding in
GDB.
GDB has no information about which registers are scratch registers and
which are preserved, but instead relies on the producer to describe
that. One way of solving that would be to emit DW_CFA_undefined
instructions for all scratch registers, but that would result in a lot
of CFI output.
When unwinding to an outer frame, GCC and LLDB subtract one byte from
the return address in order to get the correct scope for the call. GCC
utilizes that by subtracting one byte from the range for all variables
that are clobbered by the call. This means that such variables will be
printed as <optimized out> in GDB when performing virtual unwinding, but
the variables will still be printable when standing on the call before
executing it. This commit introduces the same behavior in LLVM's
location list code. This assumes that a call instruction is larger than
one byte.
LLDB has knowledge about which registers are preserved, so trimming the
ranges in this way is not valuable for LLDB, as far as I can tell. I
have therefore added this as a GDB tuning.
This fixes PR39752.