Пример #1
0
void
arm_store_vfpregset_num (struct regcache *regcache, const void *buf, int num)
{
  int i, base;

  gdb_assert (num == 16 || num == 32);

  base = find_regno (regcache->tdesc, "d0");
  for (i = 0; i < num; i++)
    supply_register (regcache, base + i, (char *) buf + i * 8);

  supply_register_by_name (regcache, "fpscr", (char *) buf + 32 * 8);
}
static void
ppc_store_vsxregset (const void *buf)
{
  int i, base;
  const char *regset = buf;

  if (!(ppc_hwcap & PPC_FEATURE_HAS_VSX))
    return;

  base = find_regno ("vs0h");
  for (i = 0; i < 32; i++)
    supply_register (base + i, &regset[i * 8]);
}
Пример #3
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");
    }
}
Пример #4
0
static void
mips_supply_register (struct regcache *regcache,
		      int use_64bit, int regno, const union mips_register *reg)
{
  int offset = 0;

  /* For big-endian 32-bit targets, ignore the high four bytes of each
     eight-byte slot.  */
  if (__BYTE_ORDER == __BIG_ENDIAN && !use_64bit)
    offset = 4;

  supply_register (regcache, regno, reg->buf + offset);
}
Пример #5
0
void
fetch_inferior_registers (int regno)
{
  register unsigned int regaddr;
  char buf[MAX_REGISTER_RAW_SIZE];
  register int i;

  struct USER u;
  unsigned int offset;

  offset = (char *) &u.pt_r0 - (char *) &u;
  regaddr = offset;		/* byte offset to r0; */

/*  offset = ptrace (3, PIDGET (inferior_ptid), (PTRACE_ARG3_TYPE) offset, 0) - KERNEL_U_ADDR; */
  for (regno = 0; regno < NUM_REGS; regno++)
    {
      /*regaddr = register_addr (regno, offset); */
      /* 88k enhancement  */

      for (i = 0; i < REGISTER_RAW_SIZE (regno); i += sizeof (int))
	{
	  *(int *) &buf[i] = ptrace (3, PIDGET (inferior_ptid),
				     (PTRACE_ARG3_TYPE) regaddr, 0);
	  regaddr += sizeof (int);
	}
      supply_register (regno, buf);
    }
  /* now load up registers 36 - 38; special pc registers */
  *(int *) &buf[0] = ptrace (3, PIDGET (inferior_ptid),
			     (PTRACE_ARG3_TYPE) SXIP_OFFSET, 0);
  supply_register (SXIP_REGNUM, buf);
  *(int *) &buf[0] = ptrace (3, PIDGET (inferior_ptid),
			     (PTRACE_ARG3_TYPE) SNIP_OFFSET, 0);
  supply_register (SNIP_REGNUM, buf);
  *(int *) &buf[0] = ptrace (3, PIDGET (inferior_ptid),
			     (PTRACE_ARG3_TYPE) SFIP_OFFSET, 0);
  supply_register (SFIP_REGNUM, buf);
}
Пример #6
0
static void
mips_store_fpregset (struct regcache *regcache, const void *buf)
{
  const union mips_register *regset = buf;
  int i, use_64bit, first_fp, big_endian;

  use_64bit = (register_size (0) == 8);
  first_fp = find_regno ("f0");
  big_endian = (__BYTE_ORDER == __BIG_ENDIAN);

  /* See GDB for a discussion of this peculiar layout.  */
  for (i = 0; i < 32; i++)
    if (use_64bit)
      supply_register (regcache, first_fp + i, regset[i].buf);
    else
      supply_register (regcache, first_fp + i,
		       regset[i & ~1].buf + 4 * (big_endian != (i & 1)));

  mips_supply_register_32bit (regcache, use_64bit,
			      find_regno ("fcsr"), regset[32].buf);
  mips_supply_register_32bit (regcache, use_64bit, find_regno ("fir"),
			      regset[32].buf + 4);
}
Пример #7
0
void
supply_static_tracepoint_registers (struct regcache *regcache,
				    const unsigned char *buf,
				    CORE_ADDR pc)
{
  int i;
  unsigned long newpc = pc;

  supply_register (regcache, AMD64_RIP_REGNUM, &newpc);

  for (i = 0; i < X86_64_NUM_ST_COLLECT_GREGS; i++)
    if (x86_64_st_collect_regmap[i].offset != -1)
      {
	switch (x86_64_st_collect_regmap[i].size)
	  {
	  case 8:
	    supply_register (regcache, i,
			     ((char *) buf)
			     + x86_64_st_collect_regmap[i].offset);
	    break;
	  case 2:
	    {
	      unsigned long reg
		= * (short *) (((char *) buf)
			       + x86_64_st_collect_regmap[i].offset);
	      reg &= 0xffff;
	      supply_register (regcache, i, &reg);
	    }
	    break;
	  default:
	    internal_error (__FILE__, __LINE__,
			    "unhandled register size: %d",
			    x86_64_st_collect_regmap[i].size);
	    break;
	  }
      }
}
Пример #8
0
void
supply_fpregset (gdb_fpregset_t *fpregsetp)
{
  int regno;
  FPA11 *fp = (FPA11 *) fpregsetp;

  /* Fetch fpsr.  */
  supply_register (FPS_REGNUM, (char *) &fp->fpsr);

  /* Fetch the floating point registers.  */
  for (regno = F0_REGNUM; regno <= F7_REGNUM; regno++)
    {
      fetch_nwfpe_register (regno, fp);
    }
}
Пример #9
0
static int
ia64_fetch_register (struct regcache *regcache, int regnum)
{
  /* r0 cannot be fetched but is always zero.  */
  if (regnum == IA64_GR0_REGNUM)
    {
      const gdb_byte zero[8] = { 0 };

      gdb_assert (sizeof (zero) == register_size (regnum));
      supply_register (regcache, regnum, zero);
      return 1;
    }

  /* fr0 cannot be fetched but is always zero.  */
  if (regnum == IA64_FR0_REGNUM)
    {
      const gdb_byte f_zero[16] = { 0 };

      gdb_assert (sizeof (f_zero) == register_size (regnum));
      supply_register (regcache, regnum, f_zero);
      return 1;
    }

  /* fr1 cannot be fetched but is always one (1.0).  */
  if (regnum == IA64_FR1_REGNUM)
    {
      const gdb_byte f_one[16] =
	{ 0, 0, 0, 0, 0, 0, 0, 0x80, 0xff, 0xff, 0, 0, 0, 0, 0, 0 };

      gdb_assert (sizeof (f_one) == register_size (regnum));
      supply_register (regcache, regnum, f_one);
      return 1;
    }

  return 0;
}
Пример #10
0
void
supply_fast_tracepoint_registers (struct regcache *regcache,
				  const unsigned char *buf)
{
  int i;

  for (i = 0; i < PPC_NUM_FT_COLLECT_GREGS; i++)
    {
      if (ppc_ft_collect_regmap[i] == -1)
	continue;
      supply_register (regcache, i,
		       ((char *) buf)
			+ ppc_ft_collect_regmap[i] * sizeof (long));
    }
}
Пример #11
0
static void
ppc_store_vrregset (const void *buf)
{
  int i, base;
  const char *regset = buf;

  if (!(ppc_hwcap & PPC_FEATURE_HAS_ALTIVEC))
    return;

  base = find_regno ("vr0");
  for (i = 0; i < 32; i++)
    supply_register (base + i, &regset[i * 16]);

  supply_register_by_name ("vscr", &regset[32 * 16 + 12]);
  supply_register_by_name ("vrsave", &regset[33 * 16]);
}
Пример #12
0
static void
ppc_store_evrregset (const void *buf)
{
  int i, ev0;
  const struct gdb_evrregset_t *regset = buf;

  if (!(ppc_hwcap & PPC_FEATURE_HAS_SPE))
    return;

  ev0 = find_regno ("ev0h");
  for (i = 0; i < 32; i++)
    supply_register (ev0 + i, &regset->evr[i]);

  supply_register_by_name ("acc", &regset->acc);
  supply_register_by_name ("spefscr", &regset->spefscr);
}
Пример #13
0
static void
fetch_fpregister (int regno)
{
  int ret, tid;
  FPA11 fp;
  
  /* Get the thread id for the ptrace call.  */
  tid = GET_THREAD_ID (inferior_ptid);

  /* Read the floating point state.  */
  ret = ptrace (PT_GETFPREGS, tid, 0, &fp);
  if (ret < 0)
    {
      warning ("Unable to fetch floating point register.");
      return;
    }

  /* Fetch fpsr.  */
  if (FPS_REGNUM == regno)
    supply_register (FPS_REGNUM, (char *) &fp.fpsr);

  /* Fetch the floating point register.  */
  if (regno >= F0_REGNUM && regno <= F7_REGNUM)
    {
      int fn = regno - F0_REGNUM;

      switch (fp.fType[fn])
	{
	case typeSingle:
	  fetch_nwfpe_single (fn, &fp);
	  break;

	case typeDouble:
	    fetch_nwfpe_double (fn, &fp);
	  break;

	case typeExtended:
	    fetch_nwfpe_extended (fn, &fp);
	  break;

	default:
	    fetch_nwfpe_none (fn);
	}
    }
}
Пример #14
0
void
supply_gregset (gregset_t *gregsetp)
{
  register int regi;
  register greg_t *regp = (greg_t *) gregsetp;

  for (regi = 0; regi <= SP_REGNUM; regi++)
    supply_register (regi, (char *) (regp + regi));

  supply_register (SXIP_REGNUM, (char *) (regp + R_XIP));
  supply_register (SNIP_REGNUM, (char *) (regp + R_NIP));
  supply_register (SFIP_REGNUM, (char *) (regp + R_FIP));
  supply_register (PSR_REGNUM, (char *) (regp + R_PSR));
  supply_register (FPSR_REGNUM, (char *) (regp + R_FPSR));
  supply_register (FPCR_REGNUM, (char *) (regp + R_FPCR));
}
Пример #15
0
void
supply_fast_tracepoint_registers (struct regcache *regcache,
				  const unsigned char *buf)
{
  int i;

  for (i = 0; i < i386_num_regs; i++)
    {
      int regval;

      if (i >= I386_CS_REGNUM && i <= I386_GS_REGNUM)
	regval = *(short *) (((char *) buf) + i386_ft_collect_regmap[i]);
      else
	regval = *(int *) (((char *) buf) + i386_ft_collect_regmap[i]);

      supply_register (regcache, i, &regval);
    }
}
static void
fetch_core_registers (char *core_reg_sect, unsigned core_reg_size, int which,
		      CORE_ADDR reg_addr)
{
  struct st_entry s;
  unsigned int regno;

  for (regno = 0; regno < NUM_REGS; regno++)
    if (regmap[regno] != -1)
      supply_register (regno, core_reg_sect + offsetof (st_t, ec)
		       + regmap[regno]);

#ifdef SPARC
/* Fetching this register causes all of the I & L regs to be read from the
   stack and validated.  */

  fetch_inferior_registers (I0_REGNUM);
#endif
}
void
fetch_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));

  {
    char buf[MAX_REGISTER_SIZE];
    for (regno = reglo; regno <= reghi; regno++)
      {
	int ptrace_fun = PTRACE_PEEKTHREAD;
	
#ifdef M68K
	ptrace_fun = regno == SP_REGNUM ? PTRACE_PEEKUSP : PTRACE_PEEKTHREAD;
#endif
	
	for (i = 0; i < DEPRECATED_REGISTER_RAW_SIZE (regno); i += sizeof (int))
	  {
	    unsigned int reg;
	    
	    errno = 0;
	    reg = ptrace (ptrace_fun, PIDGET (inferior_ptid),
			  (PTRACE_ARG3_TYPE) (ecp + regmap[regno] + i), 0);
	    if (errno)
	      perror_with_name ("ptrace(PTRACE_PEEKUSP)");
	    
	    *(int *) &buf[i] = reg;
	  }
	supply_register (regno, buf);
      }
  }
}
static void
arm_store_vfpregset (struct regcache *regcache, const void *buf)
{
  int i, num, base;

  if (!(arm_hwcap & HWCAP_VFP))
    return;

  if ((arm_hwcap & (HWCAP_VFPv3 | HWCAP_VFPv3D16)) == HWCAP_VFPv3)
    num = 32;
  else
    num = 16;

  base = find_regno ("d0");
  for (i = 0; i < num; i++)
    supply_register (regcache, base + i, (char *) buf + i * 8);

  supply_register_by_name (regcache, "fpscr", (char *) buf + 32 * 8);
}
Пример #19
0
static void
sparc_store_gregset_from_stack (struct regcache *regcache, const void *buf)
{
    int i;
    CORE_ADDR addr = 0;
    unsigned char tmp_reg_buf[8];
    const int l0_regno = find_regno("l0");
    const int i7_regno = l0_regno + 15;

    /* These registers have to be obtained from the stack.  */
    memcpy(&addr, ((char *) buf) + sparc_regmap[find_regno("sp")], sizeof(addr));

    addr += BIAS;

    for (i = l0_regno; i <= i7_regno; i++)
    {
        (*the_target->read_memory) (addr, tmp_reg_buf, sizeof(tmp_reg_buf));
        supply_register (regcache, i, tmp_reg_buf);
        addr += sizeof(tmp_reg_buf);
    }
}
Пример #20
0
/* Parse a string of hex digits starting at HEX, supply them as the
   value of register REGNO, skip any whitespace, and return a pointer
   to the next character.

   There is a function in monitor.c, monitor_supply_register, which is
   supposed to do this job.  However, there is some rather odd stuff
   in there (whitespace characters don't terminate numbers, for
   example) that is incorrect for ROM68k.  It's basically impossible
   to safely tweak monitor_supply_register --- it's used by a zillion
   other monitors; who knows what behaviors they're depending on.  So
   instead, we'll just use our own function, which can behave exactly
   the way we want it to.  */
