From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22084 invoked by alias); 26 Feb 2008 16:54:56 -0000 Received: (qmail 22057 invoked by uid 367); 26 Feb 2008 16:54:54 -0000 Date: Tue, 26 Feb 2008 16:54:00 -0000 Message-ID: <20080226165454.22041.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: 491d4ec7ba3a8e3878cca1c9f916ca7069d79469 X-Git-Newrev: 4454bcc2dd04291821f28d4e17044ab2d1d659b6 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/msg00250.txt.bz2 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 Date: Tue Feb 26 11:42:11 2008 -0500 frysk-core/frysk/hpd/ChangeLog 2008-02-25 Andrew Cagney * 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 * ProcBlockAction.java: Use LinuxCoreFactory. frysk-core/frysk/proc/dead/ChangeLog 2008-02-26 Andrew Cagney * 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 * Util.java: Use LinuxCoreFactory. * TestCoredumpAction.java: Ditto. * TestStackTraceAction.java: Ditto. frysk-sys/frysk/rsl/ChangeLog 2008-02-26 Andrew Cagney * 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 + * 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 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 [ ] [ -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 [ ] [ -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: + // + 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 + + * ProcBlockAction.java: Use LinuxCoreFactory. + 2008-02-20 Phil Muldoon * 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 + + * 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 * 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 must 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 must 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 must 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