[SCM] frysk system monitor/debugger branch, master, updated. 018fde86cb15293f8bc7fc89ae5fdc595fd1a2ce

pmuldoon@sourceware.org pmuldoon@sourceware.org
Wed Nov 7 09:55:00 GMT 2007


The branch, master has been updated
       via  018fde86cb15293f8bc7fc89ae5fdc595fd1a2ce (commit)
      from  1048e398da0387157df4237cd1e896e33821aaa9 (commit)

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

- Log -----------------------------------------------------------------
commit 018fde86cb15293f8bc7fc89ae5fdc595fd1a2ce
Author: Phil Muldoon <pmuldoon@redhat.com>
Date:   Wed Nov 7 09:55:20 2007 +0000

    Step two for building a richer fhpd corefile interaction. Report exceptions up to user, in a friendly manner, but abort further use of that core.
    
    2007-11-07  Phil Muldoon  <pmuldoon@redhat.com>
    
    	* CoreCommand.java (interpret): Check for runtime exceptions
    	from LinuxHost. Abort on exception, and (nicely) report exception message.

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

Summary of changes:
 frysk-core/frysk/hpd/ChangeLog        |    5 +++
 frysk-core/frysk/hpd/CoreCommand.java |   51 +++++++++++++++++++++++++++------
 2 files changed, 47 insertions(+), 9 deletions(-)

First 500 lines of diff:
diff --git a/frysk-core/frysk/hpd/ChangeLog b/frysk-core/frysk/hpd/ChangeLog
index 9987008..0b0b2cb 100644
--- a/frysk-core/frysk/hpd/ChangeLog
+++ b/frysk-core/frysk/hpd/ChangeLog
@@ -1,3 +1,8 @@
+2007-11-07  Phil Muldoon  <pmuldoon@redhat.com>
+
+	* CoreCommand.java (interpret): Check for runtime exceptions
+	from LinuxHost. Abort on exception, and (nicely) report exception message.
+
 2007-11-06  Phil Muldoon  <pmuldoon@redhat.com>
 
 	* CoreCommand.java (interpret): Rewrite corefile model.
diff --git a/frysk-core/frysk/hpd/CoreCommand.java b/frysk-core/frysk/hpd/CoreCommand.java
index 3173ef6..3485353 100644
--- a/frysk-core/frysk/hpd/CoreCommand.java
+++ b/frysk-core/frysk/hpd/CoreCommand.java
@@ -55,43 +55,73 @@ public class CoreCommand extends Command {
     private static String desc = "open a core file";
 
     CoreCommand() {
-	super("core", desc, "core core.file", desc);
+	super("core", desc, "core core.file [executable]", desc);
     }
 
     public void interpret(CLI cli, Input cmd) {
+    	
+    Proc coreProc;
+    File exeFile = null;
+    LinuxHost coreHost = null;
+    
+    // If parse fails, print help
 	if (!parser.parse(cmd)) {
 	    parser.printHelp(cli.outWriter);
 	    return;
 	}
 
+	// If > 2 parameter, then too many parameters.
 	if (cmd.size() > 2) {
 	    throw new InvalidCommandException("Too many parameters");
 	}
+	
+	// If < 1 parameter, then not enough parameters.
+	if (cmd.size() < 1) {
+	    throw new InvalidCommandException("Please specify a corefile with the core command");		
+	}
 
 	File coreFile = new File(cmd.parameter(0));
 
-	Proc coreProc;
-	File exeFile = null;
-	LinuxHost coreHost = null;
+	// Build corefile host, report errors and quit if any.
 	if (cmd.size() == 1)
-		coreHost = new LinuxHost(Manager.eventLoop, coreFile);
+		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));
-		coreHost = new LinuxHost(Manager.eventLoop, coreFile, exeFile);
+	    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;
+	    	
+	    }
 	}
 	
+	// Get an iterator to the one process
 	Iterator i = coreHost.getProcIterator(); 
 	
+	// Find process, if not error out and return.
 	if (i.hasNext())
-		coreProc = (Proc) i.next();
+		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);
 		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)
 	{
@@ -111,10 +141,12 @@ public class CoreCommand extends Command {
 		
 		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);
 		
-
+	// Build debug info for each task and frame.
 	Iterator foo = cli.targetset.getTasks();
 	while (foo.hasNext()) {
 	    Task task = (Task) foo.next();
@@ -125,7 +157,8 @@ public class CoreCommand extends Command {
 						     frame));
 	}
 
-	cli.addMessage("Attached to core file: " + cmd.parameter(0),
+	// Finally, done.
+	cli.addMessage("\n* Attached to core file: " + cmd.parameter(0),
 		Message.TYPE_NORMAL);
 
 	


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



More information about the Frysk-cvs mailing list