This is the mail archive of the frysk-cvs@sources.redhat.com mailing list for the frysk project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[SCM] master: Add start command to the fhpd framework.


The branch, master has been updated
       via  189dc28164b2bf1b7fb43dd43c3de8cae0fcb493 (commit)
      from  cf9bc42a978d8ee5984df226a9d741236af14a8a (commit)

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

- Log -----------------------------------------------------------------
commit 189dc28164b2bf1b7fb43dd43c3de8cae0fcb493
Author: Rick Moseley <rmoseley@localhost.localdomain>
Date:   Mon Dec 17 15:13:47 2007 -0600

    Add start command to the fhpd framework.
    
    * StartCommand.java: New.
    * TestStartCommand.java: New.
    * HpdTestbed.java (start): New method to support start
      command.
    * TopLevel.Command.java: Added start command.

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

Summary of changes:
 frysk-core/frysk/hpd/ChangeLog                     |    8 +++
 frysk-core/frysk/hpd/HpdTestbed.java               |   48 ++++++++++++++++++--
 .../hpd/{RunCommand.java => StartCommand.java}     |   46 +++++++++++--------
 ...CommandException.java => TestStartCommand.java} |   20 +++++----
 frysk-core/frysk/hpd/TopLevelCommand.java          |    1 +
 5 files changed, 91 insertions(+), 32 deletions(-)
 copy frysk-core/frysk/hpd/{RunCommand.java => StartCommand.java} (86%)
 copy frysk-core/frysk/hpd/{InvalidCommandException.java => TestStartCommand.java} (90%)

First 500 lines of diff:
diff --git a/frysk-core/frysk/hpd/ChangeLog b/frysk-core/frysk/hpd/ChangeLog
index 082baca..313cc11 100644
--- a/frysk-core/frysk/hpd/ChangeLog
+++ b/frysk-core/frysk/hpd/ChangeLog
@@ -1,3 +1,11 @@
+2007-12-17  Rick Moseley  <rmoseley@redhat.com>
+
+	* StartCommand.java: New.
+	* TestStartCommand.java: New.
+	* HpdTestbed.java (start): New method to support start
+	command.
+	* TopLevel.Command.java: Added start command.
+
 2007-12-17  Phil Muldoon  <pmuldoon@redhat.com>
 
 	* TestAuxvCommand.java (testAuxVCoreCommand): Remove expect
