Exemplo n.º 1
0
void
fetch_inferior_registers (int regno)
{
  int i;
  thread_t current_thread = ptid_get_tid (inferior_ptid);
  kern_return_t ret = KERN_SUCCESS;

  if (TARGET_OSABI == GDB_OSABI_UNKNOWN)
    arm_set_osabi_from_host_info ();
      
  if ((regno == -1) || ARM_MACOSX_IS_GP_RELATED_REGNUM (regno))
    {
      struct gdb_arm_thread_state gp_regs;
      unsigned int gp_count = GDB_ARM_THREAD_STATE_COUNT;
      ret = thread_get_state
        (current_thread, GDB_ARM_THREAD_STATE, (thread_state_t) & gp_regs,
         &gp_count);
      if (ret != KERN_SUCCESS)
       {
         printf ("Error calling thread_get_state for GP registers for thread 0x%ulx", 
		  current_thread);
         MACH_CHECK_ERROR (ret);
       }
      MACH_CHECK_ERROR (ret);
      arm_macosx_fetch_gp_registers (&gp_regs);
    }

  if ((regno == -1) || ARM_MACOSX_IS_FP_RELATED_REGNUM (regno))
    {
      /* We don't have F0-F7, though they need to exist in our register
         numbering scheme so we can connect to remote gdbserver's that use
	 FSF register numbers.  */
      for (i = ARM_F0_REGNUM; i <= ARM_F7_REGNUM; i++)
	set_register_cached (i, 1);
      set_register_cached (ARM_FPS_REGNUM, 1);
    }

  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;
	      mach_msg_type_number_t fp_count = GDB_ARM_THREAD_FPSTATE_VFPV1_COUNT;
	      ret = thread_get_state (current_thread, GDB_ARM_THREAD_FPSTATE,
                                     (thread_state_t) & fp_regs,
                                     &fp_count);
	      if (ret != KERN_SUCCESS)
		{
		  printf ("Error calling thread_get_state for VFP registers for thread 0x%ulx", 
			  current_thread);
		  MACH_CHECK_ERROR (ret);
		}
	      arm_macosx_fetch_vfpv1_regs (&fp_regs);
	    }
	    break;

	  case ARM_VFP_VERSION_3:
	    {
	      gdb_arm_thread_vfpv3_state_t fp_regs;
	      mach_msg_type_number_t fp_count = GDB_ARM_THREAD_FPSTATE_VFPV3_COUNT;
	      ret = thread_get_state (current_thread, GDB_ARM_THREAD_FPSTATE,
				      (thread_state_t) & fp_regs,
				      &fp_count);
	      if (ret != KERN_SUCCESS)
		{
		  printf ("Error calling thread_get_state for VFP registers for thread 0x%ulx", 
		          current_thread);
		  MACH_CHECK_ERROR (ret);
		}
	      arm_macosx_fetch_vfpv3_regs (&fp_regs);
	    }
	    break;

	  default:
	    error ("fetch_inferior_registers: unable to fetch ARM_THREAD_FPSTATE: "
		   "unsupported vfp version: %d", (int)vfp_version);
	    break;
	}
    }
}
Exemplo n.º 2
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) {
        ; /* ??? */
      }
  }
}