Пример #1
0
void
store_inferior_registers (int regno)
{
  int current_pid;
  thread_t current_thread;

  current_pid = ptid_get_pid (inferior_ptid);
  current_thread = ptid_get_tid (inferior_ptid);

  validate_inferior_registers (regno);

  if ((regno == -1) || PPC_MACOSX_IS_GP_REGNUM (regno)
      || PPC_MACOSX_IS_GSP_REGNUM (regno))
    {
      gdb_ppc_thread_state_64_t gp_regs;
      kern_return_t ret;
      ppc_macosx_store_gp_registers_64 (&gp_regs);
      ret = thread_set_state (current_thread, GDB_PPC_THREAD_STATE_64,
                              (thread_state_t) & gp_regs,
                              GDB_PPC_THREAD_STATE_64_COUNT);
      MACH_CHECK_ERROR (ret);
    }

  if ((regno == -1) || PPC_MACOSX_IS_FP_REGNUM (regno)
      || PPC_MACOSX_IS_FSP_REGNUM (regno))
    {
      gdb_ppc_thread_fpstate_t fp_regs;
      kern_return_t ret;
      ppc_macosx_store_fp_registers (&fp_regs);
      ret = thread_set_state (current_thread, GDB_PPC_THREAD_FPSTATE,
                              (thread_state_t) & fp_regs,
                              GDB_PPC_THREAD_FPSTATE_COUNT);
      MACH_CHECK_ERROR (ret);
    }

  if ((regno == -1) || PPC_MACOSX_IS_VP_REGNUM (regno)
      || PPC_MACOSX_IS_VSP_REGNUM (regno))
    {
      gdb_ppc_thread_vpstate_t vp_regs;
      kern_return_t ret;
      ppc_macosx_store_vp_registers (&vp_regs);
      ret = thread_set_state (current_thread, GDB_PPC_THREAD_VPSTATE,
                              (thread_state_t) & vp_regs,
                              GDB_PPC_THREAD_VPSTATE_COUNT);
      MACH_CHECK_ERROR (ret);
    }
}
Пример #2
0
void
store_inferior_registers (int regno)
{
  int current_pid;
  thread_t current_thread;

  current_pid = ptid_get_pid (inferior_ptid);
  current_thread = ptid_get_tid (inferior_ptid);

  validate_inferior_registers (regno);

  if (TARGET_OSABI == GDB_OSABI_DARWIN64)
    {
      if ((regno == -1) || IS_GP_REGNUM_64 (regno))
        {
          gdb_x86_thread_state_t gp_regs;
          kern_return_t ret;
          gp_regs.tsh.flavor = GDB_x86_THREAD_STATE64;
          gp_regs.tsh.count = GDB_x86_THREAD_STATE64_COUNT;
          x86_64_macosx_store_gp_registers (&gp_regs.uts.ts64);
          ret = thread_set_state (current_thread, GDB_x86_THREAD_STATE,
                                  (thread_state_t) & gp_regs,
                                  GDB_x86_THREAD_STATE_COUNT);
          MACH_CHECK_ERROR (ret);
        }

      if ((regno == -1)
          || IS_FP_REGNUM_64 (regno)
          || IS_VP_REGNUM_64 (regno)
          || regno == REGS_64_MXCSR)
        {
          gdb_x86_float_state_t fp_regs;
          kern_return_t ret;
          fp_regs.fsh.flavor = GDB_x86_FLOAT_STATE64;
          fp_regs.fsh.count = GDB_x86_FLOAT_STATE64_COUNT;
          if (x86_64_macosx_store_fp_registers (&fp_regs.ufs.fs64))
            {
               ret = thread_set_state (current_thread, GDB_x86_FLOAT_STATE,
                                      (thread_state_t) & fp_regs,
                                      GDB_x86_FLOAT_STATE_COUNT);
               MACH_CHECK_ERROR (ret);
            }
        }
    }
  else
    {
      if ((regno == -1) || IS_GP_REGNUM (regno))
        {
          gdb_x86_thread_state_t gp_regs;
          kern_return_t ret;
          gp_regs.tsh.flavor = GDB_x86_THREAD_STATE32;
          gp_regs.tsh.count = GDB_x86_THREAD_STATE32_COUNT;
          i386_macosx_store_gp_registers (&(gp_regs.uts.ts32));
          ret = thread_set_state (current_thread, GDB_x86_THREAD_STATE,
                                  (thread_state_t) & gp_regs,
                                  GDB_x86_THREAD_STATE_COUNT);
          MACH_CHECK_ERROR (ret);
        }

      if ((regno == -1)
          || IS_FP_REGNUM (regno)
          || i386_sse_regnum_p (current_gdbarch, regno)
          || i386_mxcsr_regnum_p (current_gdbarch, regno))
        {
          gdb_i386_float_state_t fp_regs;
          kern_return_t ret;
          if (i386_macosx_store_fp_registers (&fp_regs))
            {
               ret = thread_set_state (current_thread, GDB_i386_FLOAT_STATE,
                                      (thread_state_t) & fp_regs,
                                      GDB_i386_FLOAT_STATE_COUNT);
               MACH_CHECK_ERROR (ret);
            }
        }
    }
}
Пример #3
0
void
store_inferior_registers (int regno)
{
  int current_pid;
  thread_t current_thread;
  kern_return_t ret;

  current_pid = ptid_get_pid (inferior_ptid);
  current_thread = ptid_get_tid (inferior_ptid);

  validate_inferior_registers (regno);

  if ((regno == -1) || ARM_MACOSX_IS_GP_RELATED_REGNUM (regno))
    {
      struct gdb_arm_thread_state gp_regs;
      arm_macosx_store_gp_registers (&gp_regs);
      ret = thread_set_state (current_thread, GDB_ARM_THREAD_STATE,
                              (thread_state_t) & gp_regs,
                              GDB_ARM_THREAD_STATE_COUNT);
      MACH_CHECK_ERROR (ret);
    }

  if ((regno == -1) || ARM_MACOSX_IS_VFP_RELATED_REGNUM (regno))
    {
      enum arm_vfp_version vfp_version;
      vfp_version = gdbarch_tdep (current_gdbarch)->vfp_version;
      int fp_byte_size = -1;

      switch (vfp_version)
	{
	  case ARM_VFP_UNSUPPORTED:
	    /* No VFP support, so nothing to do.  */
	    fp_byte_size = 0;
	    break;

	  case ARM_VFP_VERSION_1:
	    {
	      gdb_arm_thread_vfpv1_state_t fp_regs;
	      arm_macosx_store_vfpv1_regs (&fp_regs);
	      ret = thread_set_state (current_thread, GDB_ARM_THREAD_FPSTATE,
				      (thread_state_t) & fp_regs,
				      GDB_ARM_THREAD_FPSTATE_VFPV1_COUNT);
	      MACH_CHECK_ERROR (ret);
	    }
	    break;
	    
	  case ARM_VFP_VERSION_3:
	    {
	      gdb_arm_thread_vfpv3_state_t fp_regs;
	      arm_macosx_store_vfpv3_regs (&fp_regs);
	      ret = thread_set_state (current_thread, GDB_ARM_THREAD_FPSTATE,
				      (thread_state_t) & fp_regs,
				      GDB_ARM_THREAD_FPSTATE_VFPV3_COUNT);
	      MACH_CHECK_ERROR (ret);
            }
	    break;

 	  default:
	    error ("store_inferior_registers: unable to store ARM_THREAD_FPSTATE: "
		   "unsupported vfp version: %d", (int)vfp_version);
	    break;
	}
    }
}
/* Store our register values back into the inferior.
 * If REGNO is -1, do this for all registers.
 * Otherwise, REGNO specifies which register (so we can save time): */
