public inbox for frysk-cvs@sourceware.org
help / color / mirror / Atom feed
From: cagney@sourceware.org
To: frysk-cvs@sourceware.org
Subject: [SCM]  master: Maintain a task list indexed by ProcessIdentifier.
Date: Thu, 07 Feb 2008 20:47:00 -0000	[thread overview]
Message-ID: <20080207204750.8358.qmail@sourceware.org> (raw)

The branch, master has been updated
       via  d54209223897ff92941df463fb87059a1e6afbf4 (commit)
      from  eac0c5123c615be6efa3ca1738175ea0a59be132 (commit)

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

- Log -----------------------------------------------------------------
commit d54209223897ff92941df463fb87059a1e6afbf4
Author: Andrew Cagney <cagney@redhat.com>
Date:   Thu Feb 7 15:46:54 2008 -0500

    Maintain a task list indexed by ProcessIdentifier.
    
    frysk-core/frysk/proc/live/ChangeLog
    2008-02-07  Andrew Cagney  <cagney@redhat.com>
    
    	* LinuxPtraceHost.java (getTask(ProcessIdentifier)): New.
    	(putTask(ProcessIdentifier,LinuxPtraceTask)): New.
    	* LinuxWaitBuilder.java (searchId): Delete.
    	(get(ProcessIdentifier,String)): New.
    	* LinuxPtraceTask.java: Register with LinuxPtraceHost.

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

Summary of changes:
 frysk-core/frysk/proc/live/ChangeLog             |    6 ++
 frysk-core/frysk/proc/live/LinuxPtraceHost.java  |   13 +++++
 frysk-core/frysk/proc/live/LinuxPtraceTask.java  |    3 +
 frysk-core/frysk/proc/live/LinuxWaitBuilder.java |   56 ++++++++-------------
 4 files changed, 43 insertions(+), 35 deletions(-)

First 500 lines of diff:
diff --git a/frysk-core/frysk/proc/live/ChangeLog b/frysk-core/frysk/proc/live/ChangeLog
index c38ab2b..86391b7 100644
--- a/frysk-core/frysk/proc/live/ChangeLog
+++ b/frysk-core/frysk/proc/live/ChangeLog
@@ -1,5 +1,11 @@
 2008-02-07  Andrew Cagney  <cagney@redhat.com>
 
+	* LinuxPtraceHost.java (getTask(ProcessIdentifier)): New.
+	(putTask(ProcessIdentifier,LinuxPtraceTask)): New.
+	* LinuxWaitBuilder.java (searchId): Delete.
+	(get(ProcessIdentifier,String)): New.
+	* LinuxPtraceTask.java: Register with LinuxPtraceHost.
+
 	* LinuxPtraceHost.java (requestRefreshXXX()): Delete.
 	* TestTaskObserverBlocked.java: Update.
 	
diff --git a/frysk-core/frysk/proc/live/LinuxPtraceHost.java b/frysk-core/frysk/proc/live/LinuxPtraceHost.java
index 67ae93b..5e89a41 100644
--- a/frysk-core/frysk/proc/live/LinuxPtraceHost.java
+++ b/frysk-core/frysk/proc/live/LinuxPtraceHost.java
@@ -61,6 +61,8 @@ import frysk.sys.Pid;
 import frysk.event.Event;
 import frysk.proc.FindProc;
 import frysk.proc.HostRefreshBuilder;
+import java.util.Map;
+import java.util.WeakHashMap;
 import java.util.Collection;
 
 /**
@@ -78,6 +80,17 @@ public class LinuxPtraceHost extends LiveHost {
 
 
     /**
+     * Maintain a cache of tasks indexed by ProcessIdentifier.
+     */
+    private final Map tasks = new WeakHashMap();
+    LinuxPtraceTask getTask(ProcessIdentifier pid) {
+	return (LinuxPtraceTask) tasks.get(pid);
+    }
+    void putTask(ProcessIdentifier pid, LinuxPtraceTask task) {
+	tasks.put(pid, task);
+    }
+
+    /**
      * Either add or update a process, however, before doing that
      * determine the parent and ensure that it has been updated.
      */
