-static LONGEST
-thread_db_xfer_partial (struct target_ops *ops, enum target_object object,
- const char *annex, gdb_byte *readbuf,
- const gdb_byte *writebuf, ULONGEST offset, LONGEST len)
-{
- struct cleanup *old_chain = save_inferior_ptid ();
- LONGEST xfer;
-
- if (is_thread (inferior_ptid))
- {
- /* FIXME: This seems to be necessary to make sure breakpoints
- are removed. */
- if (!target_thread_alive (inferior_ptid))
- inferior_ptid = pid_to_ptid (GET_PID (inferior_ptid));
- else
- inferior_ptid = lwp_from_thread (inferior_ptid);
- }
-
- xfer = target_beneath->to_xfer_partial (ops, object, annex,
- readbuf, writebuf, offset, len);
-
- do_cleanups (old_chain);
- return xfer;
-}
-
-static void
-thread_db_fetch_registers (int regno)
-{
- struct thread_info *thread_info;
- prgregset_t gregset;
- gdb_prfpregset_t fpregset;
- td_err_e err;
-
- if (!is_thread (inferior_ptid))
- {
- /* Pass the request to the target beneath us. */
- target_beneath->to_fetch_registers (regno);
- return;
- }
-
- thread_info = find_thread_pid (inferior_ptid);
- thread_db_map_id2thr (thread_info, 1);
-
- err = td_thr_getgregs_p (&thread_info->private->th, gregset);
- if (err != TD_OK)
- error (_("Cannot fetch general-purpose registers for thread %ld: %s"),
- (long) GET_THREAD (inferior_ptid), thread_db_err_str (err));
-
- err = td_thr_getfpregs_p (&thread_info->private->th, &fpregset);
- if (err != TD_OK)
- error (_("Cannot get floating-point registers for thread %ld: %s"),
- (long) GET_THREAD (inferior_ptid), thread_db_err_str (err));
-
- /* Note that we must call supply_gregset after calling the thread_db
- routines because the thread_db routines call ps_lgetgregs and
- friends which clobber GDB's register cache. */
- supply_gregset ((gdb_gregset_t *) gregset);
- supply_fpregset (&fpregset);
-}
-
-static void
-thread_db_store_registers (int regno)
-{
- prgregset_t gregset;
- gdb_prfpregset_t fpregset;
- td_err_e err;
- struct thread_info *thread_info;
-
- if (!is_thread (inferior_ptid))
- {
- /* Pass the request to the target beneath us. */
- target_beneath->to_store_registers (regno);
- return;
- }
-
- thread_info = find_thread_pid (inferior_ptid);
- thread_db_map_id2thr (thread_info, 1);
-
- if (regno != -1)
- {
- gdb_byte raw[MAX_REGISTER_SIZE];
-
- regcache_raw_collect (current_regcache, regno, raw);
- thread_db_fetch_registers (-1);
- regcache_raw_supply (current_regcache, regno, raw);
- }
-
- fill_gregset ((gdb_gregset_t *) gregset, -1);
- fill_fpregset (&fpregset, -1);
-
- err = td_thr_setgregs_p (&thread_info->private->th, gregset);
- if (err != TD_OK)
- error (_("Cannot store general-purpose registers for thread %ld: %s"),
- (long) GET_THREAD (inferior_ptid), thread_db_err_str (err));
- err = td_thr_setfpregs_p (&thread_info->private->th, &fpregset);
- if (err != TD_OK)
- error (_("Cannot store floating-point registers for thread %ld: %s"),
- (long) GET_THREAD (inferior_ptid), thread_db_err_str (err));
-}
-