static void fetch_core_registers (char *core_reg_sect, unsigned core_reg_size, int which, CORE_ADDR reg_addr) { gdb_gregset_t gregset; gdb_fpregset_t fpregset; if (which == 0) { if (core_reg_size != sizeof (gregset)) { warning ("wrong size gregset struct in core file"); } else { memcpy ((char *) &gregset, core_reg_sect, sizeof (gregset)); supply_gregset (&gregset); } } else if (which == 2) { if (core_reg_size != sizeof (fpregset)) { warning ("wrong size fpregset struct in core file"); } else { memcpy ((char *) &fpregset, core_reg_sect, sizeof (fpregset)); if (FP0_REGNUM >= 0) supply_fpregset (&fpregset); } } }
static int nbsd_thread_proc_setregs (void *arg, int regset, int lwp, void *buf) { struct nbsd_thread_proc_arg *a = (struct nbsd_thread_proc_arg *) arg; struct regcache *cache = a->cache; struct target_ops *ops = a->ops; struct cleanup *old_chain; struct target_ops *beneath = find_target_beneath (ops); int ret; ret = 0; old_chain = save_inferior_ptid (); switch (regset) { case 0: supply_gregset(cache, (gregset_t *)buf); break; case 1: #ifdef HAVE_FPREGS supply_fpregset(cache, (fpregset_t *)buf); #endif break; default: /* XXX need to handle other reg sets: SSE, AltiVec, etc. */ ret = TD_ERR_INVAL; } /* Storing registers requires that inferior_ptid is a LWP value rather than a thread value. */ inferior_ptid = ptid_build (ptid_get_pid (main_ptid), lwp, 0); beneath->to_store_registers (beneath, cache, -1); do_cleanups (old_chain); return ret; }
static void fetch_fpregs (int tid) { elf_fpregset_t fpregs; if (ptrace (PTRACE_GETFPREGS, tid, 0, (int) &fpregs) < 0) perror_with_name ("Couldn't get floating point status"); supply_fpregset (&fpregs); }
static void fetch_fpregs (struct regcache *regcache, int tid) { elf_fpregset_t fpregs; if (ptrace (PTRACE_GETFPREGS, tid, 0, (int) &fpregs) < 0) perror_with_name (_("Couldn't get floating point status")); supply_fpregset (regcache, (const elf_fpregset_t *) &fpregs); }
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; int regno; CORE_ADDR r_pc; supply_gregset (&core_reg->intreg); supply_fpregset (&core_reg->freg); }
ps_err_e ps_lsetfpregs (struct ps_prochandle *ph, lwpid_t lwpid, const gdb_prfpregset_t *fpregset) { struct regcache *regcache = get_ps_regcache (ph, lwpid); supply_fpregset (regcache, (const gdb_fpregset_t *) fpregset); target_store_registers (regcache, -1); return PS_OK; }
ps_err_e ps_lsetfpregs (gdb_ps_prochandle_t ph, lwpid_t lwpid, const gdb_prfpregset_t *fpregset) { ptid_t ptid = ptid_build (ptid_get_pid (ph->ptid), lwpid, 0); struct regcache *regcache = get_thread_arch_regcache (ptid, target_gdbarch ()); supply_fpregset (regcache, (const gdb_fpregset_t *) fpregset); target_store_registers (regcache, -1); return PS_OK; }
ps_err_e ps_lsetfpregs (struct ps_prochandle *ph, lwpid_t lwpid, const prfpregset_t *fpregset) { struct cleanup *old_chain; old_chain = save_inferior_ptid (); inferior_ptid = BUILD_LWP (lwpid, PIDGET (inferior_ptid)); supply_fpregset ((gdb_fpregset_t *) fpregset); target_store_registers (-1); do_cleanups (old_chain); return PS_OK; }
static void fbsd_thread_fetch_registers (struct target_ops *ops, struct regcache *regcache, int regnum) { 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_fetch_registers (ops, regcache, regnum); 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)); err = td_thr_getgregs_p (&th, gregset); if (err != TD_OK) error ("Cannot fetch general-purpose registers for thread %d: Thread ID=%ld, %s", pid_to_thread_id (inferior_ptid), GET_THREAD (inferior_ptid), thread_db_err_str (err)); #ifdef PT_GETXMMREGS err = td_thr_getxmmregs_p (&th, xmmregs); if (err == TD_OK) { i387_supply_fxsave (regcache, -1, xmmregs); } else { #endif err = td_thr_getfpregs_p (&th, &fpregset); if (err != TD_OK) error ("Cannot get floating-point registers for thread %d: Thread ID=%ld, %s", pid_to_thread_id (inferior_ptid), GET_THREAD (inferior_ptid), thread_db_err_str (err)); supply_fpregset (regcache, &fpregset); #ifdef PT_GETXMMREGS } #endif supply_gregset (regcache, gregset); }
/* Fetch all floating-point registers from process/thread TID and store their values in GDB's register cache. */ static void fetch_fpregs (int tid) { fpregset_t fpregs; ptrace_area parea; parea.len = sizeof (fpregs); parea.process_addr = (addr_t) &fpregs; parea.kernel_addr = offsetof (struct user_regs_struct, fp_regs); if (ptrace (PTRACE_PEEKUSR_AREA, tid, (long) &parea) < 0) perror_with_name ("Couldn't get floating point status"); supply_fpregset (&fpregs); }
ps_err_e ps_lsetfpregs (gdb_ps_prochandle_t ph, lwpid_t lwpid, const gdb_prfpregset_t *fpregset) { struct cleanup *old_chain = save_inferior_ptid (); inferior_ptid = BUILD_LWP (lwpid, ph->pid); /* FIXME: We should really make supply_fpregset const-correct. */ supply_fpregset ((gdb_fpregset_t *) fpregset); target_store_registers (-1); do_cleanups (old_chain); return PS_OK; }
ps_err_e ps_lsetfpregs (struct ps_prochandle *ph, lwpid_t lwpid, const prfpregset_t *fpregset) { struct cleanup *old_chain; struct regcache *regcache; old_chain = save_inferior_ptid (); inferior_ptid = BUILD_LWP (lwpid, ph->pid); regcache = get_thread_arch_regcache (inferior_ptid, target_gdbarch); supply_fpregset (regcache, fpregset); target_store_registers (regcache, -1); do_cleanups (old_chain); return PS_OK; }
static void fetch_core_registers (struct regcache *regcache, char *core_reg_sect, unsigned core_reg_size, int which, CORE_ADDR reg_addr) { gdb_gregset_t gregset; gdb_fpregset_t fpregset; gdb_gregset_t *gregset_p = &gregset; gdb_fpregset_t *fpregset_p = &fpregset; switch (which) { case 0: if (core_reg_size != sizeof (gregset)) warning (_("Wrong size gregset in core file.")); else { memcpy (&gregset, core_reg_sect, sizeof (gregset)); supply_gregset (regcache, (const gdb_gregset_t *) gregset_p); } break; case 2: if (core_reg_size != sizeof (fpregset)) warning (_("Wrong size fpregset in core file.")); else { memcpy (&fpregset, core_reg_sect, sizeof (fpregset)); if (gdbarch_fp0_regnum (get_regcache_arch (regcache)) >= 0) supply_fpregset (regcache, (const gdb_fpregset_t *) fpregset_p); } break; default: /* We've covered all the kinds of registers we know about here, so this must be something we wouldn't know what to do with anyway. Just ignore it. */ break; } }
ps_err_e ps_lsetfpregs (gdb_ps_prochandle_t ph, lwpid_t lwpid, const prfpregset_t * fpregset) { struct cleanup *old_chain; old_chain = save_inferior_ptid (); inferior_ptid = BUILD_LWP (lwpid, PIDGET (inferior_ptid)); supply_fpregset ((gdb_fpregset_t *) fpregset); if (target_has_execution) procfs_ops.to_store_registers (-1); else orig_core_ops.to_store_registers (-1); do_cleanups (old_chain); return PS_OK; }
static void fbsd_lwp_fetch_registers (struct target_ops *ops, struct regcache *regcache, int regnum) { gregset_t gregs; fpregset_t fpregs; lwpid_t lwp; #ifdef PT_GETXMMREGS char xmmregs[512]; #endif if (!target_has_execution) { struct target_ops *beneath = find_target_beneath (ops); beneath->to_fetch_registers (ops, regcache, regnum); return; } lwp = GET_LWP (inferior_ptid); if (ptrace (PT_GETREGS, lwp, (caddr_t) &gregs, 0) == -1) error ("Cannot get lwp %d registers: %s\n", lwp, safe_strerror (errno)); supply_gregset (regcache, &gregs); #ifdef PT_GETXMMREGS if (ptrace (PT_GETXMMREGS, lwp, xmmregs, 0) == 0) { i387_supply_fxsave (regcache, -1, xmmregs); } else { #endif if (ptrace (PT_GETFPREGS, lwp, (caddr_t) &fpregs, 0) == -1) error ("Cannot get lwp %d registers: %s\n ", lwp, safe_strerror (errno)); supply_fpregset (regcache, &fpregs); #ifdef PT_GETXMMREGS } #endif }
static void fetch_fp_regs (void) { struct fpreg inferior_fp_registers; #ifndef CROSS_DEBUGGER int ret; #endif int regno; #ifndef CROSS_DEBUGGER ret = ptrace (PT_GETFPREGS, PIDGET (inferior_ptid), (PTRACE_ARG3_TYPE) &inferior_fp_registers, 0); if (ret < 0) { warning ("unable to fetch general registers"); return; } #endif supply_fpregset (&inferior_fp_registers); }
static void fbsd_lwp_fetch_registers (int regno) { gregset_t gregs; fpregset_t fpregs; lwpid_t lwp; #ifdef PT_GETXMMREGS char xmmregs[512]; #endif if (!target_has_execution) { orig_core_ops.to_fetch_registers (-1); return; } /* XXX: We've replaced the pid with the lwpid for GDB's benefit. */ lwp = GET_PID (inferior_ptid); if (ptrace (PT_GETREGS, lwp, (caddr_t) &gregs, 0) == -1) error ("Cannot get lwp %d registers: %s\n", lwp, safe_strerror (errno)); supply_gregset (&gregs); #ifdef PT_GETXMMREGS if (ptrace (PT_GETXMMREGS, lwp, xmmregs, 0) == 0) { i387_supply_fxsave (current_regcache, -1, xmmregs); } else { #endif if (ptrace (PT_GETFPREGS, lwp, (caddr_t) &fpregs, 0) == -1) error ("Cannot get lwp %d registers: %s\n ", lwp, safe_strerror (errno)); supply_fpregset (&fpregs); #ifdef PT_GETXMMREGS } #endif }
static void fetch_elfcore_registers (char *core_reg_sect, unsigned core_reg_size, int which, CORE_ADDR ignore) { struct reg gregset; struct fpreg fparegset; switch (which) { case 0: /* Integer registers. */ if (core_reg_size != sizeof (struct reg)) warning ("wrong size of register set in core file"); else { /* The memcpy may be unnecessary, but we can't really be sure of the alignment of the data in the core file. */ memcpy (&gregset, core_reg_sect, sizeof (gregset)); supply_gregset (&gregset); } break; case 2: if (core_reg_size != sizeof (struct fpreg)) warning ("wrong size of FPA register set in core file"); else { /* The memcpy may be unnecessary, but we can't really be sure of the alignment of the data in the core file. */ memcpy (&fparegset, core_reg_sect, sizeof (fparegset)); supply_fpregset (&fparegset); } break; default: /* Don't know what kind of register request this is; just ignore it. */ break; } }
static void fetch_core_registers(char *core_reg_sect, unsigned core_reg_size, int which, CORE_ADDR reg_addr) { gdb_gregset_t gregset; gdb_fpregset_t fpregset; switch (which) { case 0: if (core_reg_size != sizeof(gregset)) warning(_("Wrong size gregset in core file.")); else { memcpy(&gregset, core_reg_sect, sizeof(gregset)); supply_gregset(&gregset); } break; case 2: if (core_reg_size != sizeof(fpregset)) warning(_("Wrong size fpregset in core file.")); else { memcpy(&fpregset, core_reg_sect, sizeof(fpregset)); if (FP0_REGNUM >= 0) supply_fpregset(&fpregset); } break; default: /* We have covered all the kinds of registers we know about here, * so this must be something that we would NOT know what to do with * anyway. Just ignore it: */ break; } }
static void sol_thread_fetch_registers (int regno) { thread_t thread; td_thrhandle_t thandle; td_err_e val; prgregset_t gregset; prfpregset_t fpregset; #if 0 int xregsize; caddr_t xregset; #endif if (!is_thread (inferior_ptid)) { /* LWP: pass the request on to procfs.c */ if (target_has_execution) procfs_ops.to_fetch_registers (regno); else orig_core_ops.to_fetch_registers (regno); return; } /* Solaris thread: convert inferior_ptid into a td_thrhandle_t */ thread = GET_THREAD (inferior_ptid); if (thread == 0) error ("sol_thread_fetch_registers: thread == 0"); val = p_td_ta_map_id2thr (main_ta, thread, &thandle); if (val != TD_OK) error ("sol_thread_fetch_registers: td_ta_map_id2thr: %s", td_err_string (val)); /* Get the integer regs */ val = p_td_thr_getgregs (&thandle, gregset); if (val != TD_OK && val != TD_PARTIALREG) error ("sol_thread_fetch_registers: td_thr_getgregs %s", td_err_string (val)); /* For the sparc, TD_PARTIALREG means that only i0->i7, l0->l7, pc and sp are saved (by a thread context switch). */ /* And, now the fp regs */ val = p_td_thr_getfpregs (&thandle, &fpregset); if (val != TD_OK && val != TD_NOFPREGS) error ("sol_thread_fetch_registers: td_thr_getfpregs %s", td_err_string (val)); /* Note that we must call supply_{g fp}regset *after* calling the td routines because the td routines call ps_lget* which affect the values stored in the registers array. */ supply_gregset ((gdb_gregset_t *) &gregset); supply_fpregset ((gdb_fpregset_t *) &fpregset); #if 0 /* thread_db doesn't seem to handle this right */ val = td_thr_getxregsize (&thandle, &xregsize); if (val != TD_OK && val != TD_NOXREGS) error ("sol_thread_fetch_registers: td_thr_getxregsize %s", td_err_string (val)); if (val == TD_OK) { xregset = alloca (xregsize); val = td_thr_getxregs (&thandle, xregset); if (val != TD_OK) error ("sol_thread_fetch_registers: td_thr_getxregs %s", td_err_string (val)); } #endif }