diff --git a/frysk-core/frysk/proc/live/LinuxPtraceTask.java b/frysk-core/frysk/proc/live/LinuxPtraceTask.java
index 3753819..51f2ca6 100644
--- a/frysk-core/frysk/proc/live/LinuxPtraceTask.java
+++ b/frysk-core/frysk/proc/live/LinuxPtraceTask.java
@@ -83,6 +83,7 @@ public class LinuxPtraceTask extends LiveTask {
     public LinuxPtraceTask(Proc proc, TaskId id) {
 	super(proc, id);
 	tid = ProcessIdentifierFactory.createFIXME(id.hashCode());
+	((LinuxPtraceHost)proc.getHost()).putTask(tid, this);
 	newState = LinuxPtraceTaskState.detachedState();
     }
     /**
@@ -92,6 +93,7 @@ public class LinuxPtraceTask extends LiveTask {
 	// XXX: shouldn't need to grub around in the old task's state.
 	super(task, new TaskId(clone.intValue()));
 	tid = clone;
+	((LinuxPtraceHost)getProc().getHost()).putTask(tid, this);
 	newState = LinuxPtraceTaskState.clonedState(((LinuxPtraceTask)task).getState ());
     }
     /**
@@ -101,6 +103,7 @@ public class LinuxPtraceTask extends LiveTask {
 			   TaskObserver.Attached attached) {
 	super(proc, attached);
 	tid = ProcessIdentifierFactory.createFIXME(proc.getPid());
+	((LinuxPtraceHost)proc.getHost()).putTask(tid, this);
 	newState = LinuxPtraceTaskState.mainState();
 	if (attached != null) {
 	    TaskObservation ob = new TaskObservation(this, attachedObservers,
diff --git a/frysk-core/frysk/proc/live/LinuxWaitBuilder.java b/frysk-core/frysk/proc/live/LinuxWaitBuilder.java
index f16d53e..a583c3f 100644
--- a/frysk-core/frysk/proc/live/LinuxWaitBuilder.java
+++ b/frysk-core/frysk/proc/live/LinuxWaitBuilder.java
@@ -44,24 +44,25 @@ import frysk.sys.Signal;
 import frysk.sys.WaitBuilder;
 import java.util.LinkedList;
 import java.util.List;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-import frysk.proc.TaskId;
+import frysk.rsl.Log;
 import frysk.proc.Task;
 import frysk.proc.TaskObserver;
 import frysk.sys.ProcessIdentifier;
+import java.util.logging.Level;
+import java.util.logging.Logger;
 
 /**
  * Handles wait events generated by the wait builder.
  */
 
 class LinuxWaitBuilder implements WaitBuilder {
-    LinuxWaitBuilder (LinuxPtraceHost host)
-    {
-	searchId = new SearchId (host);
-    }
+    private static final Logger logger = Logger.getLogger("frysk");
+    private static final Log fine = Log.fine(LinuxWaitBuilder.class);
 
-    static final Logger logger = Logger.getLogger("frysk");
+    private final LinuxPtraceHost host;
+    LinuxWaitBuilder(LinuxPtraceHost host) {
+	this.host = host;
+    }
 
     /**
      * Maintain a list of fscked up kernel waitpid events - where an
@@ -102,29 +103,14 @@ class LinuxWaitBuilder implements WaitBuilder {
 		    return "" + super.toString () + ",stopped,pid=" + pid;
 		}
 	    };
-	logger.log(Level.FINE, "{0} rescheduled\n", rescheduled);
+	fine.log(this, "rescheduled", rescheduled);
 	fsckedOrderedKernelEvents.add(rescheduled);
     }
     
-    // Hold onto a scratch ID; avoids overhead of allocating a new
-    // taskId everytime a new event arrives -- micro optimization..
-    static class SearchId extends TaskId {
-	private final LinuxPtraceHost host;
-	SearchId (LinuxPtraceHost host) {
-	    super (0);
-	    this.host = host;
-	}
-	LinuxPtraceTask get(int pid, String why) {
-	    id = pid;
-	    logger.log(Level.FINE, why, this);
-	    return (LinuxPtraceTask) (host.get(this));
-	}
-	LinuxPtraceTask get(ProcessIdentifier pid, String why) {
-	    logger.log(Level.FINE, why, pid);
-	    return get(pid.intValue(), why);
-	}
+    private LinuxPtraceTask get(ProcessIdentifier pid, String why) {
+	fine.log(this, why, pid);
+	return host.getTask(pid);
     }
-    private final SearchId searchId;
     
     private void logMissing(String what, ProcessIdentifier pid) {
 	logger.log(Level.WARNING,
@@ -140,7 +126,7 @@ class LinuxWaitBuilder implements WaitBuilder {
         // what happened. Note that hot on the heels of this event is
         // a clone.stopped event, and the clone Task must be created
         // before that event arrives.
-        LinuxPtraceTask task = searchId.get(pid, "{0} cloneEvent\n");
+        LinuxPtraceTask task = get(pid, "cloneEvent");
         // Create an attached, and running, clone of TASK.
         LinuxPtraceTask clone = new LinuxPtraceTask(task, clonePid);
         task.processClonedEvent(clone);
@@ -153,7 +139,7 @@ class LinuxWaitBuilder implements WaitBuilder {
         // happened. Note that hot on the heels of this fork event is
         // the child's stop event, the fork Proc must be created
         // before that event arrives.
-        LinuxPtraceTask task = searchId.get(pid, "{0} forkEvent\n");
+        LinuxPtraceTask task = get(pid, "forkEvent");
         // Create an attached and running fork of TASK.
         LinuxPtraceProc forkProc = new LinuxPtraceProc(task, fork);
         // The main task.
@@ -165,7 +151,7 @@ class LinuxWaitBuilder implements WaitBuilder {
     
     public void exitEvent(ProcessIdentifier pid, Signal signal,
 			  int status, boolean coreDumped) {
-        LinuxPtraceTask task = searchId.get(pid, "{0} exitEvent\n");
+        LinuxPtraceTask task = get(pid, "exitEvent");
 	if (task == null)
 	    // Stray pid from uncontrolled fork.
 	    logMissing("exited", pid);
@@ -174,12 +160,12 @@ class LinuxWaitBuilder implements WaitBuilder {
     }
     
     public void execEvent(ProcessIdentifier pid) {
-        LinuxPtraceTask task = searchId.get(pid, "{0} execEvent\n");
+        LinuxPtraceTask task = get(pid, "execEvent");
         task.processExecedEvent();
     }
     
     public void disappeared(ProcessIdentifier pid, Throwable w) {
-        LinuxPtraceTask task = searchId.get(pid, "{0} disappeared\n");
+        LinuxPtraceTask task = get(pid, "disappeared");
         // XXX Sometimes it seems it has already disappeared and this fails
         // Catch the failure, but not sure what to do with the failure right now
         // Failures were seen here while running frysk.hpd.TestRunCommand -r 20
@@ -189,12 +175,12 @@ class LinuxWaitBuilder implements WaitBuilder {
     }
 
     public void syscallEvent(ProcessIdentifier pid) {
-        LinuxPtraceTask task = searchId.get(pid, "{0} syscallEvent\n");
+        LinuxPtraceTask task = get(pid, "syscallEvent");
         task.processSyscalledEvent();
     }
     
     public void stopped(ProcessIdentifier pid, Signal sig) {
-        LinuxPtraceTask task = searchId.get(pid, "{0} stopped\n");
+        LinuxPtraceTask task = get(pid, "stopped");
 	if (task == null) {
 	    // If there's no Task corresponding to TID, assume that
 	    // the kernel fscked up its event ordering - notifying of
@@ -209,7 +195,7 @@ class LinuxWaitBuilder implements WaitBuilder {
     
     public void terminated(ProcessIdentifier pid, Signal signal,
 			   int status, boolean coreDumped) {
-        LinuxPtraceTask task = searchId.get(pid, "{0} terminated\n");
+        LinuxPtraceTask task = get(pid, "terminated");
 	if (task == null)
 	    // Stray pid from uncontrolled fork.
 	    logMissing("terminated", pid);


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


                 reply	other threads:[~2008-02-07 20:47 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=20080207204750.8358.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).