void store_inferior_registers(int regno)
{
  int current_pid;
  thread_t current_thread;
  kern_return_t ret;

  current_pid = ptid_get_pid(inferior_ptid);
  current_thread = (thread_t)ptid_get_tid(inferior_ptid);

  if (current_pid == 0) {
    ; /* do nothing; just silence '-Wunused-but-set-variable' */
  }

  validate_inferior_registers(regno);

  if ((regno == -1) || ARM_MACOSX_IS_GP_RELATED_REGNUM(regno)) {
      struct gdb_arm_thread_state gp_regs;
      arm_macosx_store_gp_registers(&gp_regs);
      ret = thread_set_state(current_thread, GDB_ARM_THREAD_STATE,
                             (thread_state_t)&gp_regs,
                             GDB_ARM_THREAD_STATE_COUNT);
      MACH_CHECK_ERROR(ret);
  }

  if ((regno == -1) || ARM_MACOSX_IS_VFP_RELATED_REGNUM(regno)) {
      enum arm_vfp_version vfp_version;
      int fp_byte_size;
      vfp_version = new_gdbarch_tdep(current_gdbarch)->vfp_version;
      fp_byte_size = -1;

      switch (vfp_version) {
	  case ARM_VFP_UNSUPPORTED:
	    /* No VFP support, so nothing to do here: */
	    fp_byte_size = 0;
	    break;

	  case ARM_VFP_VERSION_1:
	    {
	      gdb_arm_thread_vfpv1_state_t fp_regs;
	      arm_macosx_store_vfpv1_regs(&fp_regs);
	      ret = thread_set_state(current_thread, GDB_ARM_THREAD_FPSTATE,
                                     (thread_state_t) & fp_regs,
                                     GDB_ARM_THREAD_FPSTATE_VFPV1_COUNT);
	      MACH_CHECK_ERROR(ret);
	    }
	    break;

	  case ARM_VFP_VERSION_3:
	    {
	      gdb_arm_thread_vfpv3_state_t fp_regs;
	      arm_macosx_store_vfpv3_regs(&fp_regs);
	      ret = thread_set_state(current_thread, GDB_ARM_THREAD_FPSTATE,
                                     (thread_state_t)&fp_regs,
                                     GDB_ARM_THREAD_FPSTATE_VFPV3_COUNT);
	      MACH_CHECK_ERROR(ret);
            }
	    break;

 	  default:
	    error("store_inferior_registers: unable to store ARM_THREAD_FPSTATE: "
                  "unsupported vfp version: %d", (int)vfp_version);
#ifndef __clang__
	    break;
#endif /* !__clang__ */
      }

      if (fp_byte_size >= 0) {
        ; /* ??? */
      }
  }
}