From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14263 invoked by alias); 18 Mar 2008 17:41:09 -0000 Received: (qmail 14256 invoked by uid 22791); 18 Mar 2008 17:41:07 -0000 X-Spam-Status: No, hits=-0.8 required=5.0 tests=AWL,BAYES_00,J_CHICKENPOX_33,J_CHICKENPOX_54,J_CHICKENPOX_63,J_CHICKENPOX_64,J_CHICKENPOX_66,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; Tue, 18 Mar 2008 17:40:50 +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 m2IHemS2023653 for ; Tue, 18 Mar 2008 13:40:48 -0400 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 m2IHemPs030752 for ; Tue, 18 Mar 2008 13:40:48 -0400 Received: from localhost.localdomain (vpn-15-121.rdu.redhat.com [10.11.15.121]) by pobox-2.corp.redhat.com (8.13.1/8.13.1) with ESMTP id m2IHekwp014932 for ; Tue, 18 Mar 2008 13:40:46 -0400 Message-ID: <47DFFE9D.80906@redhat.com> Date: Tue, 18 Mar 2008 17:41:00 -0000 From: Phil Muldoon User-Agent: Thunderbird 2.0.0.12 (X11/20080226) MIME-Version: 1.0 To: Frysk Hackers Subject: Patch: Add Option Groups Content-Type: multipart/mixed; boundary="------------040908090406050200040400" 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: 2008-q1/txt/msg00162.txt.bz2 This is a multi-part message in MIME format. --------------040908090406050200040400 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-length: 1716 I wanted to add option groups to fcore, and also make sure that the utility options come first. I've included a draft patch. This came up in conversation with Tom and Andrew. This required a little bit of hacking in bindir/fcore, util/CommandlineParser and util/ProcStopUntil. I've added the output and the patch that makes this happen. I have not checked it in. Please pay special attention to my comments around parse() as I am not sure this is the best place to add the default options. They have to be added "late" otherwise they will be added at the top of the --help output. There is a lot of weird indenting going on in the right help column, but this was happening beforehand and is another unrelated (but hopefully soon to be fixed) bug. ./frysk_bin/frysk-core/frysk/bindir/fcore --help Usage: fcore Corefile options: -a, -allmaps Include ALL process readable maps. -s, -segments =PATTERN use PATTERN as regex to define maps inclusion. -o, -outputfile Sets the name of the corefile. Frysk specific options: -debug Set debug-tracing of COMP to LEVEL. LEVEL can be [ NONE | FINE | FINEST ]; default is FINE. Example: debug frysk.rsl=FINE -noexe Do not attempt to read an executable for a corefile -exe Specify the full path of the executable to read -sysroot Special root directory Standard options: -help print this help, then exit -version print version number, then exit Regards Phil --------------040908090406050200040400 Content-Type: text/x-patch; name="options.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="options.patch" Content-length: 7791 diff --git a/frysk-core/frysk/bindir/ChangeLog b/frysk-core/frysk/bindir/ChangeLog index 3606ba8..60dcaf2 100644 --- a/frysk-core/frysk/bindir/ChangeLog +++ b/frysk-core/frysk/bindir/ChangeLog @@ -1,3 +1,8 @@ +2008-03-18 Phil Muldoon + + * fcore.java (addOptions): Add new group. + Add options to group and tweak text. + 2008-03-17 Andrew Cagney * fstep.java: Update; using TaskAttachedObserverXXX. diff --git a/frysk-core/frysk/bindir/fcore.java b/frysk-core/frysk/bindir/fcore.java index a5d8862..07190c8 100644 --- a/frysk-core/frysk/bindir/fcore.java +++ b/frysk-core/frysk/bindir/fcore.java @@ -48,6 +48,7 @@ import frysk.util.ProcStopUtil; import frysk.isa.corefiles.LinuxElfCorefile; import frysk.isa.corefiles.LinuxElfCorefileFactory; import gnu.classpath.tools.getopt.Option; +import gnu.classpath.tools.getopt.OptionGroup; import gnu.classpath.tools.getopt.OptionException; @@ -80,12 +81,12 @@ public class fcore { */ private static void addOptions (ProcStopUtil fcore) { + + OptionGroup group = new OptionGroup("Corefile options"); + fcore.addGroup(group); - fcore.addOption(new Option( "allmaps", 'a', - " Writes all readable maps. Does not elide" - + " or omit any readable map. Caution: could" - + " take considerable amount of time to" - + " construct core file.") + group.add(new Option( "allmaps", 'a', + " Include ALL process readable maps.") { public void parsed (String mapsValue) throws OptionException { try { @@ -98,9 +99,10 @@ public class fcore { } }); - fcore.addOption(new Option("segments", 's', - "Define what segments to include via regex.", - "RegEx") { + group.add(new Option("segments", 's', + "Use PATTERN as regex to define "+ + "maps inclusion.", + "=PATTERN") { public void parsed(String regEx) throws OptionException { try { mapOptionCount++; @@ -114,10 +116,9 @@ public class fcore { - fcore.addOption(new Option( "outputfile", 'o', - " Sets the name (not extension) of the core" - + " file. Default is core.{pid}. The extension" - + " will always be the pid.", "") + group.add(new Option( "outputfile", 'o', + " Sets the name of the " + + "corefile.", "") { public void parsed (String filenameValue) throws OptionException { try { @@ -141,8 +142,8 @@ public class fcore { if (mapOptionCount > 1) - System.err.println("Please either speciy -stackonly,"+ - " -allmaps, or -match for map writing."); + System.err.println("Please either specify "+ + " -allmaps, or -segments=PATTERN for map writing."); else { Task[] tasks = (Task[]) proc.getTasks().toArray (new Task[proc.getTasks().size()]); @@ -168,7 +169,7 @@ public class fcore { } public void executeDead(Proc proc) { - System.err.println ("Cannot create core file from dead process"); + System.err.println ("Cannot create core file from a dead process."); } } } diff --git a/frysk-core/frysk/util/ChangeLog b/frysk-core/frysk/util/ChangeLog index 1ddb337..ebf40a3 100644 --- a/frysk-core/frysk/util/ChangeLog +++ b/frysk-core/frysk/util/ChangeLog @@ -1,5 +1,12 @@ 2008-03-18 Phil Muldoon + * CommandlineParser.java: (addDefaultOptions): New. + (parse): Set default options here. + (CommandlineParser): Move default option + creation to addDefaultOptions. + * ProcStopUtil.java (addGroup): New. + + * CommandlineParser.java (CommandlineParser): Trim Sys Root help output. diff --git a/frysk-core/frysk/util/CommandlineParser.java b/frysk-core/frysk/util/CommandlineParser.java index 949c061..81ade30 100644 --- a/frysk-core/frysk/util/CommandlineParser.java +++ b/frysk-core/frysk/util/CommandlineParser.java @@ -46,6 +46,7 @@ import lib.dwfl.Elf; import lib.dwfl.ElfCommand; import lib.dwfl.ElfEHeader; import gnu.classpath.tools.getopt.Option; +import gnu.classpath.tools.getopt.OptionGroup; import gnu.classpath.tools.getopt.OptionException; import gnu.classpath.tools.getopt.Parser; import frysk.rsl.LogOption; @@ -68,27 +69,6 @@ public class CommandlineParser { public CommandlineParser(String name, String version) { parser = new Parser(name, version, true); - parser.add(new LogOption("debug")); - add(new Option("noexe", "Do not attempt to read an"+ - " executable for a corefile ") { - public void parsed(String exeValue) throws OptionException { - extendedCore = false; - explicitExe = null; - } - }); - add(new Option("exe", - "Specify the full path of the executable to read", - "") { - public void parsed(String exeValue) throws OptionException { - extendedCore = true; - explicitExe = exeValue; - } - }); - add(new Option("sysroot", "Special root directory", "") { - public void parsed(String arg) throws OptionException { - parseSysRoot(arg); - } - }); } public CommandlineParser(String programName) { @@ -138,6 +118,11 @@ public class CommandlineParser { } public String[] parse(String[] args) { + + // Add in default options here. + // This is to preserve the user options as "first" + // Seems the wrong place to do it + addDefaultOptions(); try { fine.log(this, "parse", args); String[] result = doParse(args); @@ -259,6 +244,32 @@ public class CommandlineParser { } + private void addDefaultOptions () { + OptionGroup defaultGroup = new OptionGroup("Frysk specific options"); + add(defaultGroup); + defaultGroup.add(new LogOption("debug")); + defaultGroup.add(new Option("noexe", "Do not attempt to read an"+ + " executable for a corefile ") { + public void parsed(String exeValue) throws OptionException { + extendedCore = false; + explicitExe = null; + } + }); + defaultGroup.add(new Option("exe", + "Specify the full path of the executable to read", + "") { + public void parsed(String exeValue) throws OptionException { + extendedCore = true; + explicitExe = exeValue; + } + }); + defaultGroup.add(new Option("sysroot", "Special root directory", "") { + public void parsed(String arg) throws OptionException { + parseSysRoot(arg); + } + }); + + } // @Override protected void validate() throws OptionException { // Base implementation does nothing. @@ -272,6 +283,10 @@ public class CommandlineParser { parser.add(option); } + public void add(OptionGroup option) { + parser.add(option); + } + public void printHelp() { parser.printHelp(); } diff --git a/frysk-core/frysk/util/ProcStopUtil.java b/frysk-core/frysk/util/ProcStopUtil.java index af231ed..555997b 100644 --- a/frysk-core/frysk/util/ProcStopUtil.java +++ b/frysk-core/frysk/util/ProcStopUtil.java @@ -48,6 +48,7 @@ import frysk.proc.ProcBlockObserver; import frysk.proc.Task; import frysk.util.CommandlineParser; import gnu.classpath.tools.getopt.Option; +import gnu.classpath.tools.getopt.OptionGroup; import frysk.rsl.Log; /** @@ -113,6 +114,10 @@ public class ProcStopUtil { public void addOption (Option option) { parser.add (option); } + + public void addGroup (OptionGroup option) { + parser.add (option); + } public void execute () { parser.parse(args); @@ -168,4 +173,4 @@ public class ProcStopUtil { System.exit(0); } } -} \ No newline at end of file +} --------------040908090406050200040400--