-/* Support for debug registers. */
-
-static unsigned long
-x86_linux_dr_get (ptid_t ptid, int regnum)
-{
- int tid;
- unsigned long value;
-
- tid = ptid_get_lwp (ptid);
-
- errno = 0;
- value = ptrace (PTRACE_PEEKUSER, tid,
- offsetof (struct user, u_debugreg[regnum]), 0);
- if (errno != 0)
- error ("Couldn't read debug register");
-
- return value;
-}
-
-static void
-x86_linux_dr_set (ptid_t ptid, int regnum, unsigned long value)
-{
- int tid;
-
- tid = ptid_get_lwp (ptid);
-
- errno = 0;
- ptrace (PTRACE_POKEUSER, tid,
- offsetof (struct user, u_debugreg[regnum]), value);
- if (errno != 0)
- error ("Couldn't write debug register");
-}
-
-static int
-update_debug_registers_callback (struct inferior_list_entry *entry,
- void *pid_p)
-{
- struct thread_info *thr = (struct thread_info *) entry;
- struct lwp_info *lwp = get_thread_lwp (thr);
- int pid = *(int *) pid_p;
-
- /* Only update the threads of this process. */
- if (pid_of (thr) == pid)
- {
- /* The actual update is done later just before resuming the lwp,
- we just mark that the registers need updating. */
- lwp->arch_private->debug_registers_changed = 1;
-
- /* If the lwp isn't stopped, force it to momentarily pause, so
- we can update its debug registers. */
- if (!lwp->stopped)
- linux_stop_lwp (lwp);
- }
-
- return 0;
-}
-
-/* Update the inferior's debug register REGNUM from STATE. */
-
-static void
-x86_dr_low_set_addr (int regnum, CORE_ADDR addr)
-{
- /* Only update the threads of this process. */
- int pid = pid_of (current_thread);
-
- gdb_assert (DR_FIRSTADDR <= regnum && regnum <= DR_LASTADDR);
-
- find_inferior (&all_threads, update_debug_registers_callback, &pid);
-}
-
-/* Return the inferior's debug register REGNUM. */
-
-static CORE_ADDR
-x86_dr_low_get_addr (int regnum)
-{
- ptid_t ptid = ptid_of (current_thread);
-
- gdb_assert (DR_FIRSTADDR <= regnum && regnum <= DR_LASTADDR);
-
- return x86_linux_dr_get (ptid, regnum);
-}
-
-/* Update the inferior's DR7 debug control register from STATE. */
-
-static void
-x86_dr_low_set_control (unsigned long control)
-{
- /* Only update the threads of this process. */
- int pid = pid_of (current_thread);
-
- find_inferior (&all_threads, update_debug_registers_callback, &pid);
-}
-
-/* Return the inferior's DR7 debug control register. */
-
-static unsigned long
-x86_dr_low_get_control (void)
-{
- ptid_t ptid = ptid_of (current_thread);
-
- return x86_linux_dr_get (ptid, DR_CONTROL);
-}
-
-/* Get the value of the DR6 debug status register from the inferior
- and record it in STATE. */
-
-static unsigned long
-x86_dr_low_get_status (void)
-{
- ptid_t ptid = ptid_of (current_thread);
-
- return x86_linux_dr_get (ptid, DR_STATUS);
-}
-