public inbox for systemtap@sourceware.org
 help / color / mirror / Atom feed
* [PATCH -tip 3/3] perf probe: Check new event name
  2009-12-16 22:19 [PATCH -tip 0/3] perf/trace: bugfixes Masami Hiramatsu
  2009-12-16 22:19 ` [PATCH -tip 1/3] perf probe: Check debugpath is correct Masami Hiramatsu
@ 2009-12-16 22:19 ` Masami Hiramatsu
  2009-12-17 10:54   ` [tip:perf/urgent] " tip-bot for Masami Hiramatsu
  2009-12-16 22:19 ` [PATCH -tip 2/3] kprobe-tracer: Check new event/group name Masami Hiramatsu
  2 siblings, 1 reply; 7+ messages in thread
From: Masami Hiramatsu @ 2009-12-16 22:19 UTC (permalink / raw)
  To: Ingo Molnar, Frederic Weisbecker, lkml
  Cc: systemtap, DLE, Masami Hiramatsu, Ingo Molnar,
	Frederic Weisbecker, Paul Mackerras, Arnaldo Carvalho de Melo,
	Steven Rostedt, Jim Keniston, Ananth N Mavinakayanahalli,
	Christoph Hellwig, Frank Ch. Eigler, Jason Baron, K.Prasad,
	Peter Zijlstra, Srikar Dronamraju

Check new event name is same syntax as 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: Ingo Molnar <mingo@elte.hu>
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: Frank Ch. Eigler <fche@redhat.com>
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>
---

 tools/perf/util/probe-event.c |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index 2ca6215..6fca3b6 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -62,6 +62,17 @@ static int e_snprintf(char *str, size_t size, const char *format, ...)
 	return ret;
 }
 
+/* Check the name is good for event/group */
+static bool good_event_name(const char *name)
+{
+	if (!isalpha(*name) && *name != '_')
+		return false;
+	while (*++name != '\0')
+		if (!isalpha(*name) && !isdigit(*name) && *name != '_')
+			return false;
+	return true;
+}
+
 /* Parse probepoint definition. */
 static void parse_perf_probe_probepoint(char *arg, struct probe_point *pp)
 {
@@ -82,6 +93,9 @@ static void parse_perf_probe_probepoint(char *arg, struct probe_point *pp)
 		ptr = strchr(arg, ':');
 		if (ptr)	/* Group name is not supported yet. */
 			semantic_error("Group name is not supported yet.");
+		if (!good_event_name(arg))
+			semantic_error("%s is bad for event name -it must "
+				       "follow C symbol-naming rule.", arg);
 		pp->event = strdup(arg);
 		arg = tmp;
 	}


-- 
Masami Hiramatsu

Software Engineer
Hitachi Computer Products (America), Inc.
Software Solutions Division

