Example #1
0
/* All of this stuff is only relevant if both host and target are sun3.  */
void
fetch_inferior_registers ()
{
  struct regs inferior_registers;
#ifdef FP0_REGNUM
  struct fp_status inferior_fp_registers;
#endif
  extern char registers[];

  registers_fetched ();
  
  ptrace (PTRACE_GETREGS, inferior_pid,
	  (PTRACE_ARG3_TYPE) &inferior_registers, 0);
#ifdef FP0_REGNUM
  ptrace (PTRACE_GETFPREGS, inferior_pid,
	  (PTRACE_ARG3_TYPE) &inferior_fp_registers, 0);
#endif 
  
  bcopy (&inferior_registers, registers, 16 * 4);
#ifdef FP0_REGNUM
  bcopy (&inferior_fp_registers, &registers[REGISTER_BYTE (FP0_REGNUM)],
	 sizeof inferior_fp_registers.fps_regs);
#endif 
  *(int *)&registers[REGISTER_BYTE (PS_REGNUM)] = inferior_registers.r_ps;
  *(int *)&registers[REGISTER_BYTE (PC_REGNUM)] = inferior_registers.r_pc;
#ifdef FP0_REGNUM
  bcopy (&inferior_fp_registers.fps_control,
	 &registers[REGISTER_BYTE (FPC_REGNUM)],
	 sizeof inferior_fp_registers - sizeof inferior_fp_registers.fps_regs);
#endif 
}
Example #2
0
void
fetch_inferior_registers (int ignored)
{
  struct regs inferior_registers;
  struct fp_status inferior_fp_registers;

  ptrace (PTRACE_GETREGS, inferior_pid,
	  (PTRACE_ARG3_TYPE) & inferior_registers);
#ifdef FP0_REGNUM
  ptrace (PTRACE_GETFPREGS, inferior_pid,
	  (PTRACE_ARG3_TYPE) & inferior_fp_registers);
#endif /* FP0_REGNUM */

  memcpy (registers, &inferior_registers, 16 * 4);
#ifdef FP0_REGNUM
  memcpy (&registers[REGISTER_BYTE (FP0_REGNUM)], &inferior_fp_registers,
	  sizeof inferior_fp_registers.fps_regs);
#endif /* FP0_REGNUM */
  *(int *) &registers[REGISTER_BYTE (PS_REGNUM)] = inferior_registers.r_ps;
  *(int *) &registers[REGISTER_BYTE (PC_REGNUM)] = inferior_registers.r_pc;
#ifdef FP0_REGNUM
  memcpy
    (&registers[REGISTER_BYTE (FPC_REGNUM)],
     &inferior_fp_registers.fps_control,
     sizeof inferior_fp_registers - sizeof inferior_fp_registers.fps_regs);
#endif /* FP0_REGNUM */
}
Example #3
0
void
store_inferior_registers (int regno)
{
    struct regs inferior_registers;
    struct fp_status inferior_fp_registers;

    memcpy (&inferior_registers, registers, 16 * 4);
    if (FP0_REGNUM >= 0)
        memcpy (&inferior_fp_registers, &registers[REGISTER_BYTE (FP0_REGNUM)],
                sizeof inferior_fp_registers.fps_regs);

    inferior_registers.r_ps = *(int *) &registers[REGISTER_BYTE (PS_REGNUM)];
    inferior_registers.r_pc = *(int *) &registers[REGISTER_BYTE (PC_REGNUM)];

    if (FP0_REGNUM >= 0)
        memcpy (&inferior_fp_registers.fps_control,
                &registers[REGISTER_BYTE (FPC_REGNUM)],
                sizeof inferior_fp_registers -
                sizeof inferior_fp_registers.fps_regs);

    ptrace (PTRACE_SETREGS, PIDGET (inferior_ptid),
            (PTRACE_ARG3_TYPE) & inferior_registers);
    if (FP0_REGNUM >= 0)
        ptrace (PTRACE_SETFPREGS, PIDGET (inferior_ptid),
                (PTRACE_ARG3_TYPE) & inferior_fp_registers);
}
Example #4
0
void
fetch_inferior_registers (int regno)
{
    struct regs inferior_registers;
    struct fp_status inferior_fp_registers;

    registers_fetched ();

    ptrace (PTRACE_GETREGS, PIDGET (inferior_ptid),
            (PTRACE_ARG3_TYPE) & inferior_registers);

    if (FP0_REGNUM >= 0)
        ptrace (PTRACE_GETFPREGS, PIDGET (inferior_ptid),
                (PTRACE_ARG3_TYPE) & inferior_fp_registers);

    memcpy (registers, &inferior_registers, 16 * 4);
    if (FP0_REGNUM >= 0)
        memcpy (&registers[REGISTER_BYTE (FP0_REGNUM)], &inferior_fp_registers,
                sizeof inferior_fp_registers.fps_regs);

    *(int *) &registers[REGISTER_BYTE (PS_REGNUM)] = inferior_registers.r_ps;
    *(int *) &registers[REGISTER_BYTE (PC_REGNUM)] = inferior_registers.r_pc;
    if (FP0_REGNUM >= 0)
        memcpy (&registers[REGISTER_BYTE (FPC_REGNUM)],
                &inferior_fp_registers.fps_control,
                sizeof inferior_fp_registers -
                sizeof inferior_fp_registers.fps_regs);
}
Example #5
0
void
store_inferior_registers (int ignored)
{
  struct regs inferior_registers;
  struct fp_status inferior_fp_registers;

  memcpy (&inferior_registers, registers, 16 * 4);
#ifdef FP0_REGNUM
  memcpy (&inferior_fp_registers,
	  &registers[REGISTER_BYTE (FP0_REGNUM)],
	  sizeof inferior_fp_registers.fps_regs);
#endif /* FP0_REGNUM */
  inferior_registers.r_ps = *(int *) &registers[REGISTER_BYTE (PS_REGNUM)];
  inferior_registers.r_pc = *(int *) &registers[REGISTER_BYTE (PC_REGNUM)];

#ifdef FP0_REGNUM
  memcpy (&inferior_fp_registers.fps_control,
	  &registers[REGISTER_BYTE (FPC_REGNUM)],
	  (sizeof inferior_fp_registers
	   - sizeof inferior_fp_registers.fps_regs));
#endif /* FP0_REGNUM */

  ptrace (PTRACE_SETREGS, inferior_pid,
	  (PTRACE_ARG3_TYPE) & inferior_registers);
#if FP0_REGNUM
  ptrace (PTRACE_SETFPREGS, inferior_pid,
	  (PTRACE_ARG3_TYPE) & inferior_fp_registers);
#endif /* FP0_REGNUM */
}
Example #6
0
static void
mn10300_store_return_value (struct type *type, char *valbuf)
{
  if (TYPE_CODE (type) == TYPE_CODE_PTR)
    write_register_bytes (REGISTER_BYTE (4), valbuf, TYPE_LENGTH (type));
  else
    write_register_bytes (REGISTER_BYTE (0), valbuf, TYPE_LENGTH (type));
}
Example #7
0
static void
mn10300_extract_return_value (struct type *type, char *regbuf, char *valbuf)
{
  if (TYPE_CODE (type) == TYPE_CODE_PTR)
    memcpy (valbuf, regbuf + REGISTER_BYTE (4), TYPE_LENGTH (type));
  else
    memcpy (valbuf, regbuf + REGISTER_BYTE (0), TYPE_LENGTH (type));
}
Example #8
0
static void
fetch_core_registers (char *core_reg_sect, unsigned core_reg_size,
		      int which, CORE_ADDR ignore)
{

  if (which == 0)
    {

      /* Integer registers */

#define gregs ((struct regs *)core_reg_sect)
      /* G0 *always* holds 0.  */
      *(int *) &registers[REGISTER_BYTE (0)] = 0;

      /* The globals and output registers.  */
      memcpy (&registers[REGISTER_BYTE (G1_REGNUM)], &gregs->r_g1,
	      15 * REGISTER_RAW_SIZE (G1_REGNUM));
      *(int *) &registers[REGISTER_BYTE (PS_REGNUM)] = gregs->r_ps;
      *(int *) &registers[REGISTER_BYTE (PC_REGNUM)] = gregs->r_pc;
      *(int *) &registers[REGISTER_BYTE (NPC_REGNUM)] = gregs->r_npc;
      *(int *) &registers[REGISTER_BYTE (Y_REGNUM)] = gregs->r_y;

      /* My best guess at where to get the locals and input
         registers is exactly where they usually are, right above
         the stack pointer.  If the core dump was caused by a bus error
         from blowing away the stack pointer (as is possible) then this
         won't work, but it's worth the try. */
      {
	int sp;

	sp = *(int *) &registers[REGISTER_BYTE (SP_REGNUM)];
	if (0 != target_read_memory (sp, &registers[REGISTER_BYTE (L0_REGNUM)],
				     16 * REGISTER_RAW_SIZE (L0_REGNUM)))
	  {
	    /* fprintf_unfiltered so user can still use gdb */
	    fprintf_unfiltered (gdb_stderr,
		"Couldn't read input and local registers from core file\n");
	  }
      }
    }
  else if (which == 2)
    {

      /* Floating point registers */

#define fpuregs  ((struct fpu *) core_reg_sect)
      if (core_reg_size >= sizeof (struct fpu))
	{
	  memcpy (&registers[REGISTER_BYTE (FP0_REGNUM)], fpuregs->fpu_regs,
		  sizeof (fpuregs->fpu_regs));
	  memcpy (&registers[REGISTER_BYTE (FPS_REGNUM)], &fpuregs->fpu_fsr,
		  sizeof (FPU_FSR_TYPE));
	}
      else
	fprintf_unfiltered (gdb_stderr, "Couldn't read float regs from core file\n");
    }
}
Example #9
0
void
store_inferior_registers (int regno)
{
  register unsigned int regaddr;
  char buf[80];
  register int i;
  unsigned int offset = U_REGS_OFFSET;
  int scratch;

  if (regno >= 0)
    {
      if (CANNOT_STORE_REGISTER (regno))
	return;
      regaddr = register_addr (regno, offset);
      errno = 0;
      if (regno == PCOQ_HEAD_REGNUM || regno == PCOQ_TAIL_REGNUM)
	{
	  scratch = *(int *) &registers[REGISTER_BYTE (regno)] | 0x3;
	  ptrace (PT_WUREGS, PIDGET (inferior_ptid), (PTRACE_ARG3_TYPE) regaddr,
		  scratch);
	  if (errno != 0)
	    {
	      /* Error, even if attached.  Failing to write these two
	         registers is pretty serious.  */
	      sprintf (buf, "writing register number %d", regno);
	      perror_with_name (buf);
	    }
	}
      else
	for (i = 0; i < REGISTER_RAW_SIZE (regno); i += sizeof (int))
	  {
	    errno = 0;
	    ptrace (PT_WUREGS, PIDGET (inferior_ptid),
	            (PTRACE_ARG3_TYPE) regaddr,
		    *(int *) &registers[REGISTER_BYTE (regno) + i]);
	    if (errno != 0)
	      {
		/* Warning, not error, in case we are attached; sometimes the
		   kernel doesn't let us at the registers.  */
		char *err = safe_strerror (errno);
		char *msg = alloca (strlen (err) + 128);
		sprintf (msg, "writing register %s: %s",
			 REGISTER_NAME (regno), err);
		warning (msg);
		return;
	      }
	    regaddr += sizeof (int);
	  }
    }
  else
    for (regno = 0; regno < NUM_REGS; regno++)
      store_inferior_registers (regno);
}
Example #10
0
static void
fetch_core_registers (char *core_reg_sect, unsigned core_reg_size, int which,
                      CORE_ADDR ignore)
{
    struct md_core *core_reg = (struct md_core *) core_reg_sect;

    /* Integer registers */
    memcpy (&registers[REGISTER_BYTE (0)],
            &core_reg->intreg, sizeof (struct reg));
    /* Floating point registers */
    memcpy (&registers[REGISTER_BYTE (FP0_REGNUM)],
            &core_reg->freg, sizeof (struct fpreg));
}
Example #11
0
void
store_inferior_registers (int ignored)
{
  struct regs inferior_registers;
  struct fp_status inferior_fp_registers;
  CORE_ADDR sp = *(CORE_ADDR *) & registers[REGISTER_BYTE (SP_REGNUM)];

  write_inferior_memory (sp, &registers[REGISTER_BYTE (L0_REGNUM)],
			 16 * REGISTER_RAW_SIZE (L0_REGNUM));

  memcpy (&inferior_registers.r_g1, &registers[REGISTER_BYTE (G1_REGNUM)],
	  15 * REGISTER_RAW_SIZE (G1_REGNUM));

  inferior_registers.r_ps =
    *(int *) &registers[REGISTER_BYTE (PS_REGNUM)];
  inferior_registers.r_pc =
    *(int *) &registers[REGISTER_BYTE (PC_REGNUM)];
  inferior_registers.r_npc =
    *(int *) &registers[REGISTER_BYTE (NPC_REGNUM)];
  inferior_registers.r_y =
    *(int *) &registers[REGISTER_BYTE (Y_REGNUM)];

  if (ptrace (PTRACE_SETREGS, inferior_pid,
	      (PTRACE_ARG3_TYPE) & inferior_registers, 0))
    perror ("ptrace_setregs");

  memcpy (&inferior_fp_registers, &registers[REGISTER_BYTE (FP0_REGNUM)],
	  sizeof inferior_fp_registers.fpu_fr);

  if (ptrace (PTRACE_SETFPREGS, inferior_pid,
	      (PTRACE_ARG3_TYPE) & inferior_fp_registers, 0))
    perror ("ptrace_setfpregs");
}
Example #12
0
void
store_inferior_registers (int regno)
{
  struct ptrace_$data_regs_m68k inferior_registers;
  struct ptrace_$floating_regs_m68k inferior_fp_registers;
  struct ptrace_$control_regs_m68k inferior_control_registers;

  ptrace_$init_control (&inferior_control_registers);
  inferior_fp_registers.size = sizeof (inferior_fp_registers);

  ptrace (PTRACE_GETREGS, PIDGET (inferior_ptid),
	  (PTRACE_ARG3_TYPE) & inferior_fp_registers,
	  ptrace_$floating_set_m68k,
	  (PTRACE_ARG3_TYPE) & inferior_fp_registers,
	  ptrace_$floating_set_m68k);

  ptrace (PTRACE_GETREGS, PIDGET (inferior_ptid),
	  (PTRACE_ARG3_TYPE) & inferior_control_registers,
	  ptrace_$control_set_m68k,
	  (PTRACE_ARG3_TYPE) & inferior_control_registers,
	  ptrace_$control_set_m68k);

  bcopy (registers, &inferior_registers, sizeof (inferior_registers));

  bcopy (&registers[REGISTER_BYTE (FP0_REGNUM)], inferior_fp_registers.regs,
	 sizeof inferior_fp_registers.regs);

  inferior_control_registers.sr = *(int *) &registers[REGISTER_BYTE (PS_REGNUM)];
  inferior_control_registers.pc = *(int *) &registers[REGISTER_BYTE (PC_REGNUM)];

  ptrace (PTRACE_SETREGS, PIDGET (inferior_ptid),
	  (PTRACE_ARG3_TYPE) & inferior_registers,
	  ptrace_$data_set_m68k,
	  (PTRACE_ARG3_TYPE) & inferior_registers,
	  ptrace_$data_set_m68k);

  ptrace (PTRACE_SETREGS, PIDGET (inferior_ptid),
	  (PTRACE_ARG3_TYPE) & inferior_fp_registers,
	  ptrace_$floating_set_m68k,
	  (PTRACE_ARG3_TYPE) & inferior_fp_registers,
	  ptrace_$floating_set_m68k);

  ptrace (PTRACE_SETREGS, PIDGET (inferior_ptid),
	  (PTRACE_ARG3_TYPE) & inferior_control_registers,
	  ptrace_$control_set_m68k,
	  (PTRACE_ARG3_TYPE) & inferior_control_registers,
	  ptrace_$control_set_m68k);
}
Example #13
0
void
fetch_inferior_registers (int regno)
{
  struct reg inferior_registers;
  struct fpreg inferior_fp_registers;

  ptrace (PT_GETREGS, inferior_pid,
          (PTRACE_ARG3_TYPE) & inferior_registers, 0);
  memcpy (&registers[REGISTER_BYTE (0)], &inferior_registers,
          sizeof (inferior_registers));

  ptrace (PT_GETFPREGS, inferior_pid,
          (PTRACE_ARG3_TYPE) & inferior_fp_registers, 0);
  memcpy (&registers[REGISTER_BYTE (FP0_REGNUM)], &inferior_fp_registers,
          sizeof (inferior_fp_registers));
}
Example #14
0
void
store_inferior_registers (int regno)
{
    struct reg inferior_registers;
    struct fpreg inferior_fp_registers;

    memcpy (&inferior_registers, &registers[REGISTER_BYTE (0)],
            sizeof (inferior_registers));
    ptrace (PT_SETREGS, PIDGET (inferior_ptid),
            (PTRACE_ARG3_TYPE) & inferior_registers, 0);

    memcpy (&inferior_fp_registers, &registers[REGISTER_BYTE (FP0_REGNUM)],
            sizeof (inferior_fp_registers));
    ptrace (PT_SETFPREGS, PIDGET (inferior_ptid),
            (PTRACE_ARG3_TYPE) & inferior_fp_registers, 0);
}
Example #15
0
void
microblaze_store_return_value (struct type *type, char *valbuf)
{
  int value_size;
  int return_size;
  int offset;
  char *zeros;

  value_size = TYPE_LENGTH (type);

  /* Return value fits into registers. */
  return_size = (value_size + REGISTER_SIZE - 1) & ~(REGISTER_SIZE - 1);
  offset = REGISTER_BYTE (RETVAL_REGNUM) + (return_size - value_size);
  zeros = alloca (return_size);
  memset (zeros, 0, return_size);

  write_register_bytes (REGISTER_BYTE (RETVAL_REGNUM), zeros, return_size);
  write_register_bytes (offset, valbuf, value_size);
}
Example #16
0
CORE_ADDR
generic_read_register_dummy (CORE_ADDR pc, CORE_ADDR fp, int regno)
{
  char *dummy_regs = generic_find_dummy_frame (pc, fp);

  if (dummy_regs)
    return extract_address (&dummy_regs[REGISTER_BYTE (regno)],
			    REGISTER_RAW_SIZE (regno));
  else
    return 0;
}
Example #17
0
void
store_inferior_registers (int regno)
{
  if (regno == -1)
    {
      for (regno = 0; regno < NUM_REGS; regno++)
	store_inferior_registers (regno);
    }
  else
    sim_store_register (gdbsim_desc, regno, &registers[REGISTER_BYTE (regno)],
			REGISTER_RAW_SIZE (regno));
}
Example #18
0
static void
fetch_core_registers (char *core_reg_sect, unsigned core_reg_size,
                      int which, CORE_ADDR reg_addr)
{
    struct regs *regs = (struct regs *) core_reg_sect;

    if (which == 0)
    {
        if (core_reg_size < sizeof (struct regs))
            error ("Can't find registers in core file");

        memcpy (registers, (char *) regs, 16 * 4);
        supply_register (PS_REGNUM, (char *) &regs->r_ps);
        supply_register (PC_REGNUM, (char *) &regs->r_pc);

    }
    else if (which == 2)
    {

#define fpustruct  ((struct fpu *) core_reg_sect)

        if (core_reg_size >= sizeof (struct fpu))
        {
            if (FP0_REGNUM >= 0)
            {
                memcpy (&registers[REGISTER_BYTE (FP0_REGNUM)],
                        fpustruct->f_fpstatus.fps_regs,
                        sizeof fpustruct->f_fpstatus.fps_regs);
                memcpy (&registers[REGISTER_BYTE (FPC_REGNUM)],
                        &fpustruct->f_fpstatus.fps_control,
                        sizeof fpustruct->f_fpstatus -
                        sizeof fpustruct->f_fpstatus.fps_regs);
            }
        }
        else
            fprintf_unfiltered (gdb_stderr,
                                "Couldn't read float regs from core file\n");
    }
}
Example #19
0
void
fill_gregset (gregset_t *gregsetp, int regno)
{
  int regi;

  for (regi = 0; regi < NUM_REGS; regi++)
    {
      if ((regno == -1) || (regno == regi))
	{
	  (*gregsetp)[regi] = *(greg_t *) & registers[REGISTER_BYTE (regi)];
	}
    }
}
Example #20
0
void
fetch_inferior_registers (int ignored)
{
  struct regs inferior_registers;
  struct fp_status inferior_fp_registers;
  int i;

  /* Global and Out regs are fetched directly, as well as the control
     registers.  If we're getting one of the in or local regs,
     and the stack pointer has not yet been fetched,
     we have to do that first, since they're found in memory relative
     to the stack pointer.  */

  if (ptrace (PTRACE_GETREGS, inferior_pid,
	      (PTRACE_ARG3_TYPE) & inferior_registers, 0))
    perror ("ptrace_getregs");

  registers[REGISTER_BYTE (0)] = 0;
  memcpy (&registers[REGISTER_BYTE (1)], &inferior_registers.r_g1,
	  15 * REGISTER_RAW_SIZE (G0_REGNUM));
  *(int *) &registers[REGISTER_BYTE (PS_REGNUM)] = inferior_registers.r_ps;
  *(int *) &registers[REGISTER_BYTE (PC_REGNUM)] = inferior_registers.r_pc;
  *(int *) &registers[REGISTER_BYTE (NPC_REGNUM)] = inferior_registers.r_npc;
  *(int *) &registers[REGISTER_BYTE (Y_REGNUM)] = inferior_registers.r_y;

  /* Floating point registers */

  if (ptrace (PTRACE_GETFPREGS, inferior_pid,
	      (PTRACE_ARG3_TYPE) & inferior_fp_registers,
	      0))
    perror ("ptrace_getfpregs");
  memcpy (&registers[REGISTER_BYTE (FP0_REGNUM)], &inferior_fp_registers,
	  sizeof inferior_fp_registers.fpu_fr);

  /* These regs are saved on the stack by the kernel.  Only read them
     all (16 ptrace calls!) if we really need them.  */

  read_inferior_memory (*(CORE_ADDR *) & registers[REGISTER_BYTE (SP_REGNUM)],
			&registers[REGISTER_BYTE (L0_REGNUM)],
			16 * REGISTER_RAW_SIZE (L0_REGNUM));
}
Example #21
0
/* FIXME rearnsha/2002-02-23: This function shouldn't be necessary.
   The ARM generic one should be able to handle the model used by
   linux and the low-level formatting of the registers should be
   hidden behind the regcache abstraction.  */
