[1/2] S390: Take value from sub-register if applicable
Commit Message
On an s390 target with vector registers store.exp emits various FAILs
while trying to access a variable located in an unwound floating-point
register. In those cases the variable's DWARF location happens to be
DW_OP_reg24, which refers to FP register f8 or to vector register v8,
depending on whether the target has vector registers. But while f8 is
call-saved and thus can be unwound by GDB, v8 is not. Thus an uplevel
variable with such a location can neither be read nor written.
A similar situation occurs on an s390 (32-bit) target with high GPRs.
For that case we already have logic in s390_unwind_pseudo_register which
unwinds a full GPR by casting its lower half to the larger type.
However, that cast does not result in an lvalue, so an uplevel variable
based on such a location is readable, but not writable. Again, this
results in various FAILs from store.exp.
Both issues are addressed with a change to the s390 implementation of
the gdbarch method 'value_from_register': If the given type is small
enough to fit in the appropriate sub-register, then take the value from
that sub-register instead of from the full register.
gdb/ChangeLog:
* s390-linux-tdep.c (s390_value_from_register): Use sub-register
if appropriate.
---
gdb/s390-linux-tdep.c | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
@@ -518,12 +518,18 @@ s390_value_from_register (struct gdbarch *gdbarch, struct type *type,
int regnum, struct frame_id frame_id)
{
struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
- struct value *value = default_value_from_register (gdbarch, type,
- regnum, frame_id);
- check_typedef (type);
+ unsigned int len = TYPE_LENGTH (check_typedef (type));
+ struct value *value;
- if ((regnum >= S390_F0_REGNUM && regnum <= S390_F15_REGNUM
- && TYPE_LENGTH (type) < 8)
+ /* If the value fits in a sub-register, use that instead. */
+ if (regnum_is_vxr_full (tdep, regnum) && len <= 8)
+ regnum = regnum - tdep->v0_full_regnum + S390_F0_REGNUM;
+ else if (regnum_is_gpr_full (tdep, regnum) && len <= 4)
+ regnum = regnum - tdep->gpr_full_regnum + S390_R0_REGNUM;
+
+ value = default_value_from_register (gdbarch, type, regnum, frame_id);
+
+ if ((regnum >= S390_F0_REGNUM && regnum <= S390_F15_REGNUM && len < 8)
|| regnum_is_vxr_full (tdep, regnum)
|| (regnum >= S390_V16_REGNUM && regnum <= S390_V31_REGNUM))
set_value_offset (value, 0);