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: New start/run to accept parameters.


The branch, master has been updated
       via  d69fbcf1960423fa8f87fc0a61dcbc4aab25657b (commit)
      from  d9d1870cc5ebfd5e4f99383b75b4f63b93c415e2 (commit)

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

- Log -----------------------------------------------------------------
commit d69fbcf1960423fa8f87fc0a61dcbc4aab25657b
Author: Rick Moseley <rmoseley@localhost.localdomain>
Date:   Tue Jan 15 01:21:41 2008 -0600

    New start/run to accept parameters.
    
            * StartRun.java: New, consolidation of Start/RunCommand.
            * StartCommand.java: Move common code to StartRun.java.
            * RunCommand.java: Ditto.
            * TestStartCommand.java: Modify for above changes.
            * TestRunCommand.java: Ditto.
            * TestBreakpoints.java: Ditto.
            * TestListCommand.java: Ditto.
            * TestGenerateCoreCommand.java: Ditto.
            * LoadCommand.java: Improve help verbage.
            * TestLoadCommand.java: Add quit command at end of test.

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

Summary of changes:
 frysk-core/frysk/hpd/ChangeLog                     |   13 ++
 frysk-core/frysk/hpd/LoadCommand.java              |    9 +-
 frysk-core/frysk/hpd/RunCommand.java               |  184 ++----------------
 frysk-core/frysk/hpd/StartCommand.java             |  183 ++----------------
 .../frysk/hpd/{StartCommand.java => StartRun.java} |  204 ++++++++++++-------
 frysk-core/frysk/hpd/TestBreakpoints.java          |   22 ++-
 frysk-core/frysk/hpd/TestGenerateCoreCommand.java  |   97 ++++++----
 frysk-core/frysk/hpd/TestListCommand.java          |   21 ++-
 frysk-core/frysk/hpd/TestLoadCommand.java          |    3 +-
 frysk-core/frysk/hpd/TestRunCommand.java           |    9 +-
 frysk-core/frysk/hpd/TestStartCommand.java         |    9 +-
 11 files changed, 289 insertions(+), 465 deletions(-)
 copy frysk-core/frysk/hpd/{StartCommand.java => StartRun.java} (54%)

First 500 lines of diff:
diff --git a/frysk-core/frysk/hpd/ChangeLog b/frysk-core/frysk/hpd/ChangeLog
index 1b3321d..50cf389 100644
--- a/frysk-core/frysk/hpd/ChangeLog
+++ b/frysk-core/frysk/hpd/ChangeLog
@@ -1,3 +1,16 @@
+2008-01-15  Rick Moseley  <rmoseley@redhat.com>
+
+	* StartRun.java: New, consolidation of Start/RunCommand.
+	* StartCommand.java: Move common code to StartRun.java.
+	* RunCommand.java: Ditto.
+	* TestStartCommand.java: Modify for above changes.
+	* TestRunCommand.java: Ditto.
+	* TestBreakpoints.java: Ditto.
+	* TestListCommand.java: Ditto.
+	* TestGenerateCoreCommand.java: Ditto.
+	* LoadCommand.java: Improve help verbage.
+	* TestLoadCommand.java: Add quit command at end of test.
+
 2008-01-14  Mike Cvet  <mcvet@redhat.com>
 
 	* StepInstructionCommand.java (interpret): Changed from iterating over