e-mail: mhiramat@redhat.com

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH -tip 0/3] perf/trace: bugfixes
@ 2009-12-16 22:19 Masami Hiramatsu
  2009-12-16 22:19 ` [PATCH -tip 1/3] perf probe: Check debugpath is correct Masami Hiramatsu
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Masami Hiramatsu @ 2009-12-16 22:19 UTC (permalink / raw)
  To: Ingo Molnar, Frederic Weisbecker, lkml; +Cc: systemtap, DLE

Hi,

Here are several bugfixes for perf-probe and kprobe tracer.

Thank you,

---

Masami Hiramatsu (3):
      perf probe: Check new event name
      kprobe-tracer: Check new event/group name
      perf probe: Check debugpath is correct


 kernel/trace/trace_kprobe.c   |   30 ++++++++++++++++++++++++------
 tools/perf/builtin-probe.c    |    4 ++++
 tools/perf/util/probe-event.c |   14 ++++++++++++++
 3 files changed, 42 insertions(+), 6 deletions(-)

-- 
Masami Hiramatsu

Software Engineer
Hitachi Computer Products (America), Inc.
Software Solutions Division
e-mail: mhiramat@redhat.com

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH -tip 2/3] kprobe-tracer: Check new event/group name
  2009-12-16 22:19 [PATCH -tip 0/3] perf/trace: bugfixes Masami Hiramatsu
  2009-12-16 22:19 ` [PATCH -tip 1/3] perf probe: Check debugpath is correct Masami Hiramatsu
  2009-12-16 22:19 ` [PATCH -tip 3/3] perf probe: Check new event name Masami Hiramatsu
@ 2009-12-16 22:19 ` Masami Hiramatsu
  2009-12-17 10:54   ` [tip:perf/urgent] " tip-bot for Masami Hiramatsu
  2 siblings, 1 reply; 7+ messages in thread
From: Masami Hiramatsu @ 2009-12-16 22:19 UTC (permalink / raw)
  To: Ingo Molnar, Frederic Weisbecker, lkml
  Cc: systemtap, DLE, Masami Hiramatsu, Ingo Molnar,
	Frederic Weisbecker, Paul Mackerras, Arnaldo Carvalho de Melo,
	Steven Rostedt, Jim Keniston, Ananth N Mavinakayanahalli,
	Christoph Hellwig, Frank Ch. Eigler, Jason Baron, K.Prasad,
	Peter Zijlstra, Srikar Dronamraju

Check new event/group name is same syntax as c symbol. 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: Ingo Molnar <mingo@elte.hu>
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: Frank Ch. Eigler <fche@redhat.com>
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>
---

 kernel/trace/trace_kprobe.c |   30 ++++++++++++++++++++++++------
 1 files changed, 24 insertions(+), 6 deletions(-)

diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c
index 7ecab06..167c189 100644
--- a/kernel/trace/trace_kprobe.c
+++ b/kernel/trace/trace_kprobe.c
@@ -282,6 +282,17 @@ static int kprobe_dispatcher(struct kprobe *kp, struct pt_regs *regs);
 static int kretprobe_dispatcher(struct kretprobe_instance *ri,
 				struct pt_regs *regs);
 
+/* Check the name is good for event/group */
+static int good_event_name(const char *name)
+{
+	if (!isalpha(*name) && *name != '_')
+		return 0;
+	while (*++name != '\0')
+		if (!isalpha(*name) && !isdigit(*name) && *name != '_')
+			return 0;
+	return 1;
+}
+
 /*
  * Allocate new trace_probe and initialize it (including kprobes).
  */
@@ -293,10 +304,11 @@ static struct trace_probe *alloc_trace_probe(const char *group,
 					     int nargs, int is_return)
 {
 	struct trace_probe *tp;
+	int ret = -ENOMEM;
 
 	tp = kzalloc(SIZEOF_TRACE_PROBE(nargs), GFP_KERNEL);
 	if (!tp)
-		return ERR_PTR(-ENOMEM);
+		return ERR_PTR(ret);
 
 	if (symbol) {
 		tp->symbol = kstrdup(symbol, GFP_KERNEL);
@@ -312,14 +324,20 @@ static struct trace_probe *alloc_trace_probe(const char *group,
 	else
 		tp->rp.kp.pre_handler = kprobe_dispatcher;
 
-	if (!event)
+	if (!event || !good_event_name(event)) {
+		ret = -EINVAL;
 		goto error;
+	}
+
 	tp->call.name = kstrdup(event, GFP_KERNEL);
 	if (!tp->call.name)
 		goto error;
 
-	if (!group)
+	if (!group || !good_event_name(group)) {
+		ret = -EINVAL;
 		goto error;
+	}
+
 	tp->call.system = kstrdup(group, GFP_KERNEL);
 	if (!tp->call.system)
 		goto error;
@@ -330,7 +348,7 @@ error:
 	kfree(tp->call.name);
 	kfree(tp->symbol);
 	kfree(tp);
-	return ERR_PTR(-ENOMEM);
+	return ERR_PTR(ret);
 }
 
 static void free_probe_arg(struct probe_arg *arg)
@@ -695,10 +713,10 @@ static int create_trace_probe(int argc, char **argv)
 	if (!event) {
 		/* Make a new event name */
 		if (symbol)
-			snprintf(buf, MAX_EVENT_NAME_LEN, "%c@%s%+ld",
+			snprintf(buf, MAX_EVENT_NAME_LEN, "%c_%s_%ld",
 				 is_return ? 'r' : 'p', symbol, offset);
 		else
-			snprintf(buf, MAX_EVENT_NAME_LEN, "%c@0x%p",
+			snprintf(buf, MAX_EVENT_NAME_LEN, "%c_0x%p",
 				 is_return ? 'r' : 'p', addr);
 		event = buf;
 	}


-- 
Masami Hiramatsu

Software Engineer
Hitachi Computer Products (America), Inc.
Software Solutions Division

e-mail: mhiramat@redhat.com

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH -tip 1/3] perf probe: Check debugpath is correct
  2009-12-16 22:19 [PATCH -tip 0/3] perf/trace: bugfixes Masami Hiramatsu
@ 2009-12-16 22:19 ` Masami Hiramatsu
  2009-12-17 10:53   ` [tip:perf/urgent] perf probe: Check whether debugfs path " tip-bot for Masami Hiramatsu
  2009-12-16 22:19 ` [PATCH -tip 3/3] perf probe: Check new event name Masami Hiramatsu
  2009-12-16 22:19 ` [PATCH -tip 2/3] kprobe-tracer: Check new event/group name Masami Hiramatsu
  2 siblings, 1 reply; 7+ messages in thread
From: Masami Hiramatsu @ 2009-12-16 22:19 UTC (permalink / raw)
  To: Ingo Molnar, Frederic Weisbecker, lkml
  Cc: systemtap, DLE, Masami Hiramatsu, Ingo Molnar,
	Frederic Weisbecker, Paul Mackerras, Arnaldo Carvalho de Melo,
	Steven Rostedt, Jim Keniston, Ananth N Mavinakayanahalli,
	Christoph Hellwig, Frank Ch. Eigler, Jason Baron, K.Prasad,
	Peter Zijlstra, Srikar Dronamraju

Check whether debugpath is correct before executing command,
because perf-probe depends on the debugpath.

Signed-off-by: Masami Hiramatsu <mhiramat@redhat.com>
Cc: Ingo Molnar <mingo@elte.hu>
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: Frank Ch. Eigler <fche@redhat.com>
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>
---

 tools/perf/builtin-probe.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/tools/perf/builtin-probe.c b/tools/perf/builtin-probe.c
index 7e741f5..c1e6774 100644
--- a/tools/perf/builtin-probe.c
+++ b/tools/perf/builtin-probe.c
@@ -38,6 +38,7 @@
 #include "util/strlist.h"
 #include "util/event.h"
 #include "util/debug.h"
+#include "util/debugfs.h"
 #include "util/symbol.h"
 #include "util/thread.h"
 #include "util/session.h"
@@ -205,6 +206,9 @@ int cmd_probe(int argc, const char **argv, const char *prefix __used)
 	if ((!session.nr_probe && !session.dellist && !session.list_events))
 		usage_with_options(probe_usage, options);
 
+	if (debugfs_valid_mountpoint(debugfs_path) < 0)
+		die("Failed to find debugfs path.");
+
 	if (session.list_events) {
 		if (session.nr_probe != 0 || session.dellist) {
 			pr_warning("  Error: Don't use --list with"


-- 
Masami Hiramatsu

Software Engineer
Hitachi Computer Products (America), Inc.
Software Solutions Division

e-mail: mhiramat@redhat.com

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [tip:perf/urgent] perf probe: Check whether debugfs path is correct
  2009-12-16 22:19 ` [PATCH -tip 1/3] perf probe: Check debugpath is correct Masami Hiramatsu
