Improve boostrap-ubsan config (PR bootstrap/64914).
[deliverable/binutils-gdb.git] / gdb / mips-linux-nat.c
index 4e0c51bd2dd998b5f094d56fd15e67a0a716fccb..beb0ea0a26a1c489265f01a41e2fcf79971a6e34 100644 (file)
@@ -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)
@@ -219,22 +224,14 @@ fill_gregset (const struct regcache *regcache,
 void
 supply_fpregset (struct regcache *regcache, const gdb_fpregset_t *fpregsetp)
 {
-  if (mips_isa_regsize (regcache->arch ()) == 4)
-    mips_supply_fpregset (regcache, (const mips_elf_fpregset_t *) fpregsetp);
-  else
-    mips64_supply_fpregset (regcache,
-                           (const mips64_elf_fpregset_t *) fpregsetp);
+  mips64_supply_fpregset (regcache, (const mips64_elf_fpregset_t *) fpregsetp);
 }
 
 void
 fill_fpregset (const struct regcache *regcache,
               gdb_fpregset_t *fpregsetp, int regno)
 {
-  if (mips_isa_regsize (regcache->arch ()) == 4)
-    mips_fill_fpregset (regcache, (mips_elf_fpregset_t *) fpregsetp, regno);
-  else
-    mips64_fill_fpregset (regcache,
-                         (mips64_elf_fpregset_t *) fpregsetp, regno);
+  mips64_fill_fpregset (regcache, (mips64_elf_fpregset_t *) fpregsetp, regno);
 }
 
 
@@ -273,7 +270,7 @@ mips_linux_nat_target::mips64_regsets_fetch_registers
   else
     is_dsp = 0;
 
-  tid = get_ptrace_pid (regcache_get_ptid (regcache));
+  tid = get_ptrace_pid (regcache->ptid ());
 
   if (regno == -1 || (!is_fp && !is_dsp))
     {
@@ -360,7 +357,7 @@ mips_linux_nat_target::mips64_regsets_store_registers
   else
     is_dsp = 0;
 
-  tid = get_ptrace_pid (regcache_get_ptid (regcache));
+  tid = get_ptrace_pid (regcache->ptid ());
 
   if (regno == -1 || (!is_fp && !is_dsp))
     {
@@ -416,7 +413,13 @@ mips_linux_nat_target::fetch_registers (struct regcache *regcache, int regnum)
   /* If we know, or just found out, that PTRACE_GETREGS does not work, fall
      back to PTRACE_PEEKUSER.  */
   if (!have_ptrace_regsets)
-    linux_nat_trad_target::fetch_registers (regcache, regnum);
+    {
+      linux_nat_trad_target::fetch_registers (regcache, regnum);
+
+      /* Fill the inaccessible zero register with zero.  */
+      if (regnum == MIPS_ZERO_REGNUM || regnum == -1)
+       regcache->raw_supply_zeroed (MIPS_ZERO_REGNUM);
+    }
 }
 
 /* Store REGNO (or all registers if REGNO == -1) to the target
This page took 0.024212 seconds and 4 git commands to generate.