diff --git a/frysk-core/frysk/hpd/LoadCommand.java b/frysk-core/frysk/hpd/LoadCommand.java
index b330da9..0d2bb30 100644
--- a/frysk-core/frysk/hpd/LoadCommand.java
+++ b/frysk-core/frysk/hpd/LoadCommand.java
@@ -60,7 +60,14 @@ import java.util.List;
 public class LoadCommand extends ParameterizedCommand {
 
     LoadCommand() {
-	super("load", "load path-to-executable", "load an executable file");
+	super("load", 
+	      "load path-to-executable", 
+	      "The load command lets the user examine information about"
+	      + " an executable file without actually running it.  An"
+	      + " executble must be loaded with this command before it"
+	      + " can be run with either the 'start' or 'run' command."
+	      + " No arguments are entered here, they are passed to the"
+	      + " process via the 'start'/'run' commands.");
     }
 
     public void interpret(CLI cli, Input cmd, Object options) {
diff --git a/frysk-core/frysk/hpd/RunCommand.java b/frysk-core/frysk/hpd/RunCommand.java
index a7307aa..f78fb5e 100644
--- a/frysk-core/frysk/hpd/RunCommand.java
+++ b/frysk-core/frysk/hpd/RunCommand.java
@@ -39,180 +39,26 @@
 
 package frysk.hpd;
 
-import frysk.proc.Action;
-import frysk.proc.Manager;
-import frysk.proc.Proc;
-import frysk.proc.ProcObserver.ProcTasks;
-import frysk.proc.ProcTasksObserver;
-import frysk.proc.Task;
-import frysk.proc.TaskObserver;
-import frysk.util.CountDownLatch;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-class RunCommand extends ParameterizedCommand {
+class RunCommand extends StartRun {
     // 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.");
-    }
-
-    private static class Runner implements TaskObserver.Attached {
-	private final CLI cli;
-	private CountDownLatch latch;
-	Task launchedTask;
-	Runner(CLI cli) {
-	    this.cli = cli;
-	}
-	public Action updateAttached(final Task task) {
-	    final Proc proc = task.getProc();
-	    synchronized (this) {
-		launchedTask = task;
-	    }
-	    synchronized (cli) {
-		cli.getRunningProcs().add(proc);
-	    }
-	    new ProcTasksObserver(proc, new ProcTasks() {
-		    public void existingTask(Task task) {
-		    }
-		    
-		    public void addedTo(Object observable) {
-		    }
-		    
-		    public void addFailed(Object observable, Throwable w) {
-		    }
-		    
-		    public void deletedFrom(Object observable) {
-		    }
-		    
-		    public void taskAdded(Task task) {
-		    }
-		    
-		    public void taskRemoved(Task task) {
-			if (proc.getChildren().size() == 0) {
-			    synchronized (cli) {
-				HashSet procs = cli.getRunningProcs();
-				procs.remove(proc);
-			    }
-			}
-		    }
-		});
-	    latch.countDown();
-	    // Keep task blocked until the SteppingEngine notifies us that its
-	    // instruction observers, etc. have been inserted.
-	    return Action.BLOCK;
-	}
-
-	public void addedTo(Object observable) {
-	}
-
-	public void addFailed(Object observable, Throwable w) {
-	    System.out.println("couldn't get it done:" + w);
-	}
-
-	public void deletedFrom(Object observable) {
-	}
-
+	      "run <arguments*> || <--norags>",
+	      "The run command alllows the debugger to run a(any) program(s)"
+	      + " that has(have) been previously loaded via a load or"
+	      + " core command.  The run command can accept arguments to"
+	      + " be passed to the executable or if arguments have been"
+	      + " previously given and no arguments are desired for the"
+	      + " next run, use '--noargs' and the executable(s) will not be"
+	      + " passed any arguments.  The run command causes the executable"
+	      + " to be run until the first breakpoint or until the process"
+	      + " terminates either normally or abnormally.  Issuing the run"
+	      + " command at any point in the debugging sequence cause the"
+	      + " process(es) being worked on to tbe killed and a fresh copy"
+	      + " to be reloaded and run until breakpoint or termination.");
     }
 
     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*/
-	Iterator foo = cli.targetset.getTasks();
-	if (cmd.size() < 1 && foo.hasNext()) {
-	    if (cli.coreProcs.isEmpty() && cli.loadedProcs.isEmpty()) {
-		cli.execCommand("kill");
-		cli.execCommand("start");
-		cli.execCommand("go");
-		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);
-	    cli.execCommand("go");
-	    return;
-	}
-	
-	/* If we made it here, a run command was given with no parameters
-	 * and there should be either running procs or loaded procs or
-	 * core procs
-	 */
-
-	/* This is the case where there are loaded procs */
-	if (!cli.loadedProcs.isEmpty()) {
-	    Set procSet = cli.loadedProcs.entrySet();
-	    runProcs(cli, procSet);
-	    synchronized (cli) {
-		cli.loadedProcs.clear();
-	    }
-	}
-	
-	/* Check to see if there were procs loaded from a core command */
-	if (!cli.coreProcs.isEmpty()) {
-	    Set coreSet = cli.coreProcs.entrySet();
-	    runProcs(cli, coreSet);
-	    synchronized (cli) {
-		cli.coreProcs.clear();
-	    }
-	} 
-    }
-	
-    private void run(CLI cli, Input cmd) {
-	Runner runner = new Runner(cli);
-	Manager.host.requestCreateAttachedProc(cmd.stringArrayValue(), runner);
-        while (true) {
-            try {
-        	runner.latch = new CountDownLatch(1);
-                runner.latch.await();
-                break;
-            } catch (InterruptedException e) {
-            }
-        }
-        // register with SteppingEngine et.al.
-        cli.doAttach(runner.launchedTask.getProc());
-	runner.launchedTask.requestUnblock(runner);
-    }
-    
-    /*
-     * runProcs does as the name implies, it runs procs found to be loaded by a
-     * load or a core command.
-     */
-    private void runProcs(CLI cli, Set procs) {
-	Iterator foo = procs.iterator();
-	while (foo.hasNext()) {
-	    Map.Entry me = (Map.Entry) foo.next();
-	    Proc proc = (Proc) me.getKey();
-	    Integer taskid = (Integer) me.getValue();
-	    // Set the TaskID to be used to what was used when the
-	    // proc was loaded with the core or load commands
-	    synchronized (cli) {
-		cli.taskID = taskid.intValue();
-	    }
-	    cli.execCommand("run " + proc.getExe());
-	    synchronized (cli) {
-		cli.taskID = -1;
-	    }
-	}
-    }
-    
-    int completer(CLI cli, Input input, int cursor, List completions) {
-	return CompletionFactory.completeFileName(cli, input, cursor,
-						  completions);
+	interpretRun(cli, cmd, options);
     }
 }