@ 2009-12-17 10:53   ` tip-bot for Masami Hiramatsu
  0 siblings, 0 replies; 7+ messages in thread
From: tip-bot for Masami Hiramatsu @ 2009-12-17 10:53 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: acme, mingo, peterz, dle-develop, fweisbec, rostedt, jbaron,
	tglx, mhiramat, systemtap, linux-kernel, hpa, paulus, jkenisto,
	hch, ananth, srikar, mingo, prasad

Commit-ID:  96c96612e952f63cc0055db9df7d8b5b1ada02be
Gitweb:     http://git.kernel.org/tip/96c96612e952f63cc0055db9df7d8b5b1ada02be
Author:     Masami Hiramatsu <mhiramat@redhat.com>
AuthorDate: Wed, 16 Dec 2009 17:24:00 -0500
Committer:  Ingo Molnar <mingo@elte.hu>
CommitDate: Thu, 17 Dec 2009 09:42:43 +0100

perf probe: Check whether debugfs path is correct

Check whether the debugfs path is correct before executing
a command, because perf-probe depends on debugfs.

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: systemtap <systemtap@sources.redhat.com>
Cc: DLE <dle-develop@lists.sourceforge.net>
LKML-Reference: <20091216222400.14459.48162.stgit@dhcp-100-2-132.bos.redhat.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
 tools/perf/builtin-probe.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/tools/perf/builtin-probe.c b/tools/perf/builtin-probe.c
index 7e741f5..c1e6774 100644
--- a/tools/perf/builtin-probe.c
+++ b/tools/perf/builtin-probe.c
@@ -38,6 +38,7 @@
 #include "util/strlist.h"
 #include "util/event.h"
 #include "util/debug.h"
+#include "util/debugfs.h"
 #include "util/symbol.h"
 #include "util/thread.h"
 #include "util/session.h"
@@ -205,6 +206,9 @@ int cmd_probe(int argc, const char **argv, const char *prefix __used)
 	if ((!session.nr_probe && !session.dellist && !session.list_events))
 		usage_with_options(probe_usage, options);
 
+	if (debugfs_valid_mountpoint(debugfs_path) < 0)
+		die("Failed to find debugfs path.");
+
 	if (session.list_events) {
 		if (session.nr_probe != 0 || session.dellist) {
 			pr_warning("  Error: Don't use --list with"

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [tip:perf/urgent] kprobe-tracer: Check new event/group name
  2009-12-16 22:19 ` [PATCH -tip 2/3] kprobe-tracer: Check new event/group name Masami Hiramatsu
