public inbox for frysk-cvs@sourceware.org
help / color / mirror / Atom feed
From: pmachata@sourceware.org
To: frysk-cvs@sourceware.org
Subject: [SCM]  master: Fix build failure
Date: Thu, 05 Jun 2008 17:29:00 -0000	[thread overview]
Message-ID: <20080605172931.31967.qmail@sourceware.org> (raw)

The branch, master has been updated
       via  300ce92e79941af2698563a87dc82a8c03e296db (commit)
       via  01a214b126bc4ab28bf12012dd93e7aa3ef34a55 (commit)
      from  ea58fe9a9ba494eca70014a0c6e51cc7880187c6 (commit)

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

- Log -----------------------------------------------------------------
commit 300ce92e79941af2698563a87dc82a8c03e296db
Author: Petr Machata <pmachata@redhat.com>
Date:   Thu Jun 5 19:22:26 2008 +0200

    Fix build failure

commit 01a214b126bc4ab28bf12012dd93e7aa3ef34a55
Author: Petr Machata <pmachata@redhat.com>
Date:   Thu Jun 5 13:53:30 2008 +0200

    Fix race in ftrace attaching various observers to task

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

Summary of changes:
 frysk-core/frysk/ftrace/ChangeLog   |    4 ++
 frysk-core/frysk/ftrace/Ftrace.java |   83 +++++++++++++++++++++--------------
 frysk-sys/lib/dwfl/jni/Dwarf.cxx    |    2 +-
 3 files changed, 55 insertions(+), 34 deletions(-)

First 500 lines of diff:
diff --git a/frysk-core/frysk/ftrace/ChangeLog b/frysk-core/frysk/ftrace/ChangeLog
index 4e989ef..19fd300 100644
--- a/frysk-core/frysk/ftrace/ChangeLog
+++ b/frysk-core/frysk/ftrace/ChangeLog
@@ -1,3 +1,7 @@
+2008-06-05  Petr Machata  <pmachata@redhat.com>
+
+	* Ftrace.java: Fix race in attaching various task observers.
+
 2008-06-03  Andrew Cagney  <cagney@redhat.com>
 
 	* Ftrace.java: Use DwflModule.getModules() and not