diff --git a/frysk-core/frysk/hpd/StartCommand.java b/frysk-core/frysk/hpd/StartCommand.java
index baf58a1..4e5ea2d 100644
--- a/frysk-core/frysk/hpd/StartCommand.java
+++ b/frysk-core/frysk/hpd/StartCommand.java
@@ -39,178 +39,25 @@
 
 package frysk.hpd;
 
-import frysk.proc.Action;
-import frysk.proc.Manager;
-import frysk.proc.Proc;
-import frysk.proc.ProcObserver.ProcTasks;
-import frysk.proc.ProcTasksObserver;
-import frysk.proc.Task;
-import frysk.proc.TaskObserver;
-import frysk.util.CountDownLatch;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-class StartCommand extends ParameterizedCommand {
+class StartCommand extends StartRun {
     
     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;
-	Task launchedTask;
-	Runner(CLI cli) {
-	    this.cli = cli;
-	}
-	public Action updateAttached(final Task task) {
-	    final Proc proc = task.getProc();
-	    synchronized (this) {
-		launchedTask = task;
-	    }
-	    synchronized (cli) {
-		cli.getRunningProcs().add(proc);
-	    }
-	    new ProcTasksObserver(proc, new ProcTasks() {
-		    public void existingTask(Task task) {
-		    }
-		    
-		    public void addedTo(Object observable) {
-		    }
-		    
-		    public void addFailed(Object observable, Throwable w) {
-		    }
-		    
-		    public void deletedFrom(Object observable) {
-		    }
-		    
-		    public void taskAdded(Task task) {
-		    }
-		    
-		    public void taskRemoved(Task task) {
-			if (proc.getChildren().size() == 0) {
-			    synchronized (cli) {
-				HashSet procs = cli.getRunningProcs();
-				procs.remove(proc);
-			    }
-			}
-		    }
-		});
-	    latch.countDown();
-	    // Keep task blocked until the SteppingEngine notifies us that its
-	    // instruction observers, etc. have been inserted.
-	    return Action.BLOCK;
-	}
-
-	public void addedTo(Object observable) {
-	}
-
-	public void addFailed(Object observable, Throwable w) {
-	    System.out.println("couldn't get it done:" + w);
-	}
-
-	public void deletedFrom(Object observable) {
-	}
+	super("start a previously-loaded process, run until the first executable instruction",
+		"start <arguments*> || <--noargs>",
+		"The start command alllows the debugger to run a(any) process(es)"
+		      + " that has(have) either been previously loaded via a load"
+		      + " or a core command.  The difference between the run and"
+		      + " start command is that start only runs the program until"
+		      + " the first executable instruction.  Arguments can be passed to"
+		      + " the process by entering them after the command.  If arguments"
+		      + " have previously been passed to the and the next requires"
+		      + " no arguments use '--noargs' as the only argument.  Issuing"
+		      + " the start command at any time in the debug session will"
+		      + " kill the process being debugged and reload a new copy of the"
+		      + " process and run to the first executable instruction.");
     }
     
     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*/
-	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;
-	}
-	
-	/* If we made it here, a run command was given with no parameters
-	 * and there should be either running procs or loaded procs or
-	 * core procs
-	 */
-
-	/* This is the case where there are loaded procs */
-	if (!cli.loadedProcs.isEmpty()) {
-	    Set procSet = cli.loadedProcs.entrySet();
-	    runProcs(cli, procSet);
-	    synchronized (cli) {
-		cli.loadedProcs.clear();
-	    }
-	}
-	
-	/* Check to see if there were procs loaded from a core command */
-	if (!cli.coreProcs.isEmpty()) {
-	    Set coreSet = cli.coreProcs.entrySet();
-	    runProcs(cli, coreSet);
-	    synchronized (cli) {
-		cli.coreProcs.clear();
-	    }
-	} 
-    }
-	
-    private void run(CLI cli, Input cmd) {
-	Runner runner = new Runner(cli);
-	Manager.host.requestCreateAttachedProc(cmd.stringArrayValue(), runner);
-        while (true) {
-            try {
-        	runner.latch = new CountDownLatch(1);
-                runner.latch.await();
-                break;
-            } catch (InterruptedException e) {
-            }
-        }
-        // register with SteppingEngine et.al.
-        cli.doAttach(runner.launchedTask.getProc());
-	runner.launchedTask.requestUnblock(runner);
-    }
-    
-    /*
-     * runProcs does as the name implies, it runs procs found to be loaded by a
-     * load or a core command.
-     */
-    private void runProcs(CLI cli, Set procs) {
-	Iterator foo = procs.iterator();
-	while (foo.hasNext()) {
-	    Map.Entry me = (Map.Entry) foo.next();
-	    Proc proc = (Proc) me.getKey();
-	    Integer taskid = (Integer) me.getValue();
-	    // Set the TaskID to be used to what was used when the
-	    // proc was loaded with the core or load commands
-	    synchronized (cli) {
-		cli.taskID = taskid.intValue();
-	    }
-	    cli.execCommand("start " + proc.getExe());
-	    synchronized (cli) {
-		cli.taskID = -1;
-	    }
-	}
-    }
-    
-    int completer(CLI cli, Input input, int cursor, List completions) {
-	return CompletionFactory.completeFileName(cli, input, cursor,
-						  completions);
+	interpretStart(cli, cmd, options);
     }
 }
