public inbox for frysk@sourceware.org
 help / color / mirror / Atom feed
* [patch] Mark Task as justStarted when receiving an ExecedEvent
@ 2008-04-09 14:26 Mark Wielaard
  0 siblings, 0 replies; only message in thread
From: Mark Wielaard @ 2008-04-09 14:26 UTC (permalink / raw)
  To: frysk

[-- Attachment #1: Type: text/plain, Size: 883 bytes --]

Hi,

Phil found another corner case which needed to be handled specially. We
need to mark the Task as just started when it gets an execed event
because the first "step" in such a task is special (it isn't a real
step, it is just the kernel adjusting the PC to the start of the dynamic
loader).

frysk-core/frysk/proc/ChangeLog
2008-04-09  Mark Wielaard  <mwielaard@redhat.com>

   * TestTaskObserverInstruction (testFirstInstructionAtEntry):
   New test.

frysk-core/frysk/proc/live/ChangeLog
2008-04-09  Mark Wielaard  <mwielaard@redhat.com>

   * LinuxPtraceTaskState.java (Running.handleExecedEvent): Mark
   Task as justStarted.

No regressions on x86_64, fedora 8.

It would be nice to have this just depend on the state, or route the
marking of just started in Running.sendContinue() since that is the real
place this matters. I'll look into that.

Pushed and committed,

Mark

[-- Attachment #2: patch --]
[-- Type: text/x-patch, Size: 2476 bytes --]

diff --git a/frysk-core/frysk/proc/TestTaskObserverInstruction.java b/frysk-core/frysk/proc/TestTaskObserverInstruction.java
index d5e3d2a..546a763 100644
--- a/frysk-core/frysk/proc/TestTaskObserverInstruction.java
+++ b/frysk-core/frysk/proc/TestTaskObserverInstruction.java
@@ -43,6 +43,9 @@ import frysk.testbed.TestLib;
 import frysk.testbed.Offspring;
 import frysk.testbed.SlaveOffspring;
 
+import frysk.testbed.DaemonBlockedAtEntry;
+import frysk.config.Config;
+
 public class TestTaskObserverInstruction extends TestLib
 {
   public void testInstruction()
@@ -136,6 +139,30 @@ public class TestTaskObserverInstruction extends TestLib
     assertTrue("InstructionObserver hit", instr.hit == 2);
   }
 
+  /**
+   * Tests stepping the very first instruction (actualy the start of the
+   * dynamic loader which is going to load the actual program). This is
+   * a nasty corner case since this isn't a "real step" but actually the
+   * kernel adjusting the task so that it will start running.
+   */
+  public void testFirstInstructionAtEntry()
+  {
+    DaemonBlockedAtEntry daemon;
+    daemon = new DaemonBlockedAtEntry(Config.getPkgLibFile("funit-child"));
+    Task task = daemon.getMainTask();
+
+    InstructionObserver instr = new InstructionObserver();
+    task.requestAddInstructionObserver(instr);
+    assertRunUntilStop("add InstructionObserver");
+    assertTrue("InstructionObserver added", instr.added);
+    assertTrue("InstructionObserver hit", instr.hit == 1);
+
+    daemon.requestUnblock();
+    task.requestUnblock(instr);
+    assertRunUntilStop("step first instruction");
+    assertTrue("InstructionObserver hit again", instr.hit == 2);
+  }
+
   private class StepAttachedObserver implements TaskAttachedObserverXXX
   {
     private final InstructionObserver instr;
diff --git a/frysk-core/frysk/proc/live/LinuxPtraceTaskState.java b/frysk-core/frysk/proc/live/LinuxPtraceTaskState.java
index 3e590c4..9a71530 100644
--- a/frysk-core/frysk/proc/live/LinuxPtraceTaskState.java
+++ b/frysk-core/frysk/proc/live/LinuxPtraceTaskState.java
@@ -891,6 +891,10 @@ abstract class LinuxPtraceTaskState extends State {
 		((TaskObservation) i.next()).delete();
 	    }
 
+	    // Mark this LinuxPtraceTask as just started.  See
+	    // Running.handleTrapped for more explanation.
+	    task.justStartedXXX = true;
+
 	    if (task.notifyExeced() > 0) {
 		return (task.syscallObservers.numberOfObservers() > 0
 			? syscallBlockedInSyscallContinue

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2008-04-09 14:15 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-04-09 14:26 [patch] Mark Task as justStarted when receiving an ExecedEvent Mark Wielaard

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).