Skip to content

Commit b7702a2

Browse files
Masami HiramatsuIngo Molnar
authored andcommitted
perf probe: Check new event name
Check new event name is same syntax as a C symbol in perf command. In other words, checking the name is as like as other tracepoint events. This can prevent user to create an event with useless name (e.g. foo|bar, foo*bar). Signed-off-by: Masami Hiramatsu <mhiramat@redhat.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Paul Mackerras <paulus@samba.org> Cc: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Steven Rostedt <rostedt@goodmis.org> Cc: Jim Keniston <jkenisto@us.ibm.com> Cc: Ananth N Mavinakayanahalli <ananth@in.ibm.com> Cc: Christoph Hellwig <hch@infradead.org> Cc: Jason Baron <jbaron@redhat.com> Cc: K.Prasad <prasad@linux.vnet.ibm.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Srikar Dronamraju <srikar@linux.vnet.ibm.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: systemtap <systemtap@sources.redhat.com> Cc: DLE <dle-develop@lists.sourceforge.net> LKML-Reference: <20091216222415.14459.71383.stgit@dhcp-100-2-132.bos.redhat.com> [ v2: minor cleanups ] Signed-off-by: Ingo Molnar <mingo@elte.hu>
1 parent 6f3cf44 commit b7702a2

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

‎tools/perf/util/probe-event.c‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,18 @@ static int e_snprintf(char *str, size_t size, const char *format, ...)
6262
return ret;
6363
}
6464

65+
/* Check the name is good for event/group */
66+
static bool check_event_name(const char *name)
67+
{
68+
if (!isalpha(*name) && *name != '_')
69+
return false;
70+
while (*++name != '\0') {
71+
if (!isalpha(*name) && !isdigit(*name) && *name != '_')
72+
return false;
73+
}
74+
return true;
75+
}
76+
6577
/* Parse probepoint definition. */
6678
static void parse_perf_probe_probepoint(char *arg, struct probe_point *pp)
6779
{
@@ -82,6 +94,9 @@ static void parse_perf_probe_probepoint(char *arg, struct probe_point *pp)
8294
ptr = strchr(arg, ':');
8395
if (ptr) /* Group name is not supported yet. */
8496
semantic_error("Group name is not supported yet.");
97+
if (!check_event_name(arg))
98+
semantic_error("%s is bad for event name -it must "
99+
"follow C symbol-naming rule.", arg);
85100
pp->event = strdup(arg);
86101
arg = tmp;
87102
}

0 commit comments

Comments
 (0)