public inbox for frysk-cvs@sourceware.org
help / color / mirror / Atom feed
* [SCM]  master: Move CoredumpAction, TestCoredumpAction from fysk.util to frysk.testbed.
@ 2008-02-26 17:33 tthomas
  0 siblings, 0 replies; only message in thread
From: tthomas @ 2008-02-26 17:33 UTC (permalink / raw)
  To: frysk-cvs

The branch, master has been updated
       via  5ce6003ba22a6106161962b9935bc746f5ee69ca (commit)
       via  99cfecd4ed14b0aedc54961a6c15d20c7a6501e4 (commit)
      from  4454bcc2dd04291821f28d4e17044ab2d1d659b6 (commit)

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

- Log -----------------------------------------------------------------
commit 5ce6003ba22a6106161962b9935bc746f5ee69ca
Author: Teresa Thomas <tthomas@redhat.com>
Date:   Tue Feb 26 11:51:57 2008 -0500

    Move CoredumpAction, TestCoredumpAction from fysk.util to frysk.testbed.
    
    frysk-core/frysk/testbed/ChangeLog:
    2008-02-26  Teresa Thomas  <tthomas@redhat.com>
    
    	* TestCoredumpAction.java: Moved from frysk.util.
    	* CoredumpAction.java: Ditto.
    	* CorefileFactory.java: Update imports.
    
    frysk-core/frysk/util/ChangeLog:
    2008-02-26  Teresa Thomas  <tthomas@redhat.com>
    
    	* TestCoredumpAction.java: Move to frysk.testbed.
    	* CoredumpAction.java: Ditto.
    
    frysk-core/frysk/proc/dead/ChangeLog:
    2008-02-26  Teresa Thomas  <tthomas@redhat.com>
    
    	* TestLinuxCore.java: Update imports.

commit 99cfecd4ed14b0aedc54961a6c15d20c7a6501e4
Author: Teresa Thomas <tthomas@redhat.com>
Date:   Tue Feb 26 11:34:27 2008 -0500

    Refactor fcore to use ProcStopUtil.
    
    frysk-core/frysk/bindir/ChangeLog:
    2008-02-26  Teresa Thomas  <tthomas@redhat.com>
    
    	* fcore.java: Refactor to use ProcStopUtil.
    	* TestFcore.java: Update.
    
    frysk-core/frysk/util/ChangeLog:
    2008-02-26  Teresa Thomas  <tthomas@redhat.com>
    
    	* ProcStopUtil.java (.parseCommand): Indent.

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

Summary of changes:
 frysk-core/frysk/bindir/ChangeLog                  |    5 +
 frysk-core/frysk/bindir/TestFcore.java             |    4 +-
 frysk-core/frysk/bindir/fcore.java                 |  244 +++++++++-----------
 frysk-core/frysk/proc/dead/ChangeLog               |    4 +
 frysk-core/frysk/proc/dead/TestLinuxCore.java      |    2 +-
 frysk-core/frysk/testbed/ChangeLog                 |    6 +
 .../frysk/{util => testbed}/CoredumpAction.java    |    2 +-
 frysk-core/frysk/testbed/CorefileFactory.java      |    2 +-
 .../{util => testbed}/TestCoredumpAction.java      |    2 +-
 frysk-core/frysk/util/ChangeLog                    |    7 +
 frysk-core/frysk/util/ProcStopUtil.java            |    2 +-
 11 files changed, 134 insertions(+), 146 deletions(-)
 rename frysk-core/frysk/{util => testbed}/CoredumpAction.java (100%)
 rename frysk-core/frysk/{util => testbed}/TestCoredumpAction.java (100%)

First 500 lines of diff:
diff --git a/frysk-core/frysk/bindir/ChangeLog b/frysk-core/frysk/bindir/ChangeLog
index 44cc131..abdd757 100644
--- a/frysk-core/frysk/bindir/ChangeLog
+++ b/frysk-core/frysk/bindir/ChangeLog
@@ -1,3 +1,8 @@
+2008-02-26  Teresa Thomas  <tthomas@redhat.com>
+
+	* fcore.java: Refactor to use ProcStopUtil.
+	* TestFcore.java: Update.
+
 2008-02-21  Teresa Thomas  <tthomas@redhat.com>
 
 	* fexe.java (PrintExeEvent): Update for changes 
