public inbox for frysk-cvs@sourceware.org
help / color / mirror / Atom feed
* [SCM]  master: Refactor fexe to use ProcStopUtil.
@ 2008-02-20 19:27 tthomas
  0 siblings, 0 replies; only message in thread
From: tthomas @ 2008-02-20 19:27 UTC (permalink / raw)
  To: frysk-cvs

The branch, master has been updated
       via  c090884f02c5f144dd60c09657f9890aa859fa7f (commit)
      from  79c3336ab437f84fdcf207540d1cb68954ed2719 (commit)

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

- Log -----------------------------------------------------------------
commit c090884f02c5f144dd60c09657f9890aa859fa7f
Author: Teresa Thomas <tthomas@redhat.com>
Date:   Wed Feb 20 14:01:15 2008 -0500

    Refactor fexe to use ProcStopUtil.
    
    frysk-core/frysk/bindir/ChangeLog:
    2008-02-20  Teresa Thomas  <tthomas@redhat.com>
    
    	* fexe.java: Refactor to use ProcStopUtil.
    	* fdebuginfo.java (PrintDebuginfoEvent): Update.
    	* fauxv.java (PrintAuxvEvent): Update.
    	* fmaps.java (PrintMapsEvent): Update.
    
    frysk-core/frysk/event/ChangeLog:
    2008-02-20  Teresa Thomas  <tthomas@redhat.com>
    
    	* ProcEvent.java (setProcData): New.
    
    frysk-core/frysk/util/ChangeLog:
    2008-02-20  Teresa Thomas  <tthomas@redhat.com>
    
    	* ProcStopUtil.java (.parseCores): Call setProcData.

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

Summary of changes:
 frysk-core/frysk/bindir/ChangeLog       |    9 +++-
 frysk-core/frysk/bindir/fauxv.java      |    6 ++
 frysk-core/frysk/bindir/fdebuginfo.java |   82 ++++++++++++++------------
 frysk-core/frysk/bindir/fexe.java       |   95 +++++++++++++++----------------
 frysk-core/frysk/bindir/fmaps.java      |    8 ++-
 frysk-core/frysk/event/ChangeLog        |    4 +
 frysk-core/frysk/event/ProcEvent.java   |   12 ++++-
 frysk-core/frysk/util/ChangeLog         |    4 +
 frysk-core/frysk/util/ProcStopUtil.java |   85 ++++++++++++++-------------
 9 files changed, 174 insertions(+), 131 deletions(-)

First 500 lines of diff:
diff --git a/frysk-core/frysk/bindir/ChangeLog b/frysk-core/frysk/bindir/ChangeLog
index f60e599..5ead415 100644
--- a/frysk-core/frysk/bindir/ChangeLog
+++ b/frysk-core/frysk/bindir/ChangeLog
@@ -1,8 +1,15 @@
+2008-02-20  Teresa Thomas  <tthomas@redhat.com>
+
+	* fexe.java: Refactor to use ProcStopUtil.
+	* fdebuginfo.java (PrintDebuginfoEvent): Update.
+	* fauxv.java (PrintAuxvEvent): Update.
+	* fmaps.java (PrintMapsEvent): Update.
+	
 2008-02-20  Petr Machata  <pmachata@redhat.com>
 
 	* ftrace.java: Use globs instead of regular expressions.
 	(Glob): New class.
-
+	
 2008-02-19  Andrew Cagney  <cagney@redhat.com>
 
 	* TestFstep.java: Update to match lib.dwfl.Elf.
diff --git a/frysk-core/frysk/bindir/fauxv.java b/frysk-core/frysk/bindir/fauxv.java
index 7fa2b37..9dfdc37 100644
--- a/frysk-core/frysk/bindir/fauxv.java
+++ b/frysk-core/frysk/bindir/fauxv.java
@@ -39,6 +39,8 @@
 
 package frysk.bindir;
 
+import java.io.File;
+
 import frysk.event.ProcEvent;
 import frysk.proc.Proc;
 import frysk.util.AuxvStringBuilder;
@@ -75,5 +77,9 @@ public class fauxv {
         	System.out.print(buildAuxv.auxvData.toString());
             }
         }
+        
+	public void setProcData (File coreFile) {
+	    // Implementation not required here.
+	}
     }
 }
