public inbox for frysk-cvs@sourceware.org
help / color / mirror / Atom feed
From: cagney@sourceware.org
To: frysk-cvs@sourceware.org
Subject: [SCM]  master: Fix missing terminated events on non-execing thread.
Date: Fri, 14 Mar 2008 17:04:00 -0000	[thread overview]
Message-ID: <20080314170407.19867.qmail@sourceware.org> (raw)

The branch, master has been updated
       via  de852ac86b074b8100e1f9b6c504dee5374dc08a (commit)
      from  eb68a3add536b67c08e3bf5f33ee35437bd9a3b3 (commit)

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

- Log -----------------------------------------------------------------
commit de852ac86b074b8100e1f9b6c504dee5374dc08a
Author: Andrew Cagney <cagney@redhat.com>
Date:   Fri Mar 14 13:02:35 2008 -0400

    Fix missing terminated events on non-execing thread.
    
    frysk-core/frysk/proc/ChangeLog
    2008-03-14  Andrew Cagney  <cagney@redhat.com>
    
    	* TestExec.java (testTaskBlockExec()): Use
    	StopEventLoopWhenProcTerminated.
    
    frysk-core/frysk/proc/live/ChangeLog
    2008-03-14  Andrew Cagney  <cagney@redhat.com>
    
    	* LinuxPtraceTaskState.java: Don't remove non-exec tasks; already
    	deleted.
    	* LinuxWaitBuilder.java (execEvent(ProcessIdentifier)): Kill off
    	non-exec tasks.
    	* LinuxPtraceProc.java (getAllTasks()): New.

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

Summary of changes:
 frysk-core/frysk/proc/ChangeLog                    |    5 +++++
 frysk-core/frysk/proc/TestExec.java                |   15 +--------------
 frysk-core/frysk/proc/live/ChangeLog               |    8 ++++++++
 frysk-core/frysk/proc/live/LinuxPtraceProc.java    |    5 +++++
 .../frysk/proc/live/LinuxPtraceTaskState.java      |   15 +++++++--------
 frysk-core/frysk/proc/live/LinuxWaitBuilder.java   |   17 +++++++++++++++--
 6 files changed, 41 insertions(+), 24 deletions(-)

First 500 lines of diff:
diff --git a/frysk-core/frysk/proc/ChangeLog b/frysk-core/frysk/proc/ChangeLog
index 5c5b3ee..7c19295 100644
--- a/frysk-core/frysk/proc/ChangeLog
+++ b/frysk-core/frysk/proc/ChangeLog
@@ -1,3 +1,8 @@
+2008-03-14  Andrew Cagney  <cagney@redhat.com>
+
+	* TestExec.java (testTaskBlockExec()): Use
+	StopEventLoopWhenProcTerminated.
+
 2008-03-13  Mark Wielaard  <mwielaard@redhat.com>
 
 	* TestTaskObserver.java (testDetachExitingMainTask): Enabled
diff --git a/frysk-core/frysk/proc/TestExec.java b/frysk-core/frysk/proc/TestExec.java
index 26c75da..6c3037b 100644
--- a/frysk-core/frysk/proc/TestExec.java
+++ b/frysk-core/frysk/proc/TestExec.java
@@ -149,20 +149,7 @@ public class TestExec
 		 mainTask.getProc().getTasks().size());
 
     // Set things up to stop once the exec task exits.
-    class StopEventLoopWhenProcRemoved implements java.util.Observer {
-	private int pid;
-	StopEventLoopWhenProcRemoved(ExecOffspring pid) {
-	    this.pid = pid.getPid().intValue();
-	    Manager.host.observableProcRemovedXXX.addObserver(this);
-	}
-	public void update(java.util.Observable o, Object obj) {
-	    Proc proc = (Proc) obj;
-	    if (proc.getPid() == this.pid) {
-		Manager.eventLoop.requestStop();
-	    }
-	}
-    }
-    new StopEventLoopWhenProcRemoved(child);
+    new StopEventLoopWhenProcTerminated(child);
     mainTask.requestUnblock(execBlockCounter);
     assertRunUntilStop("wait for exec program exit");
 
diff --git a/frysk-core/frysk/proc/live/ChangeLog b/frysk-core/frysk/proc/live/ChangeLog
index ce3c3ee..3738d03 100644
--- a/frysk-core/frysk/proc/live/ChangeLog
+++ b/frysk-core/frysk/proc/live/ChangeLog
@@ -1,3 +1,11 @@
+2008-03-14  Andrew Cagney  <cagney@redhat.com>
+
+	* LinuxPtraceTaskState.java: Don't remove non-exec tasks; already
+	deleted.
+	* LinuxWaitBuilder.java (execEvent(ProcessIdentifier)): Kill off
+	non-exec tasks.
+	* LinuxPtraceProc.java (getAllTasks()): New.
+
 2008-03-13  Andrew Cagney  <cagney@redhat.com>
 
 	* TestTaskObserverBlocked.java: Use
