public inbox for frysk-cvs@sourceware.org
help / color / mirror / Atom feed
From: pmuldoon@sourceware.org
To: frysk-cvs@sourceware.org
Subject: [SCM] frysk system monitor/debugger branch, master, updated. 5dfe33d429e0f1c08a271e91bc7aa2e44ed938c5
Date: Thu, 08 Nov 2007 11:58:00 -0000	[thread overview]
Message-ID: <20071108115853.19043.qmail@sourceware.org> (raw)

The branch, master has been updated
       via  5dfe33d429e0f1c08a271e91bc7aa2e44ed938c5 (commit)
      from  767f3b3a74eeac703deb3c972e485ae0e5f6fee2 (commit)

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

- Log -----------------------------------------------------------------
commit 5dfe33d429e0f1c08a271e91bc7aa2e44ed938c5
Author: Phil Muldoon <pmuldoon@redhat.com>
Date:   Thu Nov 8 11:58:45 2007 +0000

    Rework corefile workflow. Touch tests to keep up with change.
    Mark one test as unresolved pending Parameter refactor.
    
    2007-11-08  Phil Muldoon  <pmuldoon@redhat.com>
    
    	* TestFhd.java (testHpdCore): Add unresolved(5295).
    
    2007-11-08  Phil Muldoon  <pmuldoon@redhat.com>
    
    	* TestCoreCommand.java (testCoreCommand): Append -noexe to
    	test.
    	* CoreCommand.java (CoreCommand): Use CommandOption.
    	Look for -noexe.
    	(interpret): Rewrite using workflow.
    	(getProc): New.
    	(getHost): New.
    
    2007-11-08  Phil Muldoon  <pmuldoon@redhat.com>
    
    	* LinuxHost.java (LinuxHost): Check in exe is set to
    	null.

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

Summary of changes:
 frysk-core/frysk/bindir/ChangeLog         |    4 +
 frysk-core/frysk/bindir/TestFhd.java      |    2 +
 frysk-core/frysk/hpd/ChangeLog            |   10 ++
 frysk-core/frysk/hpd/CoreCommand.java     |  140 ++++++++++++++++-------------
 frysk-core/frysk/hpd/TestCoreCommand.java |    2 +-
 frysk-core/frysk/proc/dead/ChangeLog      |    5 +
 frysk-core/frysk/proc/dead/LinuxHost.java |   18 +++--
 7 files changed, 110 insertions(+), 71 deletions(-)

First 500 lines of diff:
diff --git a/frysk-core/frysk/bindir/ChangeLog b/frysk-core/frysk/bindir/ChangeLog
index 05f7740..1b9e5b0 100644
--- a/frysk-core/frysk/bindir/ChangeLog
+++ b/frysk-core/frysk/bindir/ChangeLog
@@ -1,3 +1,7 @@
+2007-11-08  Phil Muldoon  <pmuldoon@redhat.com>
+
+	* TestFhd.java (testHpdCore): Add unresolved(5295).
+
 2007-11-02  Petr Machata  <pmachata@redhat.com>
 
 	* fltrace.java: Output values in hex.
