From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23516 invoked by alias); 17 Nov 2007 08:35:16 -0000 Received: (qmail 23490 invoked by uid 9519); 17 Nov 2007 08:35:16 -0000 Date: Sat, 17 Nov 2007 08:35:00 -0000 Message-ID: <20071117083516.23475.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: c9bca79bdca4785a6ca8209aaab7ffcf8ea24d1c X-Git-Newrev: c91caeb6b58115c176b57e419581084ee067888c 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: 2007-q4/txt/msg00385.txt.bz2 The branch, master has been updated via c91caeb6b58115c176b57e419581084ee067888c (commit) via b5cd3e0210e13f705c31ee46e992fbda3d61979f (commit) from c9bca79bdca4785a6ca8209aaab7ffcf8ea24d1c (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email. - Log ----------------------------------------------------------------- commit c91caeb6b58115c176b57e419581084ee067888c Merge: b5cd3e0210e13f705c31ee46e992fbda3d61979f c9bca79bdca4785a6ca8209aaab7ffcf8ea24d1c Author: Rick Moseley Date: Sat Nov 17 02:35:03 2007 -0600 Merge branch 'master' of ssh://sources.redhat.com/git/frysk Conflicts: frysk-core/frysk/hpd/ChangeLog commit b5cd3e0210e13f705c31ee46e992fbda3d61979f Author: Rick Moseley Date: Sat Nov 17 02:26:53 2007 -0600 Implement load/run capability. * AttachCommand.java: Implement load/run capability. * CLI.java: Ditto. * LoadCommand.java: Ditto. * RunCommand.java: Ditto. * TestLoadCommand: Test new load/run capability. * ProcTaskIDManager.java(removeProcID,manageProcSelect): New. * fhpd.java: Fix bz #5256. * TestFhd.java(testHpdCommand): Ditto. ----------------------------------------------------------------------- Summary of changes: frysk-core/frysk/bindir/ChangeLog | 5 +++ frysk-core/frysk/bindir/TestFhd.java | 2 +- frysk-core/frysk/bindir/fhpd.java | 13 ++----- frysk-core/frysk/hpd/AttachCommand.java | 2 +- frysk-core/frysk/hpd/CLI.java | 28 ++++++++++++--- frysk-core/frysk/hpd/ChangeLog | 8 ++++ frysk-core/frysk/hpd/LoadCommand.java | 8 +++- frysk-core/frysk/hpd/RunCommand.java | 49 +++++++++++++++++++++++++-- frysk-core/frysk/hpd/TestLoadCommand.java | 27 +++++++++++++++- frysk-core/frysk/rt/ChangeLog | 4 ++ frysk-core/frysk/rt/ProcTaskIDManager.java | 16 +++++++++ 11 files changed, 138 insertions(+), 24 deletions(-) First 500 lines of diff: diff --git a/frysk-core/frysk/bindir/ChangeLog b/frysk-core/frysk/bindir/ChangeLog index 3280ca7..69e9e03 100644 --- a/frysk-core/frysk/bindir/ChangeLog +++ b/frysk-core/frysk/bindir/ChangeLog @@ -1,3 +1,8 @@ +2007-11-16 Rick Moseley + + * fhpd.java: Fix bz #5256. + * TestFhd.java(testHpdCommand): Ditto. + 2007-11-16 Phil Muldoon * fhpd.java(main): Add option -noexe. Append diff --git a/frysk-core/frysk/bindir/TestFhd.java b/frysk-core/frysk/bindir/TestFhd.java index 0a4865f..08d4fb1 100755 --- a/frysk-core/frysk/bindir/TestFhd.java +++ b/frysk-core/frysk/bindir/TestFhd.java @@ -81,7 +81,7 @@ public class TestFhd Config.getBinFile("fhpd").getPath(), Config.getPkgLibFile("hpd-c").getPath() }); - e.expect(5, "Attached to process.*\n" + prompt); + e.expect(5, "Loaded executable file.*" + prompt); e.close(); } diff --git a/frysk-core/frysk/bindir/fhpd.java b/frysk-core/frysk/bindir/fhpd.java index f065cef..4012dd0 100644 --- a/frysk-core/frysk/bindir/fhpd.java +++ b/frysk-core/frysk/bindir/fhpd.java @@ -104,12 +104,7 @@ public class fhpd core = corePairs[0].coreFile; exeFile = corePairs[0].exeFile; } - - - - }; - parser.add(new Option("noexe", "Do not attempt to read an"+ " executable for a corefile ") { public void parsed(String exeValue) throws OptionException { @@ -121,10 +116,10 @@ public class fhpd + exeValue); } } - }); - parser.setHeader("Usage: fhpd || fhpd []"); - parser.parse(args); + }); + parser.setHeader("Usage: fhpd || fhpd || fhpd []"); + parser.parse(args); Manager.eventLoop.start(); String line = ""; @@ -133,7 +128,7 @@ public class fhpd if (pid > 0) line = "attach " + pid; else if (execFile != null) - line = "run " + execFile.getCanonicalPath(); + line = "load " + execFile.getCanonicalPath(); else if (core != null) { line = "core " + core.getCanonicalPath(); if (exeFile != null) diff --git a/frysk-core/frysk/hpd/AttachCommand.java b/frysk-core/frysk/hpd/AttachCommand.java index 69c2ba2..dd3e519 100644 --- a/frysk-core/frysk/hpd/AttachCommand.java +++ b/frysk-core/frysk/hpd/AttachCommand.java @@ -100,7 +100,7 @@ class AttachCommand extends ParameterizedCommand { cli.outWriter.println(pid); continue; } - cli.doAttach(findProc.proc); + cli.doAttach(findProc.proc, -1); } } diff --git a/frysk-core/frysk/hpd/CLI.java b/frysk-core/frysk/hpd/CLI.java index d7fcf07..2134399 100644 --- a/frysk-core/frysk/hpd/CLI.java +++ b/frysk-core/frysk/hpd/CLI.java @@ -69,6 +69,8 @@ public class CLI { CountDownLatch attachedLatch; //Processes started with run command final HashSet runningProcs = new HashSet(); + //Processes loaded with load command + final HashSet loadedProcs = new HashSet(); private class TaskInfo { DebugInfoFrame frame; @@ -125,14 +127,14 @@ public class CLI { } catch (RuntimeException e) { if (nasty(e)) e.printStackTrace(outWriter); - return -1; + return -1; } } /* * Command handlers */ - public void doAttach(Proc proc) { + public void doAttach(Proc proc, int procID) { synchronized (this) { attached = -1; attachedLatch = new CountDownLatch(1); @@ -144,7 +146,7 @@ public class CLI { outWriter.print("Attached to process "); outWriter.println(attached); } catch (InterruptedException ie) { - throw new RuntimeException("attachLatch interrupted"); + throw new RuntimeException("attachLatch interrupted"); } finally { synchronized (this) { attached = -1; @@ -152,7 +154,12 @@ public class CLI { } } steppingEngine.getBreakpointManager().manageProcess(proc); - idManager.manageProc(proc, idManager.reserveProcID()); + // If passed a taskID < 0, request a reserved ProcID + if (procID < 0) + idManager.manageProc(proc, idManager.reserveProcID()); + // Assign this proc to the passed in procID + else + idManager.manageProcSelect(proc, procID); } final PrintWriter outWriter; @@ -255,13 +262,13 @@ public class CLI { } } catch (RuntimeException e) { - printError(e); + printError(e); } flushMessages(); } return null; } - + /** * Identify "nasty", or internal exceptions; these are the * RuntimeExceptions thrown by the Java system. @@ -435,6 +442,15 @@ public class CLI { 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 HashSet getLoadedProcs() { + return loadedProcs; + } + SteppingEngine getSteppingEngine () { return this.steppingEngine; } diff --git a/frysk-core/frysk/hpd/ChangeLog b/frysk-core/frysk/hpd/ChangeLog index b5690a0..e743c96 100644 --- a/frysk-core/frysk/hpd/ChangeLog +++ b/frysk-core/frysk/hpd/ChangeLog @@ -1,3 +1,11 @@ +2007-11-16 Rick Moseley + + * AttachCommand.java: Implement load/run capability. + * CLI.java: Ditto. + * LoadCommand.java: Ditto. + * RunCommand.java: Ditto. + * TestLoadCommand: Test new load/run capability. + 2007-11-16 Stan Cox * TestListCommand.java (testListPC): Use sendCommandExpectPrompt. diff --git a/frysk-core/frysk/hpd/LoadCommand.java b/frysk-core/frysk/hpd/LoadCommand.java index cbad88d..d3f61e9 100644 --- a/frysk-core/frysk/hpd/LoadCommand.java +++ b/frysk-core/frysk/hpd/LoadCommand.java @@ -70,9 +70,10 @@ public class LoadCommand extends ParameterizedCommand { File executableFile = new File(cmd.parameter(0)); - if (!executableFile.exists() || !executableFile.canRead()) { + if (!executableFile.exists() || !executableFile.canRead() + || !executableFile.isFile()) { throw new InvalidCommandException - ("File does not exist or is not readable."); + ("File does not exist or is not readable or is not a file."); } Host exeHost = new LinuxExeHost(Manager.eventLoop, executableFile); @@ -97,6 +98,9 @@ public class LoadCommand extends ParameterizedCommand { frame)); } } + synchronized (cli) { + cli.getLoadedProcs().add(exeProc); + } } diff --git a/frysk-core/frysk/hpd/RunCommand.java b/frysk-core/frysk/hpd/RunCommand.java index f50feb3..2fec965 100644 --- a/frysk-core/frysk/hpd/RunCommand.java +++ b/frysk-core/frysk/hpd/RunCommand.java @@ -48,6 +48,7 @@ import frysk.proc.Task; import frysk.proc.TaskObserver; import frysk.util.CountDownLatch; import java.util.HashSet; +import java.util.Iterator; import java.util.List; class RunCommand extends Command { @@ -116,10 +117,44 @@ class RunCommand extends Command { } public void interpret(CLI cli, Input cmd) { + /* 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 */ if (cmd.size() < 1) { - // XXX: should default to previous values. - throw new InvalidCommandException("missing program"); + if (cli.runningProcs.isEmpty() && cli.loadedProcs.isEmpty()) + throw new InvalidCommandException("missing program"); } + + // 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 are either running procs or loaded procs + */ + + /* This is the case where there are loaded procs */ + if (!cli.loadedProcs.isEmpty()) { + Iterator foo = cli.targetset.getTasks(); + while (foo.hasNext()) { + Task task = (Task) foo.next(); + int taskID = cli.idManager.getProcID(task.getProc()); + cli.execCommand("run " + task.getProc().getExe() + " " + + Integer.toString(taskID)); + } + // Clear all of the loaded procs now that they have been run + synchronized(cli) { + cli.loadedProcs.clear(); + } + } + // Found no loaded procs, print usage message + // XXX Need to fix, add core files and running proc handling + else throw new InvalidCommandException("missing program"); + } + + private void run(CLI cli, Input cmd) { Runner runner = new Runner(cli); Manager.host.requestCreateAttachedProc(cmd.stringArrayValue(), runner); try { @@ -128,10 +163,16 @@ class RunCommand extends Command { return; } // register with SteppingEngine et.al. - cli.doAttach(runner.launchedTask.getProc()); + // If a second parameter was passed, it was a specific ProcTaskID to use + if (cmd.size() > 1) + cli.doAttach(runner.launchedTask.getProc(), + Integer.parseInt(cmd.parameter(1))); + // If not, pass a -1 so a new ProcTaskID will be assigned + else + cli.doAttach(runner.launchedTask.getProc(), -1); runner.launchedTask.requestUnblock(runner); } - + int complete(CLI cli, Input input, int cursor, List completions) { return CompletionFactory.completeFileName(cli, input, cursor, completions); diff --git a/frysk-core/frysk/hpd/TestLoadCommand.java b/frysk-core/frysk/hpd/TestLoadCommand.java index 467ccbc..10eeee4 100644 --- a/frysk-core/frysk/hpd/TestLoadCommand.java +++ b/frysk-core/frysk/hpd/TestLoadCommand.java @@ -59,7 +59,32 @@ public class TestLoadCommand extends TestLib { e = new HpdTestbed(); e.send("load " + Config.getPkgDataFile("test-exe-x86").getPath() + "foo\n"); - e.expect(5, "File does not exist or is not readable.*"); + e.expect(5, "File does not exist or is not readable*"); + e.close(); + } + + public void testLoadRun() { + e = new HpdTestbed(); + e.send("load " + Config.getPkgLibFile("funit-hello").getPath() + + "\n"); + e.expect(5, "Loaded executable file.*" + prompt); + e.send("focus\n"); + e.expect(5, "Target set*"); + e.expect(5, "[0.0]*0*0*"); + e.send("load " + Config.getPkgLibFile("funit-hello").getPath() + + "\n"); + e.expect(5, "Loaded executable file.*" + prompt); + e.send("focus\n"); + e.expect(5, "Target set*"); + e.expect(5, "[0.0]*0*0*"); + e.expect(5, "[1.0]*0*0*" + prompt); + e.send("run\n"); + e.expect(5, "Attached to process*"); + e.expect(5, "Attached to process*"); + e.send("focus\n"); + e.expect(5, "Target set*"); + e.expect(5, "[0.0]*"); + e.expect(5, "[1.0]*" + prompt); e.close(); } } diff --git a/frysk-core/frysk/rt/ChangeLog b/frysk-core/frysk/rt/ChangeLog index f1f42ec..b7ac848 100644 --- a/frysk-core/frysk/rt/ChangeLog +++ b/frysk-core/frysk/rt/ChangeLog @@ -1,3 +1,7 @@ +2007-11-16 Rick Moseley + + * ProcTaskIDManager.java(removeProcID,manageProcSelect): New. + 2007-11-06 Tim Moore * BreakpointManager.java (refreshBreakpoints): Enable breakpoint diff --git a/frysk-core/frysk/rt/ProcTaskIDManager.java b/frysk-core/frysk/rt/ProcTaskIDManager.java index d24086f..1e8934e 100644 --- a/frysk-core/frysk/rt/ProcTaskIDManager.java +++ b/frysk-core/frysk/rt/ProcTaskIDManager.java @@ -87,6 +87,15 @@ public class ProcTaskIDManager procList.add(null); return result; } + + public void manageProcSelect(Proc proc, int usedID) { + ProcEntry entry; + synchronized (this) { + entry = new ProcEntry(proc, usedID); + procList.set(usedID, entry); + procMap.put(proc, new Integer(usedID)); + } + } public void manageProc(Proc proc, int reservedID) { ProcEntry entry; @@ -103,6 +112,13 @@ public class ProcTaskIDManager else return null; } + + public synchronized boolean removeProcID(int id) { + if (id > procList.size() || id < 0) + return false; + procList.remove(id); + return true; + } public synchronized int getProcID(Proc proc) { Integer result = (Integer)procMap.get(proc); hooks/post-receive -- frysk system monitor/debugger