@ 2009-12-17 10:54   ` tip-bot for Masami Hiramatsu
  0 siblings, 0 replies; 7+ messages in thread
From: tip-bot for Masami Hiramatsu @ 2009-12-17 10:54 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: acme, mingo, peterz, dle-develop, fweisbec, rostedt, jbaron,
	tglx, mhiramat, systemtap, linux-kernel, hpa, paulus, jkenisto,
	hch, ananth, srikar, mingo, prasad

Commit-ID:  6f3cf440470650b3841d325acacd0c5ea9504c68
Gitweb:     http://git.kernel.org/tip/6f3cf440470650b3841d325acacd0c5ea9504c68
Author:     Masami Hiramatsu <mhiramat@redhat.com>
AuthorDate: Wed, 16 Dec 2009 17:24:08 -0500
Committer:  Ingo Molnar <mingo@elte.hu>
CommitDate: Thu, 17 Dec 2009 09:42:44 +0100

kprobe-tracer: Check new event/group name

Check new event/group name is same syntax as a C symbol. 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: systemtap <systemtap@sources.redhat.com>
Cc: DLE <dle-develop@lists.sourceforge.net>
LKML-Reference: <20091216222408.14459.68790.stgit@dhcp-100-2-132.bos.redhat.com>
[ v2: minor cleanups ]
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
 kernel/trace/trace_kprobe.c |   31 +++++++++++++++++++++++++------
 1 files changed, 25 insertions(+), 6 deletions(-)

diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c
index 7ecab06..375f81a 100644
--- a/kernel/trace/trace_kprobe.c
+++ b/kernel/trace/trace_kprobe.c
@@ -282,6 +282,18 @@ static int kprobe_dispatcher(struct kprobe *kp, struct pt_regs *regs);
 static int kretprobe_dispatcher(struct kretprobe_instance *ri,
 				struct pt_regs *regs);
 
+/* Check the name is good for event/group */
+static int check_event_name(const char *name)
+{
+	if (!isalpha(*name) && *name != '_')
+		return 0;
+	while (*++name != '\0') {
+		if (!isalpha(*name) && !isdigit(*name) && *name != '_')
+			return 0;
+	}
+	return 1;
+}
+
 /*
  * Allocate new trace_probe and initialize it (including kprobes).
  */
@@ -293,10 +305,11 @@ static struct trace_probe *alloc_trace_probe(const char *group,
 					     int nargs, int is_return)
 {
 	struct trace_probe *tp;
+	int ret = -ENOMEM;
 
 	tp = kzalloc(SIZEOF_TRACE_PROBE(nargs), GFP_KERNEL);
 	if (!tp)
-		return ERR_PTR(-ENOMEM);
+		return ERR_PTR(ret);
 
 	if (symbol) {
 		tp->symbol = kstrdup(symbol, GFP_KERNEL);
@@ -312,14 +325,20 @@ static struct trace_probe *alloc_trace_probe(const char *group,
 	else
 		tp->rp.kp.pre_handler = kprobe_dispatcher;
 
-	if (!event)
+	if (!event || !check_event_name(event)) {
+		ret = -EINVAL;
 		goto error;
+	}
+
 	tp->call.name = kstrdup(event, GFP_KERNEL);
 	if (!tp->call.name)
 		goto error;
 
-	if (!group)
+	if (!group || !check_event_name(group)) {
+		ret = -EINVAL;
 		goto error;
+	}
+
 	tp->call.system = kstrdup(group, GFP_KERNEL);
 	if (!tp->call.system)
 		goto error;
@@ -330,7 +349,7 @@ error:
 	kfree(tp->call.name);
 	kfree(tp->symbol);
 	kfree(tp);
-	return ERR_PTR(-ENOMEM);
+	return ERR_PTR(ret);
 }
 
 static void free_probe_arg(struct probe_arg *arg)
@@ -695,10 +714,10 @@ static int create_trace_probe(int argc, char **argv)
 	if (!event) {
 		/* Make a new event name */
 		if (symbol)
-			snprintf(buf, MAX_EVENT_NAME_LEN, "%c@%s%+ld",
+			snprintf(buf, MAX_EVENT_NAME_LEN, "%c_%s_%ld",
 				 is_return ? 'r' : 'p', symbol, offset);
 		else
-			snprintf(buf, MAX_EVENT_NAME_LEN, "%c@0x%p",
+			snprintf(buf, MAX_EVENT_NAME_LEN, "%c_0x%p",
 				 is_return ? 'r' : 'p', addr);
 		event = buf;
 	}

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [tip:perf/urgent] perf probe: Check new event name
  2009-12-16 22:19 ` [PATCH -tip 3/3] perf probe: Check new event name Masami Hiramatsu