diff --git a/frysk-core/frysk/bindir/TestFhd.java b/frysk-core/frysk/bindir/TestFhd.java
index 0f96570..0a4865f 100755
--- a/frysk-core/frysk/bindir/TestFhd.java
+++ b/frysk-core/frysk/bindir/TestFhd.java
@@ -86,6 +86,8 @@ public class TestFhd
     }
   
     public void testHpdCore ()  {
+    if (unresolved(5295))
+    	return;
 	e = new Expect(new String[] {
 			   Config.getBinFile("fhpd").getPath(),
 			   Config.getPkgDataFile("test-core-x86").getPath()
diff --git a/frysk-core/frysk/hpd/ChangeLog b/frysk-core/frysk/hpd/ChangeLog
index 990c128..80715d0 100644
--- a/frysk-core/frysk/hpd/ChangeLog
+++ b/frysk-core/frysk/hpd/ChangeLog
@@ -1,3 +1,13 @@
+2007-11-08  Phil Muldoon  <pmuldoon@redhat.com>
+
+	* TestCoreCommand.java (testCoreCommand): Append -noexe to
+	test.
+	* CoreCommand.java (CoreCommand): Use CommandOption.
+	Look for -noexe.
+	(interpret): Rewrite using workflow.
+	(getProc): New.
+	(getHost): New.
+
 2007-11-07  Andrew Cagney  <cagney@redhat.com>
 
 	* TestParameterizedCommand.java: New.
diff --git a/frysk-core/frysk/hpd/CoreCommand.java b/frysk-core/frysk/hpd/CoreCommand.java
index cdda025..c33e0bf 100644
--- a/frysk-core/frysk/hpd/CoreCommand.java
+++ b/frysk-core/frysk/hpd/CoreCommand.java
@@ -41,31 +41,44 @@ package frysk.hpd;
 
 import java.io.File;
 import java.util.Iterator;
+
 import frysk.debuginfo.DebugInfo;
 import frysk.debuginfo.DebugInfoFrame;
 import frysk.debuginfo.DebugInfoStackFactory;
-import frysk.proc.dead.CorefileStatus;
-import frysk.proc.dead.LinuxHost;
 import frysk.proc.Manager;
 import frysk.proc.Proc;
 import frysk.proc.Task;
+import frysk.proc.dead.LinuxHost;
 
 public class CoreCommand extends ParameterizedCommand {
 
+	File coreFile = null;
+	File exeFile = null;
+	boolean noExeOption = false;
+	
     CoreCommand() {
-	super("core", "core <core-file> [ <executable> ]",
-	      "open a core file");
+    	super("core", "core <core-file> [ <executable> ] [ -noexe ]",
+    	"open a core file");
+    	
+
+    	add(new CommandOption("noexe", 
+    			"Do not attempt to load executable ") {
+    			void parse(String argument, Object options) {
+    				System.out.println("Trigger noexe");
+    				noExeOption = true;
+    			}
+    		    });
+
     }
 
     void interpret(CLI cli, Input cmd, Object options) {
     	
 	Proc coreProc;
-	File exeFile = null;
 	LinuxHost coreHost = null;
     
 	// If > 2 parameter, then too many parameters.
 	if (cmd.size() > 2) {
-	    throw new InvalidCommandException("Too many parameters");
+	    throw new InvalidCommandException("Too many parameters, a maximum of two should be specified.");
 	}
 	
 	// If < 1 parameter, then not enough parameters.
@@ -73,68 +86,35 @@ public class CoreCommand extends ParameterizedCommand {
 	    throw new InvalidCommandException("Please specify a corefile with the core command");		
 	}
 
-	File coreFile = new File(cmd.parameter(0));
+	// Command line seems, sane parse.
+	parseCommandLine(cmd);
 
-	// Build corefile host, report errors and quit if any.
-	if (cmd.size() == 1)
-		try {
-			coreHost = new LinuxHost(Manager.eventLoop, coreFile);
-		} catch (Exception e) {
-			cli.addMessage("An error has occured while loading corefile: '" + coreFile.getAbsolutePath() 
-					+ "'. Error message is: " + e.getMessage(), Message.TYPE_ERROR);
-			return;
-		}
-	else {
-	    exeFile = new File(cmd.parameter(1));
-	    try {
-	    	coreHost = new LinuxHost(Manager.eventLoop, coreFile, exeFile);
-	    } catch (Exception e) {
-			cli.addMessage("An error has occured while loading corefile: '" + coreFile.getAbsolutePath() 
-					+ "'. Error message is: " + e.getMessage(), Message.TYPE_ERROR);
-			return;
-	    	
-	    }
+	// Does the corefile exist?
+	if ((!coreFile.exists()) || (!coreFile.canRead()))
+		throw new InvalidCommandException("No core file found, or cannot read corefile");
+		
+	// Build Core. Move any exceptions up to cli and print to user.
+	try {
+		coreHost = getHost(coreFile, exeFile, noExeOption);
+	} catch (Exception e) {
+		cli.addMessage("An error has occured while loading corefile: '" + coreFile.getAbsolutePath() 
+			+ "'. Error message is: " + e.getMessage(), Message.TYPE_ERROR);
+		return;		
 	}
 	
-	// Get an iterator to the one process
-	Iterator i = coreHost.getProcIterator(); 
+	// Get the core proc.
+	coreProc = getProc(coreHost);
 	
-	// Find process, if not error out and return.
-	if (i.hasNext())
-		coreProc = (Proc) i.next(); 
-	else {
-		cli.addMessage("Cannot find a process in corefile: '" + coreFile.getAbsolutePath()+"'. This may not be a valid ELF corefile.", Message.TYPE_ERROR);
+	// Error out if no exe found, and -noexe option specified
+	if ((noExeOption == false) && (coreHost.getStatus().hasExe == false))
+	{     
+		cli.addMessage("Could not find executable: '"+coreProc.getExe()+"' specified for corefile. "+
+				"You can specify one with the core command. E.g: core core.file yourexefile. Alternatively " +
+				"you can tell fhpd to ignore the executable with -noexe. E.g core core.file -noexe. No " +
+				"corefile has been loaded at this time.", Message.TYPE_ERROR);
 		return;
 	}
-	
-	// If > 1 process, this is a very odd corefile. Abort, can't handle multiple process corefiles.
-	if (i.hasNext()) {
-	    cli.addMessage("There appears to be two or more processes in corefile: '" + coreFile.getAbsolutePath()+"'. This is not valid for an ELF corefile", Message.TYPE_ERROR);
-	    return;
-	}
-	
-	// Check status, and report whether we managed to load an executable. If not build a message
-	// to the effect of why we have not.
-	CorefileStatus status = coreHost.getStatus();
-	if (status.hasExe == false)
-	{
-		String message = "The corefile: '"+coreFile.getAbsolutePath()+"' has no executable associated with it. The executable name ";
-		String exeName = "";
-		if (exeFile != null) 
-		{
-			exeName = exeFile.getAbsolutePath();
-			message += "specified by the user on the Core command was: '" + exeName;
-		}
-		else
-		{
-			exeName = coreProc.getExe();
-			message += "automatically read from the corefile was: '" + exeName;
-		}
-		message+="'. This executable could not be read. Please specifiy an executable on the 'core' command (eg core core.1234 exenamedFile) for richer metadata.";
-		
-		cli.addMessage(message,Message.TYPE_WARNING);
-	}
-	
+
 	// All checks are done. Host is built. Now start reserving space in the sets
 	int procID = cli.idManager.reserveProcID();
 	cli.idManager.manageProc(coreProc, procID);
@@ -151,10 +131,44 @@ public class CoreCommand extends ParameterizedCommand {
 	}
 
 	// Finally, done.
-	cli.addMessage("\n* Attached to core file: " + cmd.parameter(0),
+	cli.addMessage("Attached to core file: " + cmd.parameter(0),
 		Message.TYPE_NORMAL);
 
 	
     }
 
+    // Build Correct Host on options.
+    private LinuxHost getHost(File coreFile, File executable, boolean loadExe) {
+    	LinuxHost coreHost = null;
+    	if (executable == null)
+    		if (!loadExe)
+    			coreHost = new LinuxHost(Manager.eventLoop, coreFile);
+    		else
+    			coreHost = new LinuxHost(Manager.eventLoop, coreFile, null);
+    	else
+    		coreHost = new LinuxHost(Manager.eventLoop, coreFile, executable);
+    						
+    	return coreHost;
+    }
+    
+    // From a Host, get a Proc
+    private Proc getProc(LinuxHost coreHost) {
+    	// Get an iterator to the one process
+    	Iterator i = coreHost.getProcIterator(); 
+    	
+    	// Find process, if not error out and return.
+    	if (i.hasNext())
+    		return  (Proc) i.next();
+    	else
+    		return null;
+    }
+
+    // Parse the option commandline
+    private void parseCommandLine(Input cli) {
+    	coreFile = new File(cli.parameter(0));
+    	if (cli.size() == 1)
+    		return;
+    	else
+    		exeFile = new File(cli.parameter(1));
+    }
 }
diff --git a/frysk-core/frysk/hpd/TestCoreCommand.java b/frysk-core/frysk/hpd/TestCoreCommand.java
index 5bf82b6..0953093 100644
--- a/frysk-core/frysk/hpd/TestCoreCommand.java
+++ b/frysk-core/frysk/hpd/TestCoreCommand.java
@@ -50,7 +50,7 @@ public class TestCoreCommand extends TestLib {
     public void testCoreCommand() {
 	e = new HpdTestbed();
 	e.send("core " + Config.getPkgDataFile("test-core-x86").getPath()
-		+ "\n");
+		+ " -noexe\n");
 	e.expect(5, "Attached to core file.*");
 	e.close();
     }
diff --git a/frysk-core/frysk/proc/dead/ChangeLog b/frysk-core/frysk/proc/dead/ChangeLog
index 4c81cac..bd3c6f4 100644
--- a/frysk-core/frysk/proc/dead/ChangeLog
+++ b/frysk-core/frysk/proc/dead/ChangeLog
@@ -1,3 +1,8 @@
+2007-11-08  Phil Muldoon  <pmuldoon@redhat.com>
+
+	* LinuxHost.java (LinuxHost): Check in exe is set to
+	null.
+
 2007-11-07  Phil Muldoon  <pmuldoon@redhat.com>
 
 	* LinuxHost.java (LinuxHost): Create up front ET_CORE check in
diff --git a/frysk-core/frysk/proc/dead/LinuxHost.java b/frysk-core/frysk/proc/dead/LinuxHost.java
index 827cdff..3052223 100644
--- a/frysk-core/frysk/proc/dead/LinuxHost.java
+++ b/frysk-core/frysk/proc/dead/LinuxHost.java
@@ -103,14 +103,18 @@ public class LinuxHost extends DeadHost {
 		if (exeFile == null)
 			exeSetToNull = true;
 
-		if (exeFile.canRead() && exeFile.exists())
-			this.exeFile = exeFile;
-		else {
-			status.hasExe = false;
-			status.hasExeProblem = true;
-			status.message = "The user provided executable: "
+		if (exeSetToNull == false)
+			if (exeFile.canRead() && exeFile.exists()) {
+				this.exeFile = exeFile;
+				status.hasExe = true;
+				status.hasExeProblem = false;
+			}
+			else {
+				status.hasExe = false;
+				status.hasExeProblem = true;
+				status.message = "The user provided executable: "
 					+ exeFile.getAbsolutePath() + " could not be accessed";
-		}
+			}
 		this.sendRefresh(true);
 	}
 


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


                 reply	other threads:[~2007-11-08 11:58 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=20071108115853.19043.qmail@sourceware.org \
    --to=pmuldoon@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).