static char *
rom68k_supply_one_register (int regno, unsigned char *hex)
{
    ULONGEST value;
    unsigned char regbuf[MAX_REGISTER_SIZE];

    value = 0;
    while (*hex != '\0')
        if (is_hex_digit (*hex))
            value = (value * 16) + hex_digit_value (*hex++);
        else
            break;

    /* Skip any whitespace.  */
    while (is_whitespace (*hex))
        hex++;

    store_unsigned_integer (regbuf, DEPRECATED_REGISTER_RAW_SIZE (regno), value);
    supply_register (regno, regbuf);

    return hex;
}
Пример #21
0
void
kgdb_trgt_fetch_registers(int regno __unused)
{
    struct kthr *kt;
    struct pcb pcb;

    kt = kgdb_thr_lookup_tid(ptid_get_pid(inferior_ptid));
    if (kt == NULL)
        return;
    if (kvm_read(kvm, kt->pcb, &pcb, sizeof(pcb)) != sizeof(pcb)) {
        warnx("kvm_read: %s", kvm_geterr(kvm));
        memset(&pcb, 0, sizeof(pcb));
    }

    supply_register(AMD64_RBX_REGNUM, (char *)&pcb.pcb_rbx);
    supply_register(AMD64_RBP_REGNUM, (char *)&pcb.pcb_rbp);
    supply_register(AMD64_RSP_REGNUM, (char *)&pcb.pcb_rsp);
    supply_register(AMD64_R8_REGNUM + 4, (char *)&pcb.pcb_r12);
    supply_register(AMD64_R8_REGNUM + 5, (char *)&pcb.pcb_r13);
    supply_register(AMD64_R8_REGNUM + 6, (char *)&pcb.pcb_r14);
    supply_register(AMD64_R15_REGNUM, (char *)&pcb.pcb_r15);
    supply_register(AMD64_RIP_REGNUM, (char *)&pcb.pcb_rip);
    amd64_supply_fxsave(current_regcache, -1, (struct fpusave *)(&pcb + 1));
}
Пример #22
0
static void
fetch_register (int regno)
{
  struct reg inferior_registers;
#ifndef CROSS_DEBUGGER
  int ret;

  ret = ptrace (PT_GETREGS, PIDGET (inferior_ptid),
		(PTRACE_ARG3_TYPE) &inferior_registers, 0);

  if (ret < 0)
    {
      warning ("unable to fetch general register");
      return;
    }
#endif

  switch (regno)
    {
    case ARM_SP_REGNUM:
      supply_register (ARM_SP_REGNUM, (char *) &inferior_registers.r_sp);
      break;

    case ARM_LR_REGNUM:
      supply_register (ARM_LR_REGNUM, (char *) &inferior_registers.r_lr);
      break;

    case ARM_PC_REGNUM:
      /* This is ok: we're running native... */
      inferior_registers.r_pc = ADDR_BITS_REMOVE (inferior_registers.r_pc);
      supply_register (ARM_PC_REGNUM, (char *) &inferior_registers.r_pc);
      break;

    case ARM_PS_REGNUM:
      if (arm_apcs_32)
	supply_register (ARM_PS_REGNUM, (char *) &inferior_registers.r_cpsr);
      else
	supply_register (ARM_PS_REGNUM, (char *) &inferior_registers.r_pc);
      break;

    default:
      supply_register (regno, (char *) &inferior_registers.r[regno]);
      break;
    }
}
/* Fetch one register.  */
static void
fetch_register (int regno)
{
  CORE_ADDR regaddr;
  register int i;
  char *buf;

  if (regno >= the_low_target.num_regs)
    return;
  if ((*the_low_target.cannot_fetch_register) (regno))
    return;

  regaddr = register_addr (regno);
  if (regaddr == -1)
    return;
  buf = alloca (register_size (regno));
  for (i = 0; i < register_size (regno); i += sizeof (PTRACE_XFER_TYPE))
    {
      errno = 0;
      *(PTRACE_XFER_TYPE *) (buf + i) =
	ptrace (PTRACE_PEEKUSER, inferior_pid, (PTRACE_ARG3_TYPE) regaddr, 0);
      regaddr += sizeof (PTRACE_XFER_TYPE);
      if (errno != 0)
	{
	  /* Warning, not error, in case we are attached; sometimes the
	     kernel doesn't let us at the registers.  */
	  char *err = strerror (errno);
	  char *msg = alloca (strlen (err) + 128);
	  sprintf (msg, "reading register %d: %s", regno, err);
	  error (msg);
	  goto error_exit;
	}
    }
  supply_register (regno, buf);

error_exit:;
}
Пример #24
0
static int
get_hex (int *start)
{
  int value = convert_hex_digit (*start);
  int try;

  *start = readchar (timeout);
  while ((try = convert_hex_digit (*start)) >= 0)
    {
      value <<= 4;
      value += try;
      *start = readchar (timeout);
    }
  return value;
}

