public inbox for frysk-cvs@sourceware.org
help / color / mirror / Atom feed
From: cagney@sourceware.org
To: frysk-cvs@sourceware.org
Subject: [SCM]  master: Split out ProcTasksAction/ProcTasksObserver from ProcObserver.ProcTasks.
Date: Thu, 20 Mar 2008 19:23:00 -0000	[thread overview]
Message-ID: <20080320192344.2769.qmail@sourceware.org> (raw)

The branch, master has been updated
       via  f350349ada366e93c8b09c4d0fd9f8e8f88113b5 (commit)
      from  fccdc9e9af964adf0e8cf9e7f95ebd229377f169 (commit)

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

- Log -----------------------------------------------------------------
commit f350349ada366e93c8b09c4d0fd9f8e8f88113b5
Author: Andrew Cagney <cagney@redhat.com>
Date:   Thu Mar 20 15:20:42 2008 -0400

    Split out ProcTasksAction/ProcTasksObserver from ProcObserver.ProcTasks.
    
    frysk-core/frysk/ftrace/ChangeLog
    2008-03-20  Andrew Cagney  <cagney@redhat.com>
    
    	* Ftrace.java: Use ProcTasksAction and ProcTasksObserver.
    
    frysk-core/frysk/hpd/ChangeLog
    2008-03-20  Andrew Cagney  <cagney@redhat.com>
    
    	* StartRun.java: Use ProcTasksAction and ProcTasksObserver.
    
    frysk-core/frysk/proc/ChangeLog
    2008-03-20  Andrew Cagney  <cagney@redhat.com>
    
    	* ProcTasksAction.java: Rename ProcTasksObserver.
    	* ProcTasksObserver.java: Extract ProcTasks from ProcObserver.
    	* ProcObserver.java: Delete.
    	* StressAttachDetachRapidlyForkingMainTask.java: Update.
    	* TestProcTasksObserver.java: Update.
    
    frysk-core/frysk/rt/ChangeLog
    2008-03-20  Andrew Cagney  <cagney@redhat.com>
    
    	* BreakpointManager.java: Use ProcTasksAction and
    	ProcTasksObserver.
    
    frysk-core/frysk/util/ChangeLog
    2008-03-20  Andrew Cagney  <cagney@redhat.com>
    
    	* ProcRunUtil.java: Use ProcTasksObserver and ProcTasksAction.
    
    frysk-gui/frysk/gui/monitor/ChangeLog
    2008-03-20  Andrew Cagney  <cagney@redhat.com>
    
    	* eventviewer/ProcBox.java: Use ProcTasksObserver and
    	ProcTasksAction.
    	* observers/TaskObserverRoot.java: Ditto.

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

Summary of changes:
 frysk-core/frysk/ftrace/ChangeLog                  |    2 +
 frysk-core/frysk/ftrace/Ftrace.java                |   50 +++-----
 frysk-core/frysk/hpd/ChangeLog                     |    4 +
 frysk-core/frysk/hpd/StartRun.java                 |    6 +-
 frysk-core/frysk/proc/ChangeLog                    |    8 ++
 frysk-core/frysk/proc/ProcObserver.java            |   73 -----------
 ...ProcTasksObserver.java => ProcTasksAction.java} |   21 ++--
 frysk-core/frysk/proc/ProcTasksObserver.java       |  134 +++-----------------
 .../StressAttachDetachRapidlyForkingMainTask.java  |    4 +-
 frysk-core/frysk/proc/TestProcTasksObserver.java   |   16 +--
 frysk-core/frysk/rt/BreakpointManager.java         |    9 +-
 frysk-core/frysk/rt/ChangeLog                      |    5 +
 frysk-core/frysk/util/ChangeLog                    |    2 +
 frysk-core/frysk/util/ProcRunUtil.java             |    8 +-
 frysk-gui/frysk/gui/monitor/ChangeLog              |    6 +
 .../frysk/gui/monitor/eventviewer/ProcBox.java     |    4 +-
 .../gui/monitor/observers/TaskObserverRoot.java    |   10 +-
 17 files changed, 102 insertions(+), 260 deletions(-)
 delete mode 100644 frysk-core/frysk/proc/ProcObserver.java
 copy frysk-core/frysk/proc/{ProcTasksObserver.java => ProcTasksAction.java} (91%)

