diff options
author | Masami Hiramatsu <mhiramat@redhat.com> | 2009-12-16 17:24:15 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-12-17 03:42:44 -0500 |
commit | b7702a2136b5f8e0e186e22cae91aaecf98b418c (patch) | |
tree | 79562d989a3760252d50a9e2b6e55138a39a29b6 /tools/perf/util | |
parent | 6f3cf440470650b3841d325acacd0c5ea9504c68 (diff) |
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>
Diffstat (limited to 'tools/perf/util')
-rw-r--r-- | tools/perf/util/probe-event.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c index 2ca62154f79..29465d44004 100644 --- a/tools/perf/util/probe-event.c +++ b/tools/perf/util/probe-event.c | |||
@@ -62,6 +62,18 @@ static int e_snprintf(char *str, size_t size, const char *format, ...) | |||
62 | return ret; | 62 | return ret; |
63 | } | 63 | } |
64 | 64 | ||
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 | |||
65 | /* Parse probepoint definition. */ | 77 | /* Parse probepoint definition. */ |
66 | static void parse_perf_probe_probepoint(char *arg, struct probe_point *pp) | 78 | static void parse_perf_probe_probepoint(char *arg, struct probe_point *pp) |
67 | { | 79 | { |
@@ -82,6 +94,9 @@ static void parse_perf_probe_probepoint(char *arg, struct probe_point *pp) | |||
82 | ptr = strchr(arg, ':'); | 94 | ptr = strchr(arg, ':'); |
83 | if (ptr) /* Group name is not supported yet. */ | 95 | if (ptr) /* Group name is not supported yet. */ |
84 | semantic_error("Group name is not supported yet."); | 96 | 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); | ||
85 | pp->event = strdup(arg); | 100 | pp->event = strdup(arg); |
86 | arg = tmp; | 101 | arg = tmp; |
87 | } | 102 | } |