public inbox for frysk-cvs@sourceware.org
help / color / mirror / Atom feed
* [SCM]  master: Fix problem with 'go' after 'run' on mult-threaded procs(bz 5674).
@ 2008-02-02  4:55 rmoseley
  0 siblings, 0 replies; only message in thread
From: rmoseley @ 2008-02-02  4:55 UTC (permalink / raw)
  To: frysk-cvs

The branch, master has been updated
       via  d80d5af416877aef88bc9ac2bcd38d17568244cd (commit)
      from  fa49857140a9ea0d2346fa8d4d7ffc1d41d5c22d (commit)

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

- Log -----------------------------------------------------------------
commit d80d5af416877aef88bc9ac2bcd38d17568244cd
Author: Rick Moseley <rmoseley@localhost.localdomain>
Date:   Fri Feb 1 22:55:25 2008 -0600

    Fix problem with 'go' after 'run' on mult-threaded procs(bz 5674).
    
            * GoCommand.java: Fix bz#5674.
            * AttachCommand.java: Ditto.
            * CLI.java: Ditto.
            * StartRun.java: Ditto.
            * SteppingEngine.java: Ditto.
            * TestGoCommand.java: New.
            * TestStartCommand.java: Increase timeout for file creation wait.
            * TestRunCommand.java: Ditto.

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

Summary of changes:
 frysk-core/frysk/hpd/AttachCommand.java            |    4 +-
 frysk-core/frysk/hpd/CLI.java                      |   36 ++++++++++++-
 frysk-core/frysk/hpd/ChangeLog                     |   10 ++++
 frysk-core/frysk/hpd/GoCommand.java                |   37 ++++++++++---
 frysk-core/frysk/hpd/StartRun.java                 |   49 +++++++++++++----
 .../{TestPreprocessor.java => TestGoCommand.java}  |   56 ++++++++++----------
 frysk-core/frysk/hpd/TestRunCommand.java           |    4 +-
 frysk-core/frysk/hpd/TestStartCommand.java         |   12 +++-
 frysk-core/frysk/stepping/ChangeLog                |    4 ++
 frysk-core/frysk/stepping/SteppingEngine.java      |   18 +++++--
 10 files changed, 169 insertions(+), 61 deletions(-)
 copy frysk-core/frysk/hpd/{TestPreprocessor.java => TestGoCommand.java} (68%)

First 500 lines of diff:
diff --git a/frysk-core/frysk/hpd/AttachCommand.java b/frysk-core/frysk/hpd/AttachCommand.java
index 8556e5b..60ed4f1 100644
--- a/frysk-core/frysk/hpd/AttachCommand.java
+++ b/frysk-core/frysk/hpd/AttachCommand.java
@@ -1,6 +1,6 @@
 // This file is part of the program FRYSK.
 //
-// Copyright 2005, 2006, 2007 Red Hat Inc.
+// Copyright 2005, 2006, 2007, 2008 Red Hat Inc.
 //
 // FRYSK is free software; you can redistribute it and/or modify it
 // under the terms of the GNU General Public License as published by
@@ -118,7 +118,7 @@ class AttachCommand extends ParameterizedCommand {
 		continue;
 	    }
 	    DwflCache.setSysroot(findProc.proc.getMainTask(), o.sysroot);
-	    cli.doAttach(findProc.proc);
+	    cli.doAttach(findProc.proc, false);
 	}
     }
 
diff --git a/frysk-core/frysk/hpd/CLI.java b/frysk-core/frysk/hpd/CLI.java
index a46c8a2..c08fb3d 100644
--- a/frysk-core/frysk/hpd/CLI.java
+++ b/frysk-core/frysk/hpd/CLI.java
@@ -1,6 +1,6 @@
 // This file is part of the program FRYSK.
 //
-// Copyright 2005, 2006, 2007 Red Hat Inc.
+// Copyright 2005, 2006, 2007, 2008 Red Hat Inc.
 //
 // FRYSK is free software; you can redistribute it and/or modify it
 // under the terms of the GNU General Public License as published by
@@ -47,8 +47,10 @@ import java.util.HashSet;
 import java.util.Iterator;
 import java.util.LinkedList;
 import java.util.List;
+import java.util.Map;
 import java.util.Observable;
 import java.util.Observer;
+import java.util.Set;
 import java.util.WeakHashMap;
 import frysk.debuginfo.DebugInfo;
 import frysk.debuginfo.DebugInfoFrame;