First 500 lines of diff:
diff --git a/frysk-core/frysk/ftrace/ChangeLog b/frysk-core/frysk/ftrace/ChangeLog
index c612c4c..e41545e 100644
--- a/frysk-core/frysk/ftrace/ChangeLog
+++ b/frysk-core/frysk/ftrace/ChangeLog
@@ -1,5 +1,7 @@
 2008-03-20  Andrew Cagney  <cagney@redhat.com>
 
+	* Ftrace.java: Use ProcTasksAction and ProcTasksObserver.
+	
 	* Ftrace.java (Ftrace(PrintStackOptions)): New constructor.
 	* Reporter.java (Reporter(PrintWriter,PrintStackOptions)): Add
 	stackPrintOptions parameter; use.
diff --git a/frysk-core/frysk/ftrace/Ftrace.java b/frysk-core/frysk/ftrace/Ftrace.java
index 8bfd5ee..dd5defa 100644
--- a/frysk-core/frysk/ftrace/Ftrace.java
+++ b/frysk-core/frysk/ftrace/Ftrace.java
@@ -42,8 +42,8 @@ package frysk.ftrace;
 import frysk.proc.Action;
 import frysk.proc.Manager;
 import frysk.proc.Proc;
-import frysk.proc.ProcObserver;
 import frysk.proc.ProcTasksObserver;
+import frysk.proc.ProcTasksAction;
 import frysk.proc.Task;
 import frysk.proc.TaskObserver;
 import frysk.isa.syscalls.Syscall;
@@ -186,7 +186,7 @@ public class Ftrace {
     }
 
     public void addProc(Proc proc) {
-	new ProcTasksObserver(proc, tasksObserver);
+	new ProcTasksAction(proc, tasksObserver);
     }
 
     public void trace (String[] command) {
@@ -348,34 +348,26 @@ public class Ftrace {
 	}
     }
 
