public inbox for frysk-cvs@sourceware.org
help / color / mirror / Atom feed
From: cagney@sourceware.org
To: frysk-cvs@sourceware.org
Subject: [SCM]  master: Pass util's OptionGroup[]s to CommandlineParser constructor.
Date: Thu, 20 Mar 2008 03:06:00 -0000	[thread overview]
Message-ID: <20080320030644.4893.qmail@sourceware.org> (raw)

The branch, master has been updated
       via  0b1b747862f21b846d25ce05a2d9d823ca6683e4 (commit)
      from  6fa3545e8cdb22a71bc2dfbcc701cf2d232e4bc0 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email.

- Log -----------------------------------------------------------------
commit 0b1b747862f21b846d25ce05a2d9d823ca6683e4
Author: Andrew Cagney <cagney@redhat.com>
Date:   Wed Mar 19 22:48:51 2008 -0400

    Pass util's OptionGroup[]s to CommandlineParser constructor.
    
    frysk-core/frysk/bindir/ChangeLog
    2008-03-19  Phil Muldoon  <pmuldoon@redhat.com>
    	    Andrew Cagney  <cagney@redhat.com>
    
    	* fcore.java (options()): Replace addOptions(ProcStopUtil).
    	(main(String[])): Pass OptionGroup[] to ProcStopUtil constructor.
    	* ftrace.java: Similar.
    	* fstep.java: Similar.
    	* ferror.java: SImilar.
    	* fexe.java: Similiar.
    
    frysk-core/frysk/util/ChangeLog
    2008-03-19  Phil Muldoon  <pmuldoon@redhat.com>
    	    Andrew Cagney  <cagney@redhat.com>
    
    	* CommandlineParser.java (add(Option)): Delete.
    	(CommandlineParser(String,OptionGroup[])): New.
    	(CommandlineParser(String,String,OptionGroup[])): New.
    	(CommandlineParser(String,String)): Delete.
    	* ProcStopUtil.java (ProcStopUtil(String,String[],ProcEvent,
    	OptionGroup[])): New.
    	(addOption(Option)): Delete.
    	* ProcRunUtil.java (ProcRunUtil(String,String,String[],
    	NewTaskObserver,OptionGroup[],RunningUtilOptions)): Replace
    	ProcRunUtil(String,String,String[],NewTaskObserver,Option[],
    	RunningUtilOptions).
    	(ProcRunUtil(String,String,String[],NewTaskObserver[],
    	OptionGroup[],RunningUtilOptions)): Replace ProcRunUtil(String,
    	String,String[],NewTaskObserver[],Option[],RunningUtilOptions).
    	* FCatch.java (run(String[])): Pass NULL as OptionGroup[] to
    	ProcRunUtil.

-----------------------------------------------------------------------

Summary of changes:
 frysk-core/frysk/bindir/ChangeLog            |   10 ++
 frysk-core/frysk/bindir/fcore.java           |  111 ++++++--------
 frysk-core/frysk/bindir/ferror.java          |   40 +++--
 frysk-core/frysk/bindir/fexe.java            |   20 ++-
 frysk-core/frysk/bindir/fstack.java          |  208 ++++++++++++--------------
 frysk-core/frysk/bindir/fstep.java           |  139 +++++++++--------
 frysk-core/frysk/bindir/ftrace.java          |  142 ++++++++----------
 frysk-core/frysk/util/ChangeLog              |   24 +++-
 frysk-core/frysk/util/CommandlineParser.java |   48 ++++---
 frysk-core/frysk/util/FCatch.java            |   15 +--
 frysk-core/frysk/util/ProcRunUtil.java       |   47 +++----
 frysk-core/frysk/util/ProcStopUtil.java      |   24 ++--
 12 files changed, 415 insertions(+), 413 deletions(-)

First 500 lines of diff:
diff --git a/frysk-core/frysk/bindir/ChangeLog b/frysk-core/frysk/bindir/ChangeLog
index e428c8c..92ebce5 100644
--- a/frysk-core/frysk/bindir/ChangeLog
+++ b/frysk-core/frysk/bindir/ChangeLog
@@ -1,3 +1,13 @@
+2008-03-19  Phil Muldoon  <pmuldoon@redhat.com>
+	    Andrew Cagney  <cagney@redhat.com>
+
+	* fcore.java (options()): Replace addOptions(ProcStopUtil).
+	(main(String[])): Pass OptionGroup[] to ProcStopUtil constructor.
+	* ftrace.java: Similar.
+	* fstep.java: Similar.
+	* ferror.java: SImilar.
+	* fexe.java: Similiar.
+
 2008-03-19  Sami Wagiaalla  <swagiaal@redhat.com>  
 
 	* TestFstep.java: New Test.
