From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21680 invoked by alias); 8 Jan 2008 21:41:04 -0000 Received: (qmail 21653 invoked by uid 367); 8 Jan 2008 21:41:03 -0000 Date: Tue, 08 Jan 2008 21:41:00 -0000 Message-ID: <20080108214103.21638.qmail@sourceware.org> From: cagney@sourceware.org To: frysk-cvs@sourceware.org Subject: [SCM] master: frysk-core/frysk/hpd/ChangeLog X-Git-Refname: refs/heads/master X-Git-Reftype: branch X-Git-Oldrev: a7293cffc1743a71c3a5912aaa862f736a3b2bef X-Git-Newrev: 62c53ec6561a7145d53727a9e79831fb04df27b9 Mailing-List: contact frysk-cvs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: frysk-cvs-owner@sourceware.org Reply-To: frysk@sourceware.org X-SW-Source: 2008-q1/txt/msg00031.txt.bz2 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 Date: Tue Jan 8 16:27:29 2008 -0500 frysk-core/frysk/hpd/ChangeLog 2008-01-08 Andrew Cagney * CoreCommand.java (getProc(LinuxCoreHost)): Delete; use Host.getSoleProcFIXME. frysk-core/frysk/proc/ChangeLog 2008-01-08 Andrew Cagney * Host.java (getProcIterator()): Delete. (getSoleProcFIXME()): New. * ProcBlockAction.java: Use Host.getSoleProcFIXME. frysk-core/frysk/util/ChangeLog 2008-01-08 Andrew Cagney * 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 + + * CoreCommand.java (getProc(LinuxCoreHost)): Delete; use + Host.getSoleProcFIXME. + 2008-01-07 Andrew Cagney * 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 + + * Host.java (getProcIterator()): Delete. + (getSoleProcFIXME()): New. + * ProcBlockAction.java: Use Host.getSoleProcFIXME. + 2008-01-07 Andrew Cagney * 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 + + * TestStackTraceAction.java: Replace Host.getProcInterator with + Host.getSoleProcFIXME. + * Util.java: Ditto. + 2008-01-07 Andrew Cagney * 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