diff --git a/frysk-core/frysk/bindir/TestFcore.java b/frysk-core/frysk/bindir/TestFcore.java
index b01f149..9847fdd 100644
--- a/frysk-core/frysk/bindir/TestFcore.java
+++ b/frysk-core/frysk/bindir/TestFcore.java
@@ -46,7 +46,7 @@ import frysk.Config;
 public class TestFcore extends TestLib {
     public void testNoArguments() {
 	TearDownExpect e = new TearDownExpect(Config.getBinFile("fcore"));
-	e.expect("Error: No pid provided.");      
+	e.expect("ERROR: No argument provided.");    
     }
 
     public void testBadArguments () {
@@ -54,7 +54,7 @@ public class TestFcore extends TestLib {
 		Config.getBinFile("fcore").getAbsolutePath (),
 		"this is a bad argument"
 	    });
-	e.expect("Error: Commands not supported.");
+	e.expect("File does not exist or is not readable or is not a file.");
     }
 
     public void testBadConsoleParameter () {
diff --git a/frysk-core/frysk/bindir/fcore.java b/frysk-core/frysk/bindir/fcore.java
index 6a92ba4..eada166 100644
--- a/frysk-core/frysk/bindir/fcore.java
+++ b/frysk-core/frysk/bindir/fcore.java
@@ -40,162 +40,128 @@
 package frysk.bindir;
 
 import java.util.logging.Logger;
+import java.io.File;
 
-import frysk.event.Event;
+import frysk.event.ProcEvent;
 
-import frysk.proc.Manager;
 import frysk.proc.Proc;
-import frysk.proc.ProcBlockAction;
+import frysk.proc.Task;
 
-import frysk.util.CommandlineParser;
-import frysk.util.CoredumpAction;
+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.OptionException;
 
 
 public class fcore
 {
-
-  private static String filename = "core";
-
-  private static boolean writeAllMaps = false;
-
-  private static boolean stackOnly = false;
-
-  private static CoredumpAction stacker;
-
-  protected static final Logger logger = Logger.getLogger("frysk");
-  private static CommandlineParser parser;
-
-  private static class AbandonCoreEvent implements Event
-  {
-    private Proc coreProc;
-
-    AbandonCoreEvent(Proc coreProc)
-    {
-      this.coreProc = coreProc;
-    }
-    
-    public void execute()
-    {
-      coreProc.requestAbandonAndRunEvent(new Event()
-      {
-
-        public void execute ()
-        {
-          Manager.eventLoop.requestStop();
-        }
-      });
-    }
-  }
+    private static String filename = "core";  
+    private static boolean writeAllMaps = false;
+    private static boolean stackOnly = false;
+    protected static final Logger logger = Logger.getLogger("frysk");
   
-    public static void dumpPid(Proc proc) {
-	stacker = new CoredumpAction(proc, filename, 
-				     new AbandonCoreEvent(proc),
-				     writeAllMaps,
-				     stackOnly);
-	new ProcBlockAction(proc, stacker);
-	Manager.eventLoop.run();
+    /**
+     * Entry function. Starts the fcore dump process. Belongs in bindir/fcore. But
+     * here for now.
+     * 
+     * @param args - pid of the process to core dump
+     */
+    public static void main (String[] args)
+    {
+	ProcStopUtil fcore = new ProcStopUtil("fcore", args, 
+		                              new createCoreEvent());
+	fcore.setUsage("Usage: fcore <PID>"); 
+	addOptions (fcore);
+	fcore.execute();
     }
   
-  /**
-   * Entry function. Starts the fcore dump process. Belongs in bindir/fcore. But
-   * here for now.
-   * 
-   * @param args - pid of the process to core dump
-   */
-  public static void main (String[] args)
-  {
-
-      // Parse command line. Check pid provided.
-      parser = new CommandlineParser("fcore") {
-	      //@Override
-	      public void parsePids(Proc[] pids) {
-		  for (int i= 0; i< pids.length; i++)
-		      dumpPid(pids[i]);
-		  System.exit(0);
-	      }
-	  };
-
-    addOptions(parser);
-
-    parser.setHeader("Usage: fcore [-a] [-stack] [-o filename] [-c level] [-l level] <pids>");
-
-    parser.parse(args);
-
-    //If we got here, we didn't find a pid.
-    System.err.println("Error: No pid provided.");
-    parser.printHelp();
-    System.exit(1);
-  }
-
-  /**
-   * Add options to the the option parser. Belongs
-   * 
-   * @param parser - the parser that is to be worked on.
-   */
-  private static void addOptions (CommandlineParser parser)
-  {
-
-    parser.add(new Option("stack", 's',
-                          " Writes only stack segment, and elides all "+
-                          "other maps.")
+    /**
+     * Add options to fcore.
+     */
+    private static void addOptions (ProcStopUtil fcore)
     {
-      public void parsed (String mapsValue) throws OptionException
+	fcore.addOption(new Option("stack", 's',
+		                   " Writes only stack segment, and elides all"
+		                 + " other maps.")
+	{
+	    public void parsed (String mapsValue) throws OptionException {
+		try {
+		    stackOnly = true;
+		} catch (IllegalArgumentException e) {
+		    throw new OptionException( "Invalid maps parameter " 
+			                      + mapsValue);
+		}
+
+	    }
+	});
+
+      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.")
       {
-        try
-          {
-            stackOnly = true;
-
-          }
-        catch (IllegalArgumentException e)
-          {
-            throw new OptionException("Invalid maps parameter " + mapsValue);
-          }
+	  public void parsed (String mapsValue) throws OptionException {
+	      try {
+		  writeAllMaps = true;
+		  stackOnly = false;
+	      } catch (IllegalArgumentException e) {
+		  throw new OptionException("Invalid maps parameter " + mapsValue);
+	      }
 
-      }
-    });
+	  }
+      });
 
-    parser.add(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
+      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>")
       {
-        try
-          {
-            writeAllMaps = true;
-	    stackOnly = false;
-          }
-        catch (IllegalArgumentException e)
-          {
-            throw new OptionException("Invalid maps parameter " + mapsValue);
-          }
-
-      }
-    });
-
-    parser.add(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);
+	      }
+	  }
+      });
+    }
+    
+    /**
+     * Implements a ProcEvent for core file creation.
+     */
+    private static class createCoreEvent implements ProcEvent
     {
-      public void parsed (String filenameValue) throws OptionException
-      {
-        try
-          {
-            filename = filenameValue;
-
-          }
-        catch (IllegalArgumentException e)
-          {
-            throw new OptionException("Invalid output filename: "
-                                      + filenameValue);
-          }
-
-      }
-    });
-  }
+	public void executeLive(Proc proc) {
+	    
+	    Task[] tasks = (Task[]) proc.getTasks().toArray
+	                   (new Task[proc.getTasks().size()]);
+	    LinuxElfCorefile coreFile = LinuxElfCorefileFactory.
+	                                getCorefile(proc, tasks);
+	  
+	    if (coreFile == null) {
+		System.err.println (  "Architecture not supported or "
+			            + "LinuxElfCorefileFactory returned null");
+	    } else {
+		coreFile.setName(filename);
+		coreFile.setWriteAllMaps(writeAllMaps);
+		coreFile.setStackOnly(stackOnly);
+
+		try {
+		    coreFile.constructCorefile();
+		} catch (RuntimeException e) {
+		    System.err.println (  "Architecture not supported or "
+			                + "LinuxElfCorefileFactory returned null");		    
+		}
+	    }
+	}
+	
+	public void executeDead(Proc proc, File coreFile) {
+	    System.err.println ("Cannot create core file from dead process");
+	}
+    }
 }