@@ -141,7 +143,7 @@ public class CLI {
     /*
      * Command handlers
      */
-    public void doAttach(Proc proc) {
+    public void doAttach(Proc proc, boolean running) {
         synchronized (this) {
             attached = -1;
             attachedLatch = new CountDownLatch(1);
@@ -163,6 +165,14 @@ public class CLI {
         }
 
         steppingEngine.getBreakpointManager().manageProcess(proc);
+        
+        // If doAttach was called for a "run" command, continue running
+        if (running) {
+            steppingEngine.continueExecution(proc.getTasks());
+            steppingEngine.setRunning(proc.getTasks());
+            addMessage("Running process " + proc.getPid(),
+			Message.TYPE_NORMAL);
+        }
         // If passed a taskID < 0, request a reserved ProcID
         if (this.taskID < 0)
             idManager.manageProc(proc, idManager.reserveProcID());
@@ -480,4 +490,26 @@ public class CLI {
         }
         return ptset;
     }
+    
+    /**
+     * notRunningFile make sure we are not running the "go" command on 
+     * procs that are loaded or on core files.
+     * 
+     * @param checkFiles is a HashMap containing the procs we want to check
+     * @param task is what we need to check against
+     * @return true if it is a loaded or core file, false if not
+     */
+    public static boolean notRunningProc(int pid, HashMap checkFiles) {
+	if (checkFiles.isEmpty())
+	    return false;
+	Set procSet = checkFiles.entrySet();
+	Iterator foo = procSet.iterator();
+	while (foo.hasNext()) {
+	    Map.Entry me = (Map.Entry) foo.next();
+	    Proc proc = (Proc) me.getKey();
+	    if (proc.getPid() == pid)
+		return true;
+	}
+	return false;
+    }
 }
diff --git a/frysk-core/frysk/hpd/ChangeLog b/frysk-core/frysk/hpd/ChangeLog
index 0a80c6b..ca5c749 100644
--- a/frysk-core/frysk/hpd/ChangeLog
+++ b/frysk-core/frysk/hpd/ChangeLog
@@ -1,3 +1,13 @@
+2008-02-01  Rick Moseley  <rmoseley@redhat.com>
+
+	* GoCommand.java: Fix bz#5674.
+	* AttachCommand.java: Ditto.
+	* CLI.java: Ditto.
+	* StartRun.java: Ditto.
+	* TestGoCommand.java: New.
+	* TestStartCommand.java: Increase timeout for file creation wait.
+	* TestRunCommand.java: Ditto.
+
 2008-01-29  Stan Cox  <scox@redhat.com>
 
 	* TestSysRoot.java (testHaveSysRoot): test-sysroot now lives in
diff --git a/frysk-core/frysk/hpd/GoCommand.java b/frysk-core/frysk/hpd/GoCommand.java
index 9f3acde..321d7c4 100644
--- a/frysk-core/frysk/hpd/GoCommand.java
+++ b/frysk-core/frysk/hpd/GoCommand.java
@@ -1,6 +1,6 @@
 // This file is part of the program FRYSK.
 //
-// Copyright 2005, 2006, 2007 Red Hat Inc.
+// Copyright 2005, 2006, 2007, 2008 Red Hat Inc.
 //
 // FRYSK is free software; you can redistribute it and/or modify it
 // under the terms of the GNU General Public License as published by
@@ -39,10 +39,11 @@
 
 package frysk.hpd;
 
+//import java.util.HashMap;
 import java.util.Iterator;
-import frysk.proc.Task;
-import frysk.stepping.SteppingEngine;
 import java.util.List;
+import frysk.stepping.SteppingEngine;
+import frysk.proc.Task;
 
 class GoCommand extends ParameterizedCommand {
     private static String full = "Continue running a process, returning "
@@ -54,24 +55,44 @@ class GoCommand extends ParameterizedCommand {
 
     GoCommand() {
 	super("Continue a process.", "go", full);
-    }
+    } 
 
     void interpret(CLI cli, Input cmd, Object options) {
 	PTSet ptset = cli.getCommandPTSet(cmd);
 	if (cli.steppingObserver != null) {
 	    Iterator taskIter = ptset.getTasks();
 	    SteppingEngine steppingEngine = cli.getSteppingEngine();
+//	    HashMap loadedProcs = cli.getLoadedProcs();
+//	    HashMap coreProcs = cli.getCoreProcs();
 	    while (taskIter.hasNext()) {
 		Task task = (Task) taskIter.next();
-		if (!steppingEngine.isTaskRunning(task))
-		    steppingEngine.continueExecution(task);
-		cli.addMessage("Running process " + task.getProc().getPid(),
+//		int taskPid = task.getProc().getPid();
+		if (!steppingEngine.isTaskRunning(task)) { //&& 
+//			CLI.notRunningProc(taskPid, loadedProcs) && 
+//			CLI.notRunningProc(taskPid, coreProcs)) {
+		    /* Try to continue task, if an exception occurs it is 
+		     * probably because it is already running and previously
+		     * has not been marked as such.  Until the
+		     * method task.getStateFIXME is fixed, this may be the best we
+		     * can do for now.
+		     */
+		    try {
+			steppingEngine.continueExecution(task);
+		    } catch (Exception e) {
+			// OK, caught an exception, set the task to running
+			steppingEngine.setTaskRunning(task);
+		    }
+		} // else if (CLI.notRunningProc(taskPid, loadedProcs) || 
+		//	CLI.notRunningProc(taskPid, coreProcs))
+		  //     cli.addMessage("Cannot use 'go' on a loaded or core file, must 'start' first", Message.TYPE_WARNING);
+		//else
+		    cli.addMessage("Running process " + task.getProc().getPid(),
 			Message.TYPE_NORMAL);
 	    }
 	} else
 	    cli.addMessage("Not attached to any process", Message.TYPE_ERROR);
     }
-
+    
     int completer(CLI cli, Input input, int cursor, List completions) {
 	return -1;
     }
diff --git a/frysk-core/frysk/hpd/StartRun.java b/frysk-core/frysk/hpd/StartRun.java
index e9a6beb..bda78bf 100644
--- a/frysk-core/frysk/hpd/StartRun.java
+++ b/frysk-core/frysk/hpd/StartRun.java
@@ -124,14 +124,32 @@ class StartRun extends ParameterizedCommand {
 	}
     }
     
+    /**
+     * interpretRun is called from RunCommand to run a process until
+     * its first break point(if any) or until it blows up of finishes.
+     * 
+     * @param cli is the current command line interface object
+     * @param cmd is the command to be run
+     * @param options is not used at this point
+     */
     public void interpretRun(CLI cli, Input cmd, Object options) {
 	runToBreak = true;
 	interpretCmd(cli, cmd, options);
+	return;
     }
-    
+   
+    /**
+     * interpretStart is called from StartCommand to start a process and
+     * run it to the first executable statement.
+     * 
+     * @param cli is the current command line interface object
+     * @param cmd is the command to be started
+     * @param options is not used at this point
+     */
     public void interpretStart(CLI cli, Input cmd, Object options)  {
 	runToBreak = false;
 	interpretCmd(cli, cmd, options);
+	return;
     }
     
     public void interpret(CLI cli, Input cmd, Object options) {
@@ -148,13 +166,15 @@ class StartRun extends ParameterizedCommand {
 		int oldPid = -1;
 		while (foo.hasNext()) {
 		    Task task = (Task) foo.next();
-		    if (task.getProc().getPid() == oldPid)
-		        continue;
+		    // Need only one kill per PID(proc)
+		    if (task.getProc().getPid() == oldPid) {
+			continue;
+		    } else 
+			cli.execCommand("kill\n");
 		    String paramList = getParameters(cmd, task);
-		    cli.execCommand("kill\n");
-		    cli.execCommand("start " + paramList + "\n");
-		    if (runToBreak)
-			cli.execCommand("go\n");
+		    Input newcmd = new Input(task.getProc().getExe() + " " +
+			    paramList);
+		    run(cli, newcmd);
 		    oldPid = task.getProc().getPid();
 		}
 		return;
@@ -200,13 +220,17 @@ class StartRun extends ParameterizedCommand {
 	    }
 	}
 	// register with SteppingEngine et.al.
-	cli.doAttach(runner.launchedTask.getProc());
+	cli.doAttach(runner.launchedTask.getProc(), runToBreak);
 	runner.launchedTask.requestUnblock(runner);
     }
 
-    /*
+    /**
      * runProcs does as the name implies, it runs procs found to be loaded by a
      * load or a core command.
+     * 
+     * @param cli is the current commandline interface object
+     * @param procs is the set of procs to be run
+     * @param cmd is the command object to use to start the proc(s)
      */
     private void runProcs(CLI cli, Set procs, Input cmd) {
 	Iterator foo = procs.iterator();
@@ -226,8 +250,8 @@ class StartRun extends ParameterizedCommand {
 	    cli.addMessage("starting/running with this command: " + 
 		    newcmd, Message.TYPE_NORMAL);
 	    run(cli, newcmd);
-	    if (runToBreak)
-		cli.execCommand("go\n");
+	    //if (runToBreak)
+		//cli.execCommand("go\n");
 	    synchronized (cli) {
 		cli.taskID = -1;
 	    }
@@ -257,6 +281,7 @@ class StartRun extends ParameterizedCommand {
     
     /**
      * parseParameters takes a String array and returns a space-delimited String
+     * 
      * @param parameters is the String array to convert
      * @param which indicates whether or not to skip the first parameter
      * @return a String of the parameters separated by spaces
@@ -281,4 +306,4 @@ class StartRun extends ParameterizedCommand {
 	return CompletionFactory.completeFileName(cli, input, cursor,
 		completions);
     }
-}
+}
\ No newline at end of file
diff --git a/frysk-core/frysk/hpd/TestPreprocessor.java b/frysk-core/frysk/hpd/TestGoCommand.java
similarity index 68%
copy from frysk-core/frysk/hpd/TestPreprocessor.java
copy to frysk-core/frysk/hpd/TestGoCommand.java
index 000d643..c332887 100644
--- a/frysk-core/frysk/hpd/TestPreprocessor.java
+++ b/frysk-core/frysk/hpd/TestGoCommand.java
@@ -1,6 +1,6 @@
 // This file is part of the program FRYSK.
 //
-// Copyright 2007 Red Hat Inc.
+// Copyright 2008 Red Hat Inc.
 //
 // FRYSK is free software; you can redistribute it and/or modify it
 // under the terms of the GNU General Public License as published by
@@ -39,38 +39,38 @@
 
 package frysk.hpd;
 
-import frysk.expunit.Regex;
-import frysk.expunit.EndOfFileException;
+import frysk.Config;
 
 /**
- * Test the pre-processor which unpacks stuff like
- * <<COMMAND;COMMAND>>.
+ * This class tests the "go" command and makes sure it does not blow up
+ * after a run command has been issued.  (bz #5674)
  */
 
-public class TestPreprocessor extends TestLib {
-    public void testEmptyCompound() {
+public class TestGoCommand extends TestLib {
+    public void testGoCommand() {
 	e = new HpdTestbed();
-	e.sendCommandExpectPrompt(";", "\r\n");
+	e.sendCommandExpectPrompt("load " + Config.getPkgLibFile("funit-threads-looper").getPath(),
+	"Loaded executable file.*");
+	//e.sendCommandExpectPrompt("run ",
+	//	"Attached to process ([0-9]+).*Running process ([0-9]+).*");
+	e.send("run\n");
+	e.expect("Attached to process ([0-9]+).*");
+	e.expect("Running process ([0-9]+).*" + prompt);
+	e.sendCommandExpectPrompt("go","Running process ([0-9]+).*");
+	e.send("quit\n");
+	e.expect("Quitting\\.\\.\\.");
+	e.close();
     }
-    public void testUnknownSecondCompound() {
+    
+/*    public void testGoCommandError() {
 	e = new HpdTestbed();
-	e.sendCommandExpectPrompt(";oust", "Error: Unknown command: oust\r\n");
-    }
-
-    public void testEOF() {
-	e = new HpdTestbed();
-	e.send("\004"); // ^D; PTY converts this to EOF.
-	// Match just EOF, if there is any other output fail.
-	boolean eof = false;
-	try {
-	    e.expect(new Regex(".+") {
-		    public void execute() {
-			fail("Unexpected input: <<" + group() + ">>");
-		    }
-		});
-	} catch (EndOfFileException e) {
-	    eof = true;
-	}
-	assertTrue("eof", eof);
-    }
+	e.sendCommandExpectPrompt("load " + Config.getPkgLibFile("funit-threads-looper").getPath(),
+	"Loaded executable file.*");
+	e.sendCommandExpectPrompt("go", "Warning: Cannot use.*");
+	e.send("quit\n");
+	e.expect("Quitting\\.\\.\\.");
+	e.close(); 
+    } */
 }
+	
+	
\ No newline at end of file
diff --git a/frysk-core/frysk/hpd/TestRunCommand.java b/frysk-core/frysk/hpd/TestRunCommand.java
index 076316b..151368d 100644
--- a/frysk-core/frysk/hpd/TestRunCommand.java
+++ b/frysk-core/frysk/hpd/TestRunCommand.java
@@ -114,9 +114,9 @@ public class TestRunCommand extends TestLib {
 	 * machine the funit-parameters process gets put into a different CPU and gets behind
 	 * the test case.  funit-parameters creates a file that this test checks and when this
 	 * test gets ahead of it that, the test fails beause it cannot find it.  Delaying
-	 * 1/10 of a second seems to fix that problem.
+	 * 1 second seems to fix that problem.
 	 */
-	try { Thread.sleep(100); } catch (Exception e) {}
+	try { Thread.sleep(1000); } catch (Exception e) {}
 	int file_length = 0;
 	String compare = "";
 	for (int i = 0; i < param.length; i++) {
diff --git a/frysk-core/frysk/hpd/TestStartCommand.java b/frysk-core/frysk/hpd/TestStartCommand.java
index 24a0824..d185b2e 100644
--- a/frysk-core/frysk/hpd/TestStartCommand.java
+++ b/frysk-core/frysk/hpd/TestStartCommand.java
@@ -61,6 +61,12 @@ public class TestStartCommand extends TestLib {
 	e.close();
     }
     
+    /**
+     * testStartCommandParameter tests to make sure parameters are properly passed
+     * to the inferior when it is activated.  In this case, the inferior gets the
+     * parameters and writes them to a file which this test case them compares to 
+     * what it thinks it sent.
+     */
     public void testStartCommandParameter() {
 	e = new HpdTestbed();
 	String[] param = { "teststart", "parameter2start"};
@@ -73,10 +79,10 @@ public class TestStartCommand extends TestLib {
 	 * The following wait is added to make the test pass.  It seems on a dual-core
 	 * machine the funit-parameters process gets put into a different CPU and gets behind
 	 * the test case.  funit-parameters creates a file that this test checks and when this
-	 * test gets ahead of it that, the test fails beause it cannot find it.  Delaying
-	 * 1/10 of a second seems to fix that problem.
+	 * test gets ahead of it that, the test fails because it cannot find it.  Delaying
+	 * 1 second seems to fix that problem.
 	 */
-	try { Thread.sleep(100); } catch (Exception e) {}
+	try { Thread.sleep(1000); } catch (Exception e) {}
 	int file_length = 0;
 	String compare = "";
 	for (int i = 0; i < param.length; i++) {
diff --git a/frysk-core/frysk/stepping/ChangeLog b/frysk-core/frysk/stepping/ChangeLog
index 7d5777c..78b6fda 100644
--- a/frysk-core/frysk/stepping/ChangeLog
+++ b/frysk-core/frysk/stepping/ChangeLog
@@ -1,3 +1,7 @@
+2008-02-01  Rick Moseley  <rmoseley@redhat.com>
+
+	* SteppingEngine.java (setTaskRunning): New.
+
 2008-01-24  Andrew Cagney  <cagney@redhat.com>
 
 	* SteppingEngine.java: Update to match
diff --git a/frysk-core/frysk/stepping/SteppingEngine.java b/frysk-core/frysk/stepping/SteppingEngine.java
index b298a27..13224ff 100644
--- a/frysk-core/frysk/stepping/SteppingEngine.java
+++ b/frysk-core/frysk/stepping/SteppingEngine.java
@@ -767,7 +767,7 @@ public class SteppingEngine {
      * @param tasks The Tasks to check states for.
      * 
      * @return true If any of the Tasks are not stopped
-     * @retruen false If all the Tasks are stopped
+     * @return false If all the Tasks are stopped
      */
     public boolean isProcRunning(LinkedList tasks) {
 	TaskStepEngine tse = null;
@@ -960,16 +960,26 @@ public class SteppingEngine {
      * @param tasks The Tasks to be set as running.
      */
     public void setRunning(LinkedList tasks) {
-	TaskStepEngine tse = null;
 	Iterator i = tasks.iterator();
 	while (i.hasNext()) {
 	    Task t = (Task) i.next();
-	    tse = (TaskStepEngine) this.taskStateMap.get(t);
-	    tse.setState(new RunningState(t));
+	    setTaskRunning(t);
 	}
     }
 
     /**
+     * Set the current state of the given task as running.  Used when the running
+     * of this task was out of the scope of control for SteppingEngine.
+     * 
+     * @param task to be set as running
+     */
+    
+    public void setTaskRunning(Task task) {
+	TaskStepEngine tse = null;
+	tse = (TaskStepEngine) this.taskStateMap.get(task);
+	    tse.setState(new RunningState(task));
+    }
+    /**
      * Adds the given Observer to this.steppingObserver's Observer list.
      * 
      * @param o The Observer to be added.


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


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

only message in thread, other threads:[~2008-02-02  4:55 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-02-02  4:55 [SCM] master: Fix problem with 'go' after 'run' on mult-threaded procs(bz 5674) rmoseley

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