public inbox for frysk-cvs@sourceware.org
help / color / mirror / Atom feed
* [SCM]  master: frysk-core/frysk/hpd/ChangeLog
@ 2008-06-06 19:31 swagiaal
  0 siblings, 0 replies; 6+ messages in thread
From: swagiaal @ 2008-06-06 19:31 UTC (permalink / raw)
  To: frysk-cvs

The branch, master has been updated
       via  d457d47661f4f6f233456e7f2ec24a94a79b2f90 (commit)
      from  203393a2fbb9559a36f78993d292cf9ce5df9f13 (commit)

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

- Log -----------------------------------------------------------------
commit d457d47661f4f6f233456e7f2ec24a94a79b2f90
Author: Sami Wagiaalla <swagiaal@redhat.com>
Date:   Fri Jun 6 15:26:38 2008 -0400

    frysk-core/frysk/hpd/ChangeLog
    +2008-06-06  Sami Wagiaalla  <swagiaal@redhat.com>
    +
    +	* TestFhpdThreads.java
    +	(testHpdSteppingBothThreads): New test.
    +
    
    frysk-core/frysk/pkglibdir/ChangeLog
    +2008-06-06  Sami Wagiaalla  <swagiaal@redhat.com>
    +
    +	* funit-2threads.c: New test program.
    +

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

Summary of changes:
 frysk-core/frysk/hpd/ChangeLog              |    5 ++
 frysk-core/frysk/hpd/TestFhpdThreads.java   |   76 +++++++++++++++++++++++++++
 frysk-core/frysk/pkglibdir/ChangeLog        |    4 ++
 frysk-core/frysk/pkglibdir/funit-2threads.c |   72 +++++++++++++++++++++++++
 4 files changed, 157 insertions(+), 0 deletions(-)
 create mode 100644 frysk-core/frysk/hpd/TestFhpdThreads.java
 create mode 100644 frysk-core/frysk/pkglibdir/funit-2threads.c

First 500 lines of diff:
diff --git a/frysk-core/frysk/hpd/ChangeLog b/frysk-core/frysk/hpd/ChangeLog
index 99eba18..61bfb02 100644
--- a/frysk-core/frysk/hpd/ChangeLog
+++ b/frysk-core/frysk/hpd/ChangeLog
@@ -1,3 +1,8 @@
+2008-06-06  Sami Wagiaalla  <swagiaal@redhat.com>
+
+	* TestFhpdThreads.java 
+	(testHpdSteppingBothThreads): New test.
+
 2008-06-06  Teresa Thomas  <tthomas@redhat.com>
 
 	* BreakpointCommand.java (*.updateHit): 
diff --git a/frysk-core/frysk/hpd/TestFhpdThreads.java b/frysk-core/frysk/hpd/TestFhpdThreads.java
new file mode 100644
index 0000000..aefa5e4
--- /dev/null
+++ b/frysk-core/frysk/hpd/TestFhpdThreads.java
@@ -0,0 +1,76 @@
+// This file is part of the program FRYSK.
+//
+// Copyright 2006, 2007, 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.hpd;
+
+import frysk.testbed.TestLib;
+
+/**
+ * This performs a "sniff" test of Fstack, confirming basic
+ * functionality of the command line interface.
+ *
+ * For more specific tests see frysk.hpd.
+ */
+
+public class TestFhpdThreads extends TestLib {
+
+    public void testHpdSteppingBothThreads() {
+	
+	if(unresolved(6604)){
+	    return;
+	}
+	    
+	HpdTestbed e = HpdTestbed.load("funit-2threads", "");
+	e.sendCommandExpectPrompt("break main", ".*breakpoint 0.*");
+	e.send("run\n");
+	e.expect(".*Breakpoint 0 main.*");
+
+	e.sendCommandExpectPrompt("next", ".*Task stopped at line.*");
+	e.sendCommandExpectPrompt("next", ".*Task stopped at line.*");
+	e.sendCommandExpectPrompt("next", ".*Task stopped at line.*");
+	e.sendCommandExpectPrompt("next", ".*Task stopped at line.*");
+	
+	e.sendCommandExpectPrompt("next", ".*Task stopped at line.*");
+	e.sendCommandExpectPrompt("next", ".*Task stopped at line.*");
+	e.sendCommandExpectPrompt("next", ".*Task stopped at line.*");
+	e.sendCommandExpectPrompt("next", ".*Task stopped at line.*");
+	
+    }
+    
+}
diff --git a/frysk-core/frysk/pkglibdir/ChangeLog b/frysk-core/frysk/pkglibdir/ChangeLog
index 60d3428..181dd43 100644
--- a/frysk-core/frysk/pkglibdir/ChangeLog
+++ b/frysk-core/frysk/pkglibdir/ChangeLog
@@ -1,3 +1,7 @@
+2008-06-06  Sami Wagiaalla  <swagiaal@redhat.com>
+
+	* funit-2threads.c: New test program.
+
 2008-06-05  Andrew Cagney  <cagney@redhat.com>
 
 	* funit-raise.S: Fix ADD parameter order.
diff --git a/frysk-core/frysk/pkglibdir/funit-2threads.c b/frysk-core/frysk/pkglibdir/funit-2threads.c
new file mode 100644
index 0000000..83a4db5
--- /dev/null
+++ b/frysk-core/frysk/pkglibdir/funit-2threads.c
@@ -0,0 +1,72 @@
+// This file is part of the program FRYSK.
+//
+// Copyright 2005, 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 volatile interfaces identified in the file named EXCEPTION found in
+// the source code files (the "Approved volatile interfaces"). The files of
+// Non-GPL Code may instantiate templates or use macros or inline
+// functions from the Approved volatile 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 volatile 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.
+
+#include <stdio.h>
+#include <sys/types.h>
+#include <signal.h>
+#include <unistd.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <pthread.h>
+
+pthread_t thread;
+
+void* thread_func ()
+{
+  int count1 = 0;
+
+  while(count1 < 1000){
+    printf("Thread 1: %d\n", count1++);
+  }
+  return NULL;
+}
+
+int main (){
+
+  pthread_create (&thread, NULL, thread_func, NULL);
+  
+  int count0 = 0;
+
+  while(count0 < 1000){
+    printf("Thread 0: %d\n", count0++);
+  }
+
+  pthread_join(thread,NULL);
+  return 0;
+}


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


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [SCM]  master: frysk-core/frysk/hpd/ChangeLog
@ 2008-03-17 19:09 cagney
  0 siblings, 0 replies; 6+ messages in thread
From: cagney @ 2008-03-17 19:09 UTC (permalink / raw)
  To: frysk-cvs

The branch, master has been updated
       via  78f5d94e36c76819fb26e2bec7a77e6e3f41a2d4 (commit)
      from  108ba4fc6bbb312908af356faf3455b53b49424a (commit)

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

- Log -----------------------------------------------------------------
commit 78f5d94e36c76819fb26e2bec7a77e6e3f41a2d4
Author: Andrew Cagney <cagney@redhat.com>
Date:   Mon Mar 17 15:08:48 2008 -0400

    frysk-core/frysk/hpd/ChangeLog
    2008-03-17  Andrew Cagney  <cagney@redhat.com>
    
    	* TestSysRoot.java (testHaveSysRoot()): Mark as unresolved; bug
    	5953.

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

Summary of changes:
 frysk-core/frysk/hpd/ChangeLog        |    3 +++
 frysk-core/frysk/hpd/TestSysRoot.java |    2 ++
 2 files changed, 5 insertions(+), 0 deletions(-)

First 500 lines of diff:
diff --git a/frysk-core/frysk/hpd/ChangeLog b/frysk-core/frysk/hpd/ChangeLog
index c0b6878..c663336 100644
--- a/frysk-core/frysk/hpd/ChangeLog
+++ b/frysk-core/frysk/hpd/ChangeLog
@@ -1,5 +1,8 @@
 2008-03-17  Andrew Cagney  <cagney@redhat.com>
 
+	* TestSysRoot.java (testHaveSysRoot()): Mark as unresolved; bug
+	5953.
+
 	* ShellCommand.java: Update; using TaskAttachedObserverXXX.
 	* StartRun.java: Ditto.
 
