This is the mail archive of the
frysk@sourceware.org
mailing list for the frysk project.
Patchlet to convert ferror to use regex when matching -e argument
- From: Phil Muldoon <pmuldoon at redhat dot com>
- To: Frysk Hackers <frysk at sourceware dot org>
- Date: Thu, 06 Mar 2008 17:10:21 +0000
- Subject: Patchlet to convert ferror to use regex when matching -e argument
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
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();