From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S966843AbcIWPf6 (ORCPT ); Fri, 23 Sep 2016 11:35:58 -0400 Received: from mail.kernel.org ([198.145.29.136]:45300 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S966243AbcIWPf1 (ORCPT ); Fri, 23 Sep 2016 11:35:27 -0400 From: Masami Hiramatsu To: Arnaldo Carvalho de Melo Cc: Masami Hiramatsu , linux-kernel@vger.kernel.org, Thomas Gleixner , Jiri Olsa , Peter Zijlstra , Ingo Molnar , Namhyung Kim , David Ahern Subject: [PATCH perf/core 3/4] perf-probe: Fix to cut off incompatible chars from group name Date: Sat, 24 Sep 2016 00:35:16 +0900 Message-Id: <147464491667.29804.9553638175441827970.stgit@devbox> X-Mailer: git-send-email 2.7.4 In-Reply-To: <147464488719.29804.13099016520754675018.stgit@devbox> References: <147464488719.29804.13099016520754675018.stgit@devbox> User-Agent: StGit/0.17.1-dirty 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 Cut off the characters which can not use for group name of uprobes when making it based on executable filename. For example, if the exec name is libstdc++.so, without this fix perf probe generates "probe_libstdc++" as the group name, but it is failed to set because '+' can not be used for group name. With this fix perf accepts only alphabet, number or '_' for group name, thus perf generates "probe_libstdc" as the group name. E.g. with this fix, you can see the event name has no "+". ---- $ ./perf probe -x /usr/lib64/libstdc++.so.6 -D is_open p:probe_libstdc/is_open /usr/lib64/libstdc++.so.6.0.22:0x8ca80 p:probe_libstdc/is_open_1 /usr/lib64/libstdc++.so.6.0.22:0x8ca70 p:probe_libstdc/is_open_2 /usr/lib64/libstdc++.so.6.0.22:0x8ca60 p:probe_libstdc/is_open_3 /usr/lib64/libstdc++.so.6.0.22:0xb0ad0 p:probe_libstdc/is_open_4 /usr/lib64/libstdc++.so.6.0.22:0xecca9 ---- Signed-off-by: Masami Hiramatsu --- tools/perf/util/probe-event.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c index bc60ce4..fcfbef0 100644 --- a/tools/perf/util/probe-event.c +++ b/tools/perf/util/probe-event.c @@ -213,9 +213,13 @@ static int convert_exec_to_group(const char *exec, char **result) goto out; } - ptr2 = strpbrk(ptr1, "-._"); - if (ptr2) - *ptr2 = '\0'; + for (ptr2 = ptr1; ptr2 != '\0'; ptr2++) { + if (!isalnum(*ptr2) && *ptr2 != '_') { + *ptr2 = '\0'; + break; + } + } + ret = e_snprintf(buf, 64, "%s_%s", PERFPROBE_GROUP, ptr1); if (ret < 0) goto out;