public inbox for frysk-cvs@sourceware.org
help / color / mirror / Atom feed
From: rmoseley@sourceware.org
To: frysk-cvs@sourceware.org
Subject: [SCM]  master: Merge branch 'master' of ssh://sources.redhat.com/git/frysk
Date: Thu, 20 Mar 2008 20:20:00 -0000	[thread overview]
Message-ID: <20080320202017.2162.qmail@sourceware.org> (raw)

The branch, master has been updated
       via  dec89fbcd4c87a499c7801dfad629a998e3623e5 (commit)
       via  746955053a99b36631e131e355de80d4c601a75e (commit)
      from  9fc075eb7a30f68abba9de2a201b56a6a3451481 (commit)

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

- Log -----------------------------------------------------------------
commit dec89fbcd4c87a499c7801dfad629a998e3623e5
Merge: 746955053a99b36631e131e355de80d4c601a75e 9fc075eb7a30f68abba9de2a201b56a6a3451481
Author: Rick Moseley <rmoseley@dhcp-215.hsv.redhat.com>
Date:   Thu Mar 20 15:20:02 2008 -0500

    Merge branch 'master' of ssh://sources.redhat.com/git/frysk

commit 746955053a99b36631e131e355de80d4c601a75e
Author: Rick Moseley <rmoseley@dhcp-215.hsv.redhat.com>
Date:   Thu Mar 20 15:18:12 2008 -0500

    Oooops, screw-up for "start ignores focus" checkin(already checked in ChangeLog)

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

Summary of changes:
 frysk-core/frysk/hpd/LoadCommand.java      |   38 +++++++-
 frysk-core/frysk/hpd/StartRun.java         |  139 ++++++++++++----------------
 frysk-core/frysk/hpd/TestLoadCommand.java  |    2 +-
 frysk-core/frysk/hpd/TestRunCommand.java   |   20 ++++
 frysk-core/frysk/hpd/TestStartCommand.java |   26 +++++-
 5 files changed, 139 insertions(+), 86 deletions(-)

First 500 lines of diff:
diff --git a/frysk-core/frysk/hpd/LoadCommand.java b/frysk-core/frysk/hpd/LoadCommand.java
index f3b2217..936611f 100644
--- a/frysk-core/frysk/hpd/LoadCommand.java
+++ b/frysk-core/frysk/hpd/LoadCommand.java
@@ -40,7 +40,12 @@
 package frysk.hpd;
 
 import java.io.File;
+import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
 import frysk.proc.dead.LinuxExeFactory;
 import frysk.debuginfo.DebugInfo;
 import frysk.debuginfo.DebugInfoFrame;
@@ -48,7 +53,6 @@ import frysk.debuginfo.DebugInfoStackFactory;
 import frysk.sysroot.SysRootCache;
 import frysk.proc.Proc;
 import frysk.proc.Task;