diff --git a/frysk-core/frysk/hpd/HpdTestbed.java b/frysk-core/frysk/hpd/HpdTestbed.java
index 2cec313..6d7298b 100644
--- a/frysk-core/frysk/hpd/HpdTestbed.java
+++ b/frysk-core/frysk/hpd/HpdTestbed.java
@@ -82,7 +82,7 @@ public class HpdTestbed
 
     /**
      * Create an FHPD process, with PARAM, managed by expect; wait for
-     * the STARTUP message followed immediatly by the prompt.
+     * the STARTUP message followed immediately by the prompt.
      */
     public HpdTestbed(String param, String startup) {
 	this(new String[] {
@@ -128,7 +128,7 @@ public class HpdTestbed
     }
 
     /**
-     * Expect OUTPUT immediatly followed by the prompt.
+     * Expect OUTPUT immediately followed by the prompt.
      */
     public HpdTestbed expectPrompt(String output) {
 	return expectPrompt("expecting: <" + output + ">", output);
@@ -137,7 +137,7 @@ public class HpdTestbed
     /**
      * Send COMMAND ("\n" will be appended); expect OUTPUT along with
      * the prompt (OUTPUT must match everything up to the prompt
-     * including newlines); if other ooutput, or a timeout, fail.
+     * including newlines); if other output, or a timeout, fail.
      */
     public HpdTestbed sendCommandExpectPrompt(final String command,
 					      final String output) {
@@ -210,7 +210,47 @@ public class HpdTestbed
     }
 
     /**
-     * Start HPD attatched to PROGRAM that is crashing (due to a
+     * Start the specified program from under HPD.
+     */
+    static HpdTestbed start(String program, String args) {
+	HpdTestbed h = new HpdTestbed();
+	File exe = Config.getPkgLibFile(program);
+	h.send("start ");
+	h.send(exe.getAbsolutePath());
+	if (args != null) {
+	    h.send(" ");
+	    h.send(args);
+	}
+	h.send("\n");
+	try {
+	    h.expect(new Match[] {
+			 new Regex("Attached to process ([0-9]+)\r\n"
+				   + h.prompt) {
+			     public void execute() {
+				 int pid = Integer.parseInt(group(1));
+				 TearDownProcess.add(pid);
+			     }
+			 },
+			 new Regex(".*\r\n" + h.prompt) {
+			     public void execute() {
+				 TestCase.fail("Expecting <start> got: <"
+					       + group() + ">");
+			     }
+			 }
+		     });
+	} catch (EndOfFileException e) {
+	    TestCase.fail("Expecting <start " + program + "> got: <EOF>");
+	} catch (TimeoutException t) {
+	    TestCase.fail("Expecting <start " + program + "> got: <TIMEOUT>");
+	}
+	return h;
+    }
+
+    static HpdTestbed start(String program) {
+	return start(program, null);
+    }
+    /**
+     * Start HPD attached to PROGRAM that is crashing (due to a
      * signal).
      *
      * XXX: The current implementation runs the program until it
diff --git a/frysk-core/frysk/hpd/RunCommand.java b/frysk-core/frysk/hpd/StartCommand.java
similarity index 86%
copy from frysk-core/frysk/hpd/RunCommand.java
copy to frysk-core/frysk/hpd/StartCommand.java
index ee78d69..baf58a1 100644
--- a/frysk-core/frysk/hpd/RunCommand.java
+++ b/frysk-core/frysk/hpd/StartCommand.java
@@ -53,19 +53,19 @@ import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
-class RunCommand extends ParameterizedCommand {
-    // Used to synchronize with updateAttached method
-    RunCommand() {
-	super("run program and immediately attach",
-	      "run <executable> <arguments*>",
-	      "The run command alllows the debuger to run a(any) program(s)"
-	      + " that has(have) been previously loaded via a load command"
-	      + " if no parameters are given. To run an executable, just"
-	      + " give the run command the path to the executable as a"
-	      + " parameter.  In either case the debugger attaches immediately"
-	      + " to the process.");
+class StartCommand extends ParameterizedCommand {
+    
+    StartCommand() {
+	super("start a process, run until the first executable instruction",
+		"start <executable>",
+		"The start command alllows the debuger to run a(any) program(s)"
+		      + " that has(have) either been previously loaded via a load command"
+		      + " if no parameters are given. To run an executable, just"
+		      + " give the start command the path to the executable as a"
+		      + " parameter.  In either case the debugger attaches immediately"
+		      + " to the process and runs to the first executable instruction.");
     }
-
+    
     private static class Runner implements TaskObserver.Attached {
 	private final CLI cli;
 	private CountDownLatch latch;
@@ -121,20 +121,28 @@ class RunCommand extends ParameterizedCommand {
 
 	public void deletedFrom(Object observable) {
 	}
-
     }
-
+    
     public void interpret(CLI cli, Input cmd, Object options) {
 	/* If the run command is given no args, check to see if 
 	   any procs were loaded with the load command or loaded
 	   when fhpd was started or loaded with the core command*/
-	if (cmd.size() < 1) {
-	    if (cli.coreProcs.isEmpty() && cli.loadedProcs.isEmpty())
-		throw new InvalidCommandException("missing program");
+	Iterator foo = cli.targetset.getTasks();
+	if (cmd.size() < 1 && foo.hasNext()) {
+	    if (cli.coreProcs.isEmpty() && cli.loadedProcs.isEmpty()) {
+		cli.execCommand("kill");
+		cli.execCommand("start");
+		return;
+	    }
+	} else if (cmd.size() < 1 && !foo.hasNext()) {
+	    cli.addMessage("No procs in targetset to run", 
+		    Message.TYPE_NORMAL);
+	    return;
 	}
 	
 	// If a parameter was given the run command, go ahead and run it
 	if (cmd.size() >= 1) {
+	    
 	    run(cli, cmd);
 	    return;
 	}
@@ -194,7 +202,7 @@ class RunCommand extends ParameterizedCommand {
 	    synchronized (cli) {
 		cli.taskID = taskid.intValue();
 	    }
-	    cli.execCommand("run " + proc.getExe());
+	    cli.execCommand("start " + proc.getExe());
 	    synchronized (cli) {
 		cli.taskID = -1;
 	    }
@@ -205,4 +213,4 @@ class RunCommand extends ParameterizedCommand {
 	return CompletionFactory.completeFileName(cli, input, cursor,
 						  completions);
     }
-}
+}
\ No newline at end of file
diff --git a/frysk-core/frysk/hpd/InvalidCommandException.java b/frysk-core/frysk/hpd/TestStartCommand.java
similarity index 90%
copy from frysk-core/frysk/hpd/InvalidCommandException.java
copy to frysk-core/frysk/hpd/TestStartCommand.java
index 8fcd5c5..cb51c72 100644
--- a/frysk-core/frysk/hpd/InvalidCommandException.java
+++ b/frysk-core/frysk/hpd/TestStartCommand.java
@@ -10,11 +10,11 @@
 // WITHOUT ANY WARRANTY; without even the implied warranty of
 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 // General Public License for more details.
-//
+// 
 // You should have received a copy of the GNU General Public License
 // along with FRYSK; if not, write to the Free Software Foundation,
 // Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
-//
+// 
 // In addition, as a special exception, Red Hat, Inc. gives You the
 // additional right to link the code of FRYSK with code not covered
 // under the GNU General Public License ("Non-GPL Code") and to
@@ -40,11 +40,13 @@
 package frysk.hpd;
 
 /**
- * The command was invalid.
- */
-public class InvalidCommandException extends RuntimeException {
-    static final long serialVersionUID = 1;
-    InvalidCommandException(String message) {
-	super(message);
+* This class tests the "start" command.
+*/
+
+public class TestStartCommand extends TestLib {
+    public void testStartCommand() {
+	e = HpdTestbed.start("funit-threads-looper");
+	e.sendCommandExpectPrompt("where", "[0.0].*");
+	e.close();
     }
-}
+}
\ No newline at end of file
diff --git a/frysk-core/frysk/hpd/TopLevelCommand.java b/frysk-core/frysk/hpd/TopLevelCommand.java
index c6bf666..f85e691 100644
--- a/frysk-core/frysk/hpd/TopLevelCommand.java
+++ b/frysk-core/frysk/hpd/TopLevelCommand.java
@@ -109,6 +109,7 @@ public class TopLevelCommand extends MultiLevelCommand {
         add(new StackCommands.Frame(), "frame");
         add(new StackCommands.Up(), "u|p");
         add(new StackCommands.Where(), "w|here");
+        add(new StartCommand(), "start");
         add(new StepCommand(), "s|tep");
         add(new StepFinishCommand(), "finish");
         add(new StepInstructionCommand(), "stepi");


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]