From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11982 invoked by alias); 6 Nov 2007 14:58:09 -0000 Received: (qmail 11955 invoked by uid 9514); 6 Nov 2007 14:58:07 -0000 Date: Tue, 06 Nov 2007 14:58:00 -0000 Message-ID: <20071106145806.11940.qmail@sourceware.org> From: pmuldoon@sourceware.org To: frysk-cvs@sourceware.org Subject: [SCM] frysk system monitor/debugger branch, master, updated. 6c1b2134a1081b7d65f0656fcc13a9ae85d964f9 X-Git-Refname: refs/heads/master X-Git-Reftype: branch X-Git-Oldrev: 7c185652b3cca2ab1cbfeeb45482ec772d1b4c5b X-Git-Newrev: 6c1b2134a1081b7d65f0656fcc13a9ae85d964f9 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: 2007-q4/txt/msg00301.txt.bz2 The branch, master has been updated via 6c1b2134a1081b7d65f0656fcc13a9ae85d964f9 (commit) from 7c185652b3cca2ab1cbfeeb45482ec772d1b4c5b (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email. - Log ----------------------------------------------------------------- commit 6c1b2134a1081b7d65f0656fcc13a9ae85d964f9 Author: Phil Muldoon Date: Tue Nov 6 14:57:57 2007 +0000 Rework how corefiles and executables pair. Build a corefile status object. Return much richer information to CoreCommand. 2007-11-06 Phil Muldoon * LinuxProc.java (LinuxProc): Do not search for exe beyond pwd. * LinuxHost.java (LinuxHost): Build a CorefileStatus. (getStatus): New. (DeconstructCoreFile.update): Build status from Proc. * CorefileStatus.java: New 2007-11-06 Phil Muldoon * CoreCommand.java (interpret): Rewrite corefile model. Give much richer information back on corefile building. ----------------------------------------------------------------------- Summary of changes: frysk-core/frysk/hpd/ChangeLog | 5 ++ frysk-core/frysk/hpd/CoreCommand.java | 45 ++++++++++++++++++-- frysk-core/frysk/proc/dead/ChangeLog | 8 ++++ .../dead/{DeadHost.java => CorefileStatus.java} | 20 ++++----- frysk-core/frysk/proc/dead/LinuxHost.java | 30 ++++++++++++- frysk-core/frysk/proc/dead/LinuxProc.java | 21 +-------- 6 files changed, 94 insertions(+), 35 deletions(-) copy frysk-core/frysk/proc/dead/{DeadHost.java => CorefileStatus.java} (88%) First 500 lines of diff: diff --git a/frysk-core/frysk/hpd/ChangeLog b/frysk-core/frysk/hpd/ChangeLog index 324823d..9987008 100644 --- a/frysk-core/frysk/hpd/ChangeLog +++ b/frysk-core/frysk/hpd/ChangeLog @@ -1,3 +1,8 @@ +2007-11-06 Phil Muldoon + + * CoreCommand.java (interpret): Rewrite corefile model. + Give much richer information back on corefile building. + 2007-11-01 Andrew Cagney * Command.java (complete(CLI,Input,int,List)): Remove comment diff --git a/frysk-core/frysk/hpd/CoreCommand.java b/frysk-core/frysk/hpd/CoreCommand.java index 0b23e18..3173ef6 100644 --- a/frysk-core/frysk/hpd/CoreCommand.java +++ b/frysk-core/frysk/hpd/CoreCommand.java @@ -44,6 +44,9 @@ import java.util.Iterator; import frysk.debuginfo.DebugInfo; import frysk.debuginfo.DebugInfoFrame; import frysk.debuginfo.DebugInfoStackFactory; +import frysk.proc.dead.CorefileStatus; +import frysk.proc.dead.LinuxHost; +import frysk.proc.Manager; import frysk.proc.Proc; import frysk.proc.Task; @@ -68,16 +71,50 @@ public class CoreCommand extends Command { File coreFile = new File(cmd.parameter(0)); Proc coreProc; + File exeFile = null; + LinuxHost coreHost = null; if (cmd.size() == 1) - coreProc = frysk.util.Util.getProcFromCoreFile(coreFile); + coreHost = new LinuxHost(Manager.eventLoop, coreFile); else { - File exeFile = new File(cmd.parameter(1)); - coreProc = frysk.util.Util.getProcFromCoreFile(coreFile, exeFile); + exeFile = new File(cmd.parameter(1)); + coreHost = new LinuxHost(Manager.eventLoop, coreFile, exeFile); + } + + Iterator i = coreHost.getProcIterator(); + + if (i.hasNext()) + coreProc = (Proc) i.next(); + else { + cli.addMessage("Cannot find a process in corefile: '" + coreFile.getAbsolutePath()+"'. This may not be a valid ELF corefile.", Message.TYPE_ERROR); + return; + } + if (i.hasNext()) { + cli.addMessage("There appears to be two or more processes in corefile: '" + coreFile.getAbsolutePath()+"'. This is not valid for an ELF corefile", Message.TYPE_ERROR); + return; + } + CorefileStatus status = coreHost.getStatus(); + if (status.hasExe == false) + { + String message = "The corefile: '"+coreFile.getAbsolutePath()+"' has no executable associated with it. The executable name "; + String exeName = ""; + if (exeFile != null) + { + exeName = exeFile.getAbsolutePath(); + message += "specified by the user on the Core command was: '" + exeName; + } + else + { + exeName = coreProc.getExe(); + message += "automatically read from the corefile was: '" + exeName; + } + message+="'. This executable could not be read. Please specifiy an executable on the 'core' command (eg core core.1234 exenamedFile) for richer metadata."; + + cli.addMessage(message,Message.TYPE_WARNING); } - int procID = cli.idManager.reserveProcID(); cli.idManager.manageProc(coreProc, procID); + Iterator foo = cli.targetset.getTasks(); while (foo.hasNext()) { Task task = (Task) foo.next(); diff --git a/frysk-core/frysk/proc/dead/ChangeLog b/frysk-core/frysk/proc/dead/ChangeLog index 9d5d3e6..c11c271 100644 --- a/frysk-core/frysk/proc/dead/ChangeLog +++ b/frysk-core/frysk/proc/dead/ChangeLog @@ -1,3 +1,11 @@ +2007-11-06 Phil Muldoon + + * LinuxProc.java (LinuxProc): Do not search for exe beyond pwd. + * LinuxHost.java (LinuxHost): Build a CorefileStatus. + (getStatus): New. + (DeconstructCoreFile.update): Build status from Proc. + * CorefileStatus.java: New + 2007-10-18 Rick Moseley * LinuxExeHost.java: Add DeconstructExeFile class and update diff --git a/frysk-core/frysk/proc/dead/DeadHost.java b/frysk-core/frysk/proc/dead/CorefileStatus.java similarity index 88% copy from frysk-core/frysk/proc/dead/DeadHost.java copy to frysk-core/frysk/proc/dead/CorefileStatus.java index 29a077e..b99e1fc 100644 --- a/frysk-core/frysk/proc/dead/DeadHost.java +++ b/frysk-core/frysk/proc/dead/CorefileStatus.java @@ -33,20 +33,18 @@ // 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 +// modification, you must delete this exception statement from your// version and license this file solely under the GPL without // exception. -package frysk.proc.dead; - -import frysk.proc.Host; -/** - * A dead Host/Proc/Task is characterised by its lack of state, and an - * in ability to respond to stateful requests such as add/remove - * observers. - */ +package frysk.proc.dead; -abstract class DeadHost extends Host { +public class CorefileStatus { + public boolean hasExe = false; + public boolean hasCore = true; + public String exeName = ""; + public String coreName = ""; + public boolean hasExeProblem = false; + public String message = ""; } diff --git a/frysk-core/frysk/proc/dead/LinuxHost.java b/frysk-core/frysk/proc/dead/LinuxHost.java index aa2e1e3..3bc2eeb 100644 --- a/frysk-core/frysk/proc/dead/LinuxHost.java +++ b/frysk-core/frysk/proc/dead/LinuxHost.java @@ -58,6 +58,7 @@ import frysk.proc.FindProc; public class LinuxHost extends DeadHost { + CorefileStatus status = new CorefileStatus(); boolean hasRefreshed = false; boolean exeSetToNull = false; protected File coreFile = null; @@ -93,11 +94,28 @@ public class LinuxHost extends DeadHost { { this(eventLoop, coreFile, false); if (exeFile == null) - exeSetToNull = true; - this.exeFile = exeFile; + exeSetToNull = true; + + if (exeFile.canRead() && exeFile.exists()) + this.exeFile = exeFile; + else + { + status.hasExe = false; + status.hasExeProblem = true; + status.message = "The user provided executable: " + + exeFile.getAbsolutePath() + + " could not be accessed"; + } this.sendRefresh(true); + + } + public CorefileStatus getStatus() + { + return status; + } + protected void sendRefresh(boolean refreshAll) { @@ -172,6 +190,7 @@ public class LinuxHost extends DeadHost { DeconstructCoreFile(Elf coreFileElf) { this.coreFileElf = coreFileElf; + status.coreName = coreFile.getAbsolutePath(); ElfEHeader eHeader = this.coreFileElf.getEHeader(); // Get number of program header entries. @@ -210,6 +229,13 @@ public class LinuxHost extends DeadHost { addedProcs.add(proc); + if (exeFile == null) + status.hasExe = false; + else + { + status.hasExe = true; + status.exeName = exeFile.getAbsolutePath(); + } return proc; } diff --git a/frysk-core/frysk/proc/dead/LinuxProc.java b/frysk-core/frysk/proc/dead/LinuxProc.java index 1db4019..69f0d84 100644 --- a/frysk-core/frysk/proc/dead/LinuxProc.java +++ b/frysk-core/frysk/proc/dead/LinuxProc.java @@ -90,24 +90,9 @@ public class LinuxProc extends DeadProc { // as it is written in the corefile. if ((host.exeFile == null) && (host.exeSetToNull == false)) { - File exeFileName = new File(sendrecExe()); - // XXX: Hack here, some processes do not have path information - // in the name. - if ((exeFileName.exists()) && (exeFileName.canRead())) - host.exeFile = exeFileName; - else - { - String commonLocations[] = {"/bin/","/usr/bin/"}; - for (int i=0; i