#endif
#include "x86-xstate.h"
#include "nat/linux-btrace.h"
+#include "nat/linux-nat.h"
+#include "nat/x86-linux.h"
/* Per-thread arch-specific data we want to keep. */
/* DR6 and DR7 are retrieved with some other way. */
gdb_assert (DR_FIRSTADDR <= regnum && regnum <= DR_LASTADDR);
- return x86_linux_dr_get (inferior_ptid, regnum);
+ return x86_linux_dr_get (current_lwp_ptid (), regnum);
}
/* Return the inferior's DR7 debug control register. */
static unsigned long
x86_linux_dr_get_control (void)
{
- return x86_linux_dr_get (inferior_ptid, DR_CONTROL);
+ return x86_linux_dr_get (current_lwp_ptid (), DR_CONTROL);
}
/* Get DR_STATUS from only the one LWP of INFERIOR_PTID. */
static unsigned long
x86_linux_dr_get_status (void)
{
- return x86_linux_dr_get (inferior_ptid, DR_STATUS);
+ return x86_linux_dr_get (current_lwp_ptid (), DR_STATUS);
}
/* Callback for iterate_over_lwps. Update the debug registers of
static int
update_debug_registers_callback (struct lwp_info *lwp, void *arg)
{
- if (lwp->arch_private == NULL)
- lwp->arch_private = XCNEW (struct arch_lwp_info);
-
/* 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;
+ lwp_set_debug_registers_changed (lwp, 1);
/* If the lwp isn't stopped, force it to momentarily pause, so we
can update its debug registers. */
- if (!lwp->stopped)
+ if (!lwp_is_stopped (lwp))
linux_stop_lwp (lwp);
/* Continue the iteration. */
static void
x86_linux_dr_set_control (unsigned long control)
{
- ptid_t pid_ptid = pid_to_ptid (ptid_get_pid (inferior_ptid));
+ ptid_t pid_ptid = pid_to_ptid (ptid_get_pid (current_lwp_ptid ()));
iterate_over_lwps (pid_ptid, update_debug_registers_callback, NULL);
}
static void
x86_linux_dr_set_addr (int regnum, CORE_ADDR addr)
{
- ptid_t pid_ptid = pid_to_ptid (ptid_get_pid (inferior_ptid));
+ ptid_t pid_ptid = pid_to_ptid (ptid_get_pid (current_lwp_ptid ()));
- gdb_assert (regnum >= 0 && regnum <= DR_LASTADDR - DR_FIRSTADDR);
+ gdb_assert (DR_FIRSTADDR <= regnum && regnum <= DR_LASTADDR);
iterate_over_lwps (pid_ptid, update_debug_registers_callback, NULL);
}
static void
x86_linux_prepare_to_resume (struct lwp_info *lwp)
{
+ ptid_t ptid = ptid_of_lwp (lwp);
int clear_status = 0;
- /* NULL means this is the main thread still going through the shell,
- or, no watchpoint has been set yet. In that case, there's
- nothing to do. */
- if (lwp->arch_private == NULL)
- return;
-
- if (lwp->arch_private->debug_registers_changed)
+ if (lwp_debug_registers_changed (lwp))
{
struct x86_debug_reg_state *state
- = x86_debug_reg_state (ptid_get_pid (lwp->ptid));
+ = x86_debug_reg_state (ptid_get_pid (ptid));
int i;
/* On Linux kernel before 2.6.33 commit
/* Clear DR_CONTROL first. In some cases, setting DR0-3 to a
value that doesn't match what is enabled in DR_CONTROL
results in EINVAL. */
- x86_linux_dr_set (lwp->ptid, DR_CONTROL, 0);
+ x86_linux_dr_set (ptid, DR_CONTROL, 0);
ALL_DEBUG_ADDRESS_REGISTERS (i)
if (state->dr_ref_count[i] > 0)
{
- x86_linux_dr_set (lwp->ptid, i, state->dr_mirror[i]);
+ x86_linux_dr_set (ptid, i, state->dr_mirror[i]);
/* If we're setting a watchpoint, any change the inferior
had done itself to the debug registers needs to be
/* If DR_CONTROL is supposed to be zero, we've already set it
above. */
if (state->dr_control_mirror != 0)
- x86_linux_dr_set (lwp->ptid, DR_CONTROL, state->dr_control_mirror);
+ x86_linux_dr_set (ptid, DR_CONTROL, state->dr_control_mirror);
- lwp->arch_private->debug_registers_changed = 0;
+ lwp_set_debug_registers_changed (lwp, 0);
}
- if (clear_status || lwp->stop_reason == LWP_STOPPED_BY_WATCHPOINT)
- x86_linux_dr_set (lwp->ptid, DR_STATUS, 0);
+ if (clear_status
+ || lwp_stop_reason (lwp) == TARGET_STOPPED_BY_WATCHPOINT)
+ x86_linux_dr_set (ptid, DR_STATUS, 0);
}
static void
-x86_linux_new_thread (struct lwp_info *lp)
+x86_linux_new_thread (struct lwp_info *lwp)
{
- struct arch_lwp_info *info = XCNEW (struct arch_lwp_info);
-
- info->debug_registers_changed = 1;
-
- lp->arch_private = info;
+ lwp_set_debug_registers_changed (lwp, 1);
}
\f