public inbox for frysk-cvs@sourceware.org
help / color / mirror / Atom feed
From: cagney@sourceware.org
To: frysk-cvs@sourceware.org
Subject: [SCM]  master: frysk-core/frysk/hpd/ChangeLog
Date: Tue, 08 Jan 2008 21:41:00 -0000	[thread overview]
Message-ID: <20080108214103.21638.qmail@sourceware.org> (raw)

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


             reply	other threads:[~2008-01-08 21:41 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-08 21:41 cagney [this message]
2008-02-25 17:17 cagney
2008-02-26 16:54 cagney
2008-03-03 23:09 cagney
2008-03-17 19:09 cagney
2008-06-06 19:31 swagiaal

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=20080108214103.21638.qmail@sourceware.org \
    --to=cagney@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).