diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 82e249f5639..8d425a72a0d 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,9 @@ +2018-05-22 Maciej W. Rozycki + + * mips-linux-nat.c (mips64_linux_register_addr): Return -1 if + the width of the requested register exceeds the width of the + `ptrace' data type. + 2018-05-21 Tom Tromey * printcmd.c (output_command): Remove. diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog index 3c554571fbe..c577b3d0562 100644 --- a/gdb/gdbserver/ChangeLog +++ b/gdb/gdbserver/ChangeLog @@ -1,3 +1,10 @@ +2018-05-22 Maciej W. Rozycki + + * linux-mips-low.c (mips_cannot_fetch_register): Return 1 if the + width of the requested register exceeds the width of the + `ptrace' data type. + (mips_cannot_store_register): Likewise. + 2018-05-21 Maciej W. Rozycki * linux-mips-low.c (mips_fetch_register): New function. Update diff --git a/gdb/gdbserver/linux-mips-low.c b/gdb/gdbserver/linux-mips-low.c index ff87dd77d37..7fae2e69844 100644 --- a/gdb/gdbserver/linux-mips-low.c +++ b/gdb/gdbserver/linux-mips-low.c @@ -211,6 +211,10 @@ mips_cannot_fetch_register (int regno) tdesc = current_process ()->tdesc; + /* On n32 we can't access 64-bit registers via PTRACE_PEEKUSR. */ + if (register_size (tdesc, regno) > sizeof (PTRACE_XFER_TYPE)) + return 1; + if (find_regno (tdesc, "r0") == regno) return 1; @@ -227,6 +231,10 @@ mips_cannot_store_register (int regno) tdesc = current_process ()->tdesc; + /* On n32 we can't access 64-bit registers via PTRACE_POKEUSR. */ + if (register_size (tdesc, regno) > sizeof (PTRACE_XFER_TYPE)) + return 1; + if (find_regno (tdesc, "r0") == regno) return 1; diff --git a/gdb/mips-linux-nat.c b/gdb/mips-linux-nat.c index b1dbb798523..a9f0b790769 100644 --- a/gdb/mips-linux-nat.c +++ b/gdb/mips-linux-nat.c @@ -145,6 +145,11 @@ mips64_linux_register_addr (struct gdbarch *gdbarch, int regno, int store) if (regno < 0 || regno >= gdbarch_num_regs (gdbarch)) error (_("Bogon register number %d."), regno); + /* On n32 we can't access 64-bit registers via PTRACE_PEEKUSR + or PTRACE_POKEUSR. */ + if (register_size (gdbarch, regno) > sizeof (PTRACE_TYPE_RET)) + return (CORE_ADDR) -1; + if (regno > MIPS_ZERO_REGNUM && regno < MIPS_ZERO_REGNUM + 32) regaddr = regno; else if ((regno >= mips_regnum (gdbarch)->fp0)