public inbox for frysk@sourceware.org
 help / color / mirror / Atom feed
From: Phil Muldoon <pmuldoon@redhat.com>
To: Frysk Hackers <frysk@sourceware.org>
Subject: Patchlet to convert ferror to use regex when matching -e argument
Date: Thu, 06 Mar 2008 17:10:00 -0000	[thread overview]
Message-ID: <47D0257D.9080505@redhat.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 173 bytes --]

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



[-- Attachment #2: ferror_regex.patch --]
[-- Type: text/x-patch, Size: 2287 bytes --]

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  <pmuldoon@redhat.com>
+
+	* 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  <cagney@redhat.com>
 
 	* 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 \"<error string>\""){
+       Option option = new Option('e', "--error", "error regex to catch in double quotes -e \"<error string>\""){
 
 	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();
 

             reply	other threads:[~2008-03-06 17:10 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-06 17:10 Phil Muldoon [this message]
2008-03-06 22:08 ` Sami Wagiaalla

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=47D0257D.9080505@redhat.com \
    --to=pmuldoon@redhat.com \
    --cc=frysk@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).