From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 32034 invoked by alias); 4 Mar 2008 17:52:19 -0000 Received: (qmail 32002 invoked by uid 367); 4 Mar 2008 17:52:16 -0000 Date: Tue, 04 Mar 2008 17:52:00 -0000 Message-ID: <20080304175216.31987.qmail@sourceware.org> From: cagney@sourceware.org To: frysk-cvs@sourceware.org Subject: [SCM] master: Add -exe argument; test fix printing exe and args. X-Git-Refname: refs/heads/master X-Git-Reftype: branch X-Git-Oldrev: 3bc91e04a3f231066eba452688f3decc5742fab2 X-Git-Newrev: f60b1b4dd2825e758d5e4c7791264d8dea920cdf 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/msg00306.txt.bz2 The branch, master has been updated via f60b1b4dd2825e758d5e4c7791264d8dea920cdf (commit) from 3bc91e04a3f231066eba452688f3decc5742fab2 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email. - Log ----------------------------------------------------------------- commit f60b1b4dd2825e758d5e4c7791264d8dea920cdf Author: Andrew Cagney Date: Tue Mar 4 12:50:37 2008 -0500 Add -exe argument; test fix printing exe and args. frysk-core/frysk/bindir/ChangeLog 2008-03-04 Andrew Cagney * TestFexe.java (testExeOfExe()): New. frysk-core/frysk/hpd/ChangeLog 2008-03-04 Andrew Cagney * HpdTestbed.java (start(String)): Delete. (load(String)): New. * InfoCommand.java: Add "exe" and "args" commands. * InfoExeCommand.java: New file. * InfoArgsCommand.java: New file. frysk-core/frysk/util/ChangeLog 2008-03-04 Andrew Cagney * ProcStopUtil.java (proc): Delete (parseCommand(command)): Pass command through to executeDead. * TestCommandlineParser.java (testExeOption()): New. * CommandlineParser.java (-exe): New option. ----------------------------------------------------------------------- Summary of changes: frysk-core/frysk/bindir/ChangeLog | 4 ++ frysk-core/frysk/bindir/TestFexe.java | 10 ++++ frysk-core/frysk/hpd/ChangeLog | 9 ++++ frysk-core/frysk/hpd/HpdTestbed.java | 45 +++++--------------- ...{DebuginfoCommand.java => InfoArgsCommand.java} | 41 +++++++++--------- frysk-core/frysk/hpd/InfoCommand.java | 2 + .../{DebuginfoCommand.java => InfoExeCommand.java} | 38 ++++++++--------- .../hpd/{PTSet.java => TestInfoArgsCommand.java} | 15 +++---- .../hpd/{PTSet.java => TestInfoExeCommand.java} | 15 +++---- frysk-core/frysk/util/ChangeLog | 7 +++ frysk-core/frysk/util/CommandlineParser.java | 31 +++++++++++--- frysk-core/frysk/util/ProcStopUtil.java | 14 ++++-- frysk-core/frysk/util/TestCommandlineParser.java | 17 +++++++ 13 files changed, 147 insertions(+), 101 deletions(-) copy frysk-core/frysk/hpd/{DebuginfoCommand.java => InfoArgsCommand.java} (79%) copy frysk-core/frysk/hpd/{DebuginfoCommand.java => InfoExeCommand.java} (79%) copy frysk-core/frysk/hpd/{PTSet.java => TestInfoArgsCommand.java} (90%) copy frysk-core/frysk/hpd/{PTSet.java => TestInfoExeCommand.java} (90%) First 500 lines of diff: diff --git a/frysk-core/frysk/bindir/ChangeLog b/frysk-core/frysk/bindir/ChangeLog index 76db832..717fabf 100644 --- a/frysk-core/frysk/bindir/ChangeLog +++ b/frysk-core/frysk/bindir/ChangeLog @@ -1,3 +1,7 @@ +2008-03-04 Andrew Cagney + + * TestFexe.java (testExeOfExe()): New. + 2008-03-03 Andrew Cagney * TestFauxv.java: Use frysk.config. diff --git a/frysk-core/frysk/bindir/TestFexe.java b/frysk-core/frysk/bindir/TestFexe.java index 9116549..38ef99a 100644 --- a/frysk-core/frysk/bindir/TestFexe.java +++ b/frysk-core/frysk/bindir/TestFexe.java @@ -58,4 +58,14 @@ public class TestFexe extends TestLib { }); e.expect("/bin/bash" + "\r\n"); } + + public void testExeOfExe() { + TearDownExpect e = new TearDownExpect(new String[] { + Config.getBinFile("fexe").getPath(), + "-exe", "/bin/ls", + "--", + "arg0", "arg1" + }); + e.expect("/bin/ls" + "\r\n"); + } } diff --git a/frysk-core/frysk/hpd/ChangeLog b/frysk-core/frysk/hpd/ChangeLog index 3f77429..8df43bb 100644 --- a/frysk-core/frysk/hpd/ChangeLog +++ b/frysk-core/frysk/hpd/ChangeLog @@ -1,3 +1,12 @@ +2008-03-04 Andrew Cagney + + * HpdTestbed.java (start(String)): Delete. + (load(String)): New. + + * InfoCommand.java: Add "exe" and "args" commands. + * InfoExeCommand.java: New file. + * InfoArgsCommand.java: New file. + 2008-03-03 Andrew Cagney * TestBreakpoints.java: Use frysk.config. diff --git a/frysk-core/frysk/hpd/HpdTestbed.java b/frysk-core/frysk/hpd/HpdTestbed.java index 24a65bf..6334305 100644 --- a/frysk-core/frysk/hpd/HpdTestbed.java +++ b/frysk-core/frysk/hpd/HpdTestbed.java @@ -207,46 +207,23 @@ public class HpdTestbed extends TearDownExpect { } /** - * Start the specified program from under HPD. + * Load the specified program into HPD. */ - static HpdTestbed start(String program, String args) { + static HpdTestbed load(String program, String args) { HpdTestbed h = new HpdTestbed(); File exe = Config.getPkgLibFile(program); - h.send("start "); - h.send(exe.getAbsolutePath()); - if (args != null) { - h.send(" "); - h.send(args); - } - h.send("\n"); - try { - h.expect(new Match[] { - new Regex("Attached to process ([0-9]+)\r\n" - + h.prompt) { - public void execute() { - TearDownProcess.add - (ProcessIdentifierFactory.create - (Integer.parseInt(group(1)))); - } - }, - new Regex(".*\r\n" + h.prompt) { - public void execute() { - TestCase.fail("Expecting got: <" - + group() + ">"); - } - } - }); - } catch (EndOfFileException e) { - TestCase.fail("Expecting got: "); - } catch (TimeoutException t) { - TestCase.fail("Expecting got: "); - } + String command; + if (args == null) + command = "load " + exe; + else + command = "load " + exe + " " + args; + h.sendCommandExpectPrompt(command, "Loaded executable file:.*\r\n"); return h; } - - static HpdTestbed start(String program) { - return start(program, null); + static HpdTestbed load(String program) { + return load(program, null); } + /** * Start HPD attached to PROGRAM that is crashing (due to a * signal). diff --git a/frysk-core/frysk/hpd/DebuginfoCommand.java b/frysk-core/frysk/hpd/InfoArgsCommand.java similarity index 79% copy from frysk-core/frysk/hpd/DebuginfoCommand.java copy to frysk-core/frysk/hpd/InfoArgsCommand.java index 51c89b6..4202951 100644 --- a/frysk-core/frysk/hpd/DebuginfoCommand.java +++ b/frysk-core/frysk/hpd/InfoArgsCommand.java @@ -1,6 +1,6 @@ // This file is part of the program FRYSK. // -// Copyright 2007, Red Hat Inc. +// Copyright 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,30 +40,31 @@ package frysk.hpd; import java.util.Iterator; -import frysk.proc.Task; -import frysk.util.DebuginfoPaths; +import frysk.proc.Proc; import java.util.List; -class DebuginfoCommand extends ParameterizedCommand { - - DebuginfoCommand() { - super("Displays debuginfo install paths of a process.", "debuginfo", - "The debuginfo command lists the debuginfo paths " - + "for a process and its shared modules."); - } - - int completer(CLI cli, Input input, int cursor, List completions) { - return -1; +class InfoArgsCommand extends ParameterizedCommand { + + InfoArgsCommand() { + super("print arguments", "args", + "print the processes command-line arguments"); } void interpret(CLI cli, Input cmd, Object options) { PTSet ptset = cli.getCommandPTSet(cmd); - Iterator taskIter = ptset.getTasks(); - while (taskIter.hasNext()) { - Task task = (Task) taskIter.next(); - DebuginfoPaths dbg = new DebuginfoPaths(task); - String dInfo = dbg.getDebuginfo(); - cli.outWriter.println(dInfo); + Iterator taskDataIter = ptset.getTaskData(); + while (taskDataIter.hasNext()) { + TaskData td = (TaskData) taskDataIter.next(); + Proc proc = td.getTask().getProc(); + td.printHeader(cli.outWriter); + String[] args = proc.getCmdLine(); + for (int i = 0; i < args.length; i++) { + cli.outWriter.println(args[i]); + } } } -} \ No newline at end of file + + int completer(CLI cli, Input input, int cursor, List completions) { + return -1; + } +} diff --git a/frysk-core/frysk/hpd/InfoCommand.java b/frysk-core/frysk/hpd/InfoCommand.java index 13a5511..ba6ccdc 100644 --- a/frysk-core/frysk/hpd/InfoCommand.java +++ b/frysk-core/frysk/hpd/InfoCommand.java @@ -49,6 +49,8 @@ public class InfoCommand extends MultiLevelCommand { add(new DebuginfoCommand(),"debuginfo"); add(new MapsCommand(),"maps"); add(new AuxvCommand(),"auxv"); + add(new InfoExeCommand(),"exe"); + add(new InfoArgsCommand(),"args"); add(new RegsCommand("vector"), "vector-regs"); add(new RegsCommand("float"), "float-regs"); add(new RegsCommand("regs"), "general-regs"); diff --git a/frysk-core/frysk/hpd/DebuginfoCommand.java b/frysk-core/frysk/hpd/InfoExeCommand.java similarity index 79% copy from frysk-core/frysk/hpd/DebuginfoCommand.java copy to frysk-core/frysk/hpd/InfoExeCommand.java index 51c89b6..e774c0c 100644 --- a/frysk-core/frysk/hpd/DebuginfoCommand.java +++ b/frysk-core/frysk/hpd/InfoExeCommand.java @@ -1,6 +1,6 @@ // This file is part of the program FRYSK. // -// Copyright 2007, Red Hat Inc. +// Copyright 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,30 +40,28 @@ package frysk.hpd; import java.util.Iterator; -import frysk.proc.Task; -import frysk.util.DebuginfoPaths; +import frysk.proc.Proc; import java.util.List; -class DebuginfoCommand extends ParameterizedCommand { - - DebuginfoCommand() { - super("Displays debuginfo install paths of a process.", "debuginfo", - "The debuginfo command lists the debuginfo paths " - + "for a process and its shared modules."); - } - - int completer(CLI cli, Input input, int cursor, List completions) { - return -1; +class InfoExeCommand extends ParameterizedCommand { + + InfoExeCommand() { + super("print executable", "exe", + "print the processes executable"); } void interpret(CLI cli, Input cmd, Object options) { PTSet ptset = cli.getCommandPTSet(cmd); - Iterator taskIter = ptset.getTasks(); - while (taskIter.hasNext()) { - Task task = (Task) taskIter.next(); - DebuginfoPaths dbg = new DebuginfoPaths(task); - String dInfo = dbg.getDebuginfo(); - cli.outWriter.println(dInfo); + Iterator taskDataIter = ptset.getTaskData(); + while (taskDataIter.hasNext()) { + TaskData td = (TaskData) taskDataIter.next(); + Proc proc = td.getTask().getProc(); + td.printHeader(cli.outWriter); + cli.outWriter.println(proc.getExe()); } } -} \ No newline at end of file + + int completer(CLI cli, Input input, int cursor, List completions) { + return -1; + } +} diff --git a/frysk-core/frysk/hpd/PTSet.java b/frysk-core/frysk/hpd/TestInfoArgsCommand.java similarity index 90% copy from frysk-core/frysk/hpd/PTSet.java copy to frysk-core/frysk/hpd/TestInfoArgsCommand.java index 64ca07e..bbd58f2 100644 --- a/frysk-core/frysk/hpd/PTSet.java +++ b/frysk-core/frysk/hpd/TestInfoArgsCommand.java @@ -1,6 +1,6 @@ // This file is part of the program FRYSK. // -// Copyright 2005, Red Hat Inc. +// Copyright 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 @@ -36,14 +36,13 @@ // modification, you must delete this exception statement from your // version and license this file solely under the GPL without // exception. + package frysk.hpd; -import java.util.Iterator; +public class TestInfoArgsCommand extends TestLib { -interface PTSet -{ - boolean containsTask(int procid, int taskid); - void removeProc(int procid); - Iterator getTasks(); - Iterator getTaskData(); + public void testInfoArgs() { + e = HpdTestbed.load("funit-stacks"); + e.sendCommandExpectPrompt("info args", "funit-stacks\r\n"); + } } diff --git a/frysk-core/frysk/hpd/PTSet.java b/frysk-core/frysk/hpd/TestInfoExeCommand.java similarity index 90% copy from frysk-core/frysk/hpd/PTSet.java copy to frysk-core/frysk/hpd/TestInfoExeCommand.java index 64ca07e..47a1aca 100644 --- a/frysk-core/frysk/hpd/PTSet.java +++ b/frysk-core/frysk/hpd/TestInfoExeCommand.java @@ -1,6 +1,6 @@ // This file is part of the program FRYSK. // -// Copyright 2005, Red Hat Inc. +// Copyright 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 @@ -36,14 +36,13 @@ // modification, you must delete this exception statement from your // version and license this file solely under the GPL without // exception. + package frysk.hpd; -import java.util.Iterator; +public class TestInfoExeCommand extends TestLib { -interface PTSet -{ - boolean containsTask(int procid, int taskid); - void removeProc(int procid); - Iterator getTasks(); - Iterator getTaskData(); + public void testInfoExe() { + e = HpdTestbed.load("funit-stacks"); + e.sendCommandExpectPrompt("info exe", "funit-stacks\r\n"); + } } diff --git a/frysk-core/frysk/util/ChangeLog b/frysk-core/frysk/util/ChangeLog index 92268a5..4496f39 100644 --- a/frysk-core/frysk/util/ChangeLog +++ b/frysk-core/frysk/util/ChangeLog @@ -1,3 +1,10 @@ +2008-03-04 Andrew Cagney + + * ProcStopUtil.java (proc): Delete + (parseCommand(command)): Pass command through to executeDead. + * TestCommandlineParser.java (testExeOption()): New. + * CommandlineParser.java (-exe): New option. + 2008-03-03 Andrew Cagney * CommandlineParser.java: Use FryskVersion. diff --git a/frysk-core/frysk/util/CommandlineParser.java b/frysk-core/frysk/util/CommandlineParser.java index b096128..ce6e18a 100644 --- a/frysk-core/frysk/util/CommandlineParser.java +++ b/frysk-core/frysk/util/CommandlineParser.java @@ -60,9 +60,11 @@ import frysk.proc.Proc; * common options for Frysk command-line applications. */ public class CommandlineParser { - private final Log fine = Log.fine(CommandlineParser.class); + private static final Log fine = Log.fine(CommandlineParser.class); + private final Parser parser; private boolean extendedCore = true; + private String explicitExe = null; public CommandlineParser(String name, String version) { parser = new Parser(name, version, true); @@ -71,11 +73,20 @@ public class CommandlineParser { " executable for a corefile ") { public void parsed(String exeValue) throws OptionException { extendedCore = false; + explicitExe = null; + } + }); + add(new Option("exe", + "Specify the full path of the executable to read", + "") { + public void parsed(String exeValue) throws OptionException { + extendedCore = true; + explicitExe = exeValue; } }); add(new Option("sysroot", "special root directory", "Path of special root directory") { public void parsed(String arg) throws OptionException { - parseSysroot(arg); + parseSysroot(arg); } }); } @@ -177,12 +188,16 @@ public class CommandlineParser { if (isCoreFile(result[file])) { Proc proc; File coreFile = new File(result[file]); - if (file + 1 < result.length - && isExeFile(result[file + 1]) - && extendedCore) { + if (extendedCore + && file + 1 < result.length + && isExeFile(result[file + 1])) { File exeFile = new File(result[file + 1]); proc = LinuxCoreFactory.createProc(coreFile, exeFile); file += 2; + } else if (explicitExe != null) { + File exeFile = new File(explicitExe); + proc = LinuxCoreFactory.createProc(coreFile, exeFile); + file += 1; } else { proc = LinuxCoreFactory.createProc(coreFile, extendedCore); @@ -201,7 +216,11 @@ public class CommandlineParser { } // If not above, then this is an executable command. - Proc command = LinuxExeFactory.createProc(result); + Proc command; + if (explicitExe != null) + command = LinuxExeFactory.createProc(new File(explicitExe), result); + else + command = LinuxExeFactory.createProc(result); fine.log(this, "parse command", command); parseCommand(command); return result; diff --git a/frysk-core/frysk/util/ProcStopUtil.java b/frysk-core/frysk/util/ProcStopUtil.java index 4188542..f282816 100644 --- a/frysk-core/frysk/util/ProcStopUtil.java +++ b/frysk-core/frysk/util/ProcStopUtil.java @@ -48,6 +48,7 @@ import frysk.proc.ProcObserver; import frysk.proc.Task; import frysk.util.CommandlineParser; import gnu.classpath.tools.getopt.Option; +import frysk.rsl.Log; /** * Framework to be used for frysk utilities that, @@ -56,9 +57,9 @@ import gnu.classpath.tools.getopt.Option; * * Utilities must define a event.ProcEvent to execute. */ -public class ProcStopUtil -{ - private Proc proc; +public class ProcStopUtil { + private static final Log fine = Log.fine(ProcStopUtil.class); + private String[] args; private CommandlineParser parser; @@ -69,7 +70,7 @@ public class ProcStopUtil //@Override public void parsePids(Proc[] procs) { for (int i= 0; i < procs.length; i++) { - proc = procs[i]; + Proc proc = procs[i]; UtilEvent utilEvent = new UtilEvent(proc, procEvent); new ProcBlockAction(proc, new UtilAction(proc, utilEvent)); Manager.eventLoop.run(); @@ -80,13 +81,15 @@ public class ProcStopUtil public void parseCores(Proc[] cores) { for (int i = 0; i < cores.length; i++) { Proc core = cores[i]; + fine.log("execute dead core", core); procEvent.executeDead(core); } } //@Override public void parseCommand(Proc command) { - procEvent.executeDead(proc); + fine.log("execute dead command", command); + procEvent.executeDead(command); } }; } @@ -159,6 +162,7 @@ public class ProcStopUtil } public void execute() { + fine.log("execute live", proc); event.executeLive(proc); // FIXME: Should request eventloop to stop diff --git a/frysk-core/frysk/util/TestCommandlineParser.java b/frysk-core/frysk/util/TestCommandlineParser.java index e168eba..7dd491b 100644 --- a/frysk-core/frysk/util/TestCommandlineParser.java +++ b/frysk-core/frysk/util/TestCommandlineParser.java @@ -44,8 +44,10 @@ import frysk.testbed.TestLib; import frysk.testbed.CorefileFactory; import frysk.config.Config; import frysk.proc.Proc; +import frysk.rsl.Log; public class TestCommandlineParser extends TestLib { + private static final Log fine = Log.fine(TestCommandlineParser.class); private File exe; private File core; @@ -100,4 +102,19 @@ public class TestCommandlineParser extends TestLib { // args: CORE parser.parse(new String[] { core.getPath() }); } + + public void testExeOption() { + CommandlineParser parser = new CommandlineParser("test") { + public void parseCommand(Proc command) { + fine.log("command", command); + assertEquals("exe", "/bin/ls", command.getExe()); + assertEquals("arg0", "arg0", command.getCmdLine()[0]); + } + }; hooks/post-receive -- frysk system monitor/debugger