-    ProcObserver.ProcTasks tasksObserver = new ProcObserver.ProcTasks()
-    {
-	public void existingTask (Task task)
-	{
-	    handleTask(task);
-
-	    if (task == task.getProc().getMainTask()) {
-		// Unblock forked and cloned observer, which blocks
-		// main task after the fork or clone, to give us a
-		// chance to pick it up.
-		task.requestUnblock(forkedObserver);
-		task.requestUnblock(clonedObserver);
+    private ProcTasksObserver tasksObserver = new ProcTasksObserver() {
+	    public void existingTask(Task task) {
+		handleTask(task);
+		if (task == task.getProc().getMainTask()) {
+		    // Unblock forked and cloned observer, which
+		    // blocks main task after the fork or clone, to
+		    // give us a chance to pick it up.
+		    task.requestUnblock(forkedObserver);
+		    task.requestUnblock(clonedObserver);
+		}
 	    }
-	}
-
-	public void taskAdded (Task task)
-	{
-	    handleTask(task);
-	}
-
-	public void taskRemoved (Task task)
-	{
-	}
-
-	public void addedTo (Object observable)	{}
-	public void addFailed (Object observable, Throwable arg1) {}
-	public void deletedFrom (Object observable) {}
-    };
+	    public void taskAdded(Task task) {
+		handleTask(task);
+	    }
+	    public void taskRemoved(Task task) {
+	    }
+	    public void addedTo (Object observable)	{}
+	    public void addFailed (Object observable, Throwable arg1) {}
+	    public void deletedFrom (Object observable) {}
+	};
 
 
     /**
diff --git a/frysk-core/frysk/hpd/ChangeLog b/frysk-core/frysk/hpd/ChangeLog
index 9491788..1833729 100644
--- a/frysk-core/frysk/hpd/ChangeLog
+++ b/frysk-core/frysk/hpd/ChangeLog
@@ -1,3 +1,7 @@
+2008-03-20  Andrew Cagney  <cagney@redhat.com>
+
+	* StartRun.java: Use ProcTasksAction and ProcTasksObserver.
+
 2008-03-20  Rick Moseley  <rmoseley@redhat.com>
 
 	* StartRun.java: Fix to not ignore "focus" command(bz #5578).
diff --git a/frysk-core/frysk/hpd/StartRun.java b/frysk-core/frysk/hpd/StartRun.java
index 8201936..625c0fa 100644
--- a/frysk-core/frysk/hpd/StartRun.java
+++ b/frysk-core/frysk/hpd/StartRun.java
@@ -42,8 +42,8 @@ package frysk.hpd;
 import frysk.proc.Action;
 import frysk.proc.Manager;
 import frysk.proc.Proc;
-import frysk.proc.ProcObserver.ProcTasks;
 import frysk.proc.ProcTasksObserver;
+import frysk.proc.ProcTasksAction;
 import frysk.proc.Task;
 import frysk.util.CountDownLatch;
 import java.util.HashSet;
@@ -63,7 +63,7 @@ abstract class StartRun extends ParameterizedCommand {
 	super(command, help1, help2);
     }
 
-    static class Runner implements TaskAttachedObserverXXX {
+    private static class Runner implements TaskAttachedObserverXXX {
 	final CLI cli;
 	CountDownLatch latch;
 	Task launchedTask;
@@ -80,7 +80,7 @@ abstract class StartRun extends ParameterizedCommand {
 	    synchronized (cli) {
 		cli.getRunningProcs().add(proc);
 	    }
-	    new ProcTasksObserver(proc, new ProcTasks() {
+	    new ProcTasksAction(proc, new ProcTasksObserver() {
 		public void existingTask(Task task) {
 		}
 
diff --git a/frysk-core/frysk/proc/ChangeLog b/frysk-core/frysk/proc/ChangeLog
index 8682b39..90ec27c 100644
--- a/frysk-core/frysk/proc/ChangeLog
+++ b/frysk-core/frysk/proc/ChangeLog
@@ -1,3 +1,11 @@
+2008-03-20  Andrew Cagney  <cagney@redhat.com>
+
+	* ProcTasksAction.java: Rename ProcTasksObserver.
+	* ProcTasksObserver.java: Extract ProcTasks from ProcObserver.
+	* ProcObserver.java: Delete.
+	* StressAttachDetachRapidlyForkingMainTask.java: Update.
+	* TestProcTasksObserver.java: Update.
+
 2008-03-17  Andrew Cagney  <cagney@redhat.com>
 
 	* TestTaskObserver.java (attachDieingTask(int,boolean)): Do not
diff --git a/frysk-core/frysk/proc/ProcObserver.java b/frysk-core/frysk/proc/ProcObserver.java
deleted file mode 100644
index 78e1d55..0000000
--- a/frysk-core/frysk/proc/ProcObserver.java
+++ /dev/null
@@ -1,73 +0,0 @@
-// This file is part of the program FRYSK.
-//
-// Copyright 2005, 2006, Red Hat Inc.
-//
-// FRYSK is free software; you can redistribute it and/or modify it
-// under the terms of the GNU General Public License as published by
-// the Free Software Foundation; version 2 of the License.
-//
-// FRYSK is distributed in the hope that it will be useful, but
-// WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// General Public License for more details.
-// type filter text
-// You should have received a copy of the GNU General Public License
-// along with FRYSK; if not, write to the Free Software Foundation,
-// Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
-// 
-// In addition, as a special exception, Red Hat, Inc. gives You the
-// additional right to link the code of FRYSK with code not covered
-// under the GNU General Public License ("Non-GPL Code") and to
-// distribute linked combinations including the two, subject to the
-// limitations in this paragraph. Non-GPL Code permitted under this
-// exception must only link to the code of FRYSK through those well
-// defined interfaces identified in the file named EXCEPTION found in
-// the source code files (the "Approved Interfaces"). The files of
-// Non-GPL Code may instantiate templates or use macros or inline
-// functions from the Approved Interfaces without causing the
-// resulting work to be covered by the GNU General Public
-// License. Only Red Hat, Inc. may make changes or additions to the
-// list of Approved Interfaces. You must obey the GNU General Public
-// License in all respects for all of the FRYSK code and other code
-// used in conjunction with FRYSK except the Non-GPL Code covered by
-// this exception. If you modify this file, you may extend this
-// exception to your version of the file, but you are not obligated to
-// do so. If you do not wish to provide this exception without
-// modification, you must delete this exception statement from your
-// version and license this file solely under the GPL without
-// exception.
-
-
-package frysk.proc;
-
-/**
- * Interface for receiving updates on {@link frysk.proc.Proc}.
- */
-public interface ProcObserver
-    extends Observer
-{
-
-  /**
-   * Called to deliver a list of existing tasks to the client.
-   */
-  void existingTask (Task task);
-
-  /**
-   * An interface for clients to correctly know about all tasks of a Proc.
-   */
-  public interface ProcTasks
-      extends ProcObserver
-  {
-
-    /**
-     * Called when the observed process clones a new task.
-     */
-    void taskAdded (Task task);
-
-    /**
-     * Called when one of the tasks of a process exits.
-     */
-    void taskRemoved (Task task);
-
-  }
-}
diff --git a/frysk-core/frysk/proc/ProcTasksObserver.java b/frysk-core/frysk/proc/ProcTasksAction.java
similarity index 91%
copy from frysk-core/frysk/proc/ProcTasksObserver.java
copy to frysk-core/frysk/proc/ProcTasksAction.java
index 93da00a..86321a9 100644
--- a/frysk-core/frysk/proc/ProcTasksObserver.java
+++ b/frysk-core/frysk/proc/ProcTasksAction.java
@@ -50,21 +50,21 @@ import frysk.event.Event;
  * that process. 
  */
 
-public final class ProcTasksObserver
+public final class ProcTasksAction
     implements TaskObserver.Cloned, TaskObserver.Terminated
 {
-    private static final Log fine = Log.fine(ProcTasksObserver.class);
+    private static final Log fine = Log.fine(ProcTasksAction.class);
+
     private final Proc proc;
-    private final ProcObserver.ProcTasks procTasksObserver;
+    private final ProcTasksObserver procTasksObserver;
     private Task mainTask;
 	
     /**
      * An observer that monitors all Tasks of a process notifying the
      * caller of each new Task as it is added. 
      */
-    public ProcTasksObserver (Proc theProc, 
-			      ProcObserver.ProcTasks theProcTasksObserver)
-    {
+    public ProcTasksAction(Proc theProc,
+			   ProcTasksObserver theProcTasksObserver) {
 	fine.log(this, "new");
 	proc = theProc;
 	procTasksObserver = theProcTasksObserver;
@@ -91,12 +91,11 @@ public final class ProcTasksObserver
 	    });
     }
 	
-    private void requestAddObservers(Task task) 
-    {
-	task.requestAddClonedObserver(ProcTasksObserver.this);
-	task.requestAddTerminatedObserver(ProcTasksObserver.this);
+    private void requestAddObservers(Task task) {
+	task.requestAddClonedObserver(ProcTasksAction.this);
+	task.requestAddTerminatedObserver(ProcTasksAction.this);
     }
-	
+    
     // Never block the parent.
     public Action updateClonedParent (Task parent,
 				      Task offspring)
diff --git a/frysk-core/frysk/proc/ProcTasksObserver.java b/frysk-core/frysk/proc/ProcTasksObserver.java
index 93da00a..d8d921a 100644
--- a/frysk-core/frysk/proc/ProcTasksObserver.java
+++ b/frysk-core/frysk/proc/ProcTasksObserver.java
@@ -1,11 +1,11 @@
 // This file is part of the program FRYSK.
-// 
+//
 // Copyright 2005, 2006, 2008, Red Hat Inc.
-// 
+//
 // FRYSK is free software; you can redistribute it and/or modify it
 // under the terms of the GNU General Public License as published by
 // the Free Software Foundation; version 2 of the License.
-// 
+//
 // FRYSK is distributed in the hope that it will be useful, but
 // WITHOUT ANY WARRANTY; without even the implied warranty of
 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
@@ -37,124 +37,28 @@
 // version and license this file solely under the GPL without
 // exception.
 
-package frysk.proc;
 
-import frysk.isa.signals.Signal;
-import java.util.Iterator;
-import frysk.rsl.Log;
-import frysk.event.Event;
+package frysk.proc;
 
 /**
- * Provides a mechanism for tracing all clone events within a process.
- * Notifies a ProcObserver.ProcTasks of any tasks added to or deleted from
- * that process. 
+ * An interface for clients to correctly know about all tasks of a
+ * Proc.
  */
-
-public final class ProcTasksObserver
-    implements TaskObserver.Cloned, TaskObserver.Terminated
-{
-    private static final Log fine = Log.fine(ProcTasksObserver.class);
-    private final Proc proc;
-    private final ProcObserver.ProcTasks procTasksObserver;
-    private Task mainTask;
-	
+public interface ProcTasksObserver extends Observer {
+    
+    /**
+     * Called to deliver a list of existing tasks to the client.
+     */
+    void existingTask(Task task);
+    
     /**
-     * An observer that monitors all Tasks of a process notifying the
-     * caller of each new Task as it is added. 
+     * Called when the observed process clones a new task.
      */
-    public ProcTasksObserver (Proc theProc, 
-			      ProcObserver.ProcTasks theProcTasksObserver)
-    {
-	fine.log(this, "new");
-	proc = theProc;
-	procTasksObserver = theProcTasksObserver;
-		
-	// The rest of the construction must be done synchronous to
-	// the EventLoop, schedule it.
-	Manager.eventLoop.add(new Event() {
-		public void execute() {
-		    // Get a preliminary list of tasks - XXX: hack really.
-		    proc.sendRefresh ();
-		    mainTask = proc.getMainTask();
-		    if (mainTask == null) {
-			fine.log(this, "Could not get main thread of "
-				 + "process", proc);
-			procTasksObserver.addFailed (proc,
-						     new RuntimeException ("Process lost: could not " +
-									   "get the main thread of this process.\n" + 
-									   proc));
-			return;
-		    }
-				
-		    requestAddObservers(mainTask);
-		}
-	    });
-    }
-	
-    private void requestAddObservers(Task task) 
-    {
-	task.requestAddClonedObserver(ProcTasksObserver.this);
-	task.requestAddTerminatedObserver(ProcTasksObserver.this);
-    }
-	
-    // Never block the parent.
-    public Action updateClonedParent (Task parent,
-				      Task offspring)
-    {
-	return Action.CONTINUE;
-    }
-	
+    void taskAdded(Task task);
+    
     /**
-     * When ever a new cloned offspring appears notify the observer,
-     * and add a cloned observer to it.
+     * Called when one of the tasks of a process exits.
      */
-    public Action updateClonedOffspring (Task parent,
-					 Task offspring)
-    {
-	procTasksObserver.taskAdded (offspring);
-	fine.log(this, "ProcTasksObserver.updateClonedOffspring "
-		 + "parent", parent, "offspring", offspring);
-	requestAddObservers(offspring);
-	// Need to BLOCK and UNBLOCK so that the
-	// request to add an observer has enough time
-	// to be processed before the task continues.
-	offspring.requestUnblock (this);
-        return Action.BLOCK;
-    }
-	
-    private boolean isMainTaskAdded;
-	
-    public void addedTo(Object observable)
-    {
-	if (!isMainTaskAdded) {
-	    isMainTaskAdded= true;
-	    // XXX: Is there a race here with a rapidly cloning task?
-	    for (Iterator iterator = proc.getTasks().iterator();
-		 iterator.hasNext(); ) {
-		Task task = (Task) iterator.next();
-		procTasksObserver.existingTask (task);
-		if (task != mainTask) {
-		    fine.log(this, "Inside if not mainTask");
-		    requestAddObservers(task);
-		}
-	    }
-			
-	}
-    }
-	
-    public void addFailed(Object observable, Throwable w)
-    {
-	//throw new RuntimeException("How did this (addFailed) happen ?!");
-	procTasksObserver.addFailed(observable, w);
-    }
-	
-    public void deletedFrom(Object observable)
-    {
-	procTasksObserver.deletedFrom(observable);
-    }
-	
-    public Action updateTerminated(Task task, Signal signal, int value) {
-	procTasksObserver.taskRemoved(task);
-	return Action.CONTINUE;
-    }
+    void taskRemoved(Task task);
+    
 }
diff --git a/frysk-core/frysk/proc/StressAttachDetachRapidlyForkingMainTask.java b/frysk-core/frysk/proc/StressAttachDetachRapidlyForkingMainTask.java
index 8ed1346..dd0d22b 100644
--- a/frysk-core/frysk/proc/StressAttachDetachRapidlyForkingMainTask.java
+++ b/frysk-core/frysk/proc/StressAttachDetachRapidlyForkingMainTask.java
@@ -43,7 +43,6 @@ import java.util.Collection;
 import java.util.HashSet;
 import frysk.rsl.Log;
 import frysk.event.TimerEvent;
-import frysk.proc.ProcObserver.ProcTasks;
 import frysk.testbed.TestLib;
 import frysk.testbed.TaskObserverBase;
 import frysk.testbed.DaemonBlockedAtEntry;
@@ -118,7 +117,8 @@ public class StressAttachDetachRapidlyForkingMainTask extends TestLib {
 	ForkObserver forkObserver = new ForkObserver ();
 
 	// Add a tasks observer to add observers to fork's children
-	new ProcTasksObserver(child.getMainTask().getProc(), new ProcTasks(){
+	new ProcTasksAction(child.getMainTask().getProc(),
+			    new ProcTasksObserver() {
 		public void deletedFrom(Object observable) {
 		    fine.log("ProcTasksObserver.deleted from fired");
 		}
diff --git a/frysk-core/frysk/proc/TestProcTasksObserver.java b/frysk-core/frysk/proc/TestProcTasksObserver.java
index 87607a4..738a657 100644
--- a/frysk-core/frysk/proc/TestProcTasksObserver.java
+++ b/frysk-core/frysk/proc/TestProcTasksObserver.java
@@ -66,7 +66,7 @@ public class TestProcTasksObserver extends TestLib {
 	final int count = 4;
 			
 	MyTester observerTester = new MyTester(proc, count);
-	new ProcTasksObserver (proc, observerTester);
+	new ProcTasksAction(proc, observerTester);
 		
 	assertRunUntilStop("manyExistingThread");
 		
@@ -98,7 +98,7 @@ public class TestProcTasksObserver extends TestLib {
 		
 	//Add observer
 	MyTester observerTester = new MyTester(proc, count);
-	new ProcTasksObserver (proc, observerTester);
+	new ProcTasksAction(proc, observerTester);
 		
 	assertRunUntilStop("single existing clone");
 
@@ -124,7 +124,7 @@ public class TestProcTasksObserver extends TestLib {
 
 	//Add observer
 	MyTester observerTester = new MyTester(proc, count);
-	new ProcTasksObserver (proc, observerTester);
+	new ProcTasksAction(proc, observerTester);
 		
 	assertRunUntilStop("single existing thread");
 		
@@ -150,7 +150,7 @@ public class TestProcTasksObserver extends TestLib {
 		
 	//Add observer
 	ProcTasksTester observerTester = new ProcTasksTester();
-	new ProcTasksObserver (proc, observerTester);
+	new ProcTasksAction(proc, observerTester);
 


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


                 reply	other threads:[~2008-03-20 19:23 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=20080320192344.2769.qmail@sourceware.org \
    --to=cagney@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).