* Patchlet to convert ferror to use regex when matching -e argument
@ 2008-03-06 17:10 Phil Muldoon
2008-03-06 22:08 ` Sami Wagiaalla
0 siblings, 1 reply; 2+ messages in thread
From: Phil Muldoon @ 2008-03-06 17:10 UTC (permalink / raw)
To: Frysk Hackers
[-- 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();
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Patchlet to convert ferror to use regex when matching -e argument
2008-03-06 17:10 Patchlet to convert ferror to use regex when matching -e argument Phil Muldoon
@ 2008-03-06 22:08 ` Sami Wagiaalla
0 siblings, 0 replies; 2+ messages in thread
From: Sami Wagiaalla @ 2008-03-06 22:08 UTC (permalink / raw)
To: Phil Muldoon; +Cc: Frysk Hackers
Phil Muldoon wrote:
> Small patch. This converts ferror to pattern match the -e argument over
> a straight String.contains(). Useful for looking for more complex search
> queries.
Worked like a charm. I added a test and committed.
swagiaal: ferror patch by pmuldoon for regex support.
frysk-core/frysk/bindir/ChangeLog
+2008-03-06 Sami Wagiaalla <swagiaal@redhat.com>
+
+ * TestFerror.java: Added test for regext argument matching.
+
+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.
+
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2008-03-06 22:08 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-03-06 17:10 Patchlet to convert ferror to use regex when matching -e argument Phil Muldoon
2008-03-06 22:08 ` Sami Wagiaalla
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).