public inbox for frysk-cvs@sourceware.org
help / color / mirror / Atom feed
* [SCM] master: Add ability to list loaded procs and remove loaded procs.
@ 2008-02-11 23:07 rmoseley
0 siblings, 0 replies; only message in thread
From: rmoseley @ 2008-02-11 23:07 UTC (permalink / raw)
To: frysk-cvs
The branch, master has been updated
via fe1332147611ba2f06e3f5ad38339c2763847dc2 (commit)
from af5efc444c59457e9a2f9b77382ddd6073ee4edc (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email.
- Log -----------------------------------------------------------------
commit fe1332147611ba2f06e3f5ad38339c2763847dc2
Author: Rick Moseley <rmoseley@localhost.localdomain>
Date: Mon Feb 11 17:07:25 2008 -0600
Add ability to list loaded procs and remove loaded procs.
* UnloadCommand.java: New to unload loaded processes.
* LoadCommand.java: Add capability to list loaded procs.
* TestLoadCommand.java: Test above.
-----------------------------------------------------------------------
Summary of changes:
frysk-core/frysk/hpd/ChangeLog | 7 ++
frysk-core/frysk/hpd/LoadCommand.java | 14 ++-
frysk-core/frysk/hpd/TestLoadCommand.java | 2 +-
.../hpd/{KillCommand.java => UnloadCommand.java} | 100 +++++++++++---------
4 files changed, 73 insertions(+), 50 deletions(-)
copy frysk-core/frysk/hpd/{KillCommand.java => UnloadCommand.java} (57%)
First 500 lines of diff:
diff --git a/frysk-core/frysk/hpd/ChangeLog b/frysk-core/frysk/hpd/ChangeLog
index 0581c88..18c0667 100644
--- a/frysk-core/frysk/hpd/ChangeLog
+++ b/frysk-core/frysk/hpd/ChangeLog
@@ -1,3 +1,10 @@
+2008-02-11 Rick Moseley <rmoseley@redhat.com>
+
+ * UnloadCommand.java: New to unload loaded processes.
+ * LoadCommand.java: Add capability to list loaded procs.
+ * TestLoadCommand.java: Test above.
+
+
2008-02-08 Stan Cox <scox@redhat.com>
* TestListCommand.java (testListFrames): Tweak the expect output.
diff --git a/frysk-core/frysk/hpd/LoadCommand.java b/frysk-core/frysk/hpd/LoadCommand.java
index dd552e4..6754677 100644
--- a/frysk-core/frysk/hpd/LoadCommand.java
+++ b/frysk-core/frysk/hpd/LoadCommand.java
@@ -1,6 +1,6 @@
// This file is part of the program FRYSK.
//
-// Copyright 2007, Red Hat Inc.
+// Copyright 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
@@ -91,6 +91,7 @@ public class LoadCommand extends ParameterizedCommand {
}
public void interpret(CLI cli, Input cmd, Object options) {
+
Options o = (Options)options;
if (cmd.size() > 2) {
@@ -112,7 +113,12 @@ public class LoadCommand extends ParameterizedCommand {
Host exeHost = new LinuxExeHost(Manager.eventLoop, executableFile);
Proc exeProc = frysk.util.Util.getProcFromExeFile(exeHost);
- int procID = cli.idManager.reserveProcID();
+ int procID;
+ if (cli.taskID < 0)
+ procID = cli.idManager.reserveProcID();
+ else
+ procID = cli.taskID;
+
cli.idManager.manageProc(exeProc, procID);
Iterator foo = cli.targetset.getTasks();
@@ -139,7 +145,7 @@ public class LoadCommand extends ParameterizedCommand {
*
* @param cli is the current commandline interface object
*/
- private void listLoadedProcs(CLI cli) {
+ public static void listLoadedProcs(CLI cli) {
HashMap listLoaded = cli.getLoadedProcs();
if (listLoaded.isEmpty()) {
cli.addMessage("No loaded procs currently", Message.TYPE_NORMAL);
@@ -151,7 +157,7 @@ public class LoadCommand extends ParameterizedCommand {
Map.Entry me = (Map.Entry) foo.next();
Proc proc = (Proc) me.getKey();
Integer taskId = (Integer) me.getValue();
- cli.addMessage("Task Id " + taskId + " = " + proc.getExe(), Message.TYPE_NORMAL);
+ cli.addMessage("Loaded Task Id " + taskId + " = " + proc.getExe(), Message.TYPE_NORMAL);
}
}
diff --git a/frysk-core/frysk/hpd/TestLoadCommand.java b/frysk-core/frysk/hpd/TestLoadCommand.java
index 164ef1c..156202a 100644
--- a/frysk-core/frysk/hpd/TestLoadCommand.java
+++ b/frysk-core/frysk/hpd/TestLoadCommand.java
@@ -109,7 +109,7 @@ public class TestLoadCommand extends TestLib {
"Loaded executable file.*");
e.sendCommandExpectPrompt("load " + Config.getPkgLibFile("funit-hello").getPath(),
"Loaded executable file.*");
- e.sendCommandExpectPrompt("load", "Task Id ([0-9]+).*Task Id ([0-9]+).*");
+ e.sendCommandExpectPrompt("load", "Loaded Task Id ([0-9]+).*Task Id ([0-9]+).*");
e.send("quit\n");
e.expect("Quitting...");
e.close();
diff --git a/frysk-core/frysk/hpd/KillCommand.java b/frysk-core/frysk/hpd/UnloadCommand.java
similarity index 57%
copy from frysk-core/frysk/hpd/KillCommand.java
copy to frysk-core/frysk/hpd/UnloadCommand.java
index 66fc1f4..dbdadf9 100644
--- a/frysk-core/frysk/hpd/KillCommand.java
+++ b/frysk-core/frysk/hpd/UnloadCommand.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,65 +39,75 @@
package frysk.hpd;
-import java.util.ArrayList;
+import java.util.HashMap;
import java.util.Iterator;
-import frysk.proc.Proc;
-import frysk.proc.Task;
import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import frysk.proc.Proc;
/**
- * KillCommand kills the processes in the current target set.
+ * UnloadCommand handles the unloading of processes that have been loaded
+ * by the load command.
+ *
*/
-public class KillCommand extends ParameterizedCommand {
- private static String full = "kill the processes that are currently in " +
- "the current target set. The processes are then reloaded and then " +
- "ready to be run again.";
+public class UnloadCommand extends ParameterizedCommand {
- KillCommand() {
- super("kill the current targetset", "kill", full);
+ UnloadCommand() {
+ super("unload",
+ "unload [ -t id ]",
+ "The unload command allows a user to unload processes that"
+ + " have been loaded via the 'load' command. The user can"
+ + " either specify a 'path-to-executable' as a parameter if"
+ + " the name of the process is not unique or use the name"
+ + " of the process or unload the process using its target id"
+ + " which is printed out if the unload command is given"
+ + " without any parameters.");
}
-
+
public void interpret(CLI cli, Input cmd, Object options) {
- ArrayList saveProcs = new ArrayList();
- int procPID = 0;
- Iterator foo = cli.targetset.getTasks();
- while (foo.hasNext()) {
- Task task = (Task) foo.next();
- Proc proc = task.getProc();
- if (proc.getPid() != procPID) {
- cli.addMessage("Killing process " + proc.getPid(),
- // " that was created from " + proc.getExe(),
- Message.TYPE_NORMAL);
- // Save the procs we are killing so we can re-load them later
- saveProcs.add(proc.getExe());
- procPID = proc.getPid();
- // Now, call the Proc object to kill off the executable(s)
- proc.requestKill();
- }
+ if (cmd.size() > 3) {
+ throw new InvalidCommandException("Too many parameters");
+ } else if (cmd.size() < 1) {
+ // List the loaded procs if no parameters entered
+ LoadCommand.listLoadedProcs(cli);
+ return;
}
- synchronized (cli) {
- // Clear the running procs set
- cli.runningProcs.clear();
- // Clear the current targetset
- cli.idManager.clearProcIDs();
- // Clear the stepping engine structures
- cli.steppingEngine.clear();
- // Add back in the stepping observer for cli
- cli.steppingEngine.addObserver(cli.steppingObserver);
+ if (cmd.parameter(0).equals("-t")) {
+ if (cmd.size() != 2)
+ throw new InvalidCommandException("Not enough parameters");
+ int id = Integer.parseInt(cmd.parameter(1));
+ Proc proc = cli.idManager.getProc(id);
+ removeFromHashMap(proc, cli.getLoadedProcs(), cli);
+ proc.getHost().remove(proc);
+ cli.idManager.removeProcID(id);
}
- // Now loop through and re-load all of the killed procs
- Iterator bar = saveProcs.iterator();
- while (bar.hasNext()) {
- String cmdline = (String) bar.next();
- cli.execCommand("load " + cmdline + "\n");
+ }
+
+ /**
+ * removeFromHashMap removes the designated process from the designated HashMap.
+ */
+ private void removeFromHashMap(Proc proc, HashMap procMap, CLI cli) {
+ String procCommand = proc.getExe();
+ Set procSet = procMap.entrySet();
+ Iterator foo = procSet.iterator();
+ while (foo.hasNext()) {
+ Map.Entry me = (Map.Entry) foo.next();
+ Proc newProc = (Proc) me.getKey();
+ if (procCommand.equals(newProc.getExe())) {
+ synchronized (cli) {
+ foo.remove();
+ }
+ return;
+ }
}
}
-
+
int completer(CLI cli, Input input, int cursor, List completions) {
return CompletionFactory.completeFileName(cli, input, cursor,
- completions);
+ completions);
}
-}
+}
\ No newline at end of file
hooks/post-receive
--
frysk system monitor/debugger
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2008-02-11 23:07 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-02-11 23:07 [SCM] master: Add ability to list loaded procs and remove loaded procs 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).