From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27882 invoked by alias); 29 Feb 2008 13:39:35 -0000 Received: (qmail 27840 invoked by uid 9561); 29 Feb 2008 13:39:30 -0000 Date: Fri, 29 Feb 2008 13:39:00 -0000 Message-ID: <20080229133930.27825.qmail@sourceware.org> From: swagiaal@sourceware.org To: frysk-cvs@sourceware.org Subject: [SCM] master: swagiaal: added test for fcatch following forks. X-Git-Refname: refs/heads/master X-Git-Reftype: branch X-Git-Oldrev: d7701802422b53a81f7f3b56c6fbb829fac24a11 X-Git-Newrev: 2b60d77fb3bba566afc5c88022e55a3cfdbfbbd3 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/msg00284.txt.bz2 The branch, master has been updated via 2b60d77fb3bba566afc5c88022e55a3cfdbfbbd3 (commit) via 0b2af9485792c745fa25db1ba8683b8a4db936ad (commit) from d7701802422b53a81f7f3b56c6fbb829fac24a11 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email. - Log ----------------------------------------------------------------- commit 2b60d77fb3bba566afc5c88022e55a3cfdbfbbd3 Author: Sami Wagiaalla Date: Fri Feb 29 08:35:20 2008 -0500 swagiaal: added test for fcatch following forks. frysk-core/frysk/bindir/ChangeLog +2008-02-29 Sami Wagiaalla + + * TestFcatch.java (testFcatchFollowsForks): new test. + commit 0b2af9485792c745fa25db1ba8683b8a4db936ad Author: Sami Wagiaalla Date: Thu Feb 28 23:52:11 2008 -0500 swagiaal: implemented used and tested ProcRunningUtil, added ferror. frysk-core/frysk/bindir/ChangeLog +2008-02-28 Sami Wagiaalla + + * ferror.java: new command line utility. + * ferror.xml: new file. + * TestFerror.java: New test. + frysk-core/frysk/pkglibdir/ChangeLog +2008-02-28 Sami Wagiaalla + + * funit-3forks.c: New test program. + frysk-core/frysk/util/ChangeLog +2008-02-28 Sami Wagiaalla + + * ProcRunningUtil.java: Framework for all commandline + utilites which keep the process running. + ----------------------------------------------------------------------- Summary of changes: frysk-core/frysk/bindir/ChangeLog | 10 + frysk-core/frysk/bindir/TestFcatch.java | 14 + .../bindir/{TestFhpd.java => TestFerror.java} | 68 +++-- frysk-core/frysk/bindir/ferror.java | 82 ++++++ frysk-core/frysk/bindir/{fcatch.xml => ferror.xml} | 21 +- frysk-core/frysk/pkglibdir/ChangeLog | 8 + .../pkglibdir/{funit-vfork.c => funit-3forks.c} | 43 ++-- frysk-core/frysk/util/ChangeLog | 5 + frysk-core/frysk/util/ProcRunningUtil.java | 298 ++++++++++++++++++++ 9 files changed, 485 insertions(+), 64 deletions(-) copy frysk-core/frysk/bindir/{TestFhpd.java => TestFerror.java} (69%) mode change 100755 => 100644 create mode 100644 frysk-core/frysk/bindir/ferror.java copy frysk-core/frysk/bindir/{fcatch.xml => ferror.xml} (86%) copy frysk-core/frysk/pkglibdir/{funit-vfork.c => funit-3forks.c} (86%) create mode 100644 frysk-core/frysk/util/ProcRunningUtil.java First 500 lines of diff: diff --git a/frysk-core/frysk/bindir/ChangeLog b/frysk-core/frysk/bindir/ChangeLog index 087b7af..1ba5299 100644 --- a/frysk-core/frysk/bindir/ChangeLog +++ b/frysk-core/frysk/bindir/ChangeLog @@ -1,3 +1,13 @@ +2008-02-29 Sami Wagiaalla + + * TestFcatch.java (testFcatchFollowsForks): new test. + +2008-02-28 Sami Wagiaalla + + * ferror.java: new command line utility. + * ferror.xml: new file. + * TestFerror.java: New test. + 2008-02-28 Andrew Cagney * fcatch.java: Delete unused logger. diff --git a/frysk-core/frysk/bindir/TestFcatch.java b/frysk-core/frysk/bindir/TestFcatch.java index 1602173..2d76460 100644 --- a/frysk-core/frysk/bindir/TestFcatch.java +++ b/frysk-core/frysk/bindir/TestFcatch.java @@ -53,4 +53,18 @@ public class TestFcatch extends TestLib { // just look for main. e.expect(" in main "); } + + public void testFcatchFollowsForks() { + if(unresolved(4536)){ + return; + } + TearDownExpect e = new TearDownExpect(new String[] { + Config.getBinFile("fcatch").getAbsolutePath(), + Config.getPkgLibFile("funit-3forks").getAbsolutePath() + }); + // just look for main. + e.expect(" in main "); + } + + } diff --git a/frysk-core/frysk/bindir/TestFhpd.java b/frysk-core/frysk/bindir/TestFerror.java old mode 100755 new mode 100644 similarity index 69% copy from frysk-core/frysk/bindir/TestFhpd.java copy to frysk-core/frysk/bindir/TestFerror.java index f52fe7e..f63fca6 --- a/frysk-core/frysk/bindir/TestFhpd.java +++ b/frysk-core/frysk/bindir/TestFerror.java @@ -40,43 +40,47 @@ package frysk.bindir; import frysk.Config; -import frysk.testbed.TestLib; import frysk.testbed.TearDownExpect; +import frysk.testbed.TestLib; +import frysk.proc.Task; +import frysk.testbed.SlaveOffspring; -/** - * This performs a "sniff" test of Fstack, confirming basic - * functionality of the command line interface. - * - * For more specific tests see frysk.hpd. - */ - -public class TestFhpd extends TestLib { - private final String prompt = "\\(fhpd\\) "; +public class TestFerror extends TestLib { - public void testHpdPid () { - TearDownExpect child = new TearDownExpect(Config.getPkgLibFile("hpd-c")); - TearDownExpect e = new TearDownExpect(new String[] { - Config.getBinFile("fhpd").getPath(), - child.getPid().toString() - }); - e.expect("Attached to process.*\n" + prompt); + public void testFerrorTracesExecutables () { + TearDownExpect e = new TearDownExpect(new String[] { + Config.getBinFile("ferror").getAbsolutePath(), + "-e", + "fork", + "--", + Config.getPkgLibFile("funit-3forks").getAbsolutePath()}); + e.expect("Tracing"); + e.expect(".*main.*"); } - - public void testHpdCommand () { - TearDownExpect e = new TearDownExpect(new String[] { - Config.getBinFile("fhpd").getPath(), - Config.getPkgLibFile("hpd-c").getPath() - }); - e.expect("Loaded executable file.*" + prompt); + + public void testFerrorTracesPID () { + SlaveOffspring child = SlaveOffspring.createChild(); + Task task = child.findTaskUsingRefresh(true); + TearDownExpect e = new TearDownExpect(new String[] { + Config.getBinFile("ferror").getAbsolutePath(), + "-e", + "clone", + "--", + Integer.toString(task.getProc().getPid())}); + e.expect("Tracing"); + child.assertSendAddCloneWaitForAcks(); + e.expect(".*main.*"); } - - public void testHpdCore () { + + public void testFerrorFollowsForks() { TearDownExpect e = new TearDownExpect(new String[] { - Config.getBinFile("fhpd").getPath(), - Config.getPkgDataFile("test-core-x86").getPath(), - "-noexe" - }); - e.expect("Attached to core file.*"); + Config.getBinFile("ferror").getAbsolutePath(), + "-e", + "fork3", + "--", + Config.getPkgLibFile("funit-3forks").getAbsolutePath()}); + e.expect("Tracing"); + e.expect(".*main.*"); } - + } diff --git a/frysk-core/frysk/bindir/ferror.java b/frysk-core/frysk/bindir/ferror.java new file mode 100644 index 0000000..52906bc --- /dev/null +++ b/frysk-core/frysk/bindir/ferror.java @@ -0,0 +1,82 @@ +package frysk.bindir; + +import frysk.debuginfo.DebugInfoStackFactory; +import frysk.debuginfo.PrintStackOptions; +import frysk.isa.syscalls.Syscall; +import frysk.proc.Action; +import frysk.proc.Task; +import frysk.proc.TaskObserver; +import frysk.proc.TaskObserver.Syscalls; +import frysk.util.ProcRunningUtil; +import gnu.classpath.tools.getopt.Option; +import gnu.classpath.tools.getopt.OptionException; + +import java.io.PrintWriter; + +public class ferror { + + static final PrintWriter printWriter = new PrintWriter(System.out); + + private static String errorString; + public static void main (String[] args) + { + Option option = new Option('e', "--error", "error string to catch in double quotes -e \"\""){ + + public void parsed(String argument) throws OptionException { + errorString = argument; + } + }; + + ProcRunningUtil procRunningUtil = + new ProcRunningUtil("ferror", + "ferror -e \"\" -- [ARGS]", + args, + new TaskObserver[]{syscallObserver},new Option[]{option} , ProcRunningUtil.DEFAULT); + procRunningUtil.start(); + } + + + static Syscalls syscallObserver = new Syscalls(){ + + public Action updateSyscallExit (Task task) + { + return Action.CONTINUE; + } + + public void addFailed (Object observable, Throwable w){} + public void addedTo (Object observable){ + Task task = (Task) observable; + printWriter.println("Tracing " + task.getProc().getPid() + "." + task.getTid()); + printWriter.flush(); + } + public void deletedFrom (Object observable){} + + public Action updateSyscallEnter(Task task, Syscall syscall) { + if(syscall.getName().equals("write")){ + long address = syscall.getArguments(task, 2); + + StringBuffer x = new StringBuffer (); + task.getMemory().get (address, 200, x); + String xString = new String(x); + + if(xString.contains(errorString)){ + printWriter.println("Process is trying to output " + errorString); + + printWriter.println("Stack trace:\n"); + PrintStackOptions options = new PrintStackOptions(); + + options.setPrintFullpath(false); + options.setPrintParameters(true); + options.setPrintVirtualFrames(true); + options.setPrintLibrary(true); + + DebugInfoStackFactory.printTaskStackTrace(printWriter, task, options); + + } + + } + return Action.CONTINUE; + } + + }; +} diff --git a/frysk-core/frysk/bindir/fcatch.xml b/frysk-core/frysk/bindir/ferror.xml similarity index 86% copy from frysk-core/frysk/bindir/fcatch.xml copy to frysk-core/frysk/bindir/ferror.xml index 9e5e027..a1c43e9 100644 --- a/frysk-core/frysk/bindir/fcatch.xml +++ b/frysk-core/frysk/bindir/ferror.xml @@ -48,26 +48,26 @@ - + - fcatch - December 22 2006 + ferror + Feb 28 2008 - fcatch + ferror 1 - fcatch - Runs the frysk application crash and signal stack tracing utility + ferror + print stack trace when the given error is printed by the traced program - fcatch [OPTIONS] -- PATH ARGS + ferror -e "ERROR" -- [EXECUTABLE|PID] [ARGS] @@ -77,9 +77,7 @@ DESCRIPTION - fcatch Runs the frysk application crash stack tracing utility - - fcatch is a small utility that uses the frysk engine to generate stack backtraces from an application crash, or upon receiving a variety of signals. + ferror Using the Frysk back end it runs an application and waits for the process to output the given error string, then produces a stack trace at that point