Skip to content

Commit ec5ce09

Browse files
tzanussirostedt
authored andcommitted
tracing: Allow whitespace to surround hist trigger filter
The existing code only allows for one space before and after the 'if' specifying the filter for a hist trigger. Add code to make that more permissive as far as whitespace goes. Specifically, we want to allow spaces in the trigger itself now that we have additional syntax (onmatch/onmax) where spaces are more natural e.g. spaces after commas in param lists. Link: http://lkml.kernel.org/r/1053090c3c308d4f431accdeb59dff4b511d4554.1516069914.git.tom.zanussi@linux.intel.com Signed-off-by: Tom Zanussi <[email protected]> Signed-off-by: Steven Rostedt (VMware) <[email protected]>
1 parent 5045060 commit ec5ce09

File tree

1 file changed

+32
-5
lines changed

1 file changed

+32
-5
lines changed

kernel/trace/trace_events_hist.c

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5162,7 +5162,7 @@ static int event_hist_trigger_func(struct event_command *cmd_ops,
51625162
struct synth_event *se;
51635163
const char *se_name;
51645164
bool remove = false;
5165-
char *trigger;
5165+
char *trigger, *p;
51665166
int ret = 0;
51675167

51685168
if (!param)
@@ -5171,10 +5171,37 @@ static int event_hist_trigger_func(struct event_command *cmd_ops,
51715171
if (glob[0] == '!')
51725172
remove = true;
51735173

5174-
/* separate the trigger from the filter (k:v [if filter]) */
5175-
trigger = strsep(&param, " \t");
5176-
if (!trigger)
5177-
return -EINVAL;
5174+
/*
5175+
* separate the trigger from the filter (k:v [if filter])
5176+
* allowing for whitespace in the trigger
5177+
*/
5178+
p = trigger = param;
5179+
do {
5180+
p = strstr(p, "if");
5181+
if (!p)
5182+
break;
5183+
if (p == param)
5184+
return -EINVAL;
5185+
if (*(p - 1) != ' ' && *(p - 1) != '\t') {
5186+
p++;
5187+
continue;
5188+
}
5189+
if (p >= param + strlen(param) - strlen("if") - 1)
5190+
return -EINVAL;
5191+
if (*(p + strlen("if")) != ' ' && *(p + strlen("if")) != '\t') {
5192+
p++;
5193+
continue;
5194+
}
5195+
break;
5196+
} while (p);
5197+
5198+
if (!p)
5199+
param = NULL;
5200+
else {
5201+
*(p - 1) = '\0';
5202+
param = strstrip(p);
5203+
trigger = strstrip(trigger);
5204+
}
51785205

51795206
attrs = parse_hist_trigger_attrs(trigger);
51805207
if (IS_ERR(attrs))

0 commit comments

Comments
 (0)