-import java.util.List;
 
 /**
  * LoadCommand handles the "load path-to-executable" command on the fhpd
@@ -100,8 +104,7 @@ public class LoadCommand extends ParameterizedCommand {
 		return;
 	    } else {
 		// List the loaded procs if no parameters entered
-		ViewsetCommand.printLoop(cli.targetset, cli, "Target set",
-					 true);
+		printLoop(cli, "Loaded procs", cli.loadedProcs);
 		return;
 	    }
 	}
@@ -149,6 +152,35 @@ public class LoadCommand extends ParameterizedCommand {
 		exeProc.getExe(), Message.TYPE_NORMAL);
     }
     
+    /**
+     * printLoop goes through the specified set of procs/tasks and prints them out
+     * 
+     * @param cli is the current command line interface object
+     * @param displayedName is the String used for the title of the set
+     * @param hashProcs is a HashMap containing the procs to list 
+     */
+    
+    static void printLoop(CLI cli, String displayedName, HashMap hashProcs) {
+	Set procSet = hashProcs.entrySet();
+	cli.outWriter.print(displayedName);
+	cli.outWriter.println("\tpath-to-executable");
+	ArrayList listing = new ArrayList();
+	// Run through procs and put into ArrayList so we can print them out in 
+	// numerical order after sorting them
+	for (Iterator foo = procSet.iterator(); foo.hasNext();) {
+	    Map.Entry me = (Map.Entry) foo.next();
+	    Proc proc = (Proc) me.getKey();
+	    Integer taskid = (Integer) me.getValue();
+	    listing.add("[" + taskid.intValue() + ".0]\t\t" + proc.getExe());
+	}
+	String alphaListing[] = (String[]) listing.toArray(new String[listing.size()]);
+	java.util.Arrays.sort(alphaListing);
+	for (int foo = 0; foo < alphaListing.length; foo++) {
+	    cli.outWriter.println(alphaListing[foo]);
+	}
+	cli.outWriter.flush();
+    }
+    
     int completer(CLI cli, Input input, int cursor, List completions) {
 	return CompletionFactory.completeFileName(cli, input, cursor,
 		completions);
diff --git a/frysk-core/frysk/hpd/StartRun.java b/frysk-core/frysk/hpd/StartRun.java
index 625c0fa..f648ad1 100644
--- a/frysk-core/frysk/hpd/StartRun.java
+++ b/frysk-core/frysk/hpd/StartRun.java
@@ -42,16 +42,16 @@ 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.ProcTasksAction;
 import frysk.proc.Task;
+import frysk.proc.TaskAttachedObserverXXX;
+import frysk.proc.ProcTasksAction;
 import frysk.util.CountDownLatch;
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import frysk.proc.TaskAttachedObserverXXX;
+
 
 /**
  * Due to a lot of similar code in StartCommand/RunCommand this class was
@@ -124,69 +124,71 @@ abstract class StartRun extends ParameterizedCommand {
     
     public void interpretCmd(CLI cli, Input cmd, Object options,
 			     boolean runToBreak) {
-	// See if there are any running tasks, if so, process them
-	// if there are not any procs loaded with the load/core commands
+	// See if there are any tasks in the current target set
 	Iterator foo = cli.targetset.getTaskData();
+	int oldPid = -1;
 	if (foo.hasNext()) {
-	    if (cli.coreProcs.isEmpty() && cli.loadedProcs.isEmpty()) {
-		// Clear the parameters for this process
-		int oldPid = -1;
-		TaskData taskData = null;
-		while (foo.hasNext()) {
-		    taskData = (TaskData) foo.next();
-		    Task task = taskData.getTask();
-		    // Need only one kill per PID(proc)
-		    if (task.getProc().getPid() == oldPid) {
-			continue;
+	    // Clear the parameters for this process
+	    TaskData taskData = null;
+	    while (foo.hasNext()) {
+		taskData = (TaskData) foo.next();
+		Task task = taskData.getTask();
+		// Need only one kill per PID(proc) if proc is running already
+		if (task.getProc().getPid() != oldPid &&
+		  task.getProc().getPid() > 0) {
+		    cli.execCommand("kill " + task.getProc().getPid() + "\n");
+		    int taskid = taskData.getParentID();
+		    run(cli, cmd, task.getProc(), runToBreak, taskid);
+		    oldPid = task.getProc().getPid();
 		    } else {
-			cli.execCommand("kill\n");
 			int taskid = taskData.getParentID();
-			synchronized (cli) {
-				cli.taskID = taskid;
+			// Take care of loaded procs
+			if (!cli.loadedProcs.isEmpty() && 
+			    cli.loadedProcs.containsKey(task.getProc())) {
+			    run(cli, cmd, task.getProc(), runToBreak, taskid);
+			    synchronized (cli) {
+				cli.loadedProcs.remove(task.getProc());
+			    }
 			}
-		    	run(cli, cmd, task.getProc(), runToBreak);
-		    	synchronized (cli) {
-				cli.taskID = -1;
-				cli.loadedProcs.clear();
+			// Take care of core procs
+			else if (!cli.coreProcs.isEmpty() &&
+				cli.coreProcs.containsKey(task.getProc())) {
+			    run(cli, cmd, task.getProc(), runToBreak, taskid);
+			    synchronized (cli) {
+				cli.coreProcs.remove(new Integer(taskid));
+			    }
 			}
-		    	oldPid = task.getProc().getPid();
 		    }
 		}
 		return;
-	    }
+	   // }
 	} else {
 	    cli.addMessage("No procs in targetset to run", Message.TYPE_NORMAL);
 	    return;
 	}
-
-	/*
-	 * If we made it here, a run command was issued and there are no running
-	 * procs, so, see if there were 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, cmd, runToBreak);
-	    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, cmd, runToBreak);
-	    synchronized (cli) {
-		cli.coreProcs.clear();
-	    }
-	}
     }
 
-    private void run(CLI cli, Input cmd, Proc template, boolean runToBreak) {
+    /**
+     * run takes a passed proc from the target set and runs it
+     * 
+     * @param cli is the commandline object
+     * @param cmd is the command object with all the parameters
+     * @param template is the proc to run
+     * @param runToBreak true if the process is to run to the first break point
+     * 		or until it blows up("run" command), false if it should stop
+     * 		at the first executable statement("start" command)
+     * @param taskid the internal target set id that should be used for this process
+     */
+    private void run(CLI cli, Input cmd, Proc template, boolean runToBreak,
+	    int taskid) {
 	Runner runner = new Runner(cli);
+	String startrun = "";
+	    if (runToBreak)
+		startrun = "running";
+	    else
+		startrun = "starting";
 	if (cmd.size() == 0) {
-	    cli.addMessage("starting/running with this command: " + 
+	    cli.addMessage(startrun + " with this command: " + 
 			   asString(template.getCmdLine()),
 			   Message.TYPE_NORMAL);
 	    Manager.host.requestCreateAttachedProc(template, runner);
@@ -195,7 +197,7 @@ abstract class StartRun extends ParameterizedCommand {
 	    args[0] = template.getCmdLine()[0];
 	    for (int i = 1; i < args.length; i++)
 		args[i] = cmd.parameter(i - 1);
-	    cli.addMessage("starting/running with this command: " + 
+	    cli.addMessage(startrun + " with this command: " + 
 			   asString(args), Message.TYPE_NORMAL);
 	    Manager.host.requestCreateAttachedProc(args, runner);
 	}
@@ -208,8 +210,15 @@ abstract class StartRun extends ParameterizedCommand {
 	    }
 	}
 	// register with SteppingEngine et.al.
+	// Make sure we use the old task id for the new one
+	synchronized (cli) {
+		cli.taskID = taskid;
+	}
 	cli.doAttach(runner.launchedTask.getProc(), runToBreak);
 	runner.launchedTask.requestUnblock(runner);
+	synchronized (cli) {
+		cli.taskID = -1;
+	}
     }
 
     private String asString(String[] args) {
@@ -220,34 +229,6 @@ abstract class StartRun extends ParameterizedCommand {
 	}
 	return b.toString();
     }
-
-    /**
-     * 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, boolean runToBreak) {
-	Iterator foo = procs.iterator();
-	int ctr = 0;
-	while (foo.hasNext()) {
-	    ctr++;
-	    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();
-	    }
-	    run(cli, cmd, proc, runToBreak);
-	    synchronized (cli) {
-		cli.taskID = -1;
-	    }
-	}
-    }
     
     int completer(CLI cli, Input input, int cursor, List completions) {
 	return CompletionFactory.completeFileName(cli, input, cursor,
diff --git a/frysk-core/frysk/hpd/TestLoadCommand.java b/frysk-core/frysk/hpd/TestLoadCommand.java
index 81fab20..ccc3dbd 100644
--- a/frysk-core/frysk/hpd/TestLoadCommand.java
+++ b/frysk-core/frysk/hpd/TestLoadCommand.java
@@ -106,7 +106,7 @@ public class TestLoadCommand extends TestLib {
 		"\\[0\\.0\\] Loaded executable file.*");
 	e.sendCommandExpectPrompt("load " + Config.getPkgLibFile("funit-hello").getPath(),
 		"\\[1\\.0\\] Loaded executable file.*");
-	e.sendCommandExpectPrompt("load", "Target set.*\\[0\\.0\\].*\\[1\\.0\\].*");
+	e.sendCommandExpectPrompt("load", "Loaded procs.*\\[0\\.0\\].*\\[1\\.0\\].*");
 	e.send("quit\n");
 	e.expect("Quitting\\.\\.\\.");
 	e.close();
diff --git a/frysk-core/frysk/hpd/TestRunCommand.java b/frysk-core/frysk/hpd/TestRunCommand.java
index a8ab9c8..f144ebd 100644
--- a/frysk-core/frysk/hpd/TestRunCommand.java
+++ b/frysk-core/frysk/hpd/TestRunCommand.java
@@ -178,4 +178,24 @@ public class TestRunCommand extends TestLib {
 	e.expect("Quitting\\.\\.\\.");
 	e.close();
     }
+    
+    /**
+     * This test case tests to make sure the run command pays attention to the "focus"
+     * command.
+     */
+    
+    public void testRunFocus() {
+	e = new HpdTestbed();
+	e.sendCommandExpectPrompt("load " + Config.getPkgLibFile("funit-hello").getPath(),
+	"\\[0\\.0\\] Loaded executable file.*");
+	e.sendCommandExpectPrompt("load " + Config.getPkgLibFile("funit-threads-looper").getPath(),
+	"\\[1\\.0\\] Loaded executable file.*");
+	e.sendCommandExpectPrompt("focus [1.0]", "Creating new HPD notation set.*");
+	e.sendCommandExpectPrompt("run", "Attached to process ([0-9]+).*" +
+		"running.*" + "Running process ([0-9]+).*");
+	e.sendCommandExpectPrompt("load", "\\[0\\.0\\].*funit-hello.*");
+	e.send("quit\n");
+	e.expect("Quitting\\.\\.\\.");
+	e.close();
+    }
 }
\ No newline at end of file
diff --git a/frysk-core/frysk/hpd/TestStartCommand.java b/frysk-core/frysk/hpd/TestStartCommand.java
index c81650f..87aa2b9 100644
--- a/frysk-core/frysk/hpd/TestStartCommand.java
+++ b/frysk-core/frysk/hpd/TestStartCommand.java
@@ -53,11 +53,11 @@ public class TestStartCommand extends TestLib {
     public void testStartCommand() {
 	e = new HpdTestbed();
 	e.sendCommandExpectPrompt("load " + Config.getPkgLibFile("funit-threads-looper").getPath(),
-		"\\[0\\.0] Loaded executable file.*");
+		"\\[0\\.0\\] Loaded executable file.*");
 	e.sendCommandExpectPrompt("start", "Attached to process.*");
-	e.sendCommandExpectPrompt("where", "[0.0].*");
+	e.sendCommandExpectPrompt("focus", "\\[0\\.0\\].*");
 	e.send("quit\n");
-	e.expect("Quitting...");
+	e.expect("Quitting\\.\\.\\.");
 	e.close();
     }
     
@@ -111,4 +111,24 @@ public class TestStartCommand extends TestLib {
 	e.expect("Quitting\\.\\.\\.");
 	e.close();
     }
+    
+    /**
+     * This test case tests to make sure the start command pays attention to the "focus"
+     * command.
+     */
+    
+    public void testStartFocus() {
+	e = new HpdTestbed();
+	e.sendCommandExpectPrompt("load " + Config.getPkgLibFile("funit-hello").getPath(),
+	"\\[0\\.0\\] Loaded executable file.*");
+	e.sendCommandExpectPrompt("load " + Config.getPkgLibFile("funit-threads-looper").getPath(),
+	"\\[1\\.0\\] Loaded executable file.*");
+	e.sendCommandExpectPrompt("focus [1.0]", "Creating new HPD notation set.*");
+	e.sendCommandExpectPrompt("start", "Attached to process ([0-9]+).*" +
+		"starting.*");
+	e.sendCommandExpectPrompt("load", "\\[0\\.0\\].*funit-hello.*");
+	e.send("quit\n");
+	e.expect("Quitting\\.\\.\\.");
+	e.close();
+    }
 }
\ No newline at end of file


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


             reply	other threads:[~2008-03-20 20:20 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-20 20:20 rmoseley [this message]
  -- strict thread matches above, loose matches on Subject: below --
2008-06-05 15:33 rmoseley
2008-05-12 16:30 rmoseley
2008-05-12 16:07 pmuldoon
2008-05-09 17:29 rmoseley
2008-04-02 22:41 pmuldoon
2008-04-01 12:28 pmuldoon
2008-03-18 16:22 pmuldoon
2008-02-26 15:32 pmuldoon
2008-01-24 19:23 rmoseley
2008-01-23 21:10 rmoseley
2008-01-03 16:55 pmuldoon
2007-12-13 20:18 rmoseley
2007-12-04 17:45 jflavio
2007-11-30  4:24 jflavio
2007-11-28 21:40 jflavio
2007-11-28 16:20 jflavio
2007-11-28 13:08 pmuldoon
2007-11-28 12:04 mark
2007-11-20 22:47 scox
2007-11-19 17:58 scox
2007-11-17  8:35 rmoseley
2007-11-16 15:59 scox
2007-11-16 14:59 pmuldoon
2007-11-14  2:38 scox
2007-11-14  2:09 jflavio
2007-11-13  0:41 scox
2007-11-10 14:47 jflavio
2007-11-10  0:34 scox
2007-11-09 14:59 jflavio

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=20080320202017.2162.qmail@sourceware.org \
    --to=rmoseley@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).