From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22321 invoked by alias); 20 Dec 2007 10:57:38 -0000 Received: (qmail 22310 invoked by uid 22791); 20 Dec 2007 10:57:36 -0000 X-Spam-Status: No, hits=-2.3 required=5.0 tests=AWL,BAYES_00,DK_POLICY_SIGNSOME,FORGED_RCVD_HELO,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (66.187.233.31) by sourceware.org (qpsmtpd/0.31) with ESMTP; Thu, 20 Dec 2007 10:57:32 +0000 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id lBKAvTtU021553 for ; Thu, 20 Dec 2007 05:57:29 -0500 Received: from pobox-2.corp.redhat.com (pobox-2.corp.redhat.com [10.11.255.15]) by int-mx1.corp.redhat.com (8.13.1/8.13.1) with ESMTP id lBKAvTR1001788 for ; Thu, 20 Dec 2007 05:57:29 -0500 Received: from localhost.localdomain (vpn-6-13.fab.redhat.com [10.33.6.13]) by pobox-2.corp.redhat.com (8.13.1/8.13.1) with ESMTP id lBKAvRsX021650 for ; Thu, 20 Dec 2007 05:57:28 -0500 Message-ID: <476A4A97.2040108@redhat.com> Date: Thu, 20 Dec 2007 10:57:00 -0000 From: Phil Muldoon User-Agent: Thunderbird 2.0.0.9 (X11/20071115) MIME-Version: 1.0 To: Frysk Hackers Subject: Patch: Implement Info Command Content-Type: multipart/mixed; boundary="------------090705080307050405010603" X-Scanned-By: MIMEDefang 2.58 on 172.16.52.254 X-Virus-Checked: Checked by ClamAV on sourceware.org X-IsSubscribed: yes Mailing-List: contact frysk-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: frysk-owner@sourceware.org X-SW-Source: 2007-q4/txt/msg00230.txt.bz2 This is a multi-part message in MIME format. --------------090705080307050405010603 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-length: 1251 This patch implements a new Multi Level Command called: 'info' into fhpd. This new multi level command attempts to group all the 'information-providing' commands into one command-group. This is so the main top-level command's help does not get unwieldy. The commands auxv, maps and debuginfo registrations have been moved into info command. The regs command registration has been duplicated into info command due to the hpd specifying the regs command should also be a top-level command. Usage Scenarios: Usage: info help - will print out all the information sub-commands that info knows about. Usage: info help - will print out the sub-command's help. E.g. info help regs Usage: info -help. Same as above. E.g. info regs -help Usage: info - will execute the sub-command. E.g. info auxv. Class usage: To add commands to 'info', simple edit the InfoCommand.java as show in the patch, or call the .add() function. Known bugs: An unsolved issue is that info -help does not parse the -help correctly and identifies it as a command. Extending ParameterizedCommand instead of Command leads to the InfoCommand cannibalizing command options that the sub-command should process. Regards Phil --------------090705080307050405010603 Content-Type: text/x-patch; name="info.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="info.patch" Content-length: 8354 diff --git a/frysk-core/frysk/hpd/ChangeLog b/frysk-core/frysk/hpd/ChangeLog index 789cd32..3dfa4e7 100644 --- a/frysk-core/frysk/hpd/ChangeLog +++ b/frysk-core/frysk/hpd/ChangeLog @@ -1,3 +1,17 @@ +2007-12-20 Phil Muldoon + + * InfoCommand.java: New. Add auxv, maps, debuginfo. + * TopLevelCommand.java(TopLevelCommand): Add InfoCommand. + Remove auxv, maps, debuginfo. + * TestRegs.java (testRegsCommand): Add 'info regs' + to test. + * TestMapsCommand.java (testMapsCommand): Send 'info maps' + to expect instead of 'maps'. + * TestAuxvCommand.java (testAuxVCoreCommand): Send 'info auxv' + to expect instead of 'auxv'. + * TestHelp.java (TestHelp): Remove debuginfo, add + info to array. + 2007-12-18 Rick Moseley * TestLoadCommand.java: Fix regex symbols. diff --git a/frysk-core/frysk/hpd/InfoCommand.java b/frysk-core/frysk/hpd/InfoCommand.java new file mode 100644 index 0000000..d8529cd --- /dev/null +++ b/frysk-core/frysk/hpd/InfoCommand.java @@ -0,0 +1,76 @@ +// This file is part of the program FRYSK. +// +// Copyright 2007, 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 +// the Free Software Foundation; version 2 of the License. +// +// FRYSK is distributed in the hope that it will be useful, but +// WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with FRYSK; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. +// +// In addition, as a special exception, Red Hat, Inc. gives You the +// additional right to link the code of FRYSK with code not covered +// under the GNU General Public License ("Non-GPL Code") and to +// distribute linked combinations including the two, subject to the +// limitations in this paragraph. Non-GPL Code permitted under this +// exception must only link to the code of FRYSK through those well +// defined interfaces identified in the file named EXCEPTION found in +// the source code files (the "Approved Interfaces"). The files of +// Non-GPL Code may instantiate templates or use macros or inline +// functions from the Approved Interfaces without causing the +// resulting work to be covered by the GNU General Public +// License. Only Red Hat, Inc. may make changes or additions to the +// list of Approved Interfaces. You must obey the GNU General Public +// License in all respects for all of the FRYSK code and other code +// used in conjunction with FRYSK except the Non-GPL Code covered by +// this exception. If you modify this file, you may extend this +// exception to your version of the file, but you are not obligated to +// do so. If you do not wish to provide this exception without +// modification, you must delete this exception statement from your +// version and license this file solely under the GPL without +// exception. +package frysk.hpd; + +import java.util.List; + +public class InfoCommand extends MultiLevelCommand { + + private class Help extends Command { + Help() { + super("Display this help message.", "help [command]", + "Display help (possibly for a command.)"); + } + + public void interpret(CLI cli, Input cmd) { + InfoCommand.this.help(cli, cmd); + } + + /** + * Complete the line, throw problem back at the top level + * command. + */ + int complete(CLI cli, Input buffer, int cursor, List candidates) { + return InfoCommand.this.complete(cli, buffer, cursor, + candidates); + } + } + + + InfoCommand() { + super("info command", "info ", + "The info command displays useful information about " + + "various system and process level systems."); + add(new Help(), "help"); + add(new RegsCommand(),"regs"); + add(new DebuginfoCommand(),"debuginfo"); + add(new MapsCommand(),"maps"); + add(new AuxvCommand(),"auxv"); + } +} diff --git a/frysk-core/frysk/hpd/TestAuxvCommand.java b/frysk-core/frysk/hpd/TestAuxvCommand.java index 3b566b7..8434d36 100644 --- a/frysk-core/frysk/hpd/TestAuxvCommand.java +++ b/frysk-core/frysk/hpd/TestAuxvCommand.java @@ -75,7 +75,7 @@ public class TestAuxvCommand extends TestLib { e.send("core " + core.getPath() + " -noexe\n"); e.expect("Attached to core file.*"); - e.send("auxv\n"); + e.send("info auxv\n"); Iterator i = buildAuxv.auxvData.iterator(); while (i.hasNext()) e.equals((String)i.next()); diff --git a/frysk-core/frysk/hpd/TestHelp.java b/frysk-core/frysk/hpd/TestHelp.java index fd34afe..cb9414d 100644 --- a/frysk-core/frysk/hpd/TestHelp.java +++ b/frysk-core/frysk/hpd/TestHelp.java @@ -56,7 +56,6 @@ public class TestHelp "attach", "break", "core", - "debuginfo", "defset", "delete", "detach", @@ -72,6 +71,7 @@ public class TestHelp "go", "halt", "help", + "info", "list", "load", "next", diff --git a/frysk-core/frysk/hpd/TestMapsCommand.java b/frysk-core/frysk/hpd/TestMapsCommand.java index 51380af..3ac9e70 100644 --- a/frysk-core/frysk/hpd/TestMapsCommand.java +++ b/frysk-core/frysk/hpd/TestMapsCommand.java @@ -52,7 +52,7 @@ public class TestMapsCommand extends TestLib { e = new HpdTestbed(); e.send("attach " + proc.getPid() +"\n"); - e.send("maps\n"); + e.send("info maps\n"); for (int i=0; i< liveMaps.length; i++) e.equals(liveMaps[i].toString()); e.close(); diff --git a/frysk-core/frysk/hpd/TestRegs.java b/frysk-core/frysk/hpd/TestRegs.java index c3e90c2..46add1d 100644 --- a/frysk-core/frysk/hpd/TestRegs.java +++ b/frysk-core/frysk/hpd/TestRegs.java @@ -51,20 +51,23 @@ public class TestRegs extends TestLib { File exe = Config.getPkgLibFile("hpd-c"); ISA isa = ElfMap.getISA(exe); + String[] commandSet = {"regs\n", "info regs\n"}; // Regs - e.send("regs\n"); - - // Match the first register (with two values) and the last - // register. - if (isa == ISA.IA32) - e.expectPrompt("eax:\t[0-9][^\t]*\t0x.*esp:.*"); - else if (isa == ISA.X8664) - e.expectPrompt("rax:\t[0-9][^\t]*\t0x.*rip:.*"); - else - fail("Architecture " + isa + " unhandled"); + for (int i=0; i < commandSet.length; i++) { + e.send(commandSet[i]); + + // Match the first register (with two values) and the last + // register. + if (isa == ISA.IA32) + e.expectPrompt("eax:\t[0-9][^\t]*\t0x.*esp:.*"); + else if (isa == ISA.X8664) + e.expectPrompt("rax:\t[0-9][^\t]*\t0x.*rip:.*"); + else + fail("Architecture " + isa + " unhandled"); + } e.close(); } - + public void testRegsBlah() { e = HpdTestbed.attachXXX("hpd-c"); e.sendCommandExpectPrompt("regs blah", diff --git a/frysk-core/frysk/hpd/TopLevelCommand.java b/frysk-core/frysk/hpd/TopLevelCommand.java index f85e691..009ec4c 100644 --- a/frysk-core/frysk/hpd/TopLevelCommand.java +++ b/frysk-core/frysk/hpd/TopLevelCommand.java @@ -80,12 +80,10 @@ public class TopLevelCommand extends MultiLevelCommand { add(new AliasCommands.Alias(), "alias"); add(new AliasCommands.Unalias(), "unalias"); add(new AttachCommand(), "attach"); - add(new AuxvCommand(), "auxv"); add(new BreakpointCommand(), "b|reak"); add(new CoreCommand(), "core"); add(new DbgVariableCommands.Set(), "set"); add(new DbgVariableCommands.Unset(), "unset"); - add(new DebuginfoCommand(), "debuginfo"); add(new DetachCommand(), "detach"); add(new DisassembleCommand(), "disassemble"); add(new DisplayCommand(), "display"); @@ -95,10 +93,10 @@ public class TopLevelCommand extends MultiLevelCommand { add(new GoCommand(), "g|o"); add(new HaltCommand(), "h|alt"); add(new Help(), "help"); + add(new InfoCommand(), "info"); add(new KillCommand(), "k|ill"); add(new ListCommand(), "l|ist"); add(new LoadCommand(), "load"); - add(new MapsCommand(), "maps"); add(new PeekCommand(), "peek"); Command quit = new QuitCommand(); add(quit, "exit"); --------------090705080307050405010603--