From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30491 invoked by alias); 21 Nov 2007 05:08:47 -0000 Received: (qmail 30460 invoked by uid 9519); 21 Nov 2007 05:08:44 -0000 Date: Wed, 21 Nov 2007 05:08:00 -0000 Message-ID: <20071121050844.30445.qmail@sourceware.org> From: rmoseley@sourceware.org To: frysk-cvs@sourceware.org Subject: [SCM] master: Fix bz# 5380. X-Git-Refname: refs/heads/master X-Git-Reftype: branch X-Git-Oldrev: 25d68f5c3c6ad80284c5542dd5e31101265e40ae X-Git-Newrev: c6b2144b5562906445054a6fb3d991afa4356a7c 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/msg00413.txt.bz2 The branch, master has been updated via c6b2144b5562906445054a6fb3d991afa4356a7c (commit) from 25d68f5c3c6ad80284c5542dd5e31101265e40ae (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email. - Log ----------------------------------------------------------------- commit c6b2144b5562906445054a6fb3d991afa4356a7c Author: Rick Moseley Date: Tue Nov 20 23:08:28 2007 -0600 Fix bz# 5380. * PeekCommand.java: Fix bz# 5380(make peek command work with all types of Hosts). * LoadCommand.java: Ditto. * CLI.java; Ditto. * TestPeekCommand.java: Ditto. ----------------------------------------------------------------------- Summary of changes: frysk-core/frysk/hpd/CLI.java | 23 --------- frysk-core/frysk/hpd/ChangeLog | 8 +++ frysk-core/frysk/hpd/LoadCommand.java | 3 +- frysk-core/frysk/hpd/PeekCommand.java | 73 ++++++++++++++++------------- frysk-core/frysk/hpd/TestPeekCommand.java | 32 +++++++++--- 5 files changed, 73 insertions(+), 66 deletions(-) First 500 lines of diff: diff --git a/frysk-core/frysk/hpd/CLI.java b/frysk-core/frysk/hpd/CLI.java index c7374e2..1c5ef5c 100644 --- a/frysk-core/frysk/hpd/CLI.java +++ b/frysk-core/frysk/hpd/CLI.java @@ -55,7 +55,6 @@ import frysk.debuginfo.DebugInfoFrame; import frysk.debuginfo.DebugInfoStackFactory; import frysk.proc.Proc; import frysk.proc.Task; -import frysk.proc.Host; import frysk.rt.ProcTaskIDManager; import frysk.stepping.SteppingEngine; import frysk.stepping.TaskStepEngine; @@ -468,26 +467,4 @@ public class CLI { } return ptset; } - - /** - * Sets the LinuxExeHost for an executable file so we can access its memory - * via the "peek" command. - * - */ - Host exeHost; - - public void setExeHost (Host host) { - this.exeHost = host; - } - - /** - * Sets the LinuxExeProc for an executable file so we can access its memory - * via the "peek" command. - * - */ - Proc exeProc; - - public void setExeProc (Proc proc) { - this.exeProc = proc; - } } diff --git a/frysk-core/frysk/hpd/ChangeLog b/frysk-core/frysk/hpd/ChangeLog index 460da66..26827e1 100644 --- a/frysk-core/frysk/hpd/ChangeLog +++ b/frysk-core/frysk/hpd/ChangeLog @@ -1,5 +1,13 @@ 2007-11-20 Rick Moseley + * PeekCommand.java: Fix bz# 5380(make peek command + work with all types of Hosts). + * LoadCommand.java: Ditto. + * CLI.java; Ditto. + * TestLoadCommand.java: Ditto. + +2007-11-20 Rick Moseley + * RunCommand.java: Clear loadedProcs HashMap when done. * TestLoadCommand.java: Add test for the above change. diff --git a/frysk-core/frysk/hpd/LoadCommand.java b/frysk-core/frysk/hpd/LoadCommand.java index 38fd2d0..8ec7fd8 100644 --- a/frysk-core/frysk/hpd/LoadCommand.java +++ b/frysk-core/frysk/hpd/LoadCommand.java @@ -78,8 +78,7 @@ public class LoadCommand extends ParameterizedCommand { Host exeHost = new LinuxExeHost(Manager.eventLoop, executableFile); Proc exeProc = frysk.util.Util.getProcFromExeFile(exeHost); - cli.setExeHost(exeHost); - cli.setExeProc(exeProc); + int procID = cli.idManager.reserveProcID(); cli.idManager.manageProc(exeProc, procID); diff --git a/frysk-core/frysk/hpd/PeekCommand.java b/frysk-core/frysk/hpd/PeekCommand.java index 6cf1580..22d8db4 100644 --- a/frysk-core/frysk/hpd/PeekCommand.java +++ b/frysk-core/frysk/hpd/PeekCommand.java @@ -39,17 +39,14 @@ package frysk.hpd; -import java.io.PrintWriter; import inua.eio.ByteBuffer; -import frysk.proc.Proc; -import frysk.proc.ProcId; import frysk.proc.Task; +import java.util.Iterator; import java.util.List; /** * PeekCommand handles the "peek memory-location" command on the fhpd - * commandline. This command is only used after a "load" command has - * been issued. + * commandline. * */ @@ -57,40 +54,50 @@ public class PeekCommand extends ParameterizedCommand { PeekCommand() { super("peek", "peek ", - "peek at an executable file's memory"); + "peek at a process' memory"); } void interpret(CLI cli, Input cmd, Object options) { - final PrintWriter output = cli.getPrintWriter(); - if (cmd.size() > 1 ) { - throw new InvalidCommandException("Too many parameters"); + if (cmd.size() > 1) { + throw new InvalidCommandException("Too many parameters."); } - if (cli.exeHost == null) { - throw new InvalidCommandException("No executable loaded"); - } - - Proc proc = cli.exeHost.getProc(new ProcId(0)); - Task task = proc.getMainTask(); - - ByteBuffer buffer = task.getMemory(); - String memposition = cmd.parameter(0); - int radix = 10; - if (memposition.lastIndexOf("x") != -1) { - radix = 16; - memposition = memposition.substring(memposition.lastIndexOf("x") + 1); - if (memposition.lastIndexOf("L") != -1) - memposition = memposition.substring(0, memposition.lastIndexOf("L")); - } - - try { - long value = Long.parseLong(memposition.trim(), radix); - buffer.position(value); - output.println("The value at " + memposition + " = " + buffer.getUByte()); - } catch (NumberFormatException nfe) { - System.out.println("NumberFormatException: " + nfe.getMessage()); + PTSet ptset = cli.getCommandPTSet(cmd); + Iterator taskIter = ptset.getTaskData(); + while (taskIter.hasNext()) { + TaskData taskData = (TaskData) taskIter.next(); + Task task = taskData.getTask(); + + ByteBuffer buffer = task.getMemory(); + + cli.outWriter.print("["); + cli.outWriter.print(taskData.getParentID()); + cli.outWriter.print("."); + cli.outWriter.print(taskData.getID()); + cli.outWriter.println("]"); + + String memposition = cmd.parameter(0); + int radix = 10; + if (memposition.lastIndexOf("x") != -1) { + radix = 16; + memposition = memposition.substring(memposition + .lastIndexOf("x") + 1); + if (memposition.lastIndexOf("L") != -1) + memposition = memposition.substring(0, memposition + .lastIndexOf("L")); + } + + try { + long value = Long.parseLong(memposition.trim(), radix); + buffer.position(value); + cli.outWriter.println("The value at " + memposition + " = " + + buffer.getUByte()); + } catch (NumberFormatException nfe) { + cli.addMessage("NumberFormatException: " + + nfe.getMessage(), Message.TYPE_ERROR); + } } - + } int completer(CLI cli, Input input, int cursor, List completions) { diff --git a/frysk-core/frysk/hpd/TestPeekCommand.java b/frysk-core/frysk/hpd/TestPeekCommand.java index c49bc7a..545717f 100644 --- a/frysk-core/frysk/hpd/TestPeekCommand.java +++ b/frysk-core/frysk/hpd/TestPeekCommand.java @@ -48,17 +48,33 @@ import frysk.Config; public class TestPeekCommand extends TestLib { public void testPeekCommand() { e = new HpdTestbed(); - e.sendCommandExpectPrompt("load " + Config.getPkgDataFile("test-exe-x86").getPath(), - "Loaded executable file.*"); - e.sendCommandExpectPrompt("peek 0x08048000L", - "The value at 08048000 = 127.*"); + e.send("load " + Config.getPkgDataFile("test-exe-x86").getPath() + "\n"); + e.expect(5,"Loaded executable file.*"); + e.send("peek 0x08048000L\n"); + e.expect(5, "The value at 08048000 = 127.*"); + e.close(); } public void testPeekCommandError() { e = new HpdTestbed(); - e.sendCommandExpectPrompt("load " + Config.getPkgDataFile("test-exe-x86").getPath(), - "Loaded executable file.*"); - e.sendCommandExpectPrompt("peek 08048000", - "Cannot find memory in exe file.*"); + e.send("load " + Config.getPkgDataFile("test-exe-x86").getPath() + "\n"); + e.expect(5, "Loaded executable file.*"); + e.send("peek 08048000\n"); + e.expect(5, "Cannot find memory in exe file.*"); + e.close(); + } + + public void testTwoLoadedPeekCommand() { + e = new HpdTestbed(); + e.send("load " + Config.getPkgDataFile("test-exe-x86").getPath() + "\n"); + e.expect(5, "Loaded executable file.*"); + e.send("load " + Config.getPkgDataFile("test-exe-x86").getPath() + "\n"); + e.expect(5, "Loaded executable file.*"); + e.send("peek 0x08048000L\n"); + e.expect(5, "[0.0]"); + e.expect(5, "The value at 08048000 = 127.*"); + e.expect(5, "[0.1]"); + e.expect(5, "The value at 08048000 = 127.*"); + e.close(); } } hooks/post-receive -- frysk system monitor/debugger