diff --git a/frysk-core/frysk/proc/dead/ChangeLog b/frysk-core/frysk/proc/dead/ChangeLog
index a94b903..eef2273 100644
--- a/frysk-core/frysk/proc/dead/ChangeLog
+++ b/frysk-core/frysk/proc/dead/ChangeLog
@@ -1,3 +1,7 @@
+2008-02-26  Teresa Thomas  <tthomas@redhat.com>
+
+	* TestLinuxCore.java: Update imports.
+
 2008-02-26  Andrew Cagney  <cagney@redhat.com>
 
 	* LinuxCoreInfo.java: New.  Fold in LinuxCoreFactory,
diff --git a/frysk-core/frysk/proc/dead/TestLinuxCore.java b/frysk-core/frysk/proc/dead/TestLinuxCore.java
index 2c132bc..2860a80 100644
--- a/frysk-core/frysk/proc/dead/TestLinuxCore.java
+++ b/frysk-core/frysk/proc/dead/TestLinuxCore.java
@@ -67,7 +67,7 @@ import frysk.testbed.DaemonBlockedAtSignal;
 import frysk.testbed.LegacyOffspring;
 import frysk.testbed.TearDownFile;
 import frysk.testbed.TestLib;
-import frysk.util.CoredumpAction;
+import frysk.testbed.CoredumpAction;
 import frysk.util.StacktraceAction;
 
 public class TestLinuxCore extends TestLib {
diff --git a/frysk-core/frysk/testbed/ChangeLog b/frysk-core/frysk/testbed/ChangeLog
index a6a6ed6..18e1cd1 100644
--- a/frysk-core/frysk/testbed/ChangeLog
+++ b/frysk-core/frysk/testbed/ChangeLog
@@ -1,3 +1,9 @@
+2008-02-26  Teresa Thomas  <tthomas@redhat.com>
+
+	* TestCoredumpAction.java: Move from frysk.util.
+	* CoredumpAction.java: Ditto.
+	* CorefileFactory.java: Update imports.
+
 2008-02-14  Andrew Cagney  <cagney@redhat.com>
 
 	* StatState.java: Update to match Stat rewrite.
diff --git a/frysk-core/frysk/util/CoredumpAction.java b/frysk-core/frysk/testbed/CoredumpAction.java
similarity index 100%
rename from frysk-core/frysk/util/CoredumpAction.java
rename to frysk-core/frysk/testbed/CoredumpAction.java
index b17ca81..6a26ca5 100644
--- a/frysk-core/frysk/util/CoredumpAction.java
+++ b/frysk-core/frysk/testbed/CoredumpAction.java
@@ -37,7 +37,7 @@
 // version and license this file solely under the GPL without
 // exception.
 
-package frysk.util;
+package frysk.testbed;
 
 import java.util.LinkedList;
 import java.util.Observable;
diff --git a/frysk-core/frysk/testbed/CorefileFactory.java b/frysk-core/frysk/testbed/CorefileFactory.java
index 9129965..a4fd040 100644
--- a/frysk-core/frysk/testbed/CorefileFactory.java
+++ b/frysk-core/frysk/testbed/CorefileFactory.java
@@ -44,7 +44,7 @@ import frysk.event.Event;
 import frysk.proc.Manager;
 import frysk.proc.Proc;
 import frysk.proc.ProcBlockAction;
-import frysk.util.CoredumpAction;
+import frysk.testbed.CoredumpAction;
 import frysk.Config;
 
 public class CorefileFactory extends TestLib {
diff --git a/frysk-core/frysk/util/TestCoredumpAction.java b/frysk-core/frysk/testbed/TestCoredumpAction.java
similarity index 100%
rename from frysk-core/frysk/util/TestCoredumpAction.java
rename to frysk-core/frysk/testbed/TestCoredumpAction.java
index 7dac1d4..4bf30e0 100644
--- a/frysk-core/frysk/util/TestCoredumpAction.java
+++ b/frysk-core/frysk/testbed/TestCoredumpAction.java
@@ -38,7 +38,7 @@
 // exception.
 
 
-package frysk.util;
+package frysk.testbed;
 
 import inua.eio.ByteOrder;
 
diff --git a/frysk-core/frysk/util/ChangeLog b/frysk-core/frysk/util/ChangeLog
index cbb6b3d..8e20a6b 100644
--- a/frysk-core/frysk/util/ChangeLog
+++ b/frysk-core/frysk/util/ChangeLog
@@ -1,3 +1,10 @@
+2008-02-26  Teresa Thomas  <tthomas@redhat.com>
+
+	* TestCoredumpAction.java: Move to frysk.testbed.
+	* CoredumpAction.java: Ditto.
+	
+	* ProcStopUtil.java (.parseCommand): Indent.
+	
 2008-02-26  Andrew Cagney  <cagney@redhat.com>
 
 	* Util.java: Use LinuxCoreFactory.
diff --git a/frysk-core/frysk/util/ProcStopUtil.java b/frysk-core/frysk/util/ProcStopUtil.java
index 5d2ea95..6a12b32 100644
--- a/frysk-core/frysk/util/ProcStopUtil.java
+++ b/frysk-core/frysk/util/ProcStopUtil.java
@@ -97,7 +97,7 @@ public class ProcStopUtil
 		if (!exeFile.exists() || !exeFile.canRead()
 			|| !exeFile.isFile()) {
 		    System.err.println ("File does not exist or is " +
-		    "not readable or is not a file.");
+		                        "not readable or is not a file.");
 		    System.exit(1);
 		} else {
 		    Manager.eventLoop.start();


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


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

only message in thread, other threads:[~2008-02-26 17:33 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-02-26 17:33 [SCM] master: Move CoredumpAction, TestCoredumpAction from fysk.util to frysk.testbed 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).