diff --git a/frysk-core/frysk/bindir/fcore.java b/frysk-core/frysk/bindir/fcore.java
index a5d8862..e34abe4 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;
 
 
@@ -66,69 +67,57 @@ public class fcore {
      * 
      * @param args - pid of the process to core dump
      */
-    public static void main (String[] args)
-    {
+    public static void main (String[] args) {
 	ProcStopUtil fcore = new ProcStopUtil("fcore", args, 
-		                              new createCoreEvent());
-	fcore.setUsage("Usage: fcore <PID>"); 
-	addOptions (fcore);
+		                              new createCoreEvent(),
+					      options());
+	fcore.setUsage("Usage: fcore PID"); 
 	fcore.execute();
     }
-  
+    
     /**
-     * Add options to fcore.
+     * Return the fcore specific options.
      */
-    private static void addOptions (ProcStopUtil fcore)
-    {
-
-      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.")
-	  {
-	      public void parsed (String mapsValue) throws OptionException {
-		  try {
-		      writeAllMaps = true;
-		      mapOptionCount++;
-		  } catch (IllegalArgumentException e) {
-		      throw new OptionException("Invalid maps parameter " + mapsValue);
-		  }
-		  
-	      }
-	  });
-      
-      fcore.addOption(new Option("segments", 's',
-				 "Define what segments to include via regex.",
-				 "RegEx") {
-	      public void parsed(String regEx) throws OptionException {
-		  try {
-		      mapOptionCount++;
-		      matchingRegEx = regEx;
-                    } catch (IllegalArgumentException e) {
-		      throw new OptionException("Invalid match parameter "
-						+ matchingRegEx);
-		  }
-	      }
-	  });
-      
-      
-
-      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.", "<filename>")
-	  {
-	      public void parsed (String filenameValue) throws OptionException {
-		  try {
-		  filename = filenameValue;
-		  }
-		  catch (IllegalArgumentException e) {
-		      throw new OptionException(  "Invalid output filename: "
-						  + filenameValue);
-		  }
-	      }
-	  });
+    private static OptionGroup[] options() {
+	OptionGroup group = new OptionGroup("fcore options");
+	group.add(new Option("allmaps", 'a',
+			     "Include all process readable maps.") {
+		public void parsed (String mapsValue) throws OptionException {
+		    try {
+			writeAllMaps = true;
+			mapOptionCount++;
+		    } catch (IllegalArgumentException e) {
+			throw new OptionException("Invalid maps parameter " + mapsValue);
+		    }
+		}
+	    });
+	group.add(new Option("segments", 's',
+			     "Use PATTERN as regex to define maps inclusion.",
+			     "PATTERN") {
+		public void parsed(String regEx) throws OptionException {
+		    try {
+			mapOptionCount++;
+			matchingRegEx = regEx;
+		    } catch (IllegalArgumentException e) {
+			throw new OptionException("Invalid match parameter "
+						  + matchingRegEx);
+		    }
+		}
+	    });
+	group.add(new Option("outputfile", 'o',
+			     "Set the name of  the output corefile.",
+			     "FILENAME") {
+		public void parsed (String filenameValue) throws OptionException {
+		    try {
+			filename = filenameValue;
+		    }
+		    catch (IllegalArgumentException e) {
+			throw new OptionException(  "Invalid output filename: "
+						    + filenameValue);
+		    }
+		}
+	    });
+	return new OptionGroup[] { group };
     }
     
     /**
@@ -141,8 +130,8 @@ public class fcore {
 	    
 	  
 	    if (mapOptionCount > 1)
-		System.err.println("Please either speciy -stackonly,"+
-		" -allmaps, or -match <pattern> 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 +157,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/bindir/ferror.java b/frysk-core/frysk/bindir/ferror.java
index 10b5561..99b7a4a 100644
--- a/frysk-core/frysk/bindir/ferror.java
+++ b/frysk-core/frysk/bindir/ferror.java
@@ -9,6 +9,7 @@ import frysk.proc.TaskObserver;
 import frysk.proc.TaskObserver.Syscalls;
 import frysk.util.ProcRunUtil;
 import gnu.classpath.tools.getopt.Option;
+import gnu.classpath.tools.getopt.OptionGroup;
 import gnu.classpath.tools.getopt.OptionException;
 import java.util.regex.Pattern;
 import java.util.regex.Matcher;
@@ -17,24 +18,29 @@ import java.io.PrintWriter;
 
 public class ferror {
     
-    static final PrintWriter printWriter = new PrintWriter(System.out);
-    static Pattern writePattern;
+    private static final PrintWriter printWriter = new PrintWriter(System.out);
+    private static Pattern writePattern;
+    private static OptionGroup[] options() {
+	OptionGroup group = new OptionGroup("ferror options");
+	group.add(new Option('e', "--error",
+			     "error regex to catch in double quotes -e \"<error string>\"") {
+		public void parsed(String argument) throws OptionException {
+		    writePattern = Pattern.compile(argument);
+		}  
+	    });
+	return new OptionGroup[] { group };
+		  
+    }
     
-    public static void main (String[] args)
-    {
-       Option option = new Option('e', "--error", "error regex to catch in double quotes -e \"<error string>\""){
-
-	public void parsed(String argument) throws OptionException {
-	    writePattern = Pattern.compile(argument);
-	}  
-       };
-	
-       ProcRunUtil procRunningUtil = 
-	   new ProcRunUtil("ferror",
-		   "ferror -e \"<error string>\" -- <executbale|PID> [ARGS]",
-		   args, 
-		   new TaskObserver[]{syscallObserver},new Option[]{option} , ProcRunUtil.DEFAULT);
-       procRunningUtil.start();
+    public static void main(String[] args) {
+	ProcRunUtil procRunningUtil = 
+	    new ProcRunUtil("ferror",
+			    "ferror -e \"<error string>\" -- <executbale|PID> [ARGS]",
+			    args, 
+			    new TaskObserver[]{ syscallObserver },
+			    options(),
+			    ProcRunUtil.DEFAULT);
+	procRunningUtil.start();
     }
 
     
diff --git a/frysk-core/frysk/bindir/fexe.java b/frysk-core/frysk/bindir/fexe.java
index 3f203b8..962be16 100644
--- a/frysk-core/frysk/bindir/fexe.java
+++ b/frysk-core/frysk/bindir/fexe.java
@@ -46,22 +46,28 @@ import frysk.event.ProcEvent;
 import frysk.proc.Proc;
 import frysk.sys.proc.Exe;
 import gnu.classpath.tools.getopt.Option;
+import gnu.classpath.tools.getopt.OptionGroup;
 
 public class fexe 
 {
     static boolean verbose = false;
     
-    public static void main (String[] args) {
-	
-	PrintExeEvent printExe = new PrintExeEvent();
-	ProcStopUtil fexe = new ProcStopUtil("fexe", args, printExe);
-	fexe.setUsage("Usage: fexe <PID> || fexe <EXEFILE> " +
-                      "|| fexe <COREFILE> [<EXEFILE>]"); 
-	fexe.addOption(new Option('v', "More verbose output") {
+    private static OptionGroup[] options() {
+	OptionGroup group = new OptionGroup("fexe options");
+	group.add(new Option('v', "More verbose output") {
 		public void parsed (String val) {
 		    verbose = true;
 		}
 	    });
+	return new OptionGroup[] { group };
+    }
+
+    public static void main(String[] args) {
+	PrintExeEvent printExe = new PrintExeEvent();
+	ProcStopUtil fexe = new ProcStopUtil("fexe", args, printExe,
+					     options());
+	fexe.setUsage("Usage: fexe <PID> || fexe <EXEFILE> " +
+                      "|| fexe <COREFILE> [<EXEFILE>]"); 
 	fexe.execute();
     }
     
diff --git a/frysk-core/frysk/bindir/fstack.java b/frysk-core/frysk/bindir/fstack.java
index 9b57a78..4ad3c82 100644
--- a/frysk-core/frysk/bindir/fstack.java
+++ b/frysk-core/frysk/bindir/fstack.java
@@ -54,6 +54,7 @@ import frysk.rsl.Log;
 import frysk.stack.StackFactory;
 import frysk.util.ProcStopUtil;
 import gnu.classpath.tools.getopt.Option;
+import gnu.classpath.tools.getopt.OptionGroup;
 import gnu.classpath.tools.getopt.OptionException;
 
 public final class fstack {
@@ -62,14 +63,13 @@ public final class fstack {
   static PrintStackOptions options = new PrintStackOptions();
   private static final Log fine = Log.fine(fstack.class);
   
-  public static void main (String[] args)
-  {
-      ProcStopUtil fstack = new ProcStopUtil("fstack", args, 
-                                              new StackerEvent());
-      fstack.setUsage("Usage: fstack <PID> || fstack <COREFILE> [<EXEFILE>]");   
-      addOptions (fstack);
-      fstack.execute();
-  }
+    public static void main(String[] args) {
+	ProcStopUtil fstack = new ProcStopUtil("fstack", args, 
+					       new StackerEvent(),
+					       options());
+	fstack.setUsage("Usage: fstack <PID> || fstack <COREFILE> [<EXEFILE>]");   
+	fstack.execute();
+    }
   
   /**
    * Implements a ProcEvent for core file creation.
@@ -121,109 +121,91 @@ public final class fstack {
       }
   }
   
-  /**
-   * Add options to fstack.
-   */
-  private static void addOptions (ProcStopUtil fstack) {
-      fstack.addOption(new Option("number-of-frames", 'n', "number of frames to print. Use -n 0 or" +
-                                  " -n all to print all frames.", "<number of frames>") {
-          public void parsed(String arg) throws OptionException {
-              if(arg.equals("all")){
-                  options.setNumberOfFrames(0);
-              }else{
-                  options.setNumberOfFrames(Integer.parseInt(arg));
-                  return;
-              }
-          }
-      });
- 
-      fstack.addOption(new Option("fullpath", 'f', "print full path." +
-                                  "-f prints full path") {
-          public void parsed(String arg) throws OptionException {
-                options.setPrintFullpath(true);
-          }
-      });
-
-
-      fstack.addOption(new Option("all", 'a', "print all information that can currently be retrieved" +
-                                  "about the stack\n" +
-                                  "this is equivalent to -p functions,params,scopes,fullpath"){
-
-                public void parsed (String argument) throws OptionException
-                {
-                  options.setElfOnly(false);
-                  options.setPrintParameters(true);
-                  options.setPrintScopes(true);
-                  options.setPrintFullpath(true);
-                }
-              });
-    
-      fstack.addOption(new Option(
-                        "virtual",
-                        'v',
-                        "Includes virtual frames in the stack trace.\n" +
-                        "Virtual frames are artificial frames corresponding" +
-                        " to calls to inlined functions") {
-
-                    public void parsed(String argument) throws OptionException {
-                        options.setPrintVirtualFrames(true);
-                        options.setElfOnly(false);
-                    }
-                });
-
-
-      fstack.addOption(new Option("common", 'c', "print commonly used debug information:" +
-                          "this is equivalent to fstack -v -p functions,params,fullpath"){
-
-                public void parsed (String argument) throws OptionException
-                {
-                  options.setElfOnly(false);
-                  options.setPrintParameters(true);
-                  options.setPrintScopes(false);
-                  options.setPrintFullpath(true);
-                  options.setPrintVirtualFrames(true);
-                }
-    });
-              
-      fstack.addOption(new Option("print", 'p', "itmes to print. Possible items:\n" +
-                "functions : print function names using debug information\n" +
-                "scopes : print variables declared in each scope within the " +
-                "function.\n" +
-                "params : print function parameters\n" +
-                "fullpath : print full executbale path" , "[item],...") {
-      
-      public void parsed(String arg) throws OptionException
-      {
-        options.setElfOnly(true);
-        options.setPrintParameters(false);
-        options.setPrintScopes(false);
-        options.setPrintFullpath(false);
-        options.setPrintVirtualFrames(false);
-
-          StringTokenizer st = new StringTokenizer(arg, ",");
-          while (st.hasMoreTokens())
-          {
-            String name = st.nextToken();
-            if(name.equals("functions")){
-              options.setElfOnly(false);
-            }
-            
-            if(name.equals("params")){
-              options.setElfOnly(false);
-              options.setPrintParameters(true);
-            }
-            
-            if(name.equals("scopes")){
-              options.setElfOnly(false);
-              options.setPrintScopes(true);
-            }
-            
-            if(name.equals("fullpath")){
-              options.setElfOnly(false);
-              options.setPrintFullpath(true);
-            }
-          }
-      }
-      }); 
-  }
+    /**
+     * Create the default option group.
+     */
+    private static OptionGroup[] options() {
+	OptionGroup group = new OptionGroup("fstack options");
+	group.add(new Option("number-of-frames", 'n', "number of frames to print. Use -n 0 or" +
+			     " -n all to print all frames.", "<number of frames>") {
+		public void parsed(String arg) throws OptionException {
+		    if(arg.equals("all")){
+			options.setNumberOfFrames(0);
+		    }else{
+			options.setNumberOfFrames(Integer.parseInt(arg));
+			return;
+		    }
+		}
+	    });
+	group.add(new Option("fullpath", 'f', "print full path." +
+			     "-f prints full path") {
+		public void parsed(String arg) throws OptionException {
+		    options.setPrintFullpath(true);
+		}
+	    });
+	group.add(new Option("all", 'a', "print all information that can currently be retrieved" +
+			     "about the stack\n" +
+			     "this is equivalent to -p functions,params,scopes,fullpath") {
+		public void parsed(String argument) throws OptionException {
+		    options.setElfOnly(false);
+		    options.setPrintParameters(true);
+		    options.setPrintScopes(true);
+		    options.setPrintFullpath(true);
+		}
+	    });
+	group.add(new Option("virtual",
+			     'v',
+			     "Includes virtual frames in the stack trace.\n" +
+			     "Virtual frames are artificial frames corresponding" +
+			     " to calls to inlined functions") {
+		public void parsed(String argument) throws OptionException {
+		    options.setPrintVirtualFrames(true);
+		    options.setElfOnly(false);
+		}
+	    });
+	group.add(new Option("common", 'c', "print commonly used debug information:" +
+			     "this is equivalent to fstack -v -p functions,params,fullpath") {
+		public void parsed(String argument) throws OptionException {
+		    options.setElfOnly(false);
+		    options.setPrintParameters(true);
+		    options.setPrintScopes(false);
+		    options.setPrintFullpath(true);
+		    options.setPrintVirtualFrames(true);
+		}
+	    });
+	group.add(new Option("print", 'p', "itmes to print. Possible items:\n" +
+			     "functions : print function names using debug information\n" +
+			     "scopes : print variables declared in each scope within the " +
+			     "function.\n" +
+			     "params : print function parameters\n" +
+			     "fullpath : print full executbale path" , "[item],...") {
+		public void parsed(String arg) throws OptionException {
+		    options.setElfOnly(true);
+		    options.setPrintParameters(false);
+		    options.setPrintScopes(false);
+		    options.setPrintFullpath(false);
+		    options.setPrintVirtualFrames(false);
+		    StringTokenizer st = new StringTokenizer(arg, ",");
+		    while (st.hasMoreTokens()) {
+			String name = st.nextToken();
+			if (name.equals("functions")) {
+			    options.setElfOnly(false);
+			} else if (name.equals("params")) {
+			    options.setElfOnly(false);
+			    options.setPrintParameters(true);
+			} else if (name.equals("scopes")) {
+			    options.setElfOnly(false);
+			    options.setPrintScopes(true);
+			} else if (name.equals("fullpath")) {
+			    options.setElfOnly(false);
+			    options.setPrintFullpath(true);
+			} else {
+			    throw new OptionException
+				("unknown print parameter: " + name);
+			}
+		    }
+		}
+	    });
+	return new OptionGroup[] { group };
+    }
 }
diff --git a/frysk-core/frysk/bindir/fstep.java b/frysk-core/frysk/bindir/fstep.java
index 0376110..efde87c 100644
--- a/frysk-core/frysk/bindir/fstep.java
+++ b/frysk-core/frysk/bindir/fstep.java


hooks/post-receive
--
frysk system monitor/debugger


                 reply	other threads:[~2008-03-20  3:06 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20080320030644.4893.qmail@sourceware.org \
    --to=cagney@sourceware.org \
    --cc=frysk-cvs@sourceware.org \
    --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).