public inbox for frysk@sourceware.org
 help / color / mirror / Atom feed
From: Phil Muldoon <pmuldoon@redhat.com>
To: Frysk Hackers <frysk@sourceware.org>
Subject: Patch: Implement Info Command
Date: Thu, 20 Dec 2007 10:57:00 -0000	[thread overview]
Message-ID: <476A4A97.2040108@redhat.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1251 bytes --]

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 <sub-command> - will print out the sub-command's help. 
E.g. info help regs

Usage: info <sub-command> -help. Same as above. E.g. info regs -help

Usage: info <sub-command>  - 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

[-- Attachment #2: info.patch --]
[-- Type: text/x-patch, Size: 8354 bytes --]

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  <pmuldoon@redhat.com>
+
+	* 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  <rmoseley@redhat.com>
 
 	* 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 <subcommand>", 
+	      "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");

             reply	other threads:[~2007-12-20 10:57 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-12-20 10:57 Phil Muldoon [this message]
2007-12-20 11:29 ` Phil Muldoon
2007-12-20 14:12 ` Andrew Cagney
2007-12-20 14:31   ` Phil Muldoon
2007-12-20 14:35     ` Phil Muldoon

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=476A4A97.2040108@redhat.com \
    --to=pmuldoon@redhat.com \
    --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: link
Be 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).