public inbox for frysk-cvs@sourceware.org help / color / mirror / Atom feed
From: rmoseley@sourceware.org To: frysk-cvs@sourceware.org Subject: [SCM] master: Add parameter passing for fhpd/load commands, minor cleanup of superfluous methods. Date: Thu, 29 May 2008 15:10:00 -0000 [thread overview] Message-ID: <20080529151048.31061.qmail@sourceware.org> (raw) The branch, master has been updated via 8c696ff9f233e3150af639aa7d22aa387397a5d9 (commit) from 81647a994c50b61d87ec8ff4eedc079990f7e4bb (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email. - Log ----------------------------------------------------------------- commit 8c696ff9f233e3150af639aa7d22aa387397a5d9 Author: Rick Moseley <rmoseley@dhcp-215.hsv.redhat.com> Date: Thu May 29 10:04:12 2008 -0500 Add parameter passing for fhpd/load commands, minor cleanup of superfluous methods. * CLI.java: Clean up by removing unnecessary methods; changed from ArrayList to HashMap for parameter storage. * StartRun.java: Re-write for parameter storage. * LoadCommand.java: Added parameter storage. * UnloadCommand.java: Changed loaded proc storage access. * GoCommand.java: Ditto. * CoreCommand.java: Remove unnecessary method call. * TestRunCommand.java: Add tests for above changes. * TestStartCommand.java: Add tests for above changes. * TestDisplayCommand.java: Fix message testing. * TestFhpdStepping.java: Ditto. * bindir/fhpd.java: Add code for parameter passing. ----------------------------------------------------------------------- Summary of changes: frysk-core/frysk/bindir/ChangeLog | 4 + frysk-core/frysk/bindir/fhpd.java | 5 +- frysk-core/frysk/hpd/CLI.java | 31 +---- frysk-core/frysk/hpd/ChangeLog | 14 ++ frysk-core/frysk/hpd/CoreCommand.java | 2 +- frysk-core/frysk/hpd/GoCommand.java | 4 +- frysk-core/frysk/hpd/LoadCommand.java | 32 +++- frysk-core/frysk/hpd/StartRun.java | 212 +++++++++++++------------- frysk-core/frysk/hpd/TestDisplayCommand.java | 2 +- frysk-core/frysk/hpd/TestFhpdStepping.java | 10 +- frysk-core/frysk/hpd/TestRunCommand.java | 40 +++++ frysk-core/frysk/hpd/UnloadCommand.java | 4 +- 12 files changed, 207 insertions(+), 153 deletions(-) First 500 lines of diff: diff --git a/frysk-core/frysk/bindir/ChangeLog b/frysk-core/frysk/bindir/ChangeLog index c9627bb..c16c932 100644 --- a/frysk-core/frysk/bindir/ChangeLog +++ b/frysk-core/frysk/bindir/ChangeLog @@ -1,3 +1,7 @@ +2008-05-29 Rick Moseley <rmoseley@redhat.com> + + * fhpd.java: Add code for parameter passing. + 2008-05-20 Andrew Cagney <cagney@redhat.com> * TestFexe.java (testExeOfScript()): New. diff --git a/frysk-core/frysk/bindir/fhpd.java b/frysk-core/frysk/bindir/fhpd.java index aa8dca7..fcf965f 100644 --- a/frysk-core/frysk/bindir/fhpd.java +++ b/frysk-core/frysk/bindir/fhpd.java @@ -66,6 +66,7 @@ public class fhpd { private static Proc command; private static Proc[] cores; private static int exitStatus; + private static String[] params; final static class FhpdCompletor implements Completor { CLI cli; @@ -136,7 +137,7 @@ public class fhpd { CoreCommand.load(cores[i], cli); } } else if (command != null) { - LoadCommand.load(command, cli); + LoadCommand.load(command, cli, params); } // Make sure any messages logged by the Attach or Load commands @@ -176,7 +177,7 @@ public class fhpd { }; parser.setHeader("Usage: fhpd <PID> || fhpd <EXEFILE> || fhpd <COREFILE> [<EXEFILE>]"); - parser.parse(args); + params = parser.parse(args); Manager.eventLoop.add(new CommandLine()); // Add event to handle Ctrl-C signal Manager.eventLoop.add(SigIntHandler.fhpd); diff --git a/frysk-core/frysk/hpd/CLI.java b/frysk-core/frysk/hpd/CLI.java index fbad1c1..30bb51a 100644 --- a/frysk-core/frysk/hpd/CLI.java +++ b/frysk-core/frysk/hpd/CLI.java @@ -39,6 +39,7 @@ package frysk.hpd; +import frysk.expr.ExprSearchEngine; import java.io.PrintWriter; import java.io.Writer; import java.util.HashMap; @@ -64,7 +65,6 @@ import frysk.sys.Signal; import frysk.util.CountDownLatch; import frysk.util.WordWrapWriter; import frysk.event.SignalEvent; -import frysk.expr.ExprSearchEngine; import frysk.expr.Expression; import frysk.expr.ScratchSymTab; import frysk.expr.ExprSymTab; @@ -80,6 +80,8 @@ public class CLI { final HashSet runningProcs = new HashSet(); //Processes loaded with load command final HashMap loadedProcs = new HashMap(); + //Params for loaded Procs + final HashMap ptsetParams = new HashMap(); //Processes loaded with core command final HashMap coreProcs = new HashMap(); //Task ID to use @@ -499,33 +501,6 @@ public class CLI { public PrintWriter getPrintWriter() { return outWriter; } - - /** - * Get the set of processes (Proc) started by the run command. Access to the - * CLI object should be synchronized when using the set. - * @return the set - */ - public HashSet getRunningProcs() { - return runningProcs; - } - - /** - * Get the set of processes (Proc) started by the load command. Access to the - * CLI object should be synchronized when using the set. - * @return the set - */ - public HashMap getLoadedProcs() { - return loadedProcs; - } - - /** - * Get the set of processes (Proc) started by the core command. Access to the - * CLI object should be synchronized when using the set. - * @return the set - */ - public HashMap getCoreProcs() { - return coreProcs; - } SteppingEngine getSteppingEngine () { return this.steppingEngine; diff --git a/frysk-core/frysk/hpd/ChangeLog b/frysk-core/frysk/hpd/ChangeLog index 08234d4..200c141 100644 --- a/frysk-core/frysk/hpd/ChangeLog +++ b/frysk-core/frysk/hpd/ChangeLog @@ -1,3 +1,17 @@ +2008-05-29 Rick Moseley <rmoseley@redhat.com> + + * CLI.java: Clean up by removing unnecessary methods; + changed from ArrayList to HashMap for parameter storage. + * StartRun.java: Re-write for parameter storage. + * LoadCommand.java: Added parameter storage. + * UnloadCommand.java: Changed loaded proc storage access. + * GoCommand.java: Ditto. + * CoreCommand.java: Remove unnecessary method call. + * TestRunCommand.java: Add tests for above changes. + * TestStartCommand.java: Add tests for above changes. + * TestDisplayCommand.java: Fix message testing. + * TestFhpdStepping.java: Ditto. + 2008-05-28 Teresa Thomas <tthomas@redhat.com> * WatchCommand.java (interpret): Use rt.WatchObserverInstaller. diff --git a/frysk-core/frysk/hpd/CoreCommand.java b/frysk-core/frysk/hpd/CoreCommand.java index 7603099..7677ee9 100644 --- a/frysk-core/frysk/hpd/CoreCommand.java +++ b/frysk-core/frysk/hpd/CoreCommand.java @@ -139,7 +139,7 @@ public class CoreCommand extends ParameterizedCommand { } // Finally, done. synchronized (cli) { - cli.getCoreProcs().put(coreProc, new Integer(procID)); + cli.coreProcs.put(coreProc, new Integer(procID)); } cli.outWriter.println("Attached to core file: " + coreProc.getHost().getName()); diff --git a/frysk-core/frysk/hpd/GoCommand.java b/frysk-core/frysk/hpd/GoCommand.java index 246d79d..015340d 100644 --- a/frysk-core/frysk/hpd/GoCommand.java +++ b/frysk-core/frysk/hpd/GoCommand.java @@ -73,8 +73,8 @@ class GoCommand extends ParameterizedCommand { * can do for now. */ try { - if (CLI.notRunningProc(task.getProc().getPid(), cli.getLoadedProcs()) || - CLI.notRunningProc(task.getProc().getPid(), cli.getCoreProcs())) { + if (task.getProc().getPid() == 0 || + CLI.notRunningProc(task.getProc().getPid(), cli.coreProcs)) { cli.addMessage("Cannot use 'go' on a loaded or core file, must " + "use 'start' first", Message.TYPE_ERROR); diff --git a/frysk-core/frysk/hpd/LoadCommand.java b/frysk-core/frysk/hpd/LoadCommand.java index dd953d5..ff95b3b 100644 --- a/frysk-core/frysk/hpd/LoadCommand.java +++ b/frysk-core/frysk/hpd/LoadCommand.java @@ -118,14 +118,16 @@ public class LoadCommand extends ParameterizedCommand { exeProc = LinuxExeFactory.createProc(cmd.stringArrayValue(), o.sysroot); } - load(exeProc, cli, o.sysroot); + load(exeProc, cli, o.sysroot, cmd.stringArrayValue()); } - public static void load(Proc exeProc, CLI cli) { - load(exeProc, cli, null); + public static void load(Proc exeProc, CLI cli, String[] params) { + load(exeProc, cli, null, params); } - public static void load(Proc exeProc, CLI cli, String sysroot) { + public static void load(Proc exeProc, CLI cli, String sysroot, + String[] params) { + int procID; if (cli.taskID < 0) procID = cli.idManager.reserveProcID(); @@ -133,6 +135,9 @@ public class LoadCommand extends ParameterizedCommand { procID = cli.taskID; cli.idManager.manageProc(exeProc, procID); + + if (params.length == 1) + params = (String []) cli.ptsetParams.get(new Integer(procID)); Iterator foo = cli.targetset.getTasks(); while (foo.hasNext()) { @@ -144,8 +149,19 @@ public class LoadCommand extends ParameterizedCommand { cli.setTaskDebugInfo(task, new DebugInfo(frame)); } } + if (params == null) + System.out.println("LoadCommand.load: params.length = null"); + else + System.out.println("LoadCommand.load: params.length = " + params.length); synchronized (cli) { - cli.getLoadedProcs().put(exeProc, new Integer(procID)); + cli.loadedProcs.put(new Integer(procID), + exeProc.getExeFile().getSysRootedPath()); + if (params != null) + cli.ptsetParams.put(new Integer(procID), params); + else { + String[] command = { exeProc.getExeFile().getSysRootedPath() }; + cli.ptsetParams.put(new Integer(procID), command); + } } cli.addMessage("[" + procID + ".0] Loaded executable file: " + @@ -169,9 +185,9 @@ public class LoadCommand extends ParameterizedCommand { // 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.getExeFile().getSysRootedPath()); + Integer taskid = (Integer) me.getKey(); + String proc = (String) me.getValue(); + listing.add("[" + taskid.intValue() + ".0]\t\t" + proc); } String alphaListing[] = (String[]) listing.toArray(new String[listing.size()]); java.util.Arrays.sort(alphaListing); diff --git a/frysk-core/frysk/hpd/StartRun.java b/frysk-core/frysk/hpd/StartRun.java index b35ad22..56bdc50 100644 --- a/frysk-core/frysk/hpd/StartRun.java +++ b/frysk-core/frysk/hpd/StartRun.java @@ -47,7 +47,7 @@ import frysk.proc.Task; import frysk.proc.TaskAttachedObserverXXX; import frysk.proc.ProcTasksAction; import frysk.util.CountDownLatch; -import java.util.ArrayList; +import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.List; @@ -59,11 +59,11 @@ import java.util.List; */ abstract class StartRun extends ParameterizedCommand { - final ArrayList procTaskDataList = new ArrayList(); + final HashMap procTaskDataList = new HashMap(); - final ArrayList procProcCommand = new ArrayList(); + final HashMap procProcCommand = new HashMap(); - final ArrayList procProcArgs = new ArrayList(); + final HashMap procProcArgs = new HashMap(); PTSet userSet; @@ -86,7 +86,7 @@ abstract class StartRun extends ParameterizedCommand { launchedTask = task; } synchronized (cli) { - cli.getRunningProcs().add(proc); + cli.runningProcs.add(proc); } new ProcTasksAction(proc, new ProcTasksObserver() { public void existingTask(Task task) { @@ -107,7 +107,7 @@ abstract class StartRun extends ParameterizedCommand { public void taskRemoved(Task task) { if (proc.getChildren().size() == 0) { synchronized (cli) { - HashSet procs = cli.getRunningProcs(); + HashSet procs = cli.runningProcs; procs.remove(proc); } } @@ -132,24 +132,23 @@ abstract class StartRun extends ParameterizedCommand { public void interpretCmd(CLI cli, Input cmd, Object options, boolean runToBreak) { + userSet = cli.getCommandPTSet(cmd); + setParams(cmd, cli); // See if there are any tasks to be killed if (killProcs(cli)) { // See if there are any tasks in the current target set TaskData taskData = null; int counter = 0; - Iterator foo = procTaskDataList.iterator(); + Iterator foo = userSet.getTaskData(); while (foo.hasNext()) { taskData = (TaskData) foo.next(); - String command = (String) procProcCommand.get(counter); - String[] argList = (String[]) procProcArgs.get(counter); - run(cli, cmd, command, argList, runToBreak, + int parentID = taskData.getParentID(); + String command = (String) cli.loadedProcs.get(new Integer(parentID)); + run(cli, cmd, command, runToBreak, taskData.getParentID()); counter++; } - procTaskDataList.clear(); - procProcArgs.clear(); - procProcCommand.clear(); return; } // Take care of loaded procs @@ -162,18 +161,20 @@ abstract class StartRun extends ParameterizedCommand { TaskData taskData = (TaskData) foo.next(); Task task = taskData.getTask(); if (!cli.loadedProcs.isEmpty() && - cli.loadedProcs.containsKey(task.getProc())) { + cli.loadedProcs.containsKey(new Integer(taskData.getParentID()))) { run(cli, cmd, task.getProc().getExeFile().getSysRootedPath(), - task.getProc().getCmdLine(), runToBreak, taskData.getParentID()); + runToBreak, taskData.getParentID()); synchronized (cli) { cli.loadedProcs.remove(task.getProc()); } } - // Take care of core procs + // Take care of core procs + // XXX: need to take care of parameters here that were passed into the + // process that created the core file else if (!cli.coreProcs.isEmpty() && cli.coreProcs.containsKey(task.getProc())) { run(cli, cmd, task.getProc().getExeFile().getSysRootedPath(), - task.getProc().getCmdLine(), runToBreak, taskData.getParentID()); + runToBreak, taskData.getParentID()); synchronized (cli) { cli.coreProcs.remove(new Integer(taskData.getParentID())); } @@ -183,6 +184,69 @@ abstract class StartRun extends ParameterizedCommand { } /** + * setParams will take the passed parameters by the run/start commands + * and makes them the new current parameters. + * + * @param params is a String[] containing the new params + * @param cli is the current commandline interface object + */ + private void setParams(Input cmd, CLI cli) { + + Iterator foo = userSet.getTaskData(); + TaskData taskData = null; + while (foo.hasNext()) { + taskData = (TaskData) foo.next(); + int parentID = taskData.getParentID(); + switch (cmd.size()) { + + // No parameters were passed on the commandline, except maybe "--" + case 0: + /** + * There is an exception to the rule of cmd.size() being 0 and that + * is when a "--" was entered, CLI removes that but the full command + * line string in the Input object has it. So, if cmd.size() reports + * 0 parameters, check to see if actually a "--" was entered. If it + * was the user wants no args passed to the process this run. + * + * Leave the command as is if "--" was not passed. + */ + int index = cmd.getFullCommand().indexOf("--"); + if (index != -1) { + String[] command = new String[1]; + String[] oldCommand = (String[]) cli.ptsetParams.get(new Integer(parentID)); + command[0] = oldCommand[0]; + // Set proc params to null so we won't run with them again + cli.ptsetParams.put(new Integer(parentID), command); + } + break; + + // Params were passed + default: + cli.ptsetParams.put(new Integer(parentID), + makeCommand(cmd.stringArrayValue(), parentID, cli)); + break; + } + } + } + + /** + * makeCommand takes the previous command and a new set of parameters and creates a new + * command. This new command is stored in the cli.ptsetParams HashMap. + * + * @param params is the String array of parameters passed via a run or start command + * @return returns a String[] + */ + + private String[] makeCommand(String[] params, int parentID, CLI cli) { + String[] newParams = new String[params.length + 1]; + String[] oldParams = (String[]) cli.ptsetParams.get(new Integer(parentID)); + newParams[0] = oldParams[0]; + for (int i = 1; i < newParams.length; i++) + newParams[i] = params[i-1]; + return newParams; + } + + /** * killProcs loops through the current target set to see if there are any * tasks to kill, the philosophy being that all tasks should be killed before * @@ -203,9 +267,6 @@ abstract class StartRun extends ParameterizedCommand { Task task = taskData.getTask(); if (task.getProc().getPid() != oldPid && task.getProc().getPid() > 0) { - procTaskDataList.add(taskData); - procProcCommand.add(task.getProc().getExeFile().getSysRootedPath()); - procProcArgs.add(task.getProc().getCmdLine()); cli.execCommand("kill " + task.getProc().getPid() + "\n"); oldPid = task.getProc().getPid(); } @@ -222,56 +283,28 @@ abstract class StartRun extends ParameterizedCommand { * @param cli is the commandline object * @param cmd is the command object with all the parameters * @param command is a string containing the command to run - * @param argList is a String array with the args from the commandline * @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, String command, String[] argList, boolean runToBreak, + private void run(CLI cli, Input cmd, String command, boolean runToBreak, int taskid) { + Runner runner = new Runner(cli); String startrun = ""; if (runToBreak) startrun = "running"; else startrun = "starting"; - - switch (cmd.size()) { - - // No parameters were passed on the commandline, except maybe "--" - case 0: - /** There is an exception to the rule of cmd.size() being 0 and that - * is when a "--" was entered, CLI removes that but the full command line - * string in the Input object has it. So, if cmd.size() reports 0 - * parameters, check to see if actually a "--" was entered. If it was - * the user wants no args passed to the process this run. - */ - int index = cmd.getFullCommand().indexOf("--"); - if (index != -1) { - cli.addMessage(startrun + " with this commmand: " + - command, Message.TYPE_NORMAL); - Manager.host.requestCreateAttachedProc(createArgList(null, argList), runner); - } - else { - String[] temp = new String[1]; - if (command != "" || command != null) - temp[0] = command; - else - temp [0] = argList[0]; - cli.addMessage(startrun + " with this commmand: " + - asString("", temp, cmd), Message.TYPE_NORMAL); - Manager.host.requestCreateAttachedProc(createArgList(command, temp), runner); - } - break; - - default: - String[] args = createArgList(command, cmd.stringArrayValue()); - cli.addMessage(startrun + " with this command: " + - asString(command, args, cmd), Message.TYPE_NORMAL); - - Manager.host.requestCreateAttachedProc(args, runner); - } + + cli.addMessage(startrun + + " with this command: " + + asString((String[]) cli.ptsetParams.get(new Integer( + taskid))), Message.TYPE_NORMAL); + Manager.host.requestCreateAttachedProc((String[]) cli.ptsetParams + .get(new Integer(taskid)), runner); + while (true) { try { runner.latch = new CountDownLatch(1); @@ -283,64 +316,35 @@ 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.taskID = taskid; } cli.doAttach(runner.launchedTask.getProc(), runToBreak); runner.launchedTask.requestUnblock(runner); synchronized (cli) { - cli.taskID = -1; + cli.taskID = -1; } } /** - * createArgList takes a path to the executable and an argument list - * and creates a String[] to pass to the create proc method. - * @param command is a String with the path to the executable - * @param argList is a String[] with an argument list - * @return a String[] to pass to Manager.host.createAttachedProc - */ - private String[] createArgList(String command, String[] argList) { - // If command is null, the command is at the begging of argList - // so we need to do nothing - if (command == null) - return argList; hooks/post-receive -- frysk system monitor/debugger
reply other threads:[~2008-05-29 15:10 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20080529151048.31061.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: linkBe 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).