From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14429 invoked by alias); 27 Feb 2008 05:05:08 -0000 Received: (qmail 14400 invoked by uid 367); 27 Feb 2008 05:05:06 -0000 Date: Wed, 27 Feb 2008 05:05:00 -0000 Message-ID: <20080227050506.14385.qmail@sourceware.org> From: cagney@sourceware.org To: frysk-cvs@sourceware.org Subject: [SCM] master: Delete remaining parseCoreFIXME-s. X-Git-Refname: refs/heads/master X-Git-Reftype: branch X-Git-Oldrev: 79569bf5e4b48be2efebcea902795514f238ca9f X-Git-Newrev: e843db654791fb4bf47fd301bc18499d0ade8cb0 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/msg00261.txt.bz2 The branch, master has been updated via e843db654791fb4bf47fd301bc18499d0ade8cb0 (commit) from 79569bf5e4b48be2efebcea902795514f238ca9f (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email. - Log ----------------------------------------------------------------- commit e843db654791fb4bf47fd301bc18499d0ade8cb0 Author: Andrew Cagney Date: Wed Feb 27 00:03:28 2008 -0500 Delete remaining parseCoreFIXME-s. frysk-core/frysk/bindir/ChangeLog 2008-02-26 Andrew Cagney * fhpd.java (parseCommand(Proc)): Replace parseCommandFIXME. (parseCores(Proc[]): Replace parseCoresFIXME. (-noexe): Delete; moved to CommandlineParser. * TestFauxv.java (fauxv(File)): Specify -noexe. frysk-core/frysk/hpd/ChangeLog 2008-02-26 Andrew Cagney * LoadCommand.java (load(Proc,CLI,String)): New. * CoreCommand.java (load(Proc,CLI,String)): New. * AttachCommand.java (attach(Proc,CLI,String)): New. frysk-core/frysk/proc/dead/ChangeLog 2008-02-26 Andrew Cagney * LinuxCoreFactory.java (createProc(File,boolean)): New. * LinuxCoreInfo.java: Use the extracted exeFile. frysk-core/frysk/util/ChangeLog 2008-02-26 Andrew Cagney * CommandlineParser.java (parseCoresFIXME(CoreExePair[])): Delete. (-noexe): Add. ----------------------------------------------------------------------- Summary of changes: frysk-core/frysk/bindir/ChangeLog | 5 + frysk-core/frysk/bindir/TestFauxv.java | 3 +- frysk-core/frysk/bindir/fhpd.java | 88 ++++++++-------------- frysk-core/frysk/hpd/AttachCommand.java | 11 ++- frysk-core/frysk/hpd/ChangeLog | 4 + frysk-core/frysk/hpd/CoreCommand.java | 11 ++- frysk-core/frysk/hpd/KillCommand.java | 11 ++- frysk-core/frysk/hpd/LoadCommand.java | 9 ++- frysk-core/frysk/proc/dead/ChangeLog | 3 + frysk-core/frysk/proc/dead/LinuxCoreFactory.java | 8 ++ frysk-core/frysk/proc/dead/LinuxCoreInfo.java | 2 +- frysk-core/frysk/util/ChangeLog | 3 + frysk-core/frysk/util/CommandlineParser.java | 47 +++++------- 13 files changed, 104 insertions(+), 101 deletions(-) First 500 lines of diff: diff --git a/frysk-core/frysk/bindir/ChangeLog b/frysk-core/frysk/bindir/ChangeLog index 340a72c..8a6d763 100644 --- a/frysk-core/frysk/bindir/ChangeLog +++ b/frysk-core/frysk/bindir/ChangeLog @@ -1,5 +1,10 @@ 2008-02-26 Andrew Cagney + * fhpd.java (parseCommand(Proc)): Replace parseCommandFIXME. + (parseCores(Proc[]): Replace parseCoresFIXME. + (-noexe): Delete; moved to CommandlineParser. + * TestFauxv.java (fauxv(File)): Specify -noexe. + * fstack.java (parseCores(Proc[])): Replace parseCoresFIXME. (stackCore(Proc)): Replace stackCore(CoreExePair). diff --git a/frysk-core/frysk/bindir/TestFauxv.java b/frysk-core/frysk/bindir/TestFauxv.java index 98e3812..a8c01b5 100644 --- a/frysk-core/frysk/bindir/TestFauxv.java +++ b/frysk-core/frysk/bindir/TestFauxv.java @@ -47,9 +47,10 @@ import frysk.testbed.TestLib; public class TestFauxv extends TestLib { private TearDownExpect fauxv(File coreFile) { - String[] argv = new String[2]; + String[] argv = new String[3]; int argc = 0; argv[argc++] = Config.getBinFile("fauxv").getAbsolutePath(); + argv[argc++] = "-noexe"; argv[argc++] = coreFile.getAbsolutePath(); return new TearDownExpect(argv); } diff --git a/frysk-core/frysk/bindir/fhpd.java b/frysk-core/frysk/bindir/fhpd.java index ab55c52..3a5f285 100644 --- a/frysk-core/frysk/bindir/fhpd.java +++ b/frysk-core/frysk/bindir/fhpd.java @@ -39,8 +39,10 @@ package frysk.bindir; +import frysk.hpd.CoreCommand; +import frysk.hpd.LoadCommand; +import frysk.hpd.AttachCommand; import frysk.event.Event; -import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.PrintWriter; @@ -48,7 +50,6 @@ import java.util.List; import frysk.hpd.CLI; import jline.Completor; import jline.ConsoleReader; -import frysk.util.CoreExePair; import frysk.proc.Manager; import frysk.util.CommandlineParser; import frysk.util.ObservingTerminal; @@ -58,11 +59,9 @@ import frysk.sys.FileDescriptor; import frysk.proc.Proc; public class fhpd { - private static Proc[] procs; - private static File execFile; - private static File core; - private static File exeFile; - private static boolean noExe = false; + private static Proc[] pids; + private static Proc command; + private static Proc[] cores; private static String sysroot; private static int exitStatus; @@ -84,28 +83,9 @@ public class fhpd { private CLI cli; private ConsoleReader reader; CommandLine() { - // Construct a command to pass in as initialization - try { - if (procs != null) - line = "attach " + procs[0].getPid(); - else if (execFile != null) - line = "load " + execFile.getCanonicalPath(); - else if (core != null) { - line = "core " + core.getCanonicalPath(); - if (exeFile != null) - line += " " + exeFile.getCanonicalPath(); - else if (noExe) - line +=" -noexe"; - } - if (sysroot != null) - line = line + " -sysroot " + sysroot; - } catch (IOException e) { - System.err.println("Error: " + e); - System.exit(1); - return; - } // Construct the HPD. cli = new CLI("(fhpd) ", System.out); + try { reader = new ConsoleReader (new FileInputStream(java.io.FileDescriptor.in), @@ -125,14 +105,26 @@ public class fhpd { start(); } public void run() { + // Prime the CLI based on the parameters. + if (pids != null) { + for (int i = 0; i < pids.length; i++) { + AttachCommand.attach(pids[i], cli, sysroot); + } + } else if (cores != null) { + for (int i = 0; i < cores.length; i++) { + CoreCommand.load(cores[i], cli, sysroot); + } + } else if (command != null) { + LoadCommand.load(command, cli, sysroot); + } + try { - cli.execCommand(line); - while (line != null && ! (line.equals("quit") - || line.equals("q") - || line.equals("exit"))) { + do { line = reader.readLine(cli.getPrompt()); cli.execCommand(line); - } + } while (line != null && ! (line.equals("quit") + || line.equals("q") + || line.equals("exit"))); } catch (IOException ioe) { System.out.println("ERROR: Could not read from command line"); System.out.print(ioe.getMessage()); @@ -145,36 +137,18 @@ public class fhpd { public static void main (String[] args) { CommandlineParser parser = new CommandlineParser ("fhpd") { //@Override - public void parseCommandFIXME(String[] command) { - execFile = new File (command[0]); - if (execFile.canRead() == false) { - printHelp(); - throw new RuntimeException("command not readable: " - + command[0]); - } + public void parseCommand(Proc command) { + fhpd.command = command; } //@Override - public void parsePids(Proc[] procs) { - fhpd.procs = procs; + public void parsePids(Proc[] pids) { + fhpd.pids = pids; } - - public void parseCoresFIXME(CoreExePair[] corePairs) { - core = corePairs[0].coreFile; - exeFile = corePairs[0].exeFile; + //@Override + public void parseCores(Proc[] cores) { + fhpd.cores = cores; } }; - parser.add(new Option("noexe", "Do not attempt to read an"+ - " executable for a corefile ") { - public void parsed(String exeValue) throws OptionException { - try { - noExe = true; - - } catch (IllegalArgumentException e) { - throw new OptionException("Invalid noexe parameter " - + exeValue); - } - } - }); parser.add(new Option("sysroot", 's', "Assume the executable is from a sysroot build ", "SysRoot-Path") { diff --git a/frysk-core/frysk/hpd/AttachCommand.java b/frysk-core/frysk/hpd/AttachCommand.java index 3202e8b..d48ee15 100644 --- a/frysk-core/frysk/hpd/AttachCommand.java +++ b/frysk-core/frysk/hpd/AttachCommand.java @@ -45,7 +45,7 @@ import frysk.proc.Manager; import frysk.proc.FindProc; import java.util.List; -class AttachCommand extends ParameterizedCommand { +public class AttachCommand extends ParameterizedCommand { private class ProcFinder implements FindProc { Proc proc = null; @@ -116,11 +116,16 @@ class AttachCommand extends ParameterizedCommand { cli.outWriter.println(pid); continue; } - DwflCache.setSysroot(findProc.proc.getMainTask(), o.sysroot); - cli.doAttach(findProc.proc, false); + + attach(findProc.proc, cli, o.sysroot); } } + public static void attach(Proc proc, CLI cli, String sysroot) { + DwflCache.setSysroot(proc.getMainTask(), sysroot); + cli.doAttach(proc, false); + } + int completer(CLI cli, Input input, int base, List completions) { return -1; } diff --git a/frysk-core/frysk/hpd/ChangeLog b/frysk-core/frysk/hpd/ChangeLog index 6453b60..1199c61 100644 --- a/frysk-core/frysk/hpd/ChangeLog +++ b/frysk-core/frysk/hpd/ChangeLog @@ -1,5 +1,9 @@ 2008-02-26 Andrew Cagney + * LoadCommand.java (load(Proc,CLI,String)): New. + * CoreCommand.java (load(Proc,CLI,String)): New. + * AttachCommand.java (attach(Proc,CLI,String)): New. + * CoreCommand.java: Update to match LinuxCoreFactory. * LoadCommand.java: Update to match LinuxExeFactory. diff --git a/frysk-core/frysk/hpd/CoreCommand.java b/frysk-core/frysk/hpd/CoreCommand.java index d40653a..4439dab 100644 --- a/frysk-core/frysk/hpd/CoreCommand.java +++ b/frysk-core/frysk/hpd/CoreCommand.java @@ -116,6 +116,10 @@ public class CoreCommand extends ParameterizedCommand { Proc coreProc = LinuxCoreFactory.createProc(coreFile, exeFile, options.loadMetaData); + load(coreProc, cli, options.sysroot); + } + + public static void load(Proc coreProc, CLI cli, String sysroot) { // All checks are done. Host is built. Now start reserving // space in the sets. int procID = cli.idManager.reserveProcID(); @@ -128,15 +132,14 @@ public class CoreCommand extends ParameterizedCommand { .createVirtualStackTrace(task); cli.setTaskFrame(task, frame); cli.setTaskDebugInfo(task, new DebugInfo(frame)); - DwflCache.setSysroot(task, options.sysroot); + DwflCache.setSysroot(task, sysroot); } - // Finally, done. - cli.addMessage("Attached to core file: " + cmd.parameter(0), - Message.TYPE_NORMAL); synchronized (cli) { cli.getCoreProcs().put(coreProc, new Integer(procID)); } + cli.outWriter.println("Attached to core file: " + + coreProc.getHost().getName()); } int completer(CLI cli, Input input, int cursor, List completions) { diff --git a/frysk-core/frysk/hpd/KillCommand.java b/frysk-core/frysk/hpd/KillCommand.java index 5291c87..13f9bfd 100644 --- a/frysk-core/frysk/hpd/KillCommand.java +++ b/frysk-core/frysk/hpd/KillCommand.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 @@ -72,11 +72,12 @@ public class KillCommand extends ParameterizedCommand { Task task = taskData.getTask(); Proc proc = task.getProc(); if (proc.getPid() != procPID) { - cli.addMessage("Killing process " + proc.getPid() + - " that was created from " + proc.getExe(), - Message.TYPE_NORMAL); + cli.outWriter.println("Killing process " + proc.getPid() + + " that was created from " + + proc.getExe()); // Save the procs we are killing so we can re-load them later - saveProcs.put(new Integer(taskData.getParentID()), proc.getExe()); + saveProcs.put(new Integer(taskData.getParentID()), + proc.getExe()); procPID = proc.getPid(); // Now, call the Proc object to kill off the executable(s) proc.requestKill(); diff --git a/frysk-core/frysk/hpd/LoadCommand.java b/frysk-core/frysk/hpd/LoadCommand.java index f1b3b64..2493f1d 100644 --- a/frysk-core/frysk/hpd/LoadCommand.java +++ b/frysk-core/frysk/hpd/LoadCommand.java @@ -110,6 +110,10 @@ public class LoadCommand extends ParameterizedCommand { Proc exeProc = LinuxExeFactory.createProc(executableFile, cmd.stringArrayValue()); + load(exeProc, cli, o.sysroot); + } + + public static void load(Proc exeProc, CLI cli, String sysroot) { int procID; if (cli.taskID < 0) procID = cli.idManager.reserveProcID(); @@ -126,15 +130,14 @@ public class LoadCommand extends ParameterizedCommand { .createDebugInfoStackTrace(task); cli.setTaskFrame(task, frame); cli.setTaskDebugInfo(task, new DebugInfo(frame)); - DwflCache.setSysroot(task, o.sysroot); + DwflCache.setSysroot(task, sysroot); } } synchronized (cli) { cli.getLoadedProcs().put(exeProc, new Integer(procID)); } - cli.addMessage("Loaded executable file: " + cmd.parameter(0), - Message.TYPE_NORMAL); + cli.outWriter.println("Loaded executable file: " + exeProc.getExe()); } int completer(CLI cli, Input input, int cursor, List completions) { diff --git a/frysk-core/frysk/proc/dead/ChangeLog b/frysk-core/frysk/proc/dead/ChangeLog index f7d188f..5984330 100644 --- a/frysk-core/frysk/proc/dead/ChangeLog +++ b/frysk-core/frysk/proc/dead/ChangeLog @@ -1,5 +1,8 @@ 2008-02-26 Andrew Cagney + * LinuxCoreFactory.java (createProc(File,boolean)): New. + * LinuxCoreInfo.java: Use the extracted exeFile. + * TestLinuxCore.java: Update to match Proc. * TestLinuxExe.java (testRequestProc()): New. diff --git a/frysk-core/frysk/proc/dead/LinuxCoreFactory.java b/frysk-core/frysk/proc/dead/LinuxCoreFactory.java index c663d6f..5683a4c 100644 --- a/frysk-core/frysk/proc/dead/LinuxCoreFactory.java +++ b/frysk-core/frysk/proc/dead/LinuxCoreFactory.java @@ -70,6 +70,14 @@ public class LinuxCoreFactory { return createProc(coreFile, null, false); } /** + * Construct a core file, possibly with extended meta data. + * + * All File paths must be canonical. + */ + public static DeadProc createProc(File coreFile, boolean extendedMetaData) { + return createProc(coreFile, null, extendedMetaData); + } + /** * Construct a core file with extended meta data taken from the * executable. * diff --git a/frysk-core/frysk/proc/dead/LinuxCoreInfo.java b/frysk-core/frysk/proc/dead/LinuxCoreInfo.java index d239a4b..0d4e825 100644 --- a/frysk-core/frysk/proc/dead/LinuxCoreInfo.java +++ b/frysk-core/frysk/proc/dead/LinuxCoreInfo.java @@ -119,7 +119,7 @@ class LinuxCoreInfo { // have to extract this from the process information). this.exeFile = getExeFile(exeParam, args, prpsInfo); if (extendedMetaData) - exeElf = new Elf(exeParam, ElfCommand.ELF_C_READ); + exeElf = new Elf(this.exeFile, ElfCommand.ELF_C_READ); this.auxv = constructAuxv(noteSection); diff --git a/frysk-core/frysk/util/ChangeLog b/frysk-core/frysk/util/ChangeLog index fbe5f51..cb51cfa 100644 --- a/frysk-core/frysk/util/ChangeLog +++ b/frysk-core/frysk/util/ChangeLog @@ -1,5 +1,8 @@ 2008-02-26 Andrew Cagney + * CommandlineParser.java (parseCoresFIXME(CoreExePair[])): Delete. + (-noexe): Add. + * Util.java (getProcFromCoreExePair(CoreExePair)): Delete. * CommandlineParser.java: Add logging; check for null diff --git a/frysk-core/frysk/util/CommandlineParser.java b/frysk-core/frysk/util/CommandlineParser.java index d5cedd3..7f14c06 100644 --- a/frysk-core/frysk/util/CommandlineParser.java +++ b/frysk-core/frysk/util/CommandlineParser.java @@ -62,10 +62,17 @@ import frysk.proc.Proc; public class CommandlineParser { private final Log fine = Log.fine(CommandlineParser.class); private final Parser parser; + private boolean extendedCore = true; public CommandlineParser(String name, String version) { parser = new Parser(name, version, true); EventLogger.addConsoleOptions(parser); + add(new Option("noexe", "Do not attempt to read an"+ + " executable for a corefile ") { + public void parsed(String exeValue) throws OptionException { + extendedCore = false; + } + }); } public CommandlineParser(String programName) { @@ -90,25 +97,6 @@ public class CommandlineParser { * @param coreFiles The array of core files passed on the command * line. */ - public void parseCoresFIXME(CoreExePair[] coreExePairs) { - Proc[] procs = new Proc[coreExePairs.length]; - for (int i = 0; i < coreExePairs.length; i++) { - CoreExePair pair = coreExePairs[i]; - if (pair.exeFile == null) - procs[i] = LinuxCoreFactory.createProc(pair.coreFile); - else - procs[i] = LinuxCoreFactory.createProc(pair.coreFile, - pair.exeFile); - } - parseCores(procs); - } - /** - * Callback function. Gives an array of core files if core files - * were detected on the command line. - * - * @param coreFiles The array of core files passed on the command - * line. - */ public void parseCores(Proc[] cores) { System.err.println("Error: Corefiles not supported."); System.exit(1); @@ -180,26 +168,31 @@ public class CommandlineParser { // Check if arguments are all core file/ exe file pairs.. if (isCoreFile(result[0])) { - LinkedList coreExeFiles = new LinkedList(); + LinkedList coreList = new LinkedList(); for (int file = 0; file < result.length; /*see below*/) { if (isCoreFile(result[file])) { + Proc proc; File coreFile = new File(result[file]); - if (file + 1 < result.length && isExeFile(result[file + 1])) { + if (file + 1 < result.length + && isExeFile(result[file + 1]) + && extendedCore) { File exeFile = new File(result[file + 1]); - coreExeFiles.add(new CoreExePair(coreFile, exeFile)); + proc = LinuxCoreFactory.createProc(coreFile, exeFile); file += 2; } else { - coreExeFiles.add(new CoreExePair(coreFile, null)); + proc = LinuxCoreFactory.createProc(coreFile, + extendedCore); file += 1; } + coreList.add(proc); } else { throw new OptionException("Please don't mix core files with pids or executables."); } } - CoreExePair[] coreExePairs = new CoreExePair[coreExeFiles.size()]; - coreExeFiles.toArray(coreExePairs); - fine.log(this, "parse cores", coreExePairs); - parseCoresFIXME(coreExePairs); + Proc[] cores = new Proc[coreList.size()]; + coreList.toArray(cores); + fine.log(this, "parse cores", cores); + parseCores(cores); return result; } hooks/post-receive -- frysk system monitor/debugger