diff --git a/frysk-core/frysk/proc/live/LinuxPtraceProc.java b/frysk-core/frysk/proc/live/LinuxPtraceProc.java
index 7c78616..ec192ac 100644
--- a/frysk-core/frysk/proc/live/LinuxPtraceProc.java
+++ b/frysk-core/frysk/proc/live/LinuxPtraceProc.java
@@ -39,6 +39,8 @@
 
 package frysk.proc.live;
 
+import java.util.HashSet;
+import java.util.Set;
 import frysk.proc.Action;
 import frysk.sys.proc.Exe;
 import frysk.proc.Proc;
@@ -101,6 +103,9 @@ public class LinuxPtraceProc extends LiveProc {
 	tasks.remove(task.tid);
 	remove(task);
     }
+    Set getAllTasks() {
+	return new HashSet(tasks.values());
+    }
     private final HashMap tasks = new HashMap();
 
     public Task getMainTask() {
diff --git a/frysk-core/frysk/proc/live/LinuxPtraceTaskState.java b/frysk-core/frysk/proc/live/LinuxPtraceTaskState.java
index db89997..a2d557f 100644
--- a/frysk-core/frysk/proc/live/LinuxPtraceTaskState.java
+++ b/frysk-core/frysk/proc/live/LinuxPtraceTaskState.java
@@ -861,22 +861,21 @@ class LinuxPtraceTaskState extends State {
 	}
 	LinuxPtraceTaskState handleExecedEvent(LinuxPtraceTask task) {
 	    fine.log("handleExecedEvent", task); 
-	    // Remove all tasks, retaining just this one.
-	    ((LinuxPtraceProc)task.getProc()).retain(task);
 	    ((LinuxPtraceProc)task.getProc()).getStat().scan(task.tid);
 
 	    // All breakpoints have been erased.  We need to
 	    // explicitly tell those attached to the current Task.
 	    ((LinuxPtraceProc)task.getProc()).breakpoints.removeAllCodeObservers();
-	    Iterator it = task.codeObservers.iterator();
-	    while (it.hasNext())
-		((TaskObserver.Code) it.next()).deletedFrom(task);
+	    for (Iterator i = task.codeObservers.iterator(); i.hasNext(); ) {
+		TaskObserver.Code codeObserver = (TaskObserver.Code) i.next();
+		codeObserver.deletedFrom(task);
+	    }
 
 	    // XXX - Do we really need to remove all?
 	    // Remove just the code observers?
-	    it = task.pendingObservations.iterator();
-	    while (it.hasNext())
-		((TaskObservation) it.next()).delete();
+	    for (Iterator i = task.pendingObservations.iterator(); i.hasNext(); ) {
+		((TaskObservation) i.next()).delete();
+	    }
 
 	    if (task.notifyExeced() > 0) {
 		return (task.syscallObservers.numberOfObservers() > 0
diff --git a/frysk-core/frysk/proc/live/LinuxWaitBuilder.java b/frysk-core/frysk/proc/live/LinuxWaitBuilder.java
index 53e2193..1ed8ef4 100644
--- a/frysk-core/frysk/proc/live/LinuxWaitBuilder.java
+++ b/frysk-core/frysk/proc/live/LinuxWaitBuilder.java
@@ -39,6 +39,8 @@
 
 package frysk.proc.live;
 
+import java.util.Set;
+import java.util.Iterator;
 import frysk.event.Event;
 import frysk.sys.Signal;
 import frysk.sys.WaitBuilder;
@@ -157,8 +159,19 @@ class LinuxWaitBuilder implements WaitBuilder {
     }
     
     public void execEvent(ProcessIdentifier pid) {
-        LinuxPtraceTask task = get(pid, "execEvent");
-        task.processExecedEvent();
+        LinuxPtraceTask execingTask = get(pid, "execEvent");
+	// On linux an exec event implicitly kills off all of the
+	// processes other tasks; need to do that explicitly; there's
+	// no "terminating" event as, by this point, the tasks are
+	// totally gone.
+	Set tasks = ((LinuxPtraceProc)execingTask.getProc()).getAllTasks();
+	tasks.remove(execingTask);
+	for (Iterator i = tasks.iterator(); i.hasNext(); ) {
+	    LinuxPtraceTask doa = (LinuxPtraceTask) i.next();
+	    doa.processTerminatedEvent(null, 0);
+	}
+	// Finally notify the exec.
+        execingTask.processExecedEvent();
     }
     
     public void disappeared(ProcessIdentifier pid, Throwable w) {


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


                 reply	other threads:[~2008-03-14 17:04 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=20080314170407.19867.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).