aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrederic Weisbecker <fweisbec@gmail.com>2009-05-02 21:03:57 -0400
committerIngo Molnar <mingo@elte.hu>2009-05-07 04:05:57 -0400
commit5928c3cc0ffcb6894bbab6be591b7ae1786b2d87 (patch)
tree75503a660dafe84dcd434912c5a0bdf97cad3c8a
parente8808c1019b048a43686dbd25c188a035842c2e2 (diff)
tracing/filters: support for operator reserved characters in strings
When we set a filter for an event, such as: echo "name == my_lock_name" > \ /debug/tracing/events/lockdep/lock_acquired/filter then the following order of token type is parsed: - space - operator - parentheses - operand Because the operators and parentheses have a higher precedence than the operand characters, which is normal, then we can't use any string containing such special characters: ()=<>!&| To get this support and also avoid ambiguous intepretation from the parser or the human, we can do it using double quotes so that we keep the usual languages habits. Then after this patch you can still declare string condition like before: echo name == myname But if you want to compare against a string containing an operator character, you can use double quotes: echo 'name == "&myname"' Don't forget to include the whole expression into single quotes or the double ones will be eaten by echo. [ Impact: support strings with special characters for tracing filters ] Cc: Tom Zanussi <tzanussi@gmail.com> Cc: Steven Rostedt <rostedt@goodmis.org> Cc: Li Zefan <lizf@cn.fujitsu.com> Cc: Zhaolei <zhaolei@cn.fujitsu.com> Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
-rw-r--r--kernel/trace/trace_events_filter.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/kernel/trace/trace_events_filter.c b/kernel/trace/trace_events_filter.c
index 01c76eb3e168..8c62e5bdff09 100644
--- a/kernel/trace/trace_events_filter.c
+++ b/kernel/trace/trace_events_filter.c
@@ -851,10 +851,19 @@ static void postfix_clear(struct filter_parse_state *ps)
851 851
852static int filter_parse(struct filter_parse_state *ps) 852static int filter_parse(struct filter_parse_state *ps)
853{ 853{
854 int in_string = 0;
854 int op, top_op; 855 int op, top_op;
855 char ch; 856 char ch;
856 857
857 while ((ch = infix_next(ps))) { 858 while ((ch = infix_next(ps))) {
859 if (ch == '"') {
860 in_string ^= 1;
861 continue;
862 }
863
864 if (in_string)
865 goto parse_operand;
866
858 if (isspace(ch)) 867 if (isspace(ch))
859 continue; 868 continue;
860 869
@@ -908,6 +917,7 @@ static int filter_parse(struct filter_parse_state *ps)
908 } 917 }
909 continue; 918 continue;
910 } 919 }
920parse_operand:
911 if (append_operand_char(ps, ch)) { 921 if (append_operand_char(ps, ch)) {
912 parse_error(ps, FILT_ERR_OPERAND_TOO_LONG, 0); 922 parse_error(ps, FILT_ERR_OPERAND_TOO_LONG, 0);
913 return -EINVAL; 923 return -EINVAL;