linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Ingo Molnar <mingo@kernel.org>
Cc: linux-kernel@vger.kernel.org, Linux Weekly News <lwn@lwn.net>,
	Masami Hiramatsu <mhiramat@kernel.org>,
	David Ahern <dsahern@gmail.com>,
	Namhyung Kim <namhyung@kernel.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Arnaldo Carvalho de Melo <acme@redhat.com>
Subject: [PATCH 25/27] perf probe: Fix to cut off incompatible chars from group name
Date: Thu, 29 Sep 2016 11:35:54 -0300	[thread overview]
Message-ID: <1475159756-21326-26-git-send-email-acme@kernel.org> (raw)
In-Reply-To: <1475159756-21326-1-git-send-email-acme@kernel.org>

From: Masami Hiramatsu <mhiramat@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
  ----

Committer note:

Before this fix:

  # perf probe -x /usr/lib64/libstdc++.so.6 is_open
  Failed to write event: Invalid argument
    Error: Failed to add events.
  #

After the fix:

  # perf probe -x /usr/lib64/libstdc++.so.6 is_open
  Added new events:
    probe_libstdc:is_open (on is_open in /usr/lib64/libstdc++.so.6.0.22)
    probe_libstdc:is_open_1 (on is_open in /usr/lib64/libstdc++.so.6.0.22)
    probe_libstdc:is_open_2 (on is_open in /usr/lib64/libstdc++.so.6.0.22)
    probe_libstdc:is_open_3 (on is_open in /usr/lib64/libstdc++.so.6.0.22)
    probe_libstdc:is_open_4 (on is_open in /usr/lib64/libstdc++.so.6.0.22)

  You can now use it in all perf tools, such as:

	  perf record -e probe_libstdc:is_open_4 -aR sleep 1

  # perf probe -l probe_libstdc:*
    probe_libstdc:is_open (on is_open@libstdc++-v3/include/fstream in /usr/lib64/libstdc++.so.6.0.22)
    probe_libstdc:is_open_1 (on is_open@libstdc++-v3/include/fstream in /usr/lib64/libstdc++.so.6.0.22)
    probe_libstdc:is_open_2 (on is_open@libstdc++-v3/include/fstream in /usr/lib64/libstdc++.so.6.0.22)
    probe_libstdc:is_open_3 (on is_open@src/c++98/basic_file.cc in /usr/lib64/libstdc++.so.6.0.22)
    probe_libstdc:is_open_4 (on stdio_filebuf:5@include/ext/stdio_filebuf.h in /usr/lib64/libstdc++.so.6.0.22)
  #

Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Tested-by: Jiri Olsa <jolsa@kernel.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/147464491667.29804.9553638175441827970.stgit@devbox
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 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 bc60ce49720b..fcfbef07b92d 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;
-- 
2.7.4

  parent reply	other threads:[~2016-09-29 14:38 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-29 14:35 [GIT PULL 00/27] perf/core improvements and fixes Arnaldo Carvalho de Melo
2016-09-29 14:35 ` [PATCH 01/27] perf record: Fix documentation 'event_sources' -> 'event_source' Arnaldo Carvalho de Melo
2016-09-29 14:35 ` [PATCH 02/27] perf tools: Fix MMAP event synthesis broken by MAP_HUGETLB change Arnaldo Carvalho de Melo
2016-09-29 14:35 ` [PATCH 03/27] perf data: Fix building in 32 bit platform with libbabeltrace Arnaldo Carvalho de Melo
2016-09-29 14:35 ` [PATCH 04/27] perf trace: Beautify sched_[gs]et_attr return value Arnaldo Carvalho de Melo
2016-09-29 14:35 ` [PATCH 05/27] perf tools: Update documentation info about quipper Arnaldo Carvalho de Melo
2016-09-29 14:35 ` [PATCH 06/27] perf tools: Make perf_evsel__append_filter() generic Arnaldo Carvalho de Melo
2016-09-29 14:35 ` [PATCH 07/27] perf evsel: New tracepoint specific function Arnaldo Carvalho de Melo
2016-09-29 14:35 ` [PATCH 08/27] perf evsel: Add support for address filters Arnaldo Carvalho de Melo
2016-09-29 14:35 ` [PATCH 09/27] perf script: Fix vanished idle symbols Arnaldo Carvalho de Melo
2016-09-29 14:35 ` [PATCH 10/27] perf record: Rename label 'out_symbol_exit' Arnaldo Carvalho de Melo
2016-09-29 14:35 ` [PATCH 11/27] perf record: Fix error paths Arnaldo Carvalho de Melo
2016-09-29 14:35 ` [PATCH 12/27] perf symbols: Add dso__last_symbol() Arnaldo Carvalho de Melo
2016-09-29 14:35 ` [PATCH 13/27] perf record: Add support for using symbols in address filters Arnaldo Carvalho de Melo
2016-09-29 14:35 ` [PATCH 14/27] perf probe: Increase debug level of SDT debug messages Arnaldo Carvalho de Melo
2016-09-29 14:35 ` [PATCH 15/27] perf intel-pt: Fix snapshot overlap detection decoder errors Arnaldo Carvalho de Melo
2016-09-29 14:35 ` [PATCH 16/27] perf intel-pt: Add support for recording the max non-turbo ratio Arnaldo Carvalho de Melo
2016-09-29 14:35 ` [PATCH 17/27] perf intel-pt: Fix missing error codes processing auxtrace_info Arnaldo Carvalho de Melo
2016-09-29 14:35 ` [PATCH 18/27] perf intel-pt: Add a helper function for processing AUXTRACE_INFO Arnaldo Carvalho de Melo
2016-09-29 14:35 ` [PATCH 19/27] perf intel-pt: Record address filter in AUXTRACE_INFO event Arnaldo Carvalho de Melo
2016-09-29 14:35 ` [PATCH 20/27] perf intel-pt: Read address filter from " Arnaldo Carvalho de Melo
2016-09-29 14:35 ` [PATCH 21/27] perf intel-pt: Enable decoder to handle TIP.PGD with missing IP Arnaldo Carvalho de Melo
2016-09-29 14:35 ` [PATCH 22/27] perf intel-pt: Fix decoding when there are address filters Arnaldo Carvalho de Melo
2016-09-29 14:35 ` [PATCH 23/27] perf probe: Ignore the error of finding inline instance Arnaldo Carvalho de Melo
2016-09-29 14:35 ` [PATCH 24/27] perf probe: Skip if the function address is 0 Arnaldo Carvalho de Melo
2016-09-29 14:35 ` Arnaldo Carvalho de Melo [this message]
2016-09-29 14:35 ` [PATCH 26/27] perf probe: Match linkage name with mangled name Arnaldo Carvalho de Melo
2016-09-29 14:35 ` [PATCH 27/27] perf tests: Add dwarf unwind test for powerpc Arnaldo Carvalho de Melo
2016-09-29 17:11 ` [GIT PULL 00/27] perf/core improvements and fixes Ingo Molnar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1475159756-21326-26-git-send-email-acme@kernel.org \
    --to=acme@kernel.org \
    --cc=acme@redhat.com \
    --cc=dsahern@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lwn@lwn.net \
    --cc=mhiramat@kernel.org \
    --cc=mingo@kernel.org \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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 NNTP newsgroup(s).