Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1763080AbZLPWVO (ORCPT ); Wed, 16 Dec 2009 17:21:14 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1763044AbZLPWU4 (ORCPT ); Wed, 16 Dec 2009 17:20:56 -0500 Received: from mx1.redhat.com ([209.132.183.28]:7536 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1763012AbZLPWUw (ORCPT ); Wed, 16 Dec 2009 17:20:52 -0500 From: Masami Hiramatsu Subject: [PATCH -tip 3/3] perf probe: Check new event name 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 Date: Wed, 16 Dec 2009 17:24:15 -0500 Message-ID: <20091216222415.14459.71383.stgit@dhcp-100-2-132.bos.redhat.com> In-Reply-To: <20091216222354.14459.82110.stgit@dhcp-100-2-132.bos.redhat.com> References: <20091216222354.14459.82110.stgit@dhcp-100-2-132.bos.redhat.com> User-Agent: StGIT/0.14.3 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2401 Lines: 72 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 Cc: Ingo Molnar Cc: Frederic Weisbecker Cc: Paul Mackerras Cc: Arnaldo Carvalho de Melo Cc: Steven Rostedt Cc: Jim Keniston Cc: Ananth N Mavinakayanahalli Cc: Christoph Hellwig Cc: Frank Ch. Eigler Cc: Jason Baron Cc: K.Prasad Cc: Peter Zijlstra Cc: Srikar Dronamraju --- 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 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/