public inbox for frysk-cvs@sourceware.org
help / color / mirror / Atom feed
From: mark@sourceware.org
To: frysk-cvs@sourceware.org
Subject: [SCM]  master: Record Task registering TaskObserver.Code with BreakpointAddresses. Bug #5234.
Date: Mon, 21 Apr 2008 10:26:00 -0000	[thread overview]
Message-ID: <20080421102559.5304.qmail@sourceware.org> (raw)

The branch, master has been updated
       via  c9b6156e7b4d4ab4ccb29024e22625901595c15b (commit)
      from  52ced09bbfafaaf25f6b8d281797a0bd2fc7683a (commit)

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

- Log -----------------------------------------------------------------
commit c9b6156e7b4d4ab4ccb29024e22625901595c15b
Author: Mark Wielaard <mwielaard@redhat.com>
Date:   Mon Apr 21 12:24:08 2008 +0200

    Record Task registering TaskObserver.Code with BreakpointAddresses. Bug #5234.
    
    frysk-core/frysk/proc/live/ChangeLog
    2008-04-21  Mark Wielaard  <mwielaard@redhat.com>
    
            * BreakpointAddresses.java: Mark class and methods package private.
            (CodeObserver): New final static helper class.
            (addBreakpoint): Take CodeObserver as argument, not
            TaskObserver.Code.
            (removeBreakpoint): Likewise.
            (getCodeObservers): Return collection of CodeObservers, not
            TaskObserver.Code.
            * LinuxPtraceProc.java (BreakpointAction.run): Install or remove
            BreakpointAddresses.CodeObserver instead of bare TaskObserver.Code.
            * LinuxPtraceTask.java (notifyCodeBreakpoint): Check Task against
            BreakpointAddresses.CodeObserver.
            * TestTaskObserverCode.java (testMultiTaskUpdateCalledSeveralTimes):
            Resolved bug #5234.

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

Summary of changes:
 .../frysk/proc/live/BreakpointAddresses.java       |   58 ++++++++++++++++----
 frysk-core/frysk/proc/live/ChangeLog               |   16 ++++++
 frysk-core/frysk/proc/live/LinuxPtraceProc.java    |   10 +++-
 frysk-core/frysk/proc/live/LinuxPtraceTask.java    |    9 ++--
 .../frysk/proc/live/TestTaskObserverCode.java      |    3 -
 5 files changed, 77 insertions(+), 19 deletions(-)

First 500 lines of diff:
diff --git a/frysk-core/frysk/proc/live/BreakpointAddresses.java b/frysk-core/frysk/proc/live/BreakpointAddresses.java
index dc59c34..1fb127a 100644
--- a/frysk-core/frysk/proc/live/BreakpointAddresses.java
+++ b/frysk-core/frysk/proc/live/BreakpointAddresses.java
@@ -42,6 +42,7 @@ package frysk.proc.live;
 
 import frysk.proc.TaskObserver;
 import frysk.proc.Proc;
+import frysk.proc.Task;
 import java.util.Collection;
 import java.util.Iterator;
 import java.util.HashMap;
@@ -62,8 +63,45 @@ import java.util.ArrayList;
  * This datastructure isn't multithread safe, it should only be called
  * from the eventloop in response to requests pending for the Proc.
  */
