public inbox for frysk-cvs@sourceware.org
help / color / mirror / Atom feed
From: pmachata@sourceware.org
To: frysk-cvs@sourceware.org
Subject: [SCM]  master: Use globs in ftrace
Date: Wed, 20 Feb 2008 19:24:00 -0000	[thread overview]
Message-ID: <20080220192426.27127.qmail@sourceware.org> (raw)

The branch, master has been updated
       via  79c3336ab437f84fdcf207540d1cb68954ed2719 (commit)
      from  a698552443da8465f68ad185f7760ef1c9dcdf2a (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email.

- Log -----------------------------------------------------------------
commit 79c3336ab437f84fdcf207540d1cb68954ed2719
Author: Petr Machata <pmachata@redhat.com>
Date:   Wed Feb 20 20:24:11 2008 +0100

    Use globs in ftrace

-----------------------------------------------------------------------

Summary of changes:
 frysk-core/frysk/bindir/ChangeLog   |    5 ++
 frysk-core/frysk/bindir/ftrace.java |   90 +++++++++++++++++++++++++++++++++--
 2 files changed, 91 insertions(+), 4 deletions(-)

First 500 lines of diff:
diff --git a/frysk-core/frysk/bindir/ChangeLog b/frysk-core/frysk/bindir/ChangeLog
index ddf28e2..f60e599 100644
--- a/frysk-core/frysk/bindir/ChangeLog
+++ b/frysk-core/frysk/bindir/ChangeLog
@@ -1,3 +1,8 @@
+2008-02-20  Petr Machata  <pmachata@redhat.com>
+
+	* ftrace.java: Use globs instead of regular expressions.
+	(Glob): New class.
+
 2008-02-19  Andrew Cagney  <cagney@redhat.com>
 
 	* TestFstep.java: Update to match lib.dwfl.Elf.
diff --git a/frysk-core/frysk/bindir/ftrace.java b/frysk-core/frysk/bindir/ftrace.java
index a845b05..c9fcfec 100644
--- a/frysk-core/frysk/bindir/ftrace.java
+++ b/frysk-core/frysk/bindir/ftrace.java
@@ -73,6 +73,88 @@ import lib.dwfl.ElfSymbolVersion;
 import gnu.classpath.tools.getopt.Option;
 import gnu.classpath.tools.getopt.OptionException;
 
+class Glob
+{
+    private static int matchCharacterClass(String glob, int from)
+	throws PatternSyntaxException
+    {
+	int i = from + 2;
+	while (glob.charAt(++i) != ':' && i < glob.length())
+	    continue;
+	if (i >= glob.length() || glob.charAt(++i) != ']')
+	    throw new PatternSyntaxException
+		("Unmatched '['.", glob, from);
+	return i;
+    }
+
+    private static int matchBrack(String glob, int from)
+	throws PatternSyntaxException
+    {
+	// On first character, both [ and ] are legal.  But when [ is
+	// foolowed with :, it's character class.
+	int i = from + 1;
+	if (glob.charAt(i) == '[' && glob.charAt(i + 1) == ':')
+	    i = matchCharacterClass(glob, i) + 1;
+	else
+	    ++i; // skip any character, including [ or ]
+	boolean escape = false;
+	for (; i < glob.length(); ++i) {
+	    char c = glob.charAt(i);
+	    if (escape) {
+		++i;
+		escape = false;
+	    }
+	    else if (c == '[' && glob.charAt(i + 1) == ':')
+		i = matchCharacterClass(glob, i);
+	    else if (c == ']')
+		return i;
+	}
+	throw new PatternSyntaxException
+	    ("Unmatched '" + glob.charAt(from) + "'.", glob, from);
+    }
+
+    private static String toRegex(String glob) {
+	StringBuffer buf = new StringBuffer();
+	boolean escape = false;
+	for(int i = 0; i < glob.length(); ++i) {
+	    char c = glob.charAt(i);
+	    if (escape) {
+		if (c == '\\')
+		    buf.append("\\\\");
+		else if (c == '*')
+		    buf.append("\\*");
+		else if (c == '?')
+		    buf.append('?');
+		else
+		    buf.append('\\').append(c);
+		escape = false;
+	    }
+	    else {
+		if (c == '\\')
+		    escape = true;
+		else if (c == '[') {
+		    int j = matchBrack(glob, i);
+		    buf.append(glob.substring(i, j+1));
+		    i = j;
+		}
+		else if (c == '*')
+		    buf.append(".*");
+		else if (c == '?')
+		    buf.append('.');
+		else if (c == '.')
+		    buf.append("\\.");
+		else
+		    buf.append(c);
+	    }
+	}
+	return buf.toString();
+    }
+
+    public static Pattern compile(String glob) {
+	return Pattern.compile(toRegex(glob));
+    }
+}
+
 abstract class Rule
 {
     final public boolean addition;
@@ -141,9 +223,9 @@ class SymbolRule
     public SymbolRule(boolean addition, boolean stackTrace,
 		      String nameRe, String sonameRe, String versionRe) {
 	super (addition, stackTrace);
-	this.sonamePattern = Pattern.compile((sonameRe != null) ? sonameRe : ".*");
-	this.versionPattern = Pattern.compile((versionRe != null) ? versionRe : ".*");
-	this.namePattern = Pattern.compile((nameRe != null) ? nameRe : ".*");
+	this.sonamePattern = Glob.compile((sonameRe != null) ? sonameRe : "*");
+	this.versionPattern = Glob.compile((versionRe != null) ? versionRe : "*");
+	this.namePattern = Glob.compile((nameRe != null) ? nameRe : "*");
     }
 
     public String toString() {
@@ -232,7 +314,7 @@ class ByRegexpSyscallRule
     Pattern pattern;
     public ByRegexpSyscallRule(boolean addition, boolean stackTrace, String regexp) {
 	super (addition, stackTrace);
-	this.pattern = Pattern.compile(regexp);
+	this.pattern = Glob.compile(regexp);
     }
 
     public boolean matches(Object traceable) {


hooks/post-receive
--
frysk system monitor/debugger


                 reply	other threads:[~2008-02-20 19:24 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20080220192426.27127.qmail@sourceware.org \
    --to=pmachata@sourceware.org \
    --cc=frysk-cvs@sourceware.org \
    --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).