void
x86_linux_nat_target::low_new_fork (struct lwp_info *parent, pid_t child_pid)
{
  pid_t parent_pid;
  struct x86_debug_reg_state *parent_state;
  struct x86_debug_reg_state *child_state;

  /* NULL means no watchpoint has ever been set in the parent.  In
     that case, there's nothing to do.  */
  if (parent->arch_private == NULL)
    return;

  /* Linux kernel before 2.6.33 commit
     72f674d203cd230426437cdcf7dd6f681dad8b0d
     will inherit hardware debug registers from parent
     on fork/vfork/clone.  Newer Linux kernels create such tasks with
     zeroed debug registers.

     GDB core assumes the child inherits the watchpoints/hw
     breakpoints of the parent, and will remove them all from the
     forked off process.  Copy the debug registers mirrors into the
     new process so that all breakpoints and watchpoints can be
     removed together.  The debug registers mirror will become zeroed
     in the end before detaching the forked off process, thus making
     this compatible with older Linux kernels too.  */

  parent_pid = parent->ptid.pid ();
  parent_state = x86_debug_reg_state (parent_pid);
  child_state = x86_debug_reg_state (child_pid);
  *child_state = *parent_state;
}
Exemple #2
0
static int
x86_stopped_by_watchpoint (struct target_ops *ops)
{
  struct x86_debug_reg_state *state
    = x86_debug_reg_state (ptid_get_pid (inferior_ptid));

  return x86_dr_stopped_by_watchpoint (state);
}
Exemple #3
0
static int
x86_stopped_data_address (struct target_ops *ops, CORE_ADDR *addr_p)
{
  struct x86_debug_reg_state *state
    = x86_debug_reg_state (ptid_get_pid (inferior_ptid));

  return x86_dr_stopped_data_address (state, addr_p);
}
Exemple #4
0
static int
x86_region_ok_for_watchpoint (struct target_ops *self,
			      CORE_ADDR addr, int len)
{
  struct x86_debug_reg_state *state
    = x86_debug_reg_state (ptid_get_pid (inferior_ptid));

  return x86_dr_region_ok_for_watchpoint (state, addr, len);
}
Exemple #5
0
/* Remove a watchpoint that watched the memory region which starts at
   address ADDR, whose length is LEN bytes, and for accesses of the
   type TYPE.  Return 0 on success, -1 on failure.  */
static int
x86_remove_watchpoint (struct target_ops *self, CORE_ADDR addr, int len,
		       enum target_hw_bp_type type, struct expression *cond)
{
  struct x86_debug_reg_state *state
    = x86_debug_reg_state (ptid_get_pid (inferior_ptid));

  return x86_dr_remove_watchpoint (state, type, addr, len);
}
Exemple #6
0
static int
x86_remove_hw_breakpoint (struct target_ops *self, struct gdbarch *gdbarch,
			  struct bp_target_info *bp_tgt)
{
  struct x86_debug_reg_state *state
    = x86_debug_reg_state (ptid_get_pid (inferior_ptid));

  return x86_dr_remove_watchpoint (state, hw_execute,
				   bp_tgt->placed_address, 1);
}
Exemple #7
0
static int
x86_insert_hw_breakpoint (struct target_ops *self, struct gdbarch *gdbarch,
			  struct bp_target_info *bp_tgt)
{
  struct x86_debug_reg_state *state
    = x86_debug_reg_state (ptid_get_pid (inferior_ptid));

  bp_tgt->placed_address = bp_tgt->reqstd_address;
  return x86_dr_insert_watchpoint (state, hw_execute,
				   bp_tgt->placed_address, 1) ? EBUSY : 0;
}