diff --git a/frysk-core/frysk/bindir/fdebuginfo.java b/frysk-core/frysk/bindir/fdebuginfo.java
index 161f2a6..a57f666 100644
--- a/frysk-core/frysk/bindir/fdebuginfo.java
+++ b/frysk-core/frysk/bindir/fdebuginfo.java
@@ -1,44 +1,46 @@
-//This file is part of the program FRYSK.
-
-//Copyright  2008 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.
+// This file is part of the program FRYSK.
+//
+// Copyright 2008, 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.bindir;
 
+import java.io.File;
+
 import frysk.event.ProcEvent;
 import frysk.proc.Proc;
 import frysk.proc.Task;
@@ -72,5 +74,9 @@ public final class fdebuginfo
 	    if (dInfo!=null)
 		System.out.print(dInfo); 
 	}	
+	
+	public void setProcData (File coreFile) {
+	    // Implementation not required here.
+	}
     }
 }
\ No newline at end of file
diff --git a/frysk-core/frysk/bindir/fexe.java b/frysk-core/frysk/bindir/fexe.java
index b6ee139..ec6b6ce 100644
--- a/frysk-core/frysk/bindir/fexe.java
+++ b/frysk-core/frysk/bindir/fexe.java
@@ -41,65 +41,62 @@ package frysk.bindir;
 
 import frysk.sys.ProcessIdentifier;
 import frysk.sys.ProcessIdentifierFactory;
-import frysk.util.CommandlineParser;
-import frysk.util.Util;
+import frysk.util.ProcStopUtil;
+import frysk.event.ProcEvent;
 import frysk.proc.Proc;
 import frysk.sys.proc.Exe;
 import gnu.classpath.tools.getopt.Option;
 import java.io.File;
-import frysk.util.CoreExePair;
 
-public class fexe {
+public class fexe 
+{
     static boolean verbose = false;
+    
     public static void main (String[] args) {
-	// Parse command line. Check pid provided.
-	CommandlineParser parser = new CommandlineParser("fexe") {
-		public void parseCores (CoreExePair[] corePairs) {
-		    for (int i = 0; i < corePairs.length; i++) {
-			File coreFile = corePairs[i].coreFile;
-			File exeFile = corePairs[i].exeFile;
-			Proc proc;
-			if (exeFile == null)
-			    proc = Util.getProcFromCoreFile(coreFile);
-			else
-			    proc = Util.getProcFromCoreFile(coreFile, exeFile);
-			if (verbose) {
-			    System.out.println(coreFile.getPath()
-					       + " "
-					       + proc.getExe());
-			} else {
-			    System.out.println(proc.getExe());
-			}
-		    }
-		    System.exit(0);
-		}
-		public void parsePids(Proc[] procs) {
-		    for (int i= 0; i< procs.length; i++) {
-			Proc proc = procs[i];
-			ProcessIdentifier pid
-			    = ProcessIdentifierFactory.create(proc.getPid());
-			if (verbose) {
-			    System.out.println(proc.getPid()
-					       + " "
-					       + proc.getExe()
-					       + " "
-					       + Exe.get(pid));
-			} else {
-			    System.out.println(proc.getExe());
-			}
-		    }
-		    System.exit(0);
-		}
-	    };
-	parser.add(new Option('v', "More verbose output") {
+	
+	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") {
 		public void parsed (String val) {
 		    verbose = true;
 		}
 	    });
-	parser.parse(args);
-	//If we got here, we didn't find a pid.
-	System.err.println("Error: No PID or COREFILE.");
-	parser.printHelp();
-	System.exit(1);
+	fexe.execute();
+    }
+    
+    private static class PrintExeEvent implements ProcEvent
+    {	
+	private File coreFile;
+	
+	public void setProcData (File coreFile) {
+	    this.coreFile = coreFile;
+	}
+	
+	public void execute(Proc proc) {
+
+	    if (verbose) {
+		// Corefiles		
+		if (coreFile != null) 
+		    System.out.println(coreFile.getPath()
+			               + " "
+			               + proc.getExe());
+		// Processes
+		else if (proc.getPid() != 0) {
+		    ProcessIdentifier pid
+		     = ProcessIdentifierFactory.create(proc.getPid());
+		    System.out.println(proc.getPid()
+			               + " "
+			               + proc.getExe()
+			               + " "
+			               + Exe.get(pid));
+		}
+		// Executables
+		else 
+		    System.out.println(proc.getExe());
+	    } else 
+		System.out.println(proc.getExe());
+	}
     }
 }
diff --git a/frysk-core/frysk/bindir/fmaps.java b/frysk-core/frysk/bindir/fmaps.java
index 7a328b1..2cd08b3 100644
--- a/frysk-core/frysk/bindir/fmaps.java
+++ b/frysk-core/frysk/bindir/fmaps.java
@@ -39,6 +39,8 @@
 
 package frysk.bindir;
 
+import java.io.File;
+
 import frysk.util.ProcStopUtil;
 import frysk.event.ProcEvent;
 import frysk.proc.Proc;
@@ -60,6 +62,10 @@ public class fmaps {
 	    MemoryMap[] maps = proc.getMaps();
 	    for(int i=0; i<maps.length; i++)
 		System.out.println(maps[i].toString());
-	}	
+	}
+	
+	public void setProcData (File coreFile) {
+	    // Implementation not required here.
+	}
     }
 }