diff --git a/frysk-core/frysk/hpd/TestSysRoot.java b/frysk-core/frysk/hpd/TestSysRoot.java
index 3d37aab..cd0e685 100644
--- a/frysk-core/frysk/hpd/TestSysRoot.java
+++ b/frysk-core/frysk/hpd/TestSysRoot.java
@@ -53,6 +53,8 @@ public class TestSysRoot extends TestLib {
     }
 
     public void testHaveSysRoot() {
+	if (unresolved(5953))
+	    return;
 	File testSysRootDir = Config.getPkgLibFile("test-sysroot");
 	File testPath = Config.getPkgLibFile("funit-addresses");
 	e.sendCommandExpectPrompt("load "  


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


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [SCM]  master: frysk-core/frysk/hpd/ChangeLog
@ 2008-03-03 23:09 cagney
  0 siblings, 0 replies; 6+ messages in thread
From: cagney @ 2008-03-03 23:09 UTC (permalink / raw)
  To: frysk-cvs

The branch, master has been updated
       via  07f25f0deaf14fe5bc85ce04328b8b6140289547 (commit)
      from  ac50d5b81a0d2c34d901b21d0a7323b1b7de5435 (commit)

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

- Log -----------------------------------------------------------------
commit 07f25f0deaf14fe5bc85ce04328b8b6140289547
Author: Andrew Cagney <cagney@redhat.com>
Date:   Mon Mar 3 18:08:34 2008 -0500

    frysk-core/frysk/hpd/ChangeLog
    2008-03-03  Andrew Cagney  <cagney@redhat.com>
    
    	* TestListCommand.java (testListPC()): Mark as unresolved, 5855.
    
    frysk-core/frysk/value/ChangeLog
    2008-03-03  Andrew Cagney  <cagney@redhat.com>
    
    	* TestInterface.java: Extend TestLib; fix bug 5856.

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

Summary of changes:
 frysk-core/frysk/hpd/ChangeLog            |    4 ++++
 frysk-core/frysk/hpd/TestListCommand.java |    2 ++
 frysk-core/frysk/value/ChangeLog          |    4 ++++
 frysk-core/frysk/value/TestInterface.java |    6 +++---
 4 files changed, 13 insertions(+), 3 deletions(-)

First 500 lines of diff:
diff --git a/frysk-core/frysk/hpd/ChangeLog b/frysk-core/frysk/hpd/ChangeLog
index 5d27647..f6a8d3d 100644
--- a/frysk-core/frysk/hpd/ChangeLog
+++ b/frysk-core/frysk/hpd/ChangeLog
@@ -1,3 +1,7 @@
+2008-03-03  Andrew Cagney  <cagney@redhat.com>
+
+	* TestListCommand.java (testListPC()): Mark as unresolved, 5855.
+
 2008-03-02  Tom Tromey  <tromey@redhat.com>
 
 	* ParameterizedCommand.java (help): Align all option
diff --git a/frysk-core/frysk/hpd/TestListCommand.java b/frysk-core/frysk/hpd/TestListCommand.java
index 32feace..b749cd0 100644
--- a/frysk-core/frysk/hpd/TestListCommand.java
+++ b/frysk-core/frysk/hpd/TestListCommand.java
@@ -52,6 +52,8 @@ public class TestListCommand extends TestLib {
     }
 
     public void testListPC() {
+	if (unresolved(5855))
+	    return;
 	e = new HpdTestbed();
 	e.sendCommandExpectPrompt("load " + Config.getPkgLibFile("funit-quicksort").getPath(),
 		"Loaded executable file.*");
diff --git a/frysk-core/frysk/value/ChangeLog b/frysk-core/frysk/value/ChangeLog
index 7159a99..0211c0f 100644
--- a/frysk-core/frysk/value/ChangeLog
+++ b/frysk-core/frysk/value/ChangeLog
@@ -1,3 +1,7 @@
+2008-03-03  Andrew Cagney  <cagney@redhat.com>
+
+	* TestInterface.java: Extend TestLib; fix bug 5856.
+
 2008-02-19  Stan Cox  <scox@redhat.com>
 
 	* CompositeType.java (toPrint): Allow for struct/class access defaults.
diff --git a/frysk-core/frysk/value/TestInterface.java b/frysk-core/frysk/value/TestInterface.java
index e5baa2f..6f6ecb6 100644
--- a/frysk-core/frysk/value/TestInterface.java
+++ b/frysk-core/frysk/value/TestInterface.java
@@ -1,6 +1,6 @@
 // This file is part of the program FRYSK.
 //
-// Copyright 2007, Red Hat Inc.
+// Copyright 2007, 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
@@ -42,11 +42,11 @@ package frysk.value;
 import frysk.debuginfo.DebugInfoFrame;
 import frysk.debuginfo.DebugInfoStackFactory;
 import frysk.debuginfo.ObjectDeclarationSearchEngine;
-import frysk.junit.TestCase;
+import frysk.testbed.TestLib;
 import frysk.proc.Task;
 import frysk.testbed.DaemonBlockedAtSignal;
 
-public class TestInterface extends TestCase {
+public class TestInterface extends TestLib {
 
     private CompositeType getType(String program, String variableName) {
 	Task task = (new DaemonBlockedAtSignal(program)).getMainTask();


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


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [SCM]  master: frysk-core/frysk/hpd/ChangeLog
@ 2008-02-26 16:54 cagney
  0 siblings, 0 replies; 6+ messages in thread
From: cagney @ 2008-02-26 16:54 UTC (permalink / raw)
  To: frysk-cvs

The branch, master has been updated
       via  4454bcc2dd04291821f28d4e17044ab2d1d659b6 (commit)
      from  491d4ec7ba3a8e3878cca1c9f916ca7069d79469 (commit)

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

- Log -----------------------------------------------------------------
commit 4454bcc2dd04291821f28d4e17044ab2d1d659b6
Author: Andrew Cagney <cagney@redhat.com>
Date:   Tue Feb 26 11:42:11 2008 -0500

    frysk-core/frysk/hpd/ChangeLog
    2008-02-25  Andrew Cagney  <cagney@redhat.com>
    
    	* CoreCommand.java: Use LinuxCoreFactory.
    	(getHost(File,File.boolean)): Delete; replaced by LinuxCoreFactory.
    	(parseCommandLine(Input)): Fold into interpret.
    
    frysk-core/frysk/proc/ChangeLog
    2008-02-26  Andrew Cagney  <cagney@redhat.com>
    
    	* ProcBlockAction.java: Use LinuxCoreFactory.
    
    frysk-core/frysk/proc/dead/ChangeLog
    2008-02-26  Andrew Cagney  <cagney@redhat.com>
    
    	* LinuxCoreInfo.java: New.  Fold in LinuxCoreFactory,
    	LinuxCoreHost, LinuxCoreProc, and LinuxCoreTask.
    	* SOLibMapBuilder.java (construct(Elf,File,long)): New.
    	(openElf(File)): Delete.
    	* TestLinuxCore.java: Update.
    	* LinuxCoreFactory.java: Update.
    	* LinuxCoreHost.java: Update.
    	* LinuxCoreProc.java: Update.
    	* LinuxCoreTask.java: Update.
    
    frysk-core/frysk/util/ChangeLog
    2008-02-26  Andrew Cagney  <cagney@redhat.com>
    
    	* Util.java: Use LinuxCoreFactory.
    	* TestCoredumpAction.java: Ditto.
    	* TestStackTraceAction.java: Ditto.
    
    frysk-sys/frysk/rsl/ChangeLog
    2008-02-26  Andrew Cagney  <cagney@redhat.com>
    
    	* Log.java: Add more log methods.

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

Summary of changes:
 frysk-core/frysk/hpd/ChangeLog                   |    4 +
 frysk-core/frysk/hpd/CoreCommand.java            |  196 +++----
 frysk-core/frysk/proc/ChangeLog                  |    4 +
 frysk-core/frysk/proc/ProcBlockAction.java       |   33 +-
 frysk-core/frysk/proc/dead/ChangeLog             |   12 +
 frysk-core/frysk/proc/dead/LinuxCoreFactory.java |   94 +--
 frysk-core/frysk/proc/dead/LinuxCoreHost.java    |  167 +-----
 frysk-core/frysk/proc/dead/LinuxCoreInfo.java    |  685 +++++++++++++++++++
 frysk-core/frysk/proc/dead/LinuxCoreProc.java    |  769 +---------------------
 frysk-core/frysk/proc/dead/SOLibMapBuilder.java  |   24 +-
 frysk-core/frysk/proc/dead/TestLinuxCore.java    |  242 +++----
 frysk-core/frysk/util/ChangeLog                  |    6 +
 frysk-core/frysk/util/TestCoredumpAction.java    |   27 +-
 frysk-core/frysk/util/TestStackTraceAction.java  |    8 +-
 frysk-core/frysk/util/Util.java                  |   11 +-
 frysk-sys/frysk/rsl/ChangeLog                    |    2 +
 frysk-sys/frysk/rsl/Log.java                     |   10 +
 17 files changed, 992 insertions(+), 1302 deletions(-)
 create mode 100644 frysk-core/frysk/proc/dead/LinuxCoreInfo.java

First 500 lines of diff:
diff --git a/frysk-core/frysk/hpd/ChangeLog b/frysk-core/frysk/hpd/ChangeLog
index 5bf8a8a..9410dcb 100644
--- a/frysk-core/frysk/hpd/ChangeLog
+++ b/frysk-core/frysk/hpd/ChangeLog
@@ -9,6 +9,10 @@
 
 2008-02-25  Andrew Cagney  <cagney@redhat.com>
 
+	* CoreCommand.java: Use LinuxCoreFactory.
+	(getHost(File,File.boolean)): Delete; replaced by LinuxCoreFactory.
+	(parseCommandLine(Input)): Fold into interpret.
+
 	* LoadCommand.java: Use LinuxExeFactory.
 
 2008-02-21  Nurdin Premji  <npremji@redhat.com>
diff --git a/frysk-core/frysk/hpd/CoreCommand.java b/frysk-core/frysk/hpd/CoreCommand.java
index 37ca2c1..f7dbfc0 100644
--- a/frysk-core/frysk/hpd/CoreCommand.java
+++ b/frysk-core/frysk/hpd/CoreCommand.java
@@ -1,6 +1,6 @@
 // This file is part of the program FRYSK.
 //
-// Copyright 2007, Red Hat Inc.
+// Copyright 2007, 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
@@ -47,138 +47,98 @@ import frysk.debuginfo.DebugInfo;
 import frysk.debuginfo.DebugInfoFrame;
 import frysk.debuginfo.DebugInfoStackFactory;
 import frysk.dwfl.DwflCache;
-import frysk.proc.Manager;
-import frysk.proc.Proc;
 import frysk.proc.Task;
-import frysk.proc.dead.LinuxCoreHost;
+import frysk.proc.dead.LinuxCoreFactory;
+import java.io.IOException;
+import frysk.proc.dead.LinuxCoreProc;
 
 public class CoreCommand extends ParameterizedCommand {
 
-	File coreFile = null;
-
-	File exeFile = null;
-
-	boolean noExeOption = false;
-
-	CoreCommand() {
-		super("Load a Corefile.", "core <core-file> [ <executable> ] [ -noexe ]"
-			+ "[ -sysroot Path ]", "Opens, loads and models corefile.");
-
-		add(new CommandOption("noexe", "Do not attempt to load executable ") {
-			void parse(String argument, Object options) {
-				noExeOption = true;
-			}
-		});
-	        add(new CommandOption("sysroot", "pathname to use as a sysroot",
-	        "Pathname") {
-	            void parse(String args, Object options) {
-	        	((Options)options).sysroot = args;
-	            }
-	        });
-	}
-
-	private static class Options {
-	    String sysroot = "/";
-	}
-	Object options() {
-	    return new Options();
-	}
-
-	void interpret(CLI cli, Input cmd, Object options) {
-	        Options o = (Options)options;
-		
-		Proc coreProc;
-		LinuxCoreHost coreHost = null;
-
-		// If > 2 parameter, then too many parameters.
-		if (cmd.size() > 2) {
-			throw new InvalidCommandException(
-					"Too many parameters, a maximum of two should be specified.");
-		}
-
-		// If < 1 parameter, then not enough parameters.
-		if (cmd.size() < 1) {
-			throw new InvalidCommandException(
-					"Please specify a corefile with the core command");
-		}
-
-		// Command line seems, sane parse.
-		parseCommandLine(cmd);
-
-		// Does the corefile exist?
-		if ((!coreFile.exists()) || (!coreFile.canRead()
-			|| coreFile.isDirectory()))
-			throw new InvalidCommandException(
-					"No core file found, or cannot read corefile");
-
-		// Build Core. Move any exceptions up to cli and print to user.
-		coreHost = getHost(coreFile, exeFile, noExeOption);
-
-		// Get the core proc.
-		coreProc = coreHost.getSoleProcFIXME();
-
-		// 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;
-		}
+    private static class Options {
+	boolean loadMetaData = true;
+	String sysroot = "/";
+    }
+    Object options() {
+	return new Options();
+    }
 
-		// All checks are done. Host is built. Now start reserving space in the sets
-		int procID = cli.idManager.reserveProcID();
-		cli.idManager.manageProc(coreProc, procID);
-		
+    CoreCommand() {
+	super("Load a Corefile.",
+	      "core <core-file> [ <executable> ] [ -noexe ]"
+	      + "[ -sysroot Path ]", "Opens, loads and models corefile.");
 
-		// Build debug info for each task and frame.
-		Iterator foo = cli.targetset.getTasks();
-		while (foo.hasNext()) {
-			Task task = (Task) foo.next();
-			DebugInfoFrame frame = DebugInfoStackFactory
-					.createVirtualStackTrace(task);
-			cli.setTaskFrame(task, frame);
-			cli.setTaskDebugInfo(task, new DebugInfo(frame));
-			DwflCache.setSysroot(task, o.sysroot);
+	add(new CommandOption("noexe", "Do not attempt to load executable ") {
+		void parse(String argument, Object options) {
+		    ((Options)options).loadMetaData = false;
 		}
-
-		// Finally, done.
-		cli.addMessage("Attached to core file: " + cmd.parameter(0),
-				Message.TYPE_NORMAL);
-		// See if there was an executable specified
-		if (coreHost.getStatus().hasExe == false)
-		    return;
-		synchronized (cli) {
-		    cli.getCoreProcs().put(coreProc, new Integer(procID));
+	    });
+	add(new CommandOption("sysroot", "pathname to use as a sysroot",
+			      "Pathname") {
+		void parse(String args, Object options) {
+		    ((Options)options).sysroot = args;
 		}
+	    });
+    }
 
+    void interpret(CLI cli, Input cmd, Object optionsObject) {
+	Options options = (Options)optionsObject;
+	File coreFile;
+	File exeFile;
+
+	switch (cmd.size()) {
+	case 0:
+	    throw new InvalidCommandException
+		("Please specify a corefile with the core command");
+	case 1:
+	    // <core>
+	    coreFile = new File(cmd.parameter(0));
+	    exeFile = null;
+	    break;
+	case 2:
+	    coreFile = new File(cmd.parameter(0));
+	    exeFile = new File(cmd.parameter(1));
+	    break;
+	default:
+	    throw new InvalidCommandException
+		("Too many parameters, a maximum of two should be specified.");
 	}
 
-	// Build Correct Host on options.
-	private LinuxCoreHost getHost(File coreFile, File executable, boolean loadExe) {
-		LinuxCoreHost coreHost = null;
-		if (executable == null)
-			if (!loadExe)
-				coreHost = new LinuxCoreHost(Manager.eventLoop, coreFile);
-			else
-				coreHost = new LinuxCoreHost(Manager.eventLoop, coreFile, null);
-		else
-			coreHost = new LinuxCoreHost(Manager.eventLoop, coreFile, executable);
+	// Make paths canonical (keeps elfutils working).
+	try {
+	    coreFile = coreFile.getCanonicalFile();
+	    if (exeFile != null)
+		exeFile = exeFile.getCanonicalFile();
+	} catch (IOException e) {
+	    throw new RuntimeException(e);
+	}
 
-		return coreHost;
+	// Build Core. Move any exceptions up to cli and print to user.
+	LinuxCoreProc coreProc
+	    = LinuxCoreFactory.createProc(coreFile, exeFile,
+					  options.loadMetaData);
+
+	// 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.
+	for (Iterator i = cli.targetset.getTasks(); i.hasNext(); ) {
+	    Task task = (Task) i.next();
+	    DebugInfoFrame frame = DebugInfoStackFactory
+		.createVirtualStackTrace(task);
+	    cli.setTaskFrame(task, frame);
+	    cli.setTaskDebugInfo(task, new DebugInfo(frame));
+	    DwflCache.setSysroot(task, options.sysroot);
 	}
 
-	// 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));
+	// Finally, done.
+	cli.addMessage("Attached to core file: " + cmd.parameter(0),
+		       Message.TYPE_NORMAL);
+	synchronized (cli) {
+	    cli.getCoreProcs().put(coreProc, new Integer(procID));
 	}
+    }
 
     int completer(CLI cli, Input input, int cursor, List completions) {
 	return CompletionFactory.completeFileName(cli, input, cursor,
diff --git a/frysk-core/frysk/proc/ChangeLog b/frysk-core/frysk/proc/ChangeLog
index d0e9ac2..cf89fb9 100644
--- a/frysk-core/frysk/proc/ChangeLog
+++ b/frysk-core/frysk/proc/ChangeLog
@@ -1,3 +1,7 @@
+2008-02-26  Andrew Cagney  <cagney@redhat.com>
+
+	* ProcBlockAction.java: Use LinuxCoreFactory.
+
 2008-02-20  Phil Muldoon  <pmuldoon@redhat.com>
 
 	* TaskObserver.java: Add watch interface.
diff --git a/frysk-core/frysk/proc/ProcBlockAction.java b/frysk-core/frysk/proc/ProcBlockAction.java
index dadbcc3..52c6f24 100644
--- a/frysk-core/frysk/proc/ProcBlockAction.java
+++ b/frysk-core/frysk/proc/ProcBlockAction.java
@@ -47,7 +47,7 @@ import java.util.logging.Level;
 import java.util.logging.Logger;
 import frysk.isa.signals.Signal;
 import frysk.event.Event;
-import frysk.proc.dead.LinuxCoreHost;
+import frysk.proc.dead.LinuxCoreFactory;
 
 /**
  * This class blocks all of the threads in a process and performs a
@@ -167,26 +167,17 @@ public class ProcBlockAction
 	    });
     }
   
-  public ProcBlockAction (File coreFile) {
-    LinuxCoreHost core = new LinuxCoreHost(Manager.eventLoop, coreFile);
-
-    Manager.eventLoop.runPending();
-    proc = core.getSoleProcFIXME();
-    if (proc == null)
-        throw new RuntimeException("No proc in this corefile");
-
-    taskList = proc.getTasks();
-    
-    Iterator iterator = taskList.iterator();
-    
-    while (iterator.hasNext())
-      {
-        Task task = (Task) iterator.next();
-        action.existingTask(task);
-      }
-    
-    action.allExistingTasksCompleted();
-  }
+    public ProcBlockAction(File coreFile) {
+	Proc proc = LinuxCoreFactory.createProc(coreFile);
+	if (proc == null)
+	    throw new RuntimeException("No proc in this corefile");
+	taskList = proc.getTasks();
+	for (Iterator i = taskList.iterator(); i.hasNext(); ) {
+	    Task task = (Task) i.next();
+	    action.existingTask(task);
+	}
+	action.allExistingTasksCompleted();
+    }
 
   private void requestAdd ()
   {
diff --git a/frysk-core/frysk/proc/dead/ChangeLog b/frysk-core/frysk/proc/dead/ChangeLog
index ac109e9..a94b903 100644
--- a/frysk-core/frysk/proc/dead/ChangeLog
+++ b/frysk-core/frysk/proc/dead/ChangeLog
@@ -1,3 +1,15 @@
+2008-02-26  Andrew Cagney  <cagney@redhat.com>
+
+	* LinuxCoreInfo.java: New.  Fold in LinuxCoreFactory,
+	LinuxCoreHost, LinuxCoreProc, and LinuxCoreTask.
+	* SOLibMapBuilder.java (construct(Elf,File,long)): New.
+	(openElf(File)): Delete.
+	* TestLinuxCore.java: Update.
+	* LinuxCoreFactory.java: Update.
+	* LinuxCoreHost.java: Update.
+	* LinuxCoreProc.java: Update.
+	* LinuxCoreTask.java: Update.
+
 2008-02-26  Phil Muldoon  <pmuldoon@redhat.com>
 
 	* CorefileBytebuffer.java (peek): Account for segments
diff --git a/frysk-core/frysk/proc/dead/LinuxCoreFactory.java b/frysk-core/frysk/proc/dead/LinuxCoreFactory.java
index 1cb6eca..e291cf8 100644
--- a/frysk-core/frysk/proc/dead/LinuxCoreFactory.java
+++ b/frysk-core/frysk/proc/dead/LinuxCoreFactory.java
@@ -40,14 +40,6 @@
 package frysk.proc.dead;
 
 import java.io.File;
-import lib.dwfl.Elf;
-import lib.dwfl.ElfCommand;
-import lib.dwfl.ElfData;
-import lib.dwfl.ElfEHeader;
-import lib.dwfl.ElfPHeader;
-import lib.dwfl.ElfPrpsinfo;
-import frysk.proc.Proc;
-import frysk.rsl.Log;
 
 /**
  * Data needed to construct a core file; shared between the core Host,
@@ -55,11 +47,6 @@ import frysk.rsl.Log;
  */
 
 public class LinuxCoreFactory {
-    private static final Log fine = Log.fine(LinuxCoreFactory.class);
-
-    static Elf core;
-    static Elf exe;
-
     /**
      * Construct the core file; if the EXE is non-null use it for
      * meta-data; otherwise use the executable extracted from the
@@ -67,63 +54,28 @@ public class LinuxCoreFactory {
      *
      * All File paths <b>must</b> be canonical.
      */
-    public static Proc create(File coreFile, File exeFile,
-			      boolean includeMetaData) {
-	try {
-	    // Open the core file; validate it.
-	    core = new Elf(coreFile, ElfCommand.ELF_C_READ);
-	    ElfEHeader eHeader = core.getEHeader();
-	    if (eHeader.type != ElfEHeader.PHEADER_ET_CORE) {
-		throw new RuntimeException("'" + coreFile
-					   + "' is not a corefile.");
-	    }
-	
-	    // Find the note section; there is only ever one note
-	    // section and it must be present.
-	    ElfData noteData = null;
-	    for (int i = 0; i < eHeader.phnum; i++) {
-		// Test if pheader is of types notes..
-		ElfPHeader pHeader = core.getPHeader(i);
-		if (pHeader.type == ElfPHeader.PTYPE_NOTE) {
-		    // if so, copy, break an leave.
-		    noteData = core.getRawData(pHeader.offset,
-					       pHeader.filesz);
-		    break;
-		}
-	    }
-	    if (noteData == null)
-		throw new RuntimeException("'" + coreFile
-					   + "' is corrupt; no note section");
-	    
-	    // Extract the pr/ps information from the note.
-	    ElfPrpsinfo prpsInfo = ElfPrpsinfo.decode(noteData);
-	    String[] args = prpsInfo.getPrPsargs().split(" ");
-	    fine.log("args", args);
-
-	    if (exeFile == null) {
-		// Only place to find full path + exe is in the args
-		// list. Remove ./ if present.
-		if (args.length > 0) {
-		    if (args[0].startsWith("./"))
-			exeFile = new File(args[0].substring(2));
-		    else
-			exeFile = new File(args[0]);
-		} else {
-		    exeFile = new File(prpsInfo.getPrFname());
-		}
-		fine.log("exe from core", exeFile);
-	    } else {
-		fine.log("exe for core", exeFile);
-	    }
-	    if (includeMetaData)
-		exe = new Elf(exeFile, ElfCommand.ELF_C_READ);
-
-	    return null;
-	} finally { 
-	    if (core != null)
-		core.close();
-	    if (exe != null)
-		exe.close();
-	}
+    public static LinuxCoreProc createProc(File coreFile, File exeFile,
+					   boolean extendedMetaData) {
+	LinuxCoreInfo core = new LinuxCoreInfo(coreFile, exeFile,
+					       extendedMetaData);
+	LinuxCoreHost host = new LinuxCoreHost(core);
+	return host.getProc();
+    }
+    /**
+     * Construct a core file without extended meta data.
+     *
+     * All File paths <b>must</b> be canonical.
+     */
+    public static LinuxCoreProc createProc(File coreFile) {
+	return createProc(coreFile, null, false);
+    }
+    /**
+     * Construct a core file with extended meta data taken from the
+     * executable.
+     *
+     * All File paths <b>must</b> be canonical.
+     */
+    public static LinuxCoreProc createProc(File coreFile, File exeFile) {
+	return createProc(coreFile, exeFile, true);
     }
 }
diff --git a/frysk-core/frysk/proc/dead/LinuxCoreHost.java b/frysk-core/frysk/proc/dead/LinuxCoreHost.java
index feaeeba..1807ec1 100644
--- a/frysk-core/frysk/proc/dead/LinuxCoreHost.java
+++ b/frysk-core/frysk/proc/dead/LinuxCoreHost.java
@@ -39,170 +39,25 @@
 
 package frysk.proc.dead;
 
-import frysk.event.EventLoop;
-import java.util.LinkedList;
-import java.util.List;
 import java.io.File;
-import java.io.IOException;
-import java.util.Iterator;
-
-import lib.dwfl.Elf;
-import lib.dwfl.ElfCommand;
-import lib.dwfl.ElfData;
-import lib.dwfl.ElfEHeader;
-import lib.dwfl.ElfPHeader;
-import lib.dwfl.ElfPrpsinfo;
-import frysk.proc.Proc;
-import frysk.proc.ProcId;
 
 public class LinuxCoreHost extends DeadHost {
+    private final LinuxCoreProc proc;
+    private final File coreFile;
 
-    CorefileStatus status = new CorefileStatus();
-
-    boolean hasRefreshed = false;
-
-    boolean exeSetToNull = false;
-
-    protected File coreFile = null;
-
-    protected File exeFile = null;
-
-    Elf corefileElf;
-
-    EventLoop eventLoop;
-
-    private LinuxCoreHost(EventLoop eventLoop, File coreFile, boolean doRefresh) {
-
-	try {
-	    this.coreFile = coreFile.getCanonicalFile();
-	} catch (IOException e) {
-	    throw new RuntimeException(e);
-	}
-	this.eventLoop = eventLoop;
-	this.corefileElf = new Elf(coreFile, ElfCommand.ELF_C_READ);
-
-	if ((corefileElf.getEHeader() == null) || 
-	    (corefileElf.getEHeader().type != ElfEHeader.PHEADER_ET_CORE)) {
-	    this.corefileElf.close();
-	    throw new RuntimeException("'" + this.getName()


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


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [SCM]  master: frysk-core/frysk/hpd/ChangeLog
@ 2008-02-25 17:17 cagney
  0 siblings, 0 replies; 6+ messages in thread
From: cagney @ 2008-02-25 17:17 UTC (permalink / raw)
  To: frysk-cvs

The branch, master has been updated
       via  cc4b69ddad67f0d3efcb1574f32f37d0ad3e92e6 (commit)
      from  8ae8b5bbf07d2a0dde2b5db8bcf01199e3ea2ced (commit)

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

- Log -----------------------------------------------------------------
commit cc4b69ddad67f0d3efcb1574f32f37d0ad3e92e6
Author: Andrew Cagney <cagney@redhat.com>
Date:   Mon Feb 25 12:15:29 2008 -0500

    frysk-core/frysk/hpd/ChangeLog
    2008-02-25  Andrew Cagney  <cagney@redhat.com>
    
    	* LoadCommand.java: Use LinuxExeFactory.
    
    frysk-core/frysk/proc/dead/ChangeLog
    2008-02-25  Andrew Cagney  <cagney@redhat.com>
    
    	* LinuxExeFactory.java: New.  Merge in LinuxExeHost, LinuxExeProc,
    	and LinuxExeTask.
    	* LinuxExeHost.java: Simplify.
    	* LinuxExeProc.java: Simplify.
    	* LinuxExeTask.java: Simplify.
    	* ExeByteBuffer.java (ExeByteBuffer(MemoryMap[])): Replace
    	ExeByteBuffer(ArrayList).
    	* TestLinuxExe.java: Update.
    
    frysk-core/frysk/util/ChangeLog
    2008-02-25  Andrew Cagney  <cagney@redhat.com>
    
    	* ProcStopUtil.java: Use LinuxExeFactory.

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

Summary of changes:
 frysk-core/frysk/hpd/ChangeLog                     |    4 +
 frysk-core/frysk/hpd/LoadCommand.java              |   11 +--
 frysk-core/frysk/proc/dead/ChangeLog               |   11 +++
 frysk-core/frysk/proc/dead/ExeByteBuffer.java      |   53 +++++-------
 .../{LinuxExeTask.java => LinuxExeFactory.java}    |   85 ++++++++----------
 frysk-core/frysk/proc/dead/LinuxExeHost.java       |   92 ++------------------
 frysk-core/frysk/proc/dead/LinuxExeProc.java       |   67 ++++-----------
 frysk-core/frysk/proc/dead/LinuxExeTask.java       |   35 ++------
 frysk-core/frysk/proc/dead/TestLinuxExe.java       |   75 ++--------------
 frysk-core/frysk/util/ChangeLog                    |    4 +
 frysk-core/frysk/util/ProcStopUtil.java            |    7 +-
 11 files changed, 128 insertions(+), 316 deletions(-)
 copy frysk-core/frysk/proc/dead/{LinuxExeTask.java => LinuxExeFactory.java} (61%)

First 500 lines of diff:
diff --git a/frysk-core/frysk/hpd/ChangeLog b/frysk-core/frysk/hpd/ChangeLog
index 7862c42..fc9b4d7 100644
--- a/frysk-core/frysk/hpd/ChangeLog
+++ b/frysk-core/frysk/hpd/ChangeLog
@@ -1,3 +1,7 @@
+2008-02-25  Andrew Cagney  <cagney@redhat.com>
+
+	* LoadCommand.java: Use LinuxExeFactory.
+
 2008-02-21  Nurdin Premji  <npremji@redhat.com>
 
 	* StepCommand.java (StepCommand): Added -instruction parameter. 
diff --git a/frysk-core/frysk/hpd/LoadCommand.java b/frysk-core/frysk/hpd/LoadCommand.java
index bbd9893..4bc03ae 100644
--- a/frysk-core/frysk/hpd/LoadCommand.java
+++ b/frysk-core/frysk/hpd/LoadCommand.java
@@ -40,16 +40,12 @@
 package frysk.hpd;
 
 import java.io.File;
-//import java.util.HashMap;
 import java.util.Iterator;
-//import java.util.Map;
-//import java.util.Set;
+import frysk.proc.dead.LinuxExeFactory;
 import frysk.debuginfo.DebugInfo;
 import frysk.debuginfo.DebugInfoFrame;
 import frysk.debuginfo.DebugInfoStackFactory;
 import frysk.dwfl.DwflCache;
-import frysk.proc.Host;
-import frysk.proc.dead.LinuxExeHost;
 import frysk.proc.Manager;
 import frysk.proc.Proc;
 import frysk.proc.Task;
@@ -112,8 +108,9 @@ public class LoadCommand extends ParameterizedCommand {
 	    	("File does not exist or is not readable or is not a file.");
 	}
 
-	Host exeHost = new LinuxExeHost(Manager.eventLoop, executableFile);
-	Proc exeProc = frysk.util.Util.getProcFromExeFile(exeHost);
+	Proc exeProc = LinuxExeFactory.createProc(Manager.eventLoop,
+						  executableFile,
+						  cmd.stringArrayValue());
 
 	int procID;
 	if (cli.taskID < 0)
diff --git a/frysk-core/frysk/proc/dead/ChangeLog b/frysk-core/frysk/proc/dead/ChangeLog
index a79fb3b..f09f868 100644
--- a/frysk-core/frysk/proc/dead/ChangeLog
+++ b/frysk-core/frysk/proc/dead/ChangeLog
@@ -1,3 +1,14 @@
+2008-02-25  Andrew Cagney  <cagney@redhat.com>
+
+	* LinuxExeFactory.java: New.  Merge in LinuxExeHost, LinuxExeProc,
+	and LinuxExeTask.
+	* LinuxExeHost.java: Simplify.
+	* LinuxExeProc.java: Simplify.
+	* LinuxExeTask.java: Simplify.
+	* ExeByteBuffer.java (ExeByteBuffer(MemoryMap[])): Replace
+	ExeByteBuffer(ArrayList).
+	* TestLinuxExe.java: Update.
+
 2008-02-20  Andrew Cagney  <cagney@redhat.com>
 
 	* LinuxExeProc.java (sendRefresh()): Delete.
diff --git a/frysk-core/frysk/proc/dead/ExeByteBuffer.java b/frysk-core/frysk/proc/dead/ExeByteBuffer.java
index cde7b8d..59f6d09 100644
--- a/frysk-core/frysk/proc/dead/ExeByteBuffer.java
+++ b/frysk-core/frysk/proc/dead/ExeByteBuffer.java
@@ -1,6 +1,6 @@
 // This file is part of the program FRYSK.
 //
-// Copyright 2007, Red Hat Inc.
+// Copyright 2007, 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
@@ -40,52 +40,41 @@
 package frysk.proc.dead;
 
 import java.io.File;
-import java.util.ArrayList;
-import java.util.Iterator;
-
 import frysk.sys.StatelessFile;
 import frysk.proc.MemoryMap;
-
 import inua.eio.ByteBuffer;
 
 public class ExeByteBuffer extends ByteBuffer {
 
-    ArrayList metaData = new ArrayList();
+    private final MemoryMap[] memoryMaps;
+    private final StatelessFile[] statelessFiles;
+    private final byte[] buffer = new byte[1];
     
-    protected ExeByteBuffer(long lowWater, long highWater) {
-	super(lowWater, highWater);
-    }
-
-    public ExeByteBuffer(ArrayList metaData)
-    {
+    public ExeByteBuffer(MemoryMap[] memoryMaps) {
 	super(0,-1);
-	
-	this.metaData = metaData;
+	this.memoryMaps = memoryMaps;
+	this.statelessFiles = new StatelessFile[memoryMaps.length];
     }
     
     protected int peek(long caret) {
-	
-	Iterator i = metaData.iterator();
-	MemoryMap line = null;
 	long offset = -1;
-	byte[] buffer = new byte[1];
-	
-	while (i.hasNext())
-	{
-	    line = ((MemoryMap)i.next());
-	    if ((caret >= line.addressLow) && (caret<= line.addressHigh))
-		    {
-			offset = line.offset + (caret - line.addressLow);
-			break;
-		    }
+	int i;
+	MemoryMap line = null;
+	for (i = 0; i < memoryMaps.length; i++) {
+	    line = memoryMaps[i];
+	    if ((caret >= line.addressLow) && (caret<= line.addressHigh)) {
+		offset = line.offset + (caret - line.addressLow);
+		break;
+	    }
 	}
-	
-	if (offset == -1)
+	if (i >= memoryMaps.length)
 	    throw new RuntimeException("Cannot find memory in exe file");
-
-	StatelessFile temp = new StatelessFile(new File(line.name));
+	StatelessFile temp = statelessFiles[i];
+	if (temp == null) {
+	    temp = new StatelessFile(new File(line.name));
+	    statelessFiles[i] = temp;
+	}
 	temp.pread(offset, buffer,0,1);
-	
 	return buffer[0];
     }
 
diff --git a/frysk-core/frysk/proc/dead/LinuxExeTask.java b/frysk-core/frysk/proc/dead/LinuxExeFactory.java
similarity index 61%
copy from frysk-core/frysk/proc/dead/LinuxExeTask.java
copy to frysk-core/frysk/proc/dead/LinuxExeFactory.java
index 4d90354..28d0082 100644
--- a/frysk-core/frysk/proc/dead/LinuxExeTask.java
+++ b/frysk-core/frysk/proc/dead/LinuxExeFactory.java
@@ -39,59 +39,50 @@
 
 package frysk.proc.dead;
 
-import inua.eio.ArrayByteBuffer;
-import inua.eio.ByteBuffer;
-import frysk.isa.banks.RegisterBanks;
-import frysk.isa.ISA;
+import java.io.File;
+import java.util.List;
+import java.util.LinkedList;
 import lib.dwfl.Elf;
 import lib.dwfl.ElfCommand;
 import lib.dwfl.ElfEHeader;
-import lib.dwfl.ElfException;
-import java.io.File;
-
-public class LinuxExeTask extends DeadTask {
-    private final long pc;
-    private final LinuxExeProc proc;
+import frysk.proc.MemoryMap;
+import frysk.event.EventLoop;
 
-    LinuxExeTask(LinuxExeProc proc, ISA isa) {
-	super(proc, 0, isa, constructRegisterBanks(isa));
-	this.proc = proc;
-	// Compute a Fake PC.  XXX should be done in Proc instead of
-	// creating Elf object in the Task itself.
-	Elf e = null;
-	long pc;
+public class LinuxExeFactory {
+    public static LinuxExeProc createProc(EventLoop eventLoop,
+					  final File exeFile,
+					  String[] args) {
+	Elf exeElf = null;
 	try {
-	    e = new Elf(new File(getProc().getExe()), ElfCommand.ELF_C_READ);
-	    ElfEHeader h = e.getEHeader();
-	    pc = h.entry;
-	} catch (ElfException ee) {
-	    // Nice try, just give up.
-	    pc = 0;
+	    exeElf = new Elf(exeFile, ElfCommand.ELF_C_READ);
+	    ElfEHeader eHeader = exeElf.getEHeader();
+	    class BuildExeMaps extends SOLibMapBuilder {
+		private final List metaData = new LinkedList();
+		public void buildMap(long addrLow, long addrHigh, boolean permRead,
+				     boolean permWrite, boolean permExecute,
+				     long offset, String name, long align) {
+		    metaData.add(new MemoryMap(addrLow, addrHigh, permRead,
+					       permWrite, permExecute, false,
+					       offset, -1, -1, -1, -1, -1,
+					       exeFile.getAbsolutePath()));
+		}
+		MemoryMap[] getMemoryMaps() {
+		    MemoryMap[] memoryMaps = new MemoryMap[metaData.size()];
+		    metaData.toArray(memoryMaps);
+		    return memoryMaps;
+		}
+	    }
+	    BuildExeMaps SOMaps = new BuildExeMaps();
+	    // Add in case for executables maps.
+	    SOMaps.construct(exeFile, 0);
+	    
+	    LinuxExeHost host
+		= new LinuxExeHost(exeFile, eHeader, SOMaps.getMemoryMaps(),
+				   args);
+	    return host.getProc();
 	} finally {
-	    if (e != null)
-		e.close();
+	    if (exeElf != null)
+		exeElf.close();
 	}
-	this.pc = pc;
-    }
-  
-    public long getPC() {
-	return pc;
-    }
-
-    public ByteBuffer getMemory() {
-	return proc.getMemory();
     }
-  
-    private static RegisterBanks constructRegisterBanks(ISA isa) {
-	ByteBuffer[] bankBuffers = new ByteBuffer[4];
-	// Create an empty page
-	byte[] emptyBuffer = new byte[4096];
-	for (int i = 0; i < emptyBuffer.length; i++)
-	    emptyBuffer[i] = 0;
-	bankBuffers[0] = new ArrayByteBuffer(emptyBuffer);
-	bankBuffers[1] = new ArrayByteBuffer(emptyBuffer);
-	bankBuffers[2] = new ArrayByteBuffer(emptyBuffer);
-	bankBuffers[3] = new ArrayByteBuffer(emptyBuffer);
-	return CorefileRegisterBanksFactory.create(isa, bankBuffers);
-  }
 }
diff --git a/frysk-core/frysk/proc/dead/LinuxExeHost.java b/frysk-core/frysk/proc/dead/LinuxExeHost.java
index 7dd7431..a9932e0 100644
--- a/frysk-core/frysk/proc/dead/LinuxExeHost.java
+++ b/frysk-core/frysk/proc/dead/LinuxExeHost.java
@@ -40,100 +40,24 @@
 package frysk.proc.dead;
 
 import java.io.File;
-import java.util.Iterator;
-import java.util.List;
-import java.util.LinkedList;
-
-import lib.dwfl.Elf;
-import lib.dwfl.ElfCommand;
-import lib.dwfl.ElfData;
 import lib.dwfl.ElfEHeader;
-import lib.dwfl.ElfPHeader;
-
-import frysk.event.EventLoop;
-import frysk.proc.Proc;
-import frysk.proc.ProcId;
+import frysk.proc.MemoryMap;
 
 public class LinuxExeHost extends DeadHost {
-
-    protected File exeFile = null;
-    EventLoop eventLoop = null;
-    Elf exeFileElf = null;
+    private final File exeFile;
+    private final LinuxExeProc proc;
     
-    public LinuxExeHost(EventLoop eventLoop, File exeFile) {
+    LinuxExeHost(File exeFile, ElfEHeader eHeader, MemoryMap[] memoryMaps,
+		 String[] args) {
 	this.exeFile = exeFile;
-	this.eventLoop = eventLoop;
-	this.exeFileElf = new Elf(exeFile, ElfCommand.ELF_C_READ);
-	// Iterate (build) the /proc tree, passing each found PID to
-	// procChanges where it can update the /proc tree.
-	// Changes individual process.
-	new DeconstructExeFile(this.exeFileElf);
-	for (Iterator i = procPool.values().iterator(); i.hasNext();) {
-	    LinuxExeProc proc = (LinuxExeProc) i.next();
-	    proc.sendRefresh();
-	}
-    }
-
-    private class DeconstructExeFile
-    {
-      List addedProcs = new LinkedList();
-      Elf exeFileElf;
-      ElfData noteData = null;
-
-      DeconstructExeFile(Elf exeFileElf)
-      {
-        this.exeFileElf =  exeFileElf;
-        ElfEHeader eHeader = this.exeFileElf.getEHeader();
-        
-        // Get number of program header entries.
-        long phSize = eHeader.phnum;
-        for (int i=0; i<phSize; i++)
-  	{
-  	  // Test if pheader is of types notes..
-  	  ElfPHeader pHeader = exeFileElf.getPHeader(i);
-  	  if (pHeader.type == ElfPHeader.PTYPE_NOTE)
-  	    {
-  	      // if so, copy, break and leave.
-  	      noteData = exeFileElf.getRawData(pHeader.offset,pHeader.filesz);
-  	      break;
-  	    }
-  	}
-
-        if (noteData != null)
-  	update(noteData);
-      }
-
-      Proc update (ElfData proc_pid) 
-      {
-        final ProcId procId = new ProcId(0);
-        // Currently there can only be one process per core file.
-        // What happens when we have two core files denoting the same
-        // process/pid? Leave the test here for now.
-     
-        Proc proc = (Proc) procPool.get(procId);
-        if (proc == null)
-  	{
-  	  // executable file processes have no parents as thy are captured
-  	  // in isolation, and reconstructed.
-  	  proc = new LinuxExeProc(proc_pid,LinuxExeHost.this);
-  	}
-
-        addedProcs.add(proc);
-
-        return proc;
-      }
+	proc = new LinuxExeProc(this, exeFile, eHeader, memoryMaps, args);
     }
 
     public String getName() {
 	return exeFile.getName();
     }
 
-    /**
-     * finalize closes the file descriptor for the executable.
-     */
-    protected void finalize()
-    {
-	this.exeFileElf.close();
+    LinuxExeProc getProc() {
+	return proc;
     }
-
 }
diff --git a/frysk-core/frysk/proc/dead/LinuxExeProc.java b/frysk-core/frysk/proc/dead/LinuxExeProc.java
index 4732d0e..9616965 100644
--- a/frysk-core/frysk/proc/dead/LinuxExeProc.java
+++ b/frysk-core/frysk/proc/dead/LinuxExeProc.java
@@ -39,50 +39,45 @@
 
 package frysk.proc.dead;
 
-import inua.eio.ByteBuffer;
-
-import java.util.ArrayList;
-import lib.dwfl.ElfData;
-
-import frysk.isa.ISA;
-import frysk.isa.ElfMap;
+import lib.dwfl.ElfEHeader;
 import frysk.proc.Auxv;
 import frysk.proc.MemoryMap;
+import java.io.File;
 
 public class LinuxExeProc extends DeadProc {
 
-    private ElfData elfData = null;
-    ArrayList metaData = new ArrayList();
-    LinuxExeHost host = null;
+    private final MemoryMap[] memoryMaps;
+    private final String[] argv;
+    private final File exeFile;
 
-    public LinuxExeProc(ElfData data, LinuxExeHost host) {
+    public LinuxExeProc(LinuxExeHost host, File exeFile, ElfEHeader eHeader,
+			MemoryMap[] memoryMaps, String[] argv) {
 	super(host, null, 0);
-	this.host = host;
-	this.elfData = data;
-	sendRefresh();
-	ISA isa = ElfMap.getISA(elfData.getParent().getEHeader());
-	new LinuxExeTask(this, isa);
-	buildMetaData();
+	this.exeFile = exeFile;
+	this.memoryMaps = memoryMaps;
+	this.argv = argv;
+	new LinuxExeTask(this, eHeader, memoryMaps);
     }
 
     public Auxv[] getAuxv() {
-	return null;
+	return auxv;
     }
+    private final Auxv[] auxv = new Auxv[0];
     
     public int getUID() {
 	return 0;
     }
 
     public String[] getCmdLine() {
-	return null;
+	return argv;
     }
 
     public String getCommand() {
-	return this.host.exeFile.getName();
+	return exeFile.getName();
     }
 
     public String getExe() {
-	return host.exeFile.getAbsolutePath();
+	return exeFile.getAbsolutePath();
     }
 
     public int getGID() {
@@ -90,34 +85,6 @@ public class LinuxExeProc extends DeadProc {
     }
     
     public MemoryMap[] getMaps() {
-	return (MemoryMap[]) metaData.toArray(new MemoryMap[metaData.size()]);
-    }
-
-    ByteBuffer getMemory() {
-	if (memory == null)
-	    memory = new ExeByteBuffer(metaData);
-	return memory;
+	return memoryMaps;
     }
-    private ByteBuffer memory;
-    
-    private void buildMetaData()
-    {
-	class BuildExeMaps extends SOLibMapBuilder
-
-	{
-	    public void buildMap(long addrLow, long addrHigh, boolean permRead,
-		    boolean permWrite, boolean permExecute, long offset,
-		    String name, long align) 
-	    {
-		metaData.add(new MemoryMap(addrLow, addrHigh, permRead,
-			permWrite, permExecute, false, offset, -1, -1, -1, -1, -1,
-			host.exeFile.getAbsolutePath()));
-	    }
-	}
-	
-	BuildExeMaps SOMaps = new BuildExeMaps();
-	// Add in case for executables maps.
-	SOMaps.construct(this.host.exeFile, 0);
-    }
-
 }
diff --git a/frysk-core/frysk/proc/dead/LinuxExeTask.java b/frysk-core/frysk/proc/dead/LinuxExeTask.java
index 4d90354..a762769 100644
--- a/frysk-core/frysk/proc/dead/LinuxExeTask.java
+++ b/frysk-core/frysk/proc/dead/LinuxExeTask.java
@@ -43,35 +43,20 @@ import inua.eio.ArrayByteBuffer;
 import inua.eio.ByteBuffer;
 import frysk.isa.banks.RegisterBanks;
 import frysk.isa.ISA;
-import lib.dwfl.Elf;
-import lib.dwfl.ElfCommand;
 import lib.dwfl.ElfEHeader;
-import lib.dwfl.ElfException;
-import java.io.File;
+import frysk.isa.ElfMap;
+import frysk.proc.MemoryMap;
 
 public class LinuxExeTask extends DeadTask {
     private final long pc;
-    private final LinuxExeProc proc;
+    private final ByteBuffer memory;
 
-    LinuxExeTask(LinuxExeProc proc, ISA isa) {
-	super(proc, 0, isa, constructRegisterBanks(isa));
-	this.proc = proc;
-	// Compute a Fake PC.  XXX should be done in Proc instead of


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


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [SCM]  master: frysk-core/frysk/hpd/ChangeLog
@ 2008-01-08 21:41 cagney
  0 siblings, 0 replies; 6+ messages in thread
From: cagney @ 2008-01-08 21:41 UTC (permalink / raw)
  To: frysk-cvs

The branch, master has been updated
       via  62c53ec6561a7145d53727a9e79831fb04df27b9 (commit)
      from  a7293cffc1743a71c3a5912aaa862f736a3b2bef (commit)

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

- Log -----------------------------------------------------------------
commit 62c53ec6561a7145d53727a9e79831fb04df27b9
Author: Andrew Cagney <cagney@redhat.com>
Date:   Tue Jan 8 16:27:29 2008 -0500

    frysk-core/frysk/hpd/ChangeLog
    2008-01-08  Andrew Cagney  <cagney@redhat.com>
    
    	* CoreCommand.java (getProc(LinuxCoreHost)): Delete; use
    	Host.getSoleProcFIXME.
    
    frysk-core/frysk/proc/ChangeLog
    2008-01-08  Andrew Cagney  <cagney@redhat.com>
    
    	* Host.java (getProcIterator()): Delete.
    	(getSoleProcFIXME()): New.
    	* ProcBlockAction.java: Use Host.getSoleProcFIXME.
    
    frysk-core/frysk/util/ChangeLog
    2008-01-08  Andrew Cagney  <cagney@redhat.com>
    
    	* TestStackTraceAction.java: Replace Host.getProcInterator with
    	Host.getSoleProcFIXME.
    	* Util.java: Ditto.

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

Summary of changes:
 frysk-core/frysk/hpd/ChangeLog                  |    5 +
 frysk-core/frysk/hpd/CoreCommand.java           |   14 +---
 frysk-core/frysk/proc/ChangeLog                 |    6 ++
 frysk-core/frysk/proc/Host.java                 |   20 ++++-
 frysk-core/frysk/proc/ProcBlockAction.java      |   14 +---
 frysk-core/frysk/util/ChangeLog                 |    6 ++
 frysk-core/frysk/util/TestStackTraceAction.java |   58 +++++---------
 frysk-core/frysk/util/Util.java                 |   98 +++++++---------------
 8 files changed, 89 insertions(+), 132 deletions(-)

First 500 lines of diff:
diff --git a/frysk-core/frysk/hpd/ChangeLog b/frysk-core/frysk/hpd/ChangeLog
index c87fb9c..d00e10f 100644
--- a/frysk-core/frysk/hpd/ChangeLog
+++ b/frysk-core/frysk/hpd/ChangeLog
@@ -1,3 +1,8 @@
+2008-01-08  Andrew Cagney  <cagney@redhat.com>
+
+	* CoreCommand.java (getProc(LinuxCoreHost)): Delete; use
+	Host.getSoleProcFIXME.
+
 2008-01-07  Andrew Cagney  <cagney@redhat.com>
 
 	* AttachCommand.java: Update; use Host.requestProc(ProcId,FindProc).
diff --git a/frysk-core/frysk/hpd/CoreCommand.java b/frysk-core/frysk/hpd/CoreCommand.java
index ed2f2b7..20ccbc5 100644
--- a/frysk-core/frysk/hpd/CoreCommand.java
+++ b/frysk-core/frysk/hpd/CoreCommand.java
@@ -101,7 +101,7 @@ public class CoreCommand extends ParameterizedCommand {
 		coreHost = getHost(coreFile, exeFile, noExeOption);
 
 		// Get the core proc.
-		coreProc = getProc(coreHost);
+		coreProc = coreHost.getSoleProcFIXME();
 
 		// Error out if no exe found, and -noexe option specified
 		if ((noExeOption == false) && (coreHost.getStatus().hasExe == false)) {
@@ -156,18 +156,6 @@ public class CoreCommand extends ParameterizedCommand {
 		return coreHost;
 	}
 
-	// From a Host, get a Proc
-	private Proc getProc(LinuxCoreHost 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));
diff --git a/frysk-core/frysk/proc/ChangeLog b/frysk-core/frysk/proc/ChangeLog
index ac4351a..a9565d0 100644
--- a/frysk-core/frysk/proc/ChangeLog
+++ b/frysk-core/frysk/proc/ChangeLog
@@ -1,3 +1,9 @@
+2008-01-08  Andrew Cagney  <cagney@redhat.com>
+
+	* Host.java (getProcIterator()): Delete.
+	(getSoleProcFIXME()): New.
+	* ProcBlockAction.java: Use Host.getSoleProcFIXME.
+
 2008-01-07  Andrew Cagney  <cagney@redhat.com>
 
 	* Host.java requestProc(ProcId,FindProc): Make abstract.
diff --git a/frysk-core/frysk/proc/Host.java b/frysk-core/frysk/proc/Host.java
index 421e1e0..132f507 100644
--- a/frysk-core/frysk/proc/Host.java
+++ b/frysk-core/frysk/proc/Host.java
@@ -43,7 +43,6 @@ import java.net.UnknownHostException;
 import java.util.Map;
 import java.util.HashMap;
 import java.util.Collection;
-import java.util.Iterator;
 import java.util.Observable; // XXX: Temporary.
 import java.util.logging.Level;
 import java.util.logging.Logger;
@@ -107,13 +106,26 @@ public abstract class Host {
 	procPool.remove(proc.id);
 	observableProcRemovedXXX.notify(proc);
     }
-    public Iterator getProcIterator() {
-	return procPool.values().iterator();
-    }
     public Proc getProc(ProcId id) {
 	logger.log(Level.FINE, "{0} getProc ProcId {1} \n", new Object[] {this, id}); 
 	return (Proc) procPool.get(id);
     }
+    /**
+     * Assuming that this host has only one proc; return it; this is
+     * used by the EXE and CORE targets
+     *
+     * FIXME: This should this be replaced by methods to "request a
+     * core" and "request a proc".
+     */
+    public Proc getSoleProcFIXME() {
+	switch (procPool.size()) {
+	case 1:
+	    return (Proc) procPool.values().iterator().next();
+	default:
+	    return null;
+	}
+    }
+
 
     /**
      * Request that the Host scan the system's process tables
diff --git a/frysk-core/frysk/proc/ProcBlockAction.java b/frysk-core/frysk/proc/ProcBlockAction.java
index 477c150..11cec04 100644
--- a/frysk-core/frysk/proc/ProcBlockAction.java
+++ b/frysk-core/frysk/proc/ProcBlockAction.java
@@ -172,21 +172,13 @@ public class ProcBlockAction
 
     core.requestRefreshXXX();
     Manager.eventLoop.runPending();
-    Iterator iterator = core.getProcIterator();
-
-    if (iterator.hasNext())
-      proc = (Proc) iterator.next();
-    else
-      {
-        proc = null;
+    proc = core.getSoleProcFIXME();
+    if (proc == null)
         throw new RuntimeException("No proc in this corefile");
-      }
-    if (iterator.hasNext())
-      throw new RuntimeException("Too many procs on this corefile");
 
     taskList = proc.getTasks();
     
-    iterator = taskList.iterator();
+    Iterator iterator = taskList.iterator();
     
     while (iterator.hasNext())
       {
diff --git a/frysk-core/frysk/util/ChangeLog b/frysk-core/frysk/util/ChangeLog
index 4e000f6..55134d3 100644
--- a/frysk-core/frysk/util/ChangeLog
+++ b/frysk-core/frysk/util/ChangeLog
@@ -1,3 +1,9 @@
+2008-01-08  Andrew Cagney  <cagney@redhat.com>
+
+	* TestStackTraceAction.java: Replace Host.getProcInterator with
+	Host.getSoleProcFIXME.
+	* Util.java: Ditto.
+
 2008-01-07  Andrew Cagney  <cagney@redhat.com>
 
 	* FCatch.java: Update; use Host.requestProc.
diff --git a/frysk-core/frysk/util/TestStackTraceAction.java b/frysk-core/frysk/util/TestStackTraceAction.java
index f264a8e..3af07cb 100644
--- a/frysk-core/frysk/util/TestStackTraceAction.java
+++ b/frysk-core/frysk/util/TestStackTraceAction.java
@@ -1,6 +1,6 @@
 // This file is part of the program FRYSK.
 //
-// Copyright 2005, 2006, Red Hat Inc.
+// Copyright 2005, 2006, 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
@@ -42,9 +42,7 @@ package frysk.util;
 
 import java.io.PrintWriter;
 import java.io.StringWriter;
-import java.util.Iterator;
 import java.util.logging.Level;
-
 import frysk.Config;
 import frysk.event.RequestStopEvent;
 import frysk.proc.Host;
@@ -127,38 +125,24 @@ public class TestStackTraceAction
 
   }
   
-  public void testCore ()
-  {
-    if (unresolved(4581))
-      return;
-   
-    StringWriter stringWriter = new StringWriter();
-    
-    Host coreHost = new LinuxCoreHost(Manager.eventLoop,
-                                  Config.getPkgDataFile("test-core-x86"));
-
-    assertNotNull("Core file Host is Null?", coreHost);
-
-    Iterator iter = coreHost.getProcIterator();
-    while (iter.hasNext())
-      {
-        Proc proc = (Proc) iter.next();
-        StacktraceAction stacker;
-
-        stacker = new StacktraceAction(new PrintWriter(stringWriter),proc, new RequestStopEvent(Manager.eventLoop),20, true, false,false, false,true,true)
-        {
-
-          public void addFailed (Object observable, Throwable w)
-          {
-            fail("Proc add failed: " + w.getMessage());
-          }
-        };
-
-        new ProcCoreAction (proc, stacker);
-        assertRunUntilStop("perform backtrace");
-        
-        assertNotNull("has backtrace?", stringWriter.getBuffer().toString());
-      }
-
-  }
+    public void testCore() {
+	if (unresolved(4581))
+	    return;
+	StringWriter stringWriter = new StringWriter();
+	Host coreHost = new LinuxCoreHost(Manager.eventLoop,
+					  Config.getPkgDataFile("test-core-x86"));
+	assertNotNull("Core file Host is Null?", coreHost);
+	Proc proc = coreHost.getSoleProcFIXME();
+	assertNotNull("core proc", proc);
+	StacktraceAction stacker;
+	stacker = new StacktraceAction(new PrintWriter(stringWriter),proc, new RequestStopEvent(Manager.eventLoop),20, true, false,false, false,true,true) {
+		
+		public void addFailed (Object observable, Throwable w) {
+		    fail("Proc add failed: " + w.getMessage());
+		}
+	    };
+	new ProcCoreAction (proc, stacker);
+	assertRunUntilStop("perform backtrace");
+	assertNotNull("has backtrace?", stringWriter.getBuffer().toString());
+    }
 }
diff --git a/frysk-core/frysk/util/Util.java b/frysk-core/frysk/util/Util.java
index a13664a..f4c0323 100644
--- a/frysk-core/frysk/util/Util.java
+++ b/frysk-core/frysk/util/Util.java
@@ -1,6 +1,6 @@
 // This file is part of the program FRYSK.
 //
-// Copyright 2005, 2007, Red Hat Inc.
+// Copyright 2005, 2007, 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
@@ -40,8 +40,6 @@
 package frysk.util;
 
 import java.io.File;
-import java.util.Iterator;
-
 import frysk.proc.Host;
 import frysk.proc.FindProc;
 import frysk.proc.Manager;
@@ -56,50 +54,27 @@ public class Util
   {
   }
   
-  /**
-   * Return the Proc associated with a coreFile.
-   * @param coreFile the given coreFile.
-   * @return The Proc for the given coreFile.
-   */
-  public static Proc getProcFromCoreFile(File coreFile)
-  {
-    LinuxCoreHost core = new LinuxCoreHost(Manager.eventLoop, coreFile);
-
-    Iterator iterator = core.getProcIterator();
-
-    Proc proc;
-    if (iterator.hasNext())
-      proc = (Proc) iterator.next();
-    else
-      {
-        proc = null;
-        throw new RuntimeException("Cannot find a process in this corefile.");
-      }
-    if (iterator.hasNext())
-      throw new RuntimeException("Too many processes in this corefile.");
-    
-    return proc;
-  }
+    /**
+     * Return the Proc associated with a coreFile.
+     * @param coreFile the given coreFile.
+     * @return The Proc for the given coreFile.
+     */
+    public static Proc getProcFromCoreFile(File coreFile) {
+	LinuxCoreHost core = new LinuxCoreHost(Manager.eventLoop, coreFile);
+	Proc proc = core.getSoleProcFIXME();
+	if (proc == null)
+	    throw new RuntimeException("Core file contains no proc.");
+	return proc;
+    }
   
-  public static Proc getProcFromCoreFile(File coreFile, File exeFile)
-  {
-    LinuxCoreHost core = new LinuxCoreHost(Manager.eventLoop, coreFile, exeFile);
-
-    Iterator iterator = core.getProcIterator();
-
-    Proc proc;
-    if (iterator.hasNext())
-      proc = (Proc) iterator.next();
-    else
-      {
-        proc = null;
-        throw new RuntimeException("Cannot find a process in this corefile.");
-      }
-    if (iterator.hasNext())
-      throw new RuntimeException("Too many processes in this corefile.");
-    
-    return proc;
-  }
+    public static Proc getProcFromCoreFile(File coreFile, File exeFile) {
+	LinuxCoreHost core = new LinuxCoreHost(Manager.eventLoop, coreFile,
+					       exeFile);
+	Proc proc = core.getSoleProcFIXME();
+	if (proc == null)
+	    throw new RuntimeException("Cannot find a process in this corefile.");
+	return proc;
+    }
   
   public static Proc getProcFromCoreExePair(CoreExePair coreExePair) {
       if (coreExePair.exeFile == null)
@@ -133,26 +108,15 @@ public class Util
       return finder.proc;
   }
   
-  /**
-   * Return the Proc associated with an executable File.
-   * @param exeHost the Host associated with the desired Proc.
-   * @return The Proc for the given executable File.
-   */
-  public static Proc getProcFromExeFile(Host exeHost)
-  {
-      Iterator iterator = exeHost.getProcIterator();
-
-      Proc proc;
-      if (iterator.hasNext())
-        proc = (Proc) iterator.next();
-      else
-        {
-          proc = null;
-          throw new RuntimeException("Cannot find a process in this executable.");
-        }
-      if (iterator.hasNext())
-        throw new RuntimeException("Too many processes in this executable.");
-      
-      return proc;
+    /**
+     * Return the Proc associated with an executable File.
+     * @param exeHost the Host associated with the desired Proc.
+     * @return The Proc for the given executable File.
+     */
+    public static Proc getProcFromExeFile(Host exeHost) {
+	Proc proc = exeHost.getSoleProcFIXME();
+	if (proc == null)
+	    throw new RuntimeException("Cannot find a process in this executable.");
+	return proc;
     }
 }


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


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2008-06-06 19:31 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-06-06 19:31 [SCM] master: frysk-core/frysk/hpd/ChangeLog swagiaal
  -- strict thread matches above, loose matches on Subject: below --
2008-03-17 19:09 cagney
2008-03-03 23:09 cagney
2008-02-26 16:54 cagney
2008-02-25 17:17 cagney
2008-01-08 21:41 cagney

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