diff --git a/frysk-core/frysk/ftrace/Ftrace.java b/frysk-core/frysk/ftrace/Ftrace.java
index adfa35a..68ecadb 100644
--- a/frysk-core/frysk/ftrace/Ftrace.java
+++ b/frysk-core/frysk/ftrace/Ftrace.java
@@ -73,6 +73,7 @@ import lib.dwfl.DwflModule;
 public class Ftrace {
     static private final Log fine = LogFactory.fine(Ftrace.class);
     static private final Log finest = LogFactory.finest(Ftrace.class);
+    static private final Log warning = LogFactory.warning(Ftrace.class);
 
     private final PrintStackOptions stackPrintOptions;
 
@@ -233,38 +234,55 @@ public class Ftrace {
 	Manager.eventLoop.run();
     }
 
+    class TaskObservations {
+	boolean locked = false;
+	int counter = 1;
+    }
+
     private HashMap observationCounters = new HashMap();
 
-    synchronized private void observationRequested(Task task) {
-	Integer i = (Integer)observationCounters.get(task);
-	if (i == null)
-	    i = new Integer(1);
+    synchronized private void observationRequested(Task task, String what) {
+	fine.log("Observation requested", what);
+	TaskObservations to = (TaskObservations)observationCounters.get(task);
+	if (to == null)
+	    observationCounters.put(task, new TaskObservations());
+	else if (to.locked)
+	    warning.log("Attempt to add new observation to locked task.");
 	else
-	    i = new Integer(i.intValue() + 1);
-	observationCounters.put(task, i);
+	    to.counter++;
     }
 
-    synchronized private void observationRealized(Task task) {
-	Integer i = (Integer)observationCounters.get(task);
-	// must be non-null
-	int j = i.intValue();
-	if (j == 1) {
-	    // Store a dummy into the map to detect errors.
-	    observationCounters.put(task, new Object());
-	    task.requestUnblock(attachedObserver);
+    synchronized private void observationRealized(Task task, String what) {
+	fine.log("Observation realized", what);
+	TaskObservations to = (TaskObservations)observationCounters.get(task);
+	if (to == null || to.counter < 0)
+	    warning.log("Observation realization for invalid task.");
+	else {
+	    to.counter--;
+	    if (to.counter == 0 && to.locked)
+		task.requestUnblock(attachedObserver);
 	}
-	else
-	    observationCounters.put(task, new Integer(--j));
     }
 
-    synchronized void handleTask (Task task)
-    {
+    synchronized private void noMoreObservations(Task task) {
+	TaskObservations to = (TaskObservations)observationCounters.get(task);
+	if (to == null || to.locked || to.counter < 0)
+	    warning.log("Attempt to lock invalid or locked task.");
+	else {
+	    to.locked = true;
+	    if (to.counter == 0)
+		task.requestUnblock(attachedObserver);
+	}
+    }
+
+    synchronized void handleTask(Task task) {
+
 	Proc proc = task.getProc();
 
 	if (tracedSyscallProvider != null) {
 	    finest.log("requesting syscall observer");
 	    task.requestAddSyscallsObserver(new MySyscallObserver(reporter));
-	    observationRequested(task);
+	    observationRequested(task, "syscall");
 	    Map workingSet
 		= tracedSyscallProvider.computeSyscallWorkingSet(task);
 	    syscallSetForTask.put(task, workingSet);
@@ -273,20 +291,20 @@ public class Ftrace {
 	if (tracedSignalProvider != null) {
 	    finest.log("requesting signal observer");
 	    task.requestAddSignaledObserver(new MySignaledObserver());
-	    observationRequested(task);
+	    observationRequested(task, "signal");
 	    Map workingSet
 		= tracedSignalProvider.computeSignalWorkingSet(task);
 	    signalSetForTask.put(task, workingSet);
 	}
 
 	task.requestAddForkedObserver(forkedObserver);
-	observationRequested(task);
+	observationRequested(task, "forked");
 
 	task.requestAddClonedObserver(clonedObserver);
-	observationRequested(task);
+	observationRequested(task, "cloned");
 
 	task.requestAddTerminatingObserver(new MyTerminatingObserver());
-	observationRequested(task);
+	observationRequested(task, "terminating");
 
 	if (ftraceController != null || traceMmapUnmap) {
 	    MyMappingObserver o = new MyMappingObserver(ftraceController);
@@ -298,11 +316,12 @@ public class Ftrace {
 		MappingGuard.requestAddSyscallBasedMappingObserver(task, o);
 	    else
 		MappingGuard.requestAddMappingObserver(task, o);
-	    observationRequested(task);
+	    observationRequested(task, "mapping");
 	}
 
 	new ProcRemovedObserver(proc);
 
+	noMoreObservations(task);
 	reporter.eventSingle(task, "attached " + proc.getExeFile().getSysRootedPath());
 	++numProcesses;
     }
@@ -394,11 +413,11 @@ public class Ftrace {
 			public void run() {
 			    finest.log("Attaching breakpoint manager");
 			    steppingEngine.getBreakpointManager().manageProcess(proc);
-			    observationRealized(task);
+			    observationRealized(task, "breakpoint manager");
 			}
 		    }
 		    Manager.eventLoop.add(new AddProcToBreakpointManager());
-		    observationRequested(task);
+		    observationRequested(task, "breakpoint manager");
 		}
 
 		addProc(task.getProc());
@@ -471,9 +490,8 @@ public class Ftrace {
 
 	public void addedTo (Object observable)
 	{
-	    finest.log("syscall observer realized");
 	    Task task = (Task) observable;
-	    observationRealized(task);
+	    observationRealized(task, "syscall");
 	}
 
 	public void addFailed (Object observable, Throwable w)
@@ -494,7 +512,7 @@ public class Ftrace {
 	public void addedTo (Object observable)
 	{
 	    Task task = (Task) observable;
-	    observationRealized(task);
+	    observationRealized(task, "clone");
 	}
 
 	public void deletedFrom (Object observable)
@@ -560,7 +578,7 @@ public class Ftrace {
 
 	public void addedTo (Object observable) {
 	    Task task = (Task) observable;
-	    observationRealized(task);
+	    observationRealized(task, "terminating");
 	}
 	public void deletedFrom (Object observable) { }
 	public void addFailed (Object observable, Throwable w) { }
@@ -584,9 +602,8 @@ public class Ftrace {
 	}
 
 	public void addedTo (Object observable) {
-	    finest.log("signal observer realized for " + observable);
 	    Task task = (Task) observable;
-	    observationRealized(task);
+	    observationRealized(task, "signal");
 	}
 	public void deletedFrom (Object observable) {
 	    finest.log("signal observer deleted from " + observable);
@@ -706,7 +723,7 @@ public class Ftrace {
 
 	public void addedTo (Object observable) {
 	    Task task = (Task) observable;
-	    observationRealized(task);
+	    observationRealized(task, "mapping");
 	}
 	public void deletedFrom (Object observable) { }
 	public void addFailed (Object observable, Throwable w) { }
diff --git a/frysk-sys/lib/dwfl/jni/Dwarf.cxx b/frysk-sys/lib/dwfl/jni/Dwarf.cxx
index b4eafdf..a3af80f 100644
--- a/frysk-sys/lib/dwfl/jni/Dwarf.cxx
+++ b/frysk-sys/lib/dwfl/jni/Dwarf.cxx
@@ -162,6 +162,6 @@ lib::dwfl::Dwarf::get_source_files(jnixx::env env) {
 }
 
 jint 
-lib::dwfl::Dwarf::dwarfEnd(jnixx::env env, long pointer){
+lib::dwfl::Dwarf::dwarfEnd(jnixx::env env, jlong pointer){
   return ::dwarf_end(DWARF_POINTER);
 }


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


                 reply	other threads:[~2008-06-05 17:29 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=20080605172931.31967.qmail@sourceware.org \
    --to=pmachata@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).