From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 32422 invoked by alias); 5 Jun 2008 15:33:37 -0000 Received: (qmail 32395 invoked by uid 9519); 5 Jun 2008 15:33:36 -0000 Date: Thu, 05 Jun 2008 15:33:00 -0000 Message-ID: <20080605153336.32380.qmail@sourceware.org> From: rmoseley@sourceware.org To: frysk-cvs@sourceware.org Subject: [SCM] master: Merge branch 'master' of ssh://sources.redhat.com/git/frysk X-Git-Refname: refs/heads/master X-Git-Reftype: branch X-Git-Oldrev: 0ef023547a5ee68baa4f7c6fc375dac6f886ddfb X-Git-Newrev: ad36974015d8a9f2404e3deb5c537a8e8f89dea0 Mailing-List: contact frysk-cvs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: frysk-cvs-owner@sourceware.org Reply-To: frysk@sourceware.org X-SW-Source: 2008-q2/txt/msg00338.txt.bz2 The branch, master has been updated via ad36974015d8a9f2404e3deb5c537a8e8f89dea0 (commit) via 36be80f0873e0dd9255e99c3b995aecc0fdd0863 (commit) from 0ef023547a5ee68baa4f7c6fc375dac6f886ddfb (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email. - Log ----------------------------------------------------------------- commit ad36974015d8a9f2404e3deb5c537a8e8f89dea0 Merge: 36be80f0873e0dd9255e99c3b995aecc0fdd0863 0ef023547a5ee68baa4f7c6fc375dac6f886ddfb Author: Rick Moseley Date: Thu Jun 5 10:33:12 2008 -0500 Merge branch 'master' of ssh://sources.redhat.com/git/frysk commit 36be80f0873e0dd9255e99c3b995aecc0fdd0863 Author: Rick Moseley Date: Thu Jun 5 10:27:07 2008 -0500 Fix UnloadCommand errors. * UnloadCommand.java: Fix errors for unloading processes. * TestUnloadCommand.java: Add tests for above fix. ----------------------------------------------------------------------- Summary of changes: frysk-core/frysk/hpd/ChangeLog | 5 ++ frysk-core/frysk/hpd/TestUnloadCommand.java | 22 +++++++ frysk-core/frysk/hpd/UnloadCommand.java | 81 +++++++-------------------- 3 files changed, 47 insertions(+), 61 deletions(-) First 500 lines of diff: diff --git a/frysk-core/frysk/hpd/ChangeLog b/frysk-core/frysk/hpd/ChangeLog index 0b67fba..33e1546 100644 --- a/frysk-core/frysk/hpd/ChangeLog +++ b/frysk-core/frysk/hpd/ChangeLog @@ -1,3 +1,8 @@ +2008-06-05 Rick Moseley + + * UnloadCommand.java: Fix errors for unloading processes. + * TestUnloadCommand.java: Add tests for above fix. + 2008-06-01 Rick Moseley * TestUnloadCommand.java: New. diff --git a/frysk-core/frysk/hpd/TestUnloadCommand.java b/frysk-core/frysk/hpd/TestUnloadCommand.java index e8cf5b4..39a76a4 100644 --- a/frysk-core/frysk/hpd/TestUnloadCommand.java +++ b/frysk-core/frysk/hpd/TestUnloadCommand.java @@ -58,4 +58,26 @@ public class TestUnloadCommand extends TestLib { e.expect("Quitting\\.\\.\\."); e.close(); } + + public void testUnloadSingle() { + e = new HpdTestbed(); + e.sendCommandExpectPrompt("load " + Prefix.pkgLibFile("funit-parameters").getPath() + + " abc def ghi", "\\[0\\.0\\] Loaded executable file.*"); + e.sendCommandExpectPrompt("unload -t 0", "Removed Target set \\[0\\].*"); + e.sendCommandExpectPrompt("load", "No loaded procs currently.*"); + e.send("quit\n"); + e.expect("Quitting\\.\\.\\."); + e.close(); + } + + public void testUnloadError() { + e = new HpdTestbed(); + e.sendCommandExpectPrompt("unload -t 0", "Error: Trying to remove a proc that has not been loaded.*"); + e.sendCommandExpectPrompt("unload", "No loaded procs currently.*"); + e.send("quit\n"); + e.expect("Quitting\\.\\.\\."); + e.close(); + } + + } \ No newline at end of file diff --git a/frysk-core/frysk/hpd/UnloadCommand.java b/frysk-core/frysk/hpd/UnloadCommand.java index 0e4c056..1ca36f8 100644 --- a/frysk-core/frysk/hpd/UnloadCommand.java +++ b/frysk-core/frysk/hpd/UnloadCommand.java @@ -39,13 +39,7 @@ package frysk.hpd; -import java.util.HashMap; -import java.util.Iterator; import java.util.List; -import java.util.Map; -import java.util.Set; -import frysk.proc.Proc; -//import frysk.proc.Task; /** * UnloadCommand handles the unloading of processes that have been loaded @@ -71,13 +65,12 @@ public class UnloadCommand extends ParameterizedCommand { if (cmd.size() > 3) { throw new InvalidCommandException("Too many parameters"); - } else if (cmd.size() < 1 && !cli.loadedProcs.isEmpty()) { + } else if (cmd.size() < 1) { + if (!cli.loadedProcs.isEmpty()) // List the loaded procs if no parameters entered - LoadCommand.printLoop(cli, "Loaded Procs", cli.loadedProcs); - return; - } else if (cmd.size() < 1 && cli.loadedProcs.isEmpty()) { - cli.addMessage("No loaded procs currently, must load a proc before unloading", - Message.TYPE_NORMAL); + LoadCommand.printLoop(cli, "Loaded Procs", cli.loadedProcs); + else + cli.addMessage("No loaded procs currently", Message.TYPE_NORMAL); return; } @@ -85,63 +78,29 @@ public class UnloadCommand extends ParameterizedCommand { if (cmd.size() != 2) throw new InvalidCommandException("Not enough parameters"); int id = Integer.parseInt(cmd.parameter(1)); - Proc proc = cli.idManager.getProc(id); - if (proc == null) { - cli.addMessage("Trying to remove a proc that has not been loaded", Message.TYPE_ERROR); - return; - } - if (removeFromHashMap(proc, cli.loadedProcs, cli)) { - cli.targetset.removeProc(id); - cli.addMessage("Removed Target set [" + id + "]" , Message.TYPE_NORMAL); - } else { - cli.addMessage("Target id " + id + " could not be found", Message.TYPE_ERROR); + synchronized (cli) { + if (cli.loadedProcs.remove(new Integer(id)) == null) { + cli.addMessage( + "Trying to remove a proc that has not been loaded", + Message.TYPE_ERROR); + return; + } else { + cli.targetset.removeProc(id); + cli.addMessage("Removed Target set [" + id + "]" , Message.TYPE_NORMAL); + return; + } } - return; } if (cmd.parameter(0).equals("-all")) { - removeAllProcs(cli.loadedProcs, cli); + System.out.println("UnloadCommand.interpret: looking at -all"); + synchronized (cli) { + cli.loadedProcs.clear(); + } cli.addMessage("All loaded procs removed", Message.TYPE_NORMAL); return; } } - /** - * removeFromHashMap removes the designated process from the designated HashMap. - * - * @param proc is the proc object to be removed - * @param procMap is the HashMap of the procs to search for removal - * @param cli is the current command line interface object - */ - private boolean removeFromHashMap(Proc proc, HashMap procMap, CLI cli) { - Set procSet = procMap.entrySet(); - Iterator foo = procSet.iterator(); - while (foo.hasNext()) { - Map.Entry me = (Map.Entry) foo.next(); - Proc newProc = (Proc) me.getKey(); - if (proc.getExeFile().getSysRootedPath().equals(newProc.getExeFile().getSysRootedPath())) { - synchronized (cli) { - foo.remove(); - } - return true; - } - } - return false; - } - - /** - * removeAllProcs removes all of the procs loaded via the load command - * - * @param procMap is a HashMap of the set of procs to remove - * @param cli is the current command line interface object - * - */ - private void removeAllProcs(HashMap procMap, CLI cli) { - synchronized (cli) { - procMap.clear(); - } - - } - int completer(CLI cli, Input input, int cursor, List completions) { return CompletionFactory.completeFileName(cli, input, cursor, completions); hooks/post-receive -- frysk system monitor/debugger