public inbox for archer-commits@sourceware.org
help / color / mirror / Atom feed
* [SCM]  archer-jankratochvil-watchpoint3: sync i386 to amd64 style.
@ 2010-12-06  5:43 jkratoch
  0 siblings, 0 replies; only message in thread
From: jkratoch @ 2010-12-06  5:43 UTC (permalink / raw)
  To: archer-commits

The branch, archer-jankratochvil-watchpoint3 has been updated
       via  889f084891b14e5afdd92c545808f6ed4541333e (commit)
       via  8e5da73e41e015cd993d733a5361810a9040219d (commit)
      from  0fb20226dad52db5c9a6a8bb0d3e308cbee76a6f (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email.

- Log -----------------------------------------------------------------
commit 889f084891b14e5afdd92c545808f6ed4541333e
Author: Jan Kratochvil <jan.kratochvil@redhat.com>
Date:   Mon Dec 6 06:42:15 2010 +0100

    sync i386 to amd64 style.

commit 8e5da73e41e015cd993d733a5361810a9040219d
Author: Jan Kratochvil <jan.kratochvil@redhat.com>
Date:   Mon Dec 6 06:24:14 2010 +0100

    +comments

-----------------------------------------------------------------------

Summary of changes:
 gdb/amd64-linux-nat.c |    8 +++-
 gdb/i386-linux-nat.c  |   90 ++++++++++++++++++++++++++----------------------
 gdb/linux-nat.c       |   20 ++++++++---
 3 files changed, 69 insertions(+), 49 deletions(-)

First 500 lines of diff:
diff --git a/gdb/amd64-linux-nat.c b/gdb/amd64-linux-nat.c
index c1e88a6..0a38f5e 100644
--- a/gdb/amd64-linux-nat.c
+++ b/gdb/amd64-linux-nat.c
@@ -311,13 +311,17 @@ amd64_linux_dr_set_control_callback (int tid, void *control_voidp)
   int inferior_pid = ptid_get_pid (inferior_ptid);
   struct inferior *inf = current_inferior ();
 
+  /* Are we detaching breakpoints from a fork-ed child?  See
+     linux_nat_iterate_watchpoint_lwps.  */
   if (inf->pid != inferior_pid)
     {
       int i;
 
       /* Workaround some kernel versions reporting EINVAL on setting
-         DR_CONTROL with still unset DR_*ADDR registers.
-         See: https://bugzilla.redhat.com/show_bug.cgi?id=660204  */
+         DR_CONTROL with still unset (and thus zero) DR_*ADDR registers.
+         See: https://bugzilla.redhat.com/show_bug.cgi?id=660204
+	 It can happen as some kernel versions reset all DR registers to zero
+	 for the fork-ed child; other kernels copy them from the parent.  */
 
       for (i = DR_FIRSTADDR; i <= DR_LASTADDR; i++)
 	amd64_linux_dr_set (tid, i, amd64_linux_dr[i]);
diff --git a/gdb/i386-linux-nat.c b/gdb/i386-linux-nat.c
index eb85397..07bc5fe 100644
--- a/gdb/i386-linux-nat.c
+++ b/gdb/i386-linux-nat.c
@@ -640,15 +640,10 @@ static unsigned long i386_linux_dr[DR_CONTROL + 1];
 /* Get debug register REGNUM value from only the one LWP of PTID.  */
 
 static unsigned long
-i386_linux_dr_get (ptid_t ptid, int regnum)
+i386_linux_dr_get (int tid, int regnum)
 {
-  int tid;
   unsigned long value;
 
-  tid = TIDGET (ptid);
-  if (tid == 0)
-    tid = PIDGET (ptid);
-
   /* FIXME: kettenis/2001-03-27: Calling perror_with_name if the
      ptrace call fails breaks debugging remote targets.  The correct
      way to fix this is to add the hardware breakpoint and watchpoint
@@ -670,14 +665,8 @@ i386_linux_dr_get (ptid_t ptid, int regnum)
 /* Set debug register REGNUM to VALUE in only the one LWP of PTID.  */
 
 static void
-i386_linux_dr_set (ptid_t ptid, int regnum, unsigned long value)
+i386_linux_dr_set (int tid, int regnum, unsigned long value)
 {
-  int tid;
-
-  tid = TIDGET (ptid);
-  if (tid == 0)
-    tid = PIDGET (ptid);
-
   errno = 0;
   ptrace (PTRACE_POKEUSER, tid,
 	  offsetof (struct user, u_debugreg[regnum]), value);
@@ -687,15 +676,31 @@ i386_linux_dr_set (ptid_t ptid, int regnum, unsigned long value)
 
 /* Helper for i386_linux_dr_set_control.  */
 
-static int
-i386_linux_dr_set_control_callback (struct lwp_info *lp, void *control_voidp)
+static void
+i386_linux_dr_set_control_callback (int tid, void *control_voidp)
 {
   unsigned long control = (unsigned long) control_voidp;
+  int inferior_pid = ptid_get_pid (inferior_ptid);
+  struct inferior *inf = current_inferior ();
 
-  i386_linux_dr_set (lp->ptid, DR_CONTROL, control);
+  /* Are we detaching breakpoints from a fork-ed child?  See
+     linux_nat_iterate_watchpoint_lwps.  */
+  if (inf->pid != inferior_pid)
+    {
+      int i;
+
+      /* Workaround some kernel versions reporting EINVAL on setting
+         DR_CONTROL with still unset (and thus zero) DR_*ADDR registers.
+         See: https://bugzilla.redhat.com/show_bug.cgi?id=660204
+	 It can happen as some kernel versions reset all DR registers to zero
+	 for the fork-ed child; other kernels copy them from the parent.  */
+
+      for (i = DR_FIRSTADDR; i <= DR_LASTADDR; i++)
+	i386_linux_dr_set (tid, i, i386_linux_dr[i]);
+    }
 
-  /* Continue the traversal.  */
-  return 0;
+
+  i386_linux_dr_set (tid, DR_CONTROL, control);
 }
 
 /* Set DR_CONTROL to ADDR in all LWPs of CURRENT_INFERIOR.  */
@@ -705,8 +710,8 @@ i386_linux_dr_set_control (unsigned long control)
 {
   i386_linux_dr[DR_CONTROL] = control;
 
-  iterate_over_lwps (pid_to_ptid (GET_PID (inferior_ptid)),
-		     i386_linux_dr_set_control_callback, (void *) control);
+  linux_nat_iterate_watchpoint_lwps (i386_linux_dr_set_control_callback,
+				     (void *) control);
 }
 
 /* Helper for i386_linux_dr_set_addr.  */
@@ -717,15 +722,12 @@ struct i386_linux_dr_set_addr_data
     CORE_ADDR addr;
   };
 
-static int
-i386_linux_dr_set_addr_callback (struct lwp_info *lp, void *datap_voidp)
+static void
+i386_linux_dr_set_addr_callback (int tid, void *datap_voidp)
 {
   const struct i386_linux_dr_set_addr_data *datap = datap_voidp;
 
-  i386_linux_dr_set (lp->ptid, DR_FIRSTADDR + datap->regnum, datap->addr);
-
-  /* Continue the traversal.  */
-  return 0;
+  i386_linux_dr_set (tid, DR_FIRSTADDR + datap->regnum, datap->addr);
 }
 
 /* Set address REGNUM (zero based) to ADDR in all LWPs of CURRENT_INFERIOR.
@@ -742,8 +744,7 @@ i386_linux_dr_set_addr (int regnum, CORE_ADDR addr)
 
   data.regnum = regnum;
   data.addr = addr;
-  iterate_over_lwps (pid_to_ptid (GET_PID (inferior_ptid)),
-		     i386_linux_dr_set_addr_callback, &data);
+  linux_nat_iterate_watchpoint_lwps (i386_linux_dr_set_addr_callback, &data);
 }
 
 /* Set address REGNUM (zero based) to zero in all LWPs of CURRENT_INFERIOR.
@@ -760,23 +761,26 @@ i386_linux_dr_reset_addr (int regnum)
 static unsigned long
 i386_linux_dr_get_status (void)
 {
-  return i386_linux_dr_get (inferior_ptid, DR_STATUS);
+  int tid;
+
+  tid = TIDGET (inferior_ptid);
+  if (tid == 0)
+    tid = PIDGET (inferior_ptid);
+
+  return i386_linux_dr_get (tid, DR_STATUS);
 }
 
 /* Helper for i386_linux_dr_unset_status.  */
 
-static int
-i386_linux_dr_unset_status_callback (struct lwp_info *lp, void *mask_voidp)
+static void
+i386_linux_dr_unset_status_callback (int tid, void *mask_voidp)
 {
   unsigned long mask = (unsigned long) mask_voidp;
   unsigned long value;
       
-  value = i386_linux_dr_get (lp->ptid, DR_STATUS);
+  value = i386_linux_dr_get (tid, DR_STATUS);
   value &= ~mask;
-  i386_linux_dr_set (lp->ptid, DR_STATUS, value);
-
-  /* Continue the traversal.  */
-  return 0;
+  i386_linux_dr_set (tid, DR_STATUS, value);
 }
 
 /* Unset MASK bits in DR_STATUS in all LWPs of CURRENT_INFERIOR.  */
@@ -784,19 +788,23 @@ i386_linux_dr_unset_status_callback (struct lwp_info *lp, void *mask_voidp)
 static void
 i386_linux_dr_unset_status (unsigned long mask)
 {
-  iterate_over_lwps (pid_to_ptid (GET_PID (inferior_ptid)),
-		     i386_linux_dr_unset_status_callback, (void *) mask);
+  linux_nat_iterate_watchpoint_lwps (i386_linux_dr_unset_status_callback,
+				     (void *) mask);
 }
 
 static void
 i386_linux_new_thread (ptid_t ptid)
 {
-  int i;
+  int i, tid;
+
+  tid = TIDGET (ptid);
+  if (tid == 0)
+    tid = PIDGET (ptid);
 
   for (i = DR_FIRSTADDR; i <= DR_LASTADDR; i++)
-    i386_linux_dr_set (ptid, i, i386_linux_dr[i]);
+    i386_linux_dr_set (tid, i, i386_linux_dr[i]);
 
-  i386_linux_dr_set (ptid, DR_CONTROL, i386_linux_dr[DR_CONTROL]);
+  i386_linux_dr_set (tid, DR_CONTROL, i386_linux_dr[DR_CONTROL]);
 }
 \f
 
diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c
index 6794517..bfff6c5 100644
--- a/gdb/linux-nat.c
+++ b/gdb/linux-nat.c
@@ -1267,9 +1267,11 @@ iterate_watchpoint_lwps_callback (struct lwp_info *lp, void *datap_voidp)
   return 0;
 }
 
-/* Iterate the same style like iterate_over_lwps does except when forking-off
-   a child call CALLBACK with CALLBACK_DATA specifically only for that new
-   child PID.  */
+/* Iterate like iterate_over_lwps does except when forking-off a child call
+   CALLBACK with CALLBACK_DATA specifically only for that new child PID.
+
+   During `set follow-fork-mode child' the call is also made for the new child
+   PID; parent watchpoints get detached elsewhere (during target_detach).  */
 
 void
 linux_nat_iterate_watchpoint_lwps
@@ -1283,10 +1285,16 @@ linux_nat_iterate_watchpoint_lwps
   data.callback_data = callback_data;
 
   if (inf->pid == inferior_pid)
-    iterate_over_lwps (pid_to_ptid (inferior_pid),
-		       iterate_watchpoint_lwps_callback, &data);
+    {
+      /* Standard mode.  */
+      iterate_over_lwps (pid_to_ptid (inferior_pid),
+			 iterate_watchpoint_lwps_callback, &data);
+    }
   else
-    callback (inferior_pid, callback_data);
+    {
+      /* Detaching a new child PID temporarily present in INFERIOR_PID.  */
+      callback (inferior_pid, callback_data);
+    }
 }
 
 /* Update our internal state when changing from one checkpoint to


hooks/post-receive
--
Repository for Project Archer.


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2010-12-06  5:43 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-12-06  5:43 [SCM] archer-jankratochvil-watchpoint3: sync i386 to amd64 style jkratoch

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).