From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16298 invoked by alias); 2 Jan 2008 16:47:54 -0000 Received: (qmail 16262 invoked by uid 367); 2 Jan 2008 16:47:54 -0000 Date: Wed, 02 Jan 2008 16:47:00 -0000 Message-ID: <20080102164754.16247.qmail@sourceware.org> From: cagney@sourceware.org To: frysk-cvs@sourceware.org Subject: [SCM] master: Move frysk.proc.Task.handle and state to sub-classes. X-Git-Refname: refs/heads/master X-Git-Reftype: branch X-Git-Oldrev: 9fe41592a9cf5fe5eb8c460f8b1506035eac4651 X-Git-Newrev: 4c4cfe069af4958748eb748965a592d720a99e71 Mailing-List: contact frysk-cvs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: frysk-cvs-owner@sourceware.org Reply-To: frysk@sourceware.org X-SW-Source: 2008-q1/txt/msg00000.txt.bz2 The branch, master has been updated via 4c4cfe069af4958748eb748965a592d720a99e71 (commit) via 5b7ad362ca9f8b008f7fb9baa0403aeba0c77e2b (commit) from 9fe41592a9cf5fe5eb8c460f8b1506035eac4651 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email. - Log ----------------------------------------------------------------- commit 4c4cfe069af4958748eb748965a592d720a99e71 Author: Andrew Cagney Date: Wed Jan 2 11:46:16 2008 -0500 Move frysk.proc.Task.handle and state to sub-classes. frysk-core/frysk/proc/ChangeLog 2008-01-02 Andrew Cagney * Task.java (handleAddObservation(TaskObservation)): Make abstract. (handleDeleteObservation(TaskObservation)): Make abstract. (performContinue()): Make abstract. (performRemoval()): Make abstract. (performAttach()): Make abstract. (performDetach(boolean)): Make abstract. (newState): Delete. (oldState): Delete. (getState()): Delete. (set(TaskState)): Delete. (oldState()): Delete. (toString()): Update. (handleUnblock(TaskObserver)): New. (requestUnblock(TaskObserver)): Use. (getStateFIXME()): New. * TestRefresh.java (testProcRefresh()): Update. frysk-core/frysk/proc/dead/ChangeLog 2008-01-02 Andrew Cagney * DeadTask.java (handleAddObservation(TaskObservation)): New. (handleDeleteObservation(TaskObservation)): New. (performContinue()): New. (performRemoval()): New. (performAttach()): New. (performDetach(boolean)): New. (newState): New. (oldState): New. (getState()): New. (set(TaskState)): New. (oldState()): New. (handleUnblock(TaskObserver)): New. (getStateFIXME()): New. frysk-core/frysk/proc/dummy/ChangeLog 2008-01-02 Andrew Cagney * Task.java (handleAddObservation(TaskObservation)): New. (handleDeleteObservation(TaskObservation)): New. (performContinue()): New. (performRemoval()): New. (performAttach()): New. (performDetach(boolean)): New. (newState): New. (oldState): New. (getState()): New. (set(TaskState)): New. (oldState()): New. (handleUnblock(TaskObserver)): New. (getStateFIXME()): New. frysk-core/frysk/proc/live/ChangeLog 2008-01-02 Andrew Cagney * LiveTask.java (handleAddObservation(TaskObservation)): New. (handleDeleteObservation(TaskObservation)): New. (performContinue()): New. (performRemoval()): New. (performAttach()): New. (performDetach(boolean)): New. (newState): New. (oldState): New. (getState()): New. (set(TaskState)): New. (oldState()): New. (handleUnblock(TaskObserver)): New. (getStateFIXME()): New. commit 5b7ad362ca9f8b008f7fb9baa0403aeba0c77e2b Author: Andrew Cagney Date: Wed Jan 2 09:35:06 2008 -0500 Re-indent. frysk-core/frysk/proc/ChangeLog 2008-01-02 Andrew Cagney * Host.java: Re-indent. * Proc.java: Re-indent. * Task.java: Re-indent. ----------------------------------------------------------------------- Summary of changes: frysk-core/frysk/proc/ChangeLog | 23 + frysk-core/frysk/proc/Host.java | 215 ++--- frysk-core/frysk/proc/Proc.java | 1761 ++++++++++++++---------------- frysk-core/frysk/proc/Task.java | 1729 ++++++++++++++---------------- frysk-core/frysk/proc/TestRefresh.java | 6 +- frysk-core/frysk/proc/dead/ChangeLog | 16 + frysk-core/frysk/proc/dead/DeadTask.java | 102 ++ frysk-core/frysk/proc/dummy/ChangeLog | 16 + frysk-core/frysk/proc/dummy/Task.java | 106 ++- frysk-core/frysk/proc/live/ChangeLog | 16 + frysk-core/frysk/proc/live/LiveTask.java | 104 ++- 11 files changed, 2098 insertions(+), 1996 deletions(-) First 500 lines of diff: diff --git a/frysk-core/frysk/proc/ChangeLog b/frysk-core/frysk/proc/ChangeLog index 0bccd95..8d8c2c6 100644 --- a/frysk-core/frysk/proc/ChangeLog +++ b/frysk-core/frysk/proc/ChangeLog @@ -1,3 +1,26 @@ +2008-01-02 Andrew Cagney + + * Task.java (handleAddObservation(TaskObservation)): Make abstract. + (handleDeleteObservation(TaskObservation)): Make abstract. + (performContinue()): Make abstract. + (performRemoval()): Make abstract. + (performAttach()): Make abstract. + (performDetach(boolean)): Make abstract. + (newState): Delete. + (oldState): Delete. + (getState()): Delete. + (set(TaskState)): Delete. + (oldState()): Delete. + (toString()): Update. + (handleUnblock(TaskObserver)): New. + (requestUnblock(TaskObserver)): Use. + (getStateFIXME()): New. + * TestRefresh.java (testProcRefresh()): Update. + + * Host.java: Re-indent. + * Proc.java: Re-indent. + * Task.java: Re-indent. + 2007-12-28 Andrew Cagney * TestIsa.java (test64To32To64()): Update; skip32on64 renamed to diff --git a/frysk-core/frysk/proc/Host.java b/frysk-core/frysk/proc/Host.java index e0c23f8..12d2834 100644 --- a/frysk-core/frysk/proc/Host.java +++ b/frysk-core/frysk/proc/Host.java @@ -56,16 +56,14 @@ import java.util.logging.Logger; * process that is running this code - frysk is self aware. */ -public abstract class Host -{ +public abstract class Host { static protected final Logger logger = Logger.getLogger("frysk");//.proc /** * The host corresponds to a specific system. */ - protected Host () - { - newState = HostState.initial (this); - logger.log (Level.FINE, "{0} Host\n", this); + protected Host() { + newState = HostState.initial(this); + logger.log(Level.FINE, "{0} Host\n", this); } // Maintain a collection of all known Tasks. @@ -75,61 +73,53 @@ public abstract class Host // THREAD events. That way its possible for the client to observe // things on a per-PROC basis. - Map taskPool = new HashMap (); - void add (Task task) - { - logger.log (Level.FINEST, "{0} add Task\n", this); - taskPool.put (task.id, task); + Map taskPool = new HashMap(); + void add(Task task) { + logger.log(Level.FINEST, "{0} add Task\n", this); + taskPool.put(task.id, task); } - void remove (Task task) - { - logger.log (Level.FINEST, "{0} remove Task\n", this); - taskPool.remove (task.id); + void remove(Task task) { + logger.log(Level.FINEST, "{0} remove Task\n", this); + taskPool.remove(task.id); } - void removeTasks (Collection c) - { - logger.log (Level.FINE, "{0} removeTasks Collection\n", this); - taskPool.values().removeAll (c); + void removeTasks(Collection c) { + logger.log(Level.FINE, "{0} removeTasks Collection\n", this); + taskPool.values().removeAll(c); } - public Task get (TaskId id) - { - logger.log (Level.FINE, "{0} get TaskId\n", this); - return (Task) taskPool.get (id); + public Task get(TaskId id) { + logger.log(Level.FINE, "{0} get TaskId\n", this); + return (Task) taskPool.get(id); } // Maintain a Collection of all known (live) PROCes. - protected Map procPool = new HashMap (); - void add (Proc proc) - { - logger.log (Level.FINEST, "{0} add Proc\n", this); - observableProcAddedXXX.notify (proc); - procPool.put (proc.id, proc); + protected Map procPool = new HashMap(); + void add(Proc proc) { + logger.log(Level.FINEST, "{0} add Proc\n", this); + observableProcAddedXXX.notify(proc); + procPool.put(proc.id, proc); } /** * XXX: Should not be public. */ - public void remove (Proc proc) - { - logger.log (Level.FINEST, "{0} remove Proc\n", this); - procPool.remove (proc.id); - observableProcRemovedXXX.notify (proc); + public void remove(Proc proc) { + logger.log(Level.FINEST, "{0} remove Proc\n", this); + procPool.remove(proc.id); + observableProcRemovedXXX.notify(proc); } - public Iterator getProcIterator () - { - return procPool.values ().iterator (); + public Iterator getProcIterator() { + return procPool.values().iterator(); } - public Proc getProc (ProcId id) - { - logger.log (Level.FINE, "{0} getProc ProcId {1} \n", new Object[] {this, id}); - return (Proc) procPool.get (id); + public Proc getProc(ProcId id) { + logger.log(Level.FINE, "{0} getProc ProcId {1} \n", new Object[] {this, id}); + return (Proc) procPool.get(id); } // Refresh the list of processes. - protected abstract void sendRefresh (boolean refreshAll); + protected abstract void sendRefresh(boolean refreshAll); - protected abstract void sendRefresh (ProcId procId, FindProc finder); + protected abstract void sendRefresh(ProcId procId, FindProc finder); /** * Tell the host to create a running child process. @@ -143,11 +133,11 @@ public abstract class Host * * XXX: Is this the best thing? */ - protected abstract void sendCreateAttachedProc (String stdin, - String stdout, - String stderr, - String[] args, - TaskObserver.Attached attached); + protected abstract void sendCreateAttachedProc(String stdin, + String stdout, + String stderr, + String[] args, + TaskObserver.Attached attached); /** * The current state of this host. @@ -157,8 +147,7 @@ public abstract class Host /** * Return the current state. */ - HostState getState () - { + HostState getState() { if (newState != null) return newState; else @@ -167,14 +156,13 @@ public abstract class Host /** * Return the current state while at the same time marking that * the state is in flux. If a second attempt to change state - * occurs before the current state transition has completed, - * barf. XXX: Bit of a hack, but at least this prevents state - * transition code attempting a second recursive state transition. + * occurs before the current state transition has completed, barf. + * XXX: Bit of a hack, but at least this prevents state transition + * code attempting a second recursive state transition. */ - private HostState oldState () - { + private HostState oldState() { if (newState == null) - throw new RuntimeException ("double state transition"); + throw new RuntimeException("double state transition"); oldState = newState; newState = null; return oldState; @@ -185,13 +173,10 @@ public abstract class Host * refreshing the internal structure to match. Optionally refresh * each processes task list. */ - public void requestRefreshXXX () - { - logger.log (Level.FINEST, "{0} requestRefreshXXX\n", this); - Manager.eventLoop.add (new HostEvent ("RequestRefresh") - { - public void execute () - { + public void requestRefreshXXX() { + logger.log(Level.FINEST, "{0} requestRefreshXXX\n", this); + Manager.eventLoop.add(new HostEvent("RequestRefresh") { + public void execute() { newState = oldState().handleRefresh(Host.this, false); } }); @@ -200,57 +185,47 @@ public abstract class Host /** * Find a specifc process from its Id. */ - public void requestFindProc(final ProcId procId, final FindProc finder) - { - Manager.eventLoop.add(new HostEvent("FindProc") { - - public void execute () - { - newState = oldState().handleRefresh (Host.this, procId, finder); - }}); + public void requestFindProc(final ProcId procId, final FindProc finder) { + Manager.eventLoop.add(new HostEvent("FindProc") { + public void execute() { + newState = oldState().handleRefresh(Host.this, procId, finder); + }}); } /** * Request that a new attached and running process be created. */ - public final void requestCreateAttachedProc (final String stdin, - final String stdout, - final String stderr, - final String[] args, - final TaskObserver.Attached attachedObserver) - { - logger.log (Level.FINE, "{0} requestCreateAttachedProc\n", this); - Manager.eventLoop.add (new HostEvent ("requestCreateAttachedProc") - { - public void execute () - { - newState= oldState ().handleCreateAttachedProc + public final void requestCreateAttachedProc(final String stdin, + final String stdout, + final String stderr, + final String[] args, + final TaskObserver.Attached attachedObserver) { + logger.log(Level.FINE, "{0} requestCreateAttachedProc\n", this); + Manager.eventLoop.add(new HostEvent("requestCreateAttachedProc") { + public void execute() { + newState= oldState().handleCreateAttachedProc (Host.this, stdin, stdout, stderr, args, attachedObserver); } }); } /** - * Request that a new attached and running process (with stdin, + * Request that a new attached and running process(with stdin, * stdout, and stderr are shared with this process) be created. */ - public final void requestCreateAttachedProc (String[] args, - TaskObserver.Attached attachedObserver) - { - logger.log (Level.FINE, "{0} requestCreateAttachedProc String[] TaskObserver.Attached\n", this); - requestCreateAttachedProc (null, null, null, args, attachedObserver); + public final void requestCreateAttachedProc(String[] args, + TaskObserver.Attached attachedObserver) { + logger.log(Level.FINE, "{0} requestCreateAttachedProc String[] TaskObserver.Attached\n", this); + requestCreateAttachedProc(null, null, null, args, attachedObserver); } /** * XXX: Temporary until .observable's are converted to * .requestAddObserver. */ - public class ObservableXXX - extends Observable - { - void notify (Object o) - { - setChanged (); - notifyObservers (o); + public class ObservableXXX extends Observable { + void notify(Object o) { + setChanged(); + notifyObservers(o); } } @@ -261,7 +236,7 @@ public abstract class Host * XXX: Should be made private and instead accessor methods added. * Should more formally define the observable and the event. */ - public ObservableXXX observableProcAddedXXX = new ObservableXXX (); + public ObservableXXX observableProcAddedXXX = new ObservableXXX(); /* * An existing process has been removed. Possible reasons include @@ -271,7 +246,7 @@ public abstract class Host * XXX: Should be made private and instead accessor methods added. * Should more formally define the observable and the event. */ - public ObservableXXX observableProcRemovedXXX = new ObservableXXX (); + public ObservableXXX observableProcRemovedXXX = new ObservableXXX(); /** * Notify of the addition of a task attached to this process. @@ -282,23 +257,22 @@ public abstract class Host * XXX: Should be made private and instead accessor methods added. * Should more formally define the observable and the event. */ - public ObservableXXX observableTaskAddedXXX = new ObservableXXX (); + public ObservableXXX observableTaskAddedXXX = new ObservableXXX(); /** * Notify of the removal of a task attached to this process. * * XXX: Should be made private and instead accessor methods added. * Should more formally define the observable and the event. */ - public ObservableXXX observableTaskRemovedXXX = new ObservableXXX (); + public ObservableXXX observableTaskRemovedXXX = new ObservableXXX(); /** * Return the process corresponding to this running frysk instance * found on this host. */ - public Proc getSelf () - { + public Proc getSelf() { if (self == null) - self = sendrecSelf (); + self = sendrecSelf(); return self; } /** @@ -308,34 +282,27 @@ public abstract class Host /** * Extract a pointer to frysk running on this Host. */ - protected abstract Proc sendrecSelf (); + protected abstract Proc sendrecSelf(); /** * Print this. */ - public String toString () - { - return ("{" + super.toString () - + ",state=" + getState () + public String toString() { + return ("{" + super.toString() + + ",state=" + getState() + "}"); } /** - * Returns the name of the host + * Returns the name of the host */ - public String getName () - { - try - { - return java.net.InetAddress.getLocalHost().getHostName(); - } - catch (UnknownHostException e) - { - return "Unknown Host"; - } - catch (NullPointerException npe) - { - return "Problem reading network address"; - } - } + public String getName() { + try { + return java.net.InetAddress.getLocalHost().getHostName(); + } catch (UnknownHostException e) { + return "Unknown Host"; + } catch (NullPointerException npe) { + return "Problem reading network address"; + } + } } diff --git a/frysk-core/frysk/proc/Proc.java b/frysk-core/frysk/proc/Proc.java index 2446455..ee5ed10 100644 --- a/frysk-core/frysk/proc/Proc.java +++ b/frysk-core/frysk/proc/Proc.java @@ -37,7 +37,6 @@ // version and license this file solely under the GPL without // exception. - package frysk.proc; import java.util.ArrayList; @@ -61,951 +60,841 @@ import frysk.sys.Signal; * A UNIX Process, containing tasks, memory, ... */ -public abstract class Proc -{ - protected static final Logger logger = Logger.getLogger(ProcLogger.LOGGER_ID); +public abstract class Proc { + protected static final Logger logger = Logger.getLogger(ProcLogger.LOGGER_ID); - final ProcId id; + final ProcId id; - private CountDownLatch quitLatch; + private CountDownLatch quitLatch; - public ProcId getId () - { - return id; - } - - /** - * If known, due to the tracing of a fork, the Task that created this process. - */ - final Task creator; - - /** - * XXX: This should not be public. - */ - public Proc parent; - - public Proc getParent () - { - // XXX: This needs to be made on-demand. - return this.parent; - } - - /** - * Return the Proc's Host. - */ - public Host getHost () - { - return host; - } - private final Host host; - - public int getPid () - { - return id.hashCode(); - } - - /** - * Return the basename of the program that this process is running. - */ - public String getCommand () - { - command = sendrecCommand(); - return command; - } - - private String command; - - protected abstract String sendrecCommand (); - - /** - * Return the full path of the program that this process is running. - */ - public String getExe () - { - exe = sendrecExe(); - return exe; - } - - private String exe; - - protected abstract String sendrecExe (); - - /** - * Return the UID of the Proc. - */ - public int getUID () - { - uid = sendrecUID(); - return uid; - } - - protected abstract int sendrecUID (); - - private int uid; - - /** - * Return the GID of the Proc. - */ - public int getGID () - { - gid = sendrecGID(); - return gid; - } - - protected abstract int sendrecGID (); hooks/post-receive -- frysk system monitor/debugger