#if 0
/* Get N 32-bit words from remote, each preceded by a space, and put
   them in registers starting at REGNO.  */

static void
get_hex_regs (int n, int regno)
{
  long val;
  int i;

  for (i = 0; i < n; i++)
    {
      int j;

      val = 0;
      for (j = 0; j < 8; j++)
	val = (val << 4) + get_hex_digit (j == 0);
      supply_register (regno++, (char *) &val);
    }
}
Пример #25
0
void
supply_gregset (struct reg *gregset)
{
  int regno;
  CORE_ADDR r_pc;

  /* Integer registers.  */
  for (regno = ARM_A1_REGNUM; regno < ARM_SP_REGNUM; regno++)
    supply_register (regno, (char *) &gregset->r[regno]);

  supply_register (ARM_SP_REGNUM, (char *) &gregset->r_sp);
  supply_register (ARM_LR_REGNUM, (char *) &gregset->r_lr);
  supply_register (ARM_PC_REGNUM, (char *) &gregset->r_pc);

  if (arm_apcs_32)
    supply_register (ARM_PS_REGNUM, (char *) &gregset->r_cpsr);
  else
    supply_register (ARM_PS_REGNUM, (char *) &gregset->r_pc);
}
Пример #26
0
void
kgdb_trgt_fetch_registers(int regno __unused)
{
	struct kthr *kt;
	struct pcb pcb;

	kt = kgdb_thr_lookup_tid(ptid_get_pid(inferior_ptid));
	if (kt == NULL)
		return;
	if (kvm_read(kvm, kt->pcb, &pcb, sizeof(pcb)) != sizeof(pcb)) {
		warnx("kvm_read: %s", kvm_geterr(kvm));
		memset(&pcb, 0, sizeof(pcb));
	}
	supply_register(I386_EBX_REGNUM, (char *)&pcb.pcb_ebx);
	supply_register(I386_ESP_REGNUM, (char *)&pcb.pcb_esp);
	supply_register(I386_EBP_REGNUM, (char *)&pcb.pcb_ebp);
	supply_register(I386_ESI_REGNUM, (char *)&pcb.pcb_esi);
	supply_register(I386_EDI_REGNUM, (char *)&pcb.pcb_edi);
	supply_register(I386_EIP_REGNUM, (char *)&pcb.pcb_eip);
}
Пример #27
0
static void
lynx_ppc_store_gregset (struct regcache *regcache, const char *buf)
{
  int i;

  /* r0 - r31 */
  for (i = 0; i < 32; i++)
    supply_register (regcache, R0_REGNUM + i,
                      buf + offsetof (usr_econtext_t, uec_iregs[i]));

  /* The other registers provided in the GP register context.  */
  supply_register (regcache, PC_REGNUM,
                   buf + offsetof (usr_econtext_t, uec_srr0));
  supply_register (regcache, MSR_REGNUM,
                   buf + offsetof (usr_econtext_t, uec_srr1));
  supply_register (regcache, CR_REGNUM,
                   buf + offsetof (usr_econtext_t, uec_cr));
  supply_register (regcache, LR_REGNUM,
                   buf + offsetof (usr_econtext_t, uec_lr));
  supply_register (regcache, CTR_REGNUM,
                   buf + offsetof (usr_econtext_t, uec_ctr));
  supply_register (regcache, XER_REGNUM,
                   buf + offsetof (usr_econtext_t, uec_xer));
}
Пример #28
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);
    }
}
Пример #29
0
static void
fbsd_thread_store_registers (int regno)
{
  prgregset_t gregset;
  prfpregset_t fpregset;
  td_thrhandle_t th;
  td_err_e err;
#ifdef PT_GETXMMREGS
  char xmmregs[512];
#endif

  if (!IS_THREAD (inferior_ptid))
    {
      fbsd_lwp_store_registers (regno);
      return;
    }

  err = td_ta_map_id2thr_p (thread_agent, GET_THREAD (inferior_ptid), &th);
  if (err != TD_OK)
    error ("Cannot find thread %d: Thread ID=%ld, %s",
           pid_to_thread_id (inferior_ptid),
           GET_THREAD (inferior_ptid),
           thread_db_err_str (err));

  if (regno != -1)
    {
      char old_value[MAX_REGISTER_SIZE];

      regcache_collect (regno, old_value);
      err = td_thr_getgregs_p (&th, gregset);
      if (err != TD_OK)
        error ("%s: td_thr_getgregs %s", __func__, thread_db_err_str (err));
#ifdef PT_GETXMMREGS
      err = td_thr_getxmmregs_p (&th, xmmregs);
      if (err != TD_OK)
        {
#endif
          err = td_thr_getfpregs_p (&th, &fpregset);
          if (err != TD_OK)
            error ("%s: td_thr_getfpgregs %s", __func__, thread_db_err_str (err));
#ifdef PT_GETXMMREGS
        }
#endif
      supply_register (regno, old_value);
    }

  fill_gregset (gregset, regno);
  err = td_thr_setgregs_p (&th, gregset);
  if (err != TD_OK)
    error ("Cannot store general-purpose registers for thread %d: Thread ID=%d, %s",
           pid_to_thread_id (inferior_ptid), GET_THREAD (inferior_ptid),
           thread_db_err_str (err));

#ifdef PT_GETXMMREGS
  i387_fill_fxsave (xmmregs, regno);
  err = td_thr_setxmmregs_p (&th, xmmregs);
  if (err == TD_OK)
    return;
#endif

  fill_fpregset (&fpregset, regno);
  err = td_thr_setfpregs_p (&th, &fpregset);
  if (err != TD_OK)
    error ("Cannot store floating-point registers for thread %d: Thread ID=%d, %s",
           pid_to_thread_id (inferior_ptid), GET_THREAD (inferior_ptid),
           thread_db_err_str (err));
}
Пример #30
0
void
supply_register_by_name (struct regcache *regcache,
			 const char *name, const void *buf)
{
  supply_register (regcache, find_regno (regcache->tdesc, name), buf);
}