From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3063 invoked by alias); 6 Mar 2008 17:10:46 -0000 Received: (qmail 3055 invoked by uid 22791); 6 Mar 2008 17:10:45 -0000 X-Spam-Status: No, hits=-1.4 required=5.0 tests=AWL,BAYES_00,J_CHICKENPOX_64,J_CHICKENPOX_66,J_CHICKENPOX_84,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (66.187.233.31) by sourceware.org (qpsmtpd/0.31) with ESMTP; Thu, 06 Mar 2008 17:10:28 +0000 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id m26HAQ8k030553 for ; Thu, 6 Mar 2008 12:10:26 -0500 Received: from pobox-2.corp.redhat.com (pobox-2.corp.redhat.com [10.11.255.15]) by int-mx1.corp.redhat.com (8.13.1/8.13.1) with ESMTP id m26HAPR7009516 for ; Thu, 6 Mar 2008 12:10:25 -0500 Received: from localhost.localdomain (vpn-14-95.rdu.redhat.com [10.11.14.95]) by pobox-2.corp.redhat.com (8.13.1/8.13.1) with ESMTP id m26HAMSN032047 for ; Thu, 6 Mar 2008 12:10:22 -0500 Message-ID: <47D0257D.9080505@redhat.com> Date: Thu, 06 Mar 2008 17:10:00 -0000 From: Phil Muldoon User-Agent: Thunderbird 2.0.0.12 (X11/20080226) MIME-Version: 1.0 To: Frysk Hackers Subject: Patchlet to convert ferror to use regex when matching -e argument Content-Type: multipart/mixed; boundary="------------090606080709050308070908" X-Scanned-By: MIMEDefang 2.58 on 172.16.52.254 X-Virus-Checked: Checked by ClamAV on sourceware.org X-IsSubscribed: yes Mailing-List: contact frysk-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: frysk-owner@sourceware.org X-SW-Source: 2008-q1/txt/msg00135.txt.bz2 This is a multi-part message in MIME format. --------------090606080709050308070908 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-length: 173 Small patch. This converts ferror to pattern match the -e argument over a straight String.contains(). Useful for looking for more complex search queries. Regards Phil --------------090606080709050308070908 Content-Type: text/x-patch; name="ferror_regex.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="ferror_regex.patch" Content-length: 2287 diff --git a/frysk-core/frysk/bindir/ChangeLog b/frysk-core/frysk/bindir/ChangeLog index 8cc896a..4e114f9 100644 --- a/frysk-core/frysk/bindir/ChangeLog +++ b/frysk-core/frysk/bindir/ChangeLog @@ -1,3 +1,9 @@ +2008-03-06 Phil Muldoon + + * ferror.java (main): Update option text. + (parsed): Do not store argument. Compile into pattern. + (updateSyscallEnter): Use Matcher instead of contains. + 2008-03-04 Andrew Cagney * TestFexe.java testExePath()): New. diff --git a/frysk-core/frysk/bindir/ferror.java b/frysk-core/frysk/bindir/ferror.java index 52906bc..901ccf2 100644 --- a/frysk-core/frysk/bindir/ferror.java +++ b/frysk-core/frysk/bindir/ferror.java @@ -10,20 +10,22 @@ import frysk.proc.TaskObserver.Syscalls; import frysk.util.ProcRunningUtil; import gnu.classpath.tools.getopt.Option; import gnu.classpath.tools.getopt.OptionException; +import java.util.regex.Pattern; +import java.util.regex.Matcher; import java.io.PrintWriter; public class ferror { static final PrintWriter printWriter = new PrintWriter(System.out); + static Pattern writePattern; - private static String errorString; public static void main (String[] args) { - Option option = new Option('e', "--error", "error string to catch in double quotes -e \"\""){ + Option option = new Option('e', "--error", "error regex to catch in double quotes -e \"\""){ public void parsed(String argument) throws OptionException { - errorString = argument; + writePattern = Pattern.compile(argument); } }; @@ -59,9 +61,13 @@ public class ferror { task.getMemory().get (address, 200, x); String xString = new String(x); - if(xString.contains(errorString)){ - printWriter.println("Process is trying to output " + errorString); - + Matcher match = writePattern.matcher(xString); + if (match.find()) { + printWriter.println("Process is trying to output: " + + xString + + " which matches pattern: " + + writePattern.pattern()); + printWriter.println("Stack trace:\n"); PrintStackOptions options = new PrintStackOptions(); --------------090606080709050308070908--