diff --git a/frysk-core/frysk/event/ChangeLog b/frysk-core/frysk/event/ChangeLog
index 5a0e1a6..b42be74 100644
--- a/frysk-core/frysk/event/ChangeLog
+++ b/frysk-core/frysk/event/ChangeLog
@@ -1,3 +1,7 @@
+2008-02-20  Teresa Thomas  <tthomas@redhat.com>
+
+	* ProcEvent.java (setProcData): New.
+
 2008-02-13  Andrew Cagney  <cagney@redhat.com>
 
 	* WaitEventLoop.java: Update to match frysk.sys.Wait.
diff --git a/frysk-core/frysk/event/ProcEvent.java b/frysk-core/frysk/event/ProcEvent.java
index 265dc65..0e4c7c1 100644
--- a/frysk-core/frysk/event/ProcEvent.java
+++ b/frysk-core/frysk/event/ProcEvent.java
@@ -40,11 +40,21 @@
 package frysk.event;
 
 import frysk.proc.Proc;
+import java.io.File;
 
 /**
- * The proc event interface.
+ * The proc event interface. Used by frysk utilities.
  */
 public interface ProcEvent
 {
     void execute (Proc proc);
+    
+    /**
+     * Use to set proc specific information. 
+     * 
+     * XXX: Add parameters to this function for 
+     * access to more process specific information 
+     * by the utilities. 
+     */
+    void setProcData (File coreFile);
 }
diff --git a/frysk-core/frysk/util/ChangeLog b/frysk-core/frysk/util/ChangeLog
index fb96bc0..4addd82 100644
--- a/frysk-core/frysk/util/ChangeLog
+++ b/frysk-core/frysk/util/ChangeLog
@@ -1,3 +1,7 @@
+2008-02-20  Teresa Thomas  <tthomas@redhat.com>
+
+	* ProcStopUtil.java (.parseCores): Call setProcData.
+
 2008-02-19  Andrew Cagney  <cagney@redhat.com>
 
 	* TestCoredumpAction.java: Fix merge botch.
diff --git a/frysk-core/frysk/util/ProcStopUtil.java b/frysk-core/frysk/util/ProcStopUtil.java
index 92e10cc..c859fe0 100644
--- a/frysk-core/frysk/util/ProcStopUtil.java
+++ b/frysk-core/frysk/util/ProcStopUtil.java
@@ -1,41 +1,41 @@
-//This file is part of the program FRYSK.
-
-//Copyright 2008, 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.
+// This file is part of the program FRYSK.
+//
+// Copyright 2008, 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.util;
 
@@ -66,7 +66,8 @@ public class ProcStopUtil
     private Proc proc;
     private String[] args;
     private CommandlineParser parser;
-    
+    private File coreFile;
+	
     public ProcStopUtil (String utilName, String[] args, 
 	                  final ProcEvent procEvent) {
 	this.args = args;
@@ -86,6 +87,8 @@ public class ProcStopUtil
 	    {
 		for (int i = 0; i < coreExePairs.length; i++)
 		{       
+		    coreFile = coreExePairs[i].coreFile;
+		    procEvent.setProcData  (coreFile);
 		    proc = Util.getProcFromCoreExePair(coreExePairs[i]);
 		    failIfProcNull(proc);
 		    procEvent.execute(proc);
@@ -109,8 +112,8 @@ public class ProcStopUtil
 		}
 	    }
 	};
-    }
-
+    }    
+    
     /**
      * Use to set the usage of utility.
      * 


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


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2008-02-20 19:27 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-02-20 19:27 [SCM] master: Refactor fexe to use ProcStopUtil tthomas

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).