@ 2009-12-17 10:54   ` tip-bot for Masami Hiramatsu
  0 siblings, 0 replies; 7+ messages in thread
From: tip-bot for Masami Hiramatsu @ 2009-12-17 10:54 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: acme, mingo, peterz, dle-develop, fweisbec, rostedt, jbaron,
	tglx, mhiramat, systemtap, linux-kernel, hpa, paulus, jkenisto,
	hch, ananth, srikar, mingo, prasad

Commit-ID:  b7702a2136b5f8e0e186e22cae91aaecf98b418c
Gitweb:     http://git.kernel.org/tip/b7702a2136b5f8e0e186e22cae91aaecf98b418c
Author:     Masami Hiramatsu <mhiramat@redhat.com>
AuthorDate: Wed, 16 Dec 2009 17:24:15 -0500
Committer:  Ingo Molnar <mingo@elte.hu>
CommitDate: Thu, 17 Dec 2009 09:42:44 +0100

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>
---
 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 2ca6215..29465d4 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, ...)
 	return ret;
 }
 
+/* Check the name is good for event/group */
+static bool check_event_name(const char *name)
+{
+	if (!isalpha(*name) && *name != '_')
+		return false;
+	while (*++name != '\0') {
+		if (!isalpha(*name) && !isdigit(*name) && *name != '_')
+			return false;
+	}
+	return true;
+}
+
 /* Parse probepoint definition. */
 static void parse_perf_probe_probepoint(char *arg, struct probe_point *pp)
 {
@@ -82,6 +94,9 @@ static void parse_perf_probe_probepoint(char *arg, struct probe_point *pp)
 		ptr = strchr(arg, ':');
 		if (ptr)	/* Group name is not supported yet. */
 			semantic_error("Group name is not supported yet.");
+		if (!check_event_name(arg))
+			semantic_error("%s is bad for event name -it must "
+				       "follow C symbol-naming rule.", arg);
 		pp->event = strdup(arg);
 		arg = tmp;
 	}

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2009-12-17 10:54 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-12-16 22:19 [PATCH -tip 0/3] perf/trace: bugfixes Masami Hiramatsu
2009-12-16 22:19 ` [PATCH -tip 1/3] perf probe: Check debugpath is correct Masami Hiramatsu
2009-12-17 10:53   ` [tip:perf/urgent] perf probe: Check whether debugfs path " tip-bot for Masami Hiramatsu
2009-12-16 22:19 ` [PATCH -tip 3/3] perf probe: Check new event name Masami Hiramatsu
2009-12-17 10:54   ` [tip:perf/urgent] " tip-bot for Masami Hiramatsu
2009-12-16 22:19 ` [PATCH -tip 2/3] kprobe-tracer: Check new event/group name Masami Hiramatsu
2009-12-17 10:54   ` [tip:perf/urgent] " tip-bot for Masami Hiramatsu

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).