void
fill_gregset (gregset_t *gregsetp, int regno)
{
  int regi;
  greg_t *regp = &(*gregsetp)[0];
  LONGEST regval;

  /* Under Irix6, if GDB is built with N32 ABI and is debugging an O32
     executable, we have to sign extend the registers to 64 bits before
     filling in the gregset structure.  */

  for (regi = 0; regi <= CTX_RA; regi++)
    if ((regno == -1) || (regno == regi))
      {
        regcache_raw_read_signed (current_regcache, regi, &regval);
        *(regp + regi) = regval;
      }

  if ((regno == -1) || (regno == PC_REGNUM))
    {
      regcache_raw_read_signed
        (current_regcache, mips_regnum (current_gdbarch)->pc, &regval);
      *(regp + CTX_EPC) = regval;
    }

  if ((regno == -1) || (regno == mips_regnum (current_gdbarch)->cause))
    {
      regcache_raw_read_signed
        (current_regcache, mips_regnum (current_gdbarch)->cause, &regval);
      *(regp + CTX_CAUSE) = regval;
    }

  if ((regno == -1)
      || (regno == mips_regnum (current_gdbarch)->hi))
    {
      regcache_raw_read_signed
        (current_regcache, mips_regnum (current_gdbarch)->hi, &regval);
      *(regp + CTX_MDHI) = regval;
    }

  if ((regno == -1) || (regno == mips_regnum (current_gdbarch)->lo))
    {
      regcache_raw_read_signed
        (current_regcache, mips_regnum (current_gdbarch)->lo, &regval);
      *(regp + CTX_MDLO) = regval;
    }
}
static int
i386_linux_intx80_sysenter_syscall_record (struct regcache *regcache)
{
  int ret;
  LONGEST syscall_native;
  enum gdb_syscall syscall_gdb;

  regcache_raw_read_signed (regcache, I386_EAX_REGNUM, &syscall_native);

  syscall_gdb = i386_canonicalize_syscall (syscall_native);

  if (syscall_gdb < 0)
    {
      printf_unfiltered (_("Process record and replay target doesn't "
                           "support syscall number %s\n"), 
			 plongest (syscall_native));
      return -1;
    }

  if (syscall_gdb == gdb_sys_sigreturn
      || syscall_gdb == gdb_sys_rt_sigreturn)
   {
     if (i386_all_but_ip_registers_record (regcache))
       return -1;
     return 0;
   }

  ret = record_linux_system_call (syscall_gdb, regcache,
				  &i386_linux_record_tdep);
  if (ret)
    return ret;

  /* Record the return value of the system call.  */
  if (record_arch_list_add_reg (regcache, I386_EAX_REGNUM))
    return -1;

  return 0;
}