\ No newline at end of file
diff --git a/frysk-core/frysk/hpd/StartCommand.java b/frysk-core/frysk/hpd/StartRun.java
similarity index 54%
copy from frysk-core/frysk/hpd/StartCommand.java
copy to frysk-core/frysk/hpd/StartRun.java
index baf58a1..c8f340c 100644
--- a/frysk-core/frysk/hpd/StartCommand.java
+++ b/frysk-core/frysk/hpd/StartRun.java
@@ -53,26 +53,27 @@ import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
-class StartCommand extends ParameterizedCommand {
+/**
+ * Due to a lot of similar code in StartCommand/RunCommand this class was
+ * created to consolidate most of the methods to one code base.
+ */
+class StartRun 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.");
-    }
+    boolean runToBreak = false;
     
-    private static class Runner implements TaskObserver.Attached {
-	private final CLI cli;
-	private CountDownLatch latch;
+    StartRun(String command, String help1, String help2) {
+	super(command, help1, help2);
+    }
+
+    static class Runner implements TaskObserver.Attached {
+	final CLI cli;
+	CountDownLatch latch;
 	Task launchedTask;
+
 	Runner(CLI cli) {
 	    this.cli = cli;
 	}
+
 	public Action updateAttached(final Task task) {
 	    final Proc proc = task.getProc();
 	    synchronized (this) {
@@ -82,30 +83,30 @@ class StartCommand extends ParameterizedCommand {
 		cli.getRunningProcs().add(proc);
 	    }
 	    new ProcTasksObserver(proc, new ProcTasks() {
-		    public void existingTask(Task task) {
-		    }
-		    
-		    public void addedTo(Object observable) {
-		    }
-		    
-		    public void addFailed(Object observable, Throwable w) {


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]