-public class BreakpointAddresses
+class BreakpointAddresses
 {
+
+  /**
+   * Small package private class holding Task and TaskObserver.Code
+   * interested in a particular breakpoint. Used by
+   * <code>addBreakpoint()</code>, <code>removeBreakpoint</code> and
+   * <code>getBreakpoints()</code>.
+   */
+  final static class CodeObserver
+  {
+    final Task task;
+    final TaskObserver.Code observer;
+
+    CodeObserver(Task task, TaskObserver.Code observer)
+    {
+      if (task == null || observer == null)
+	throw new NullPointerException();
+
+      this.task = task;
+      this.observer = observer;
+    }
+
+    public boolean equals(Object o)
+    {
+      if (! (o instanceof CodeObserver))
+	return false;
+
+      CodeObserver other = (CodeObserver) o;
+      return (this.task.equals(other.task)
+	      && this.observer.equals(other.observer));
+    }
+
+    public int hashCode()
+    {
+      return task.hashCode() ^ observer.hashCode();
+    }
+  }
+
   /**
    * Proc used to set breakpoints and which sents us notifications
    * when breakpoints are hit.
@@ -85,7 +123,7 @@ public class BreakpointAddresses
   /**
    * Package private constructor used by the Proc when created.
    */
-  public BreakpointAddresses(Proc proc)
+  BreakpointAddresses(Proc proc)
   {
     this.proc = proc;
     map = new HashMap();
@@ -99,7 +137,7 @@ public class BreakpointAddresses
    * added to the list of objects to notify when the breakpoint is
    * hit (and the method returns false).
    */
-  public boolean addBreakpoint(TaskObserver.Code observer, long address)
+  boolean addBreakpoint(CodeObserver observer, long address)
   {
     Breakpoint breakpoint = Breakpoint.create(address, proc);
 
@@ -129,7 +167,7 @@ public class BreakpointAddresses
    *
    * @throws IllegalArgumentException if the observer was never added.
    */
-  public boolean removeBreakpoint(TaskObserver.Code observer, long address)
+  boolean removeBreakpoint(CodeObserver observer, long address)
   {
     Breakpoint breakpoint = Breakpoint.create(address, proc);
     ArrayList list = (ArrayList) map.get(breakpoint);
@@ -149,10 +187,11 @@ public class BreakpointAddresses
 
     /**
      * Called by the Proc when it has trapped a breakpoint.  Returns a
-     * Collection of TaskObserver.Code observers interested in the given
+     * Collection of CodeObservers interested in the given
      * address or null when no Code observer was installed on this address.
+     * Package private (as is CodeObserver).
      */
-    public Collection getCodeObservers(long address) {
+    Collection getCodeObservers(long address) {
 	ArrayList observers;
 	Breakpoint breakpoint = Breakpoint.create(address, proc);
 	ArrayList list = (ArrayList) map.get(breakpoint);
@@ -165,7 +204,7 @@ public class BreakpointAddresses
 	return observers;
     }
 
-  public Breakpoint getBreakpoint(long address)
+  Breakpoint getBreakpoint(long address)
   {
     Breakpoint breakpoint = Breakpoint.create(address, proc);
     Object observer = map.get(breakpoint);
@@ -180,7 +219,7 @@ public class BreakpointAddresses
    * (possibly) installed starting at the from address up to (but not
    * including) the till address.
    */
-  public Iterator getBreakpoints(long from, long till)
+  Iterator getBreakpoints(long from, long till)
   {
     Breakpoint fromBreakpoint = Breakpoint.create(from, proc);
     Breakpoint tillBreakpoint = Breakpoint.create(till, proc);
@@ -191,9 +230,8 @@ public class BreakpointAddresses
    * Called from TaskState when the Task gets an execed event which
    * clears the whole address space.
    *
-   * XXX: Should not be public.
    */
-  public void removeAllCodeObservers()
+  void removeAllCodeObservers()
   {
     map.clear();
     breakpoints.clear();
diff --git a/frysk-core/frysk/proc/live/ChangeLog b/frysk-core/frysk/proc/live/ChangeLog
index 8826d51..9d495c6 100644
--- a/frysk-core/frysk/proc/live/ChangeLog
+++ b/frysk-core/frysk/proc/live/ChangeLog
@@ -1,3 +1,19 @@
+2008-04-21  Mark Wielaard  <mwielaard@redhat.com>
+
+	* BreakpointAddresses.java: Mark class and methods package private.
+	(CodeObserver): New final static helper class.
+	(addBreakpoint): Take CodeObserver as argument, not
+	TaskObserver.Code.
+	(removeBreakpoint): Likewise.
+	(getCodeObservers): Return collection of CodeObservers, not
+	TaskObserver.Code.
+	* LinuxPtraceProc.java (BreakpointAction.run): Install or remove
+	BreakpointAddresses.CodeObserver instead of bare TaskObserver.Code.
+	* LinuxPtraceTask.java (notifyCodeBreakpoint): Check Task against
+	BreakpointAddresses.CodeObserver.
+	* TestTaskObserverCode.java (testMultiTaskUpdateCalledSeveralTimes):
+	Resolved bug #5234.
+
 2008-04-15  Teresa Thomas  <tthomas@redhat.com>
 
 	* LinuxPtraceTask.java (isInstructionObserverAdded): New.
diff --git a/frysk-core/frysk/proc/live/LinuxPtraceProc.java b/frysk-core/frysk/proc/live/LinuxPtraceProc.java
index d376fc2..14e1e00 100644
--- a/frysk-core/frysk/proc/live/LinuxPtraceProc.java
+++ b/frysk-core/frysk/proc/live/LinuxPtraceProc.java
@@ -552,14 +552,20 @@ public class LinuxPtraceProc extends LiveProc {
 
 	public void run() {
 	    if (addition) {
-		boolean mustInstall = breakpoints.addBreakpoint(code, address);
+	        BreakpointAddresses.CodeObserver observer;
+		boolean mustInstall;
+		observer = new BreakpointAddresses.CodeObserver(task, code);
+		mustInstall = breakpoints.addBreakpoint(observer, address);
 		if (mustInstall) {
 		    Breakpoint breakpoint;
 		    breakpoint = Breakpoint.create(address, LinuxPtraceProc.this);
 		    breakpoint.install(task);
 		}
 	    } else {
-		boolean mustRemove = breakpoints.removeBreakpoint(code, address);
+	        BreakpointAddresses.CodeObserver observer;
+		boolean mustRemove;
+		observer = new BreakpointAddresses.CodeObserver(task, code);
+		mustRemove = breakpoints.removeBreakpoint(observer, address);
 		if (mustRemove) {
 		    Breakpoint breakpoint;
 		    breakpoint = Breakpoint.create(address, LinuxPtraceProc.this);
diff --git a/frysk-core/frysk/proc/live/LinuxPtraceTask.java b/frysk-core/frysk/proc/live/LinuxPtraceTask.java
index 2121018..397f69b 100644
--- a/frysk-core/frysk/proc/live/LinuxPtraceTask.java
+++ b/frysk-core/frysk/proc/live/LinuxPtraceTask.java
@@ -966,10 +966,11 @@ public class LinuxPtraceTask extends LiveTask {
 
 	Iterator i = observers.iterator();
 	while (i.hasNext()) {
-	    TaskObserver.Code observer = (TaskObserver.Code) i.next();
-	    if (codeObservers.contains(observer))
-		if (observer.updateHit(this, address) == Action.BLOCK)
-		    blockers.add(observer);
+	    BreakpointAddresses.CodeObserver co;
+	    co = (BreakpointAddresses.CodeObserver) i.next();
+	    if (co.task.equals(this))
+		if (co.observer.updateHit(this, address) == Action.BLOCK)
+		    blockers.add(co.observer);
 	}
 	return blockers.size();
     }
diff --git a/frysk-core/frysk/proc/live/TestTaskObserverCode.java b/frysk-core/frysk/proc/live/TestTaskObserverCode.java
index 62108f2..db209b8 100644
--- a/frysk-core/frysk/proc/live/TestTaskObserverCode.java
+++ b/frysk-core/frysk/proc/live/TestTaskObserverCode.java
@@ -763,9 +763,6 @@ public class TestTaskObserverCode extends TestLib
   // get separate update events. bug #5234
   public void testMultiTaskUpdateCalledSeveralTimes() throws Exception
   {
-    if (unresolved(5234))
-      return;
-
     // Create a child.
     LegacyOffspring child = LegacyOffspring.createDaemon();
 


hooks/post-receive
--
frysk system monitor/debugger


                 reply	other threads:[~2008-04-21 10:26 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080421102559.5304.qmail@sourceware.org \
    --to=mark@sourceware.org \
    --cc=frysk-cvs@sourceware.org \
    --cc=frysk@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).