static void ia64_linux_store_register (const struct regcache *regcache, int regnum) { struct gdbarch *gdbarch = get_regcache_arch (regcache); CORE_ADDR addr; size_t size; PTRACE_TYPE_RET *buf; int pid, i; if (ia64_cannot_store_register (gdbarch, regnum)) return; /* Cater for systems like GNU/Linux, that implement threads as separate processes. */ pid = ptid_get_lwp (inferior_ptid); if (pid == 0) pid = ptid_get_pid (inferior_ptid); /* This isn't really an address, but ptrace thinks of it as one. */ addr = ia64_register_addr (gdbarch, regnum); size = register_size (gdbarch, regnum); gdb_assert ((size % sizeof (PTRACE_TYPE_RET)) == 0); buf = alloca (size); /* Write the register contents into the inferior a chunk at a time. */ regcache_raw_collect (regcache, regnum, buf); for (i = 0; i < size / sizeof (PTRACE_TYPE_RET); i++) { errno = 0; ptrace (PT_WRITE_U, pid, (PTRACE_TYPE_ARG3)addr, buf[i]); if (errno != 0) error (_("Couldn't write register %s (#%d): %s."), gdbarch_register_name (gdbarch, regnum), regnum, safe_strerror (errno)); addr += sizeof (PTRACE_TYPE_RET); } }
static void ia64_linux_store_register (const struct regcache *regcache, int regnum) { struct gdbarch *gdbarch = regcache->arch (); CORE_ADDR addr; size_t size; PTRACE_TYPE_RET *buf; pid_t pid; int i; if (ia64_cannot_store_register (gdbarch, regnum)) return; pid = get_ptrace_pid (regcache->ptid ()); /* This isn't really an address, but ptrace thinks of it as one. */ addr = ia64_register_addr (gdbarch, regnum); size = register_size (gdbarch, regnum); gdb_assert ((size % sizeof (PTRACE_TYPE_RET)) == 0); buf = (PTRACE_TYPE_RET *) alloca (size); /* Write the register contents into the inferior a chunk at a time. */ regcache->raw_collect (regnum, buf); for (i = 0; i < size / sizeof (PTRACE_TYPE_RET); i++) { errno = 0; ptrace (PT_WRITE_U, pid, (PTRACE_TYPE_ARG3)addr, buf[i]); if (errno != 0) error (_("Couldn't write register %s (#%d): %s."), gdbarch_register_name (gdbarch, regnum), regnum, safe_strerror (errno)); addr += sizeof (PTRACE_TYPE_RET); } }
static void ia64_linux_fetch_register (struct regcache *regcache, int regnum) { struct gdbarch *gdbarch = get_regcache_arch (regcache); CORE_ADDR addr; size_t size; PTRACE_TYPE_RET *buf; int pid, i; /* 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 (gdbarch, regnum)); regcache_raw_supply (regcache, regnum, zero); return; } /* 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 (gdbarch, regnum)); regcache_raw_supply (regcache, regnum, f_zero); return; } /* 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 (gdbarch, regnum)); regcache_raw_supply (regcache, regnum, f_one); return; } if (ia64_cannot_fetch_register (gdbarch, regnum)) { regcache_raw_supply (regcache, regnum, NULL); return; } /* Cater for systems like GNU/Linux, that implement threads as separate processes. */ pid = ptid_get_lwp (inferior_ptid); if (pid == 0) pid = ptid_get_pid (inferior_ptid); /* This isn't really an address, but ptrace thinks of it as one. */ addr = ia64_register_addr (gdbarch, regnum); size = register_size (gdbarch, regnum); gdb_assert ((size % sizeof (PTRACE_TYPE_RET)) == 0); buf = alloca (size); /* Read the register contents from the inferior a chunk at a time. */ for (i = 0; i < size / sizeof (PTRACE_TYPE_RET); i++) { errno = 0; buf[i] = ptrace (PT_READ_U, pid, (PTRACE_TYPE_ARG3)addr, 0); if (errno != 0) error (_("Couldn't read register %s (#%d): %s."), gdbarch_register_name (gdbarch, regnum), regnum, safe_strerror (errno)); addr += sizeof (PTRACE_TYPE_RET); } regcache_raw_supply (regcache, regnum, buf); }