static void
arm_linux_extract_return_value (struct type *type,
				char regbuf[REGISTER_BYTES],
				char *valbuf)
{
  /* ScottB: This needs to be looked at to handle the different
     floating point emulators on ARM GNU/Linux.  Right now the code
     assumes that fetch inferior registers does the right thing for
     GDB.  I suspect this won't handle NWFPE registers correctly, nor
     will the default ARM version (arm_extract_return_value()).  */

  int regnum = ((TYPE_CODE_FLT == TYPE_CODE (type))
		? ARM_F0_REGNUM : ARM_A1_REGNUM);
  memcpy (valbuf, &regbuf[REGISTER_BYTE (regnum)], TYPE_LENGTH (type));
}
Example #22
0
void
fetch_inferior_registers (int ignored)
{
  struct ptrace_$data_regs_m68k inferior_registers;
  struct ptrace_$floating_regs_m68k inferior_fp_registers;
  struct ptrace_$control_regs_m68k inferior_control_registers;

  ptrace_$init_control (&inferior_control_registers);
  inferior_fp_registers.size = sizeof (inferior_fp_registers);

  registers_fetched ();

  ptrace (PTRACE_GETREGS, PIDGET (inferior_ptid),
	  (PTRACE_ARG3_TYPE) & inferior_registers,
	  ptrace_$data_set,
	  (PTRACE_ARG3_TYPE) & inferior_registers,
	  ptrace_$data_set);

  ptrace (PTRACE_GETREGS, PIDGET (inferior_ptid),
	  (PTRACE_ARG3_TYPE) & inferior_fp_registers,
	  ptrace_$floating_set_m68k,
	  (PTRACE_ARG3_TYPE) & inferior_fp_registers,
	  ptrace_$floating_set_m68k);

  ptrace (PTRACE_GETREGS, PIDGET (inferior_ptid),
	  (PTRACE_ARG3_TYPE) & inferior_control_registers,
	  ptrace_$control_set_m68k,
	  (PTRACE_ARG3_TYPE) & inferior_control_registers,
	  ptrace_$control_set_m68k);

  bcopy (&inferior_registers, registers, 16 * 4);
  bcopy (&inferior_fp_registers, &registers[REGISTER_BYTE (FP0_REGNUM)],
	 sizeof inferior_fp_registers.regs);
  *(int *) &registers[REGISTER_BYTE (PS_REGNUM)] = inferior_control_registers.sr;
  *(int *) &registers[REGISTER_BYTE (PC_REGNUM)] = inferior_control_registers.pc;
}
Example #23
0
void
store_inferior_registers (int regno)
{
  int reglo, reghi;
  int i;
  unsigned long ecp;

  if (regno == -1)
    {
      reglo = 0;
      reghi = NUM_REGS - 1;
    }
  else
    reglo = reghi = regno;

  ecp = registers_addr (PIDGET (inferior_ptid));

  for (regno = reglo; regno <= reghi; regno++)
    {
      int ptrace_fun = PTRACE_POKEUSER;

      if (CANNOT_STORE_REGISTER (regno))
	continue;

#ifdef M68K
      ptrace_fun = regno == SP_REGNUM ? PTRACE_POKEUSP : PTRACE_POKEUSER;
#endif

      for (i = 0; i < REGISTER_RAW_SIZE (regno); i += sizeof (int))
	{
	  unsigned int reg;

	  reg = *(unsigned int *) &registers[REGISTER_BYTE (regno) + i];

	  errno = 0;
	  ptrace (ptrace_fun, PIDGET (inferior_ptid),
		  (PTRACE_ARG3_TYPE) (ecp + regmap[regno] + i), reg);
	  if (errno)
	    perror_with_name ("ptrace(PTRACE_POKEUSP)");
	}
    }
}
Example #24
0
void
m68k_pop_frame ()
{
  register FRAME frame = get_current_frame ();
  register CORE_ADDR fp;
  register int regnum;
  struct frame_saved_regs fsr;
  struct frame_info *fi;
  char raw_buffer[12];

  fi = get_frame_info (frame);
  fp = fi -> frame;
  get_frame_saved_regs (fi, &fsr);
#if defined (HAVE_68881)
  for (regnum = FP0_REGNUM + 7 ; regnum >= FP0_REGNUM ; regnum--)
    {
      if (fsr.regs[regnum])
	{
	  read_memory (fsr.regs[regnum], raw_buffer, 12);
	  write_register_bytes (REGISTER_BYTE (regnum), raw_buffer, 12);
	}
    }
#endif
  for (regnum = FP_REGNUM - 1 ; regnum >= 0 ; regnum--)
    {
      if (fsr.regs[regnum])
	{
	  write_register (regnum, read_memory_integer (fsr.regs[regnum], 4));
	}
    }
  if (fsr.regs[PS_REGNUM])
    {
      write_register (PS_REGNUM, read_memory_integer (fsr.regs[PS_REGNUM], 4));
    }
  write_register (FP_REGNUM, read_memory_integer (fp, 4));
  write_register (PC_REGNUM, read_memory_integer (fp + 4, 4));
  write_register (SP_REGNUM, fp + 8);
  flush_cached_frames ();
  set_current_frame (create_new_frame (read_register (FP_REGNUM),
				       read_pc ()));
}
Example #25
0
void
microblaze_extract_return_value (struct type *type, char *regbuf, char *valbuf)
{
  /* Copy the return value (starting) in RETVAL_REGNUM to VALBUF. */
  char *reg = regbuf + REGISTER_BYTE(RETVAL_REGNUM);
  switch (TYPE_LENGTH(type)) {
	  case 1:	/* return last byte in the register */
		  memcpy(valbuf, reg + REGISTER_SIZE - 1, 1);
		  return;
	  case 2:	/* return last 2 bytes in register */
		  memcpy(valbuf, reg + REGISTER_SIZE - 2, 2);
		  return;
	  case 4:	/* for sizes 4 or 8, copy the required length */
	  case 8:
		  memcpy (valbuf, reg, TYPE_LENGTH (type));
		  return;
	  default:
		  printf_filtered("Fatal error: unsupported return value size requested (%s @ %d)\n", 
				  __FILE__, __LINE__);
  }
}
Example #26
0
void
m68k_push_dummy_frame ()
{
  register CORE_ADDR sp = read_register (SP_REGNUM);
  register int regnum;
  char raw_buffer[12];

  sp = push_word (sp, read_register (PC_REGNUM));
  sp = push_word (sp, read_register (FP_REGNUM));
  write_register (FP_REGNUM, sp);
#if defined (HAVE_68881)
  for (regnum = FP0_REGNUM + 7; regnum >= FP0_REGNUM; regnum--)
    {
      read_register_bytes (REGISTER_BYTE (regnum), raw_buffer, 12);
      sp = push_bytes (sp, raw_buffer, 12);
    }
#endif
  for (regnum = FP_REGNUM - 1; regnum >= 0; regnum--)
    {
      sp = push_word (sp, read_register (regnum));
    }
  sp = push_word (sp, read_register (PS_REGNUM));
  write_register (SP_REGNUM, sp);
}
Example #27
0
void
fill_gregset (gregset_t *gregsetp, int regno)
{
  int regi;
  register greg_t *regp = (greg_t *) gregsetp;

  for (regi = 0; regi <= R_R31; regi++)
    if ((regno == -1) || (regno == regi))
      *(regp + regi) = *(int *) &registers[REGISTER_BYTE (regi)];

  if ((regno == -1) || (regno == SXIP_REGNUM))
    *(regp + R_XIP) = *(int *) &registers[REGISTER_BYTE (SXIP_REGNUM)];
  if ((regno == -1) || (regno == SNIP_REGNUM))
    *(regp + R_NIP) = *(int *) &registers[REGISTER_BYTE (SNIP_REGNUM)];
  if ((regno == -1) || (regno == SFIP_REGNUM))
    *(regp + R_FIP) = *(int *) &registers[REGISTER_BYTE (SFIP_REGNUM)];
  if ((regno == -1) || (regno == PSR_REGNUM))
    *(regp + R_PSR) = *(int *) &registers[REGISTER_BYTE (PSR_REGNUM)];
  if ((regno == -1) || (regno == FPSR_REGNUM))
    *(regp + R_FPSR) = *(int *) &registers[REGISTER_BYTE (FPSR_REGNUM)];
  if ((regno == -1) || (regno == FPCR_REGNUM))
    *(regp + R_FPCR) = *(int *) &registers[REGISTER_BYTE (FPCR_REGNUM)];
}
Example #28
0
void
store_inferior_registers (int regno)
{
  int whatregs = 0;

  if (regno == -1)
    whatregs = WHATREGS_FLOAT | WHATREGS_GEN | WHATREGS_STACK;
  else if (regno >= L0_REGNUM && regno <= I7_REGNUM)
    whatregs = WHATREGS_STACK;
  else if (regno >= FP0_REGNUM && regno < FP0_REGNUM + 32)
    whatregs = WHATREGS_FLOAT;
  else if (regno == SP_REGNUM)
    whatregs = WHATREGS_STACK | WHATREGS_GEN;
  else
    whatregs = WHATREGS_GEN;

  if (whatregs & WHATREGS_GEN)
    {
      struct econtext ec;	/* general regs */
      int retval;

      ec.tbr = read_register (TBR_REGNUM);
      memcpy (&ec.g1, &registers[REGISTER_BYTE (G1_REGNUM)],
	      4 * REGISTER_RAW_SIZE (G1_REGNUM));

      ec.psr = read_register (PS_REGNUM);
      ec.y = read_register (Y_REGNUM);
      ec.pc = read_register (PC_REGNUM);
      ec.npc = read_register (NPC_REGNUM);
      ec.wim = read_register (WIM_REGNUM);

      memcpy (ec.o, &registers[REGISTER_BYTE (O0_REGNUM)],
	      8 * REGISTER_RAW_SIZE (O0_REGNUM));

      errno = 0;
      retval = ptrace (PTRACE_SETREGS, PIDGET (inferior_ptid),
                       (PTRACE_ARG3_TYPE) & ec, 0);
      if (errno)
	perror_with_name ("ptrace(PTRACE_SETREGS)");
    }

  if (whatregs & WHATREGS_STACK)
    {
      int regoffset;
      CORE_ADDR sp;

      sp = read_register (SP_REGNUM);

      if (regno == -1 || regno == SP_REGNUM)
	{
	  if (!register_valid[L0_REGNUM + 5])
	    internal_error (__FILE__, __LINE__, "failed internal consistency check");
	  target_write_memory (sp + FRAME_SAVED_I0,
			      &registers[REGISTER_BYTE (I0_REGNUM)],
			      8 * REGISTER_RAW_SIZE (I0_REGNUM));

	  target_write_memory (sp + FRAME_SAVED_L0,
			      &registers[REGISTER_BYTE (L0_REGNUM)],
			      8 * REGISTER_RAW_SIZE (L0_REGNUM));
	}
      else if (regno >= L0_REGNUM && regno <= I7_REGNUM)
	{
	  if (!register_valid[regno])
	    internal_error (__FILE__, __LINE__, "failed internal consistency check");
	  if (regno >= L0_REGNUM && regno <= L0_REGNUM + 7)
	    regoffset = REGISTER_BYTE (regno) - REGISTER_BYTE (L0_REGNUM)
	      + FRAME_SAVED_L0;
	  else
	    regoffset = REGISTER_BYTE (regno) - REGISTER_BYTE (I0_REGNUM)
	      + FRAME_SAVED_I0;
	  target_write_memory (sp + regoffset, 
			      &registers[REGISTER_BYTE (regno)],
			      REGISTER_RAW_SIZE (regno));
	}
    }

  if (whatregs & WHATREGS_FLOAT)
    {
      struct fcontext fc;	/* fp regs */
      int retval;

/* We read fcontext first so that we can get good values for fq_t... */
      errno = 0;
      retval = ptrace (PTRACE_GETFPREGS, PIDGET (inferior_ptid),
                       (PTRACE_ARG3_TYPE) & fc, 0);
      if (errno)
	perror_with_name ("ptrace(PTRACE_GETFPREGS)");

      memcpy (fc.f.fregs, &registers[REGISTER_BYTE (FP0_REGNUM)],
	      32 * REGISTER_RAW_SIZE (FP0_REGNUM));

      fc.fsr = read_register (FPS_REGNUM);

      errno = 0;
      retval = ptrace (PTRACE_SETFPREGS, PIDGET (inferior_ptid),
                       (PTRACE_ARG3_TYPE) & fc, 0);
      if (errno)
	perror_with_name ("ptrace(PTRACE_SETFPREGS)");
    }
}
Example #29
0
void
fetch_inferior_registers (int regno)
{
  int whatregs = 0;

#define WHATREGS_FLOAT 1
#define WHATREGS_GEN 2
#define WHATREGS_STACK 4

  if (regno == -1)
    whatregs = WHATREGS_FLOAT | WHATREGS_GEN | WHATREGS_STACK;
  else if (regno >= L0_REGNUM && regno <= I7_REGNUM)
    whatregs = WHATREGS_STACK;
  else if (regno >= FP0_REGNUM && regno < FP0_REGNUM + 32)
    whatregs = WHATREGS_FLOAT;
  else
    whatregs = WHATREGS_GEN;

  if (whatregs & WHATREGS_GEN)
    {
      struct econtext ec;	/* general regs */
      char buf[MAX_REGISTER_RAW_SIZE];
      int retval;
      int i;

      errno = 0;
      retval = ptrace (PTRACE_GETREGS, PIDGET (inferior_ptid),
                       (PTRACE_ARG3_TYPE) & ec, 0);
      if (errno)
	perror_with_name ("ptrace(PTRACE_GETREGS)");

      memset (buf, 0, REGISTER_RAW_SIZE (G0_REGNUM));
      supply_register (G0_REGNUM, buf);
      supply_register (TBR_REGNUM, (char *) &ec.tbr);

      memcpy (&registers[REGISTER_BYTE (G1_REGNUM)], &ec.g1,
	      4 * REGISTER_RAW_SIZE (G1_REGNUM));
      for (i = G1_REGNUM; i <= G1_REGNUM + 3; i++)
	register_valid[i] = 1;

      supply_register (PS_REGNUM, (char *) &ec.psr);
      supply_register (Y_REGNUM, (char *) &ec.y);
      supply_register (PC_REGNUM, (char *) &ec.pc);
      supply_register (NPC_REGNUM, (char *) &ec.npc);
      supply_register (WIM_REGNUM, (char *) &ec.wim);

      memcpy (&registers[REGISTER_BYTE (O0_REGNUM)], ec.o,
	      8 * REGISTER_RAW_SIZE (O0_REGNUM));
      for (i = O0_REGNUM; i <= O0_REGNUM + 7; i++)
	register_valid[i] = 1;
    }

  if (whatregs & WHATREGS_STACK)
    {
      CORE_ADDR sp;
      int i;

      sp = read_register (SP_REGNUM);

      target_read_memory (sp + FRAME_SAVED_I0,
			  &registers[REGISTER_BYTE (I0_REGNUM)],
			  8 * REGISTER_RAW_SIZE (I0_REGNUM));
      for (i = I0_REGNUM; i <= I7_REGNUM; i++)
	register_valid[i] = 1;

      target_read_memory (sp + FRAME_SAVED_L0,
			  &registers[REGISTER_BYTE (L0_REGNUM)],
			  8 * REGISTER_RAW_SIZE (L0_REGNUM));
      for (i = L0_REGNUM; i <= L0_REGNUM + 7; i++)
	register_valid[i] = 1;
    }

  if (whatregs & WHATREGS_FLOAT)
    {
      struct fcontext fc;	/* fp regs */
      int retval;
      int i;

      errno = 0;
      retval = ptrace (PTRACE_GETFPREGS, PIDGET (inferior_ptid),
                       (PTRACE_ARG3_TYPE) & fc, 0);
      if (errno)
	perror_with_name ("ptrace(PTRACE_GETFPREGS)");

      memcpy (&registers[REGISTER_BYTE (FP0_REGNUM)], fc.f.fregs,
	      32 * REGISTER_RAW_SIZE (FP0_REGNUM));
      for (i = FP0_REGNUM; i <= FP0_REGNUM + 31; i++)
	register_valid[i] = 1;

      supply_register (FPS_REGNUM, (char *) &fc.fsr);
    }
}
Example #30
0
static void
fetch_register (int regno)
{
  sim_fetch_register (gdbsim_desc, regno, &registers[REGISTER_BYTE (regno)],
		      REGISTER_RAW_SIZE (regno));
}