Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753939AbbFRIPP (ORCPT ); Thu, 18 Jun 2015 04:15:15 -0400 Received: from terminus.zytor.com ([198.137.202.10]:57119 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932098AbbFRIOM (ORCPT ); Thu, 18 Jun 2015 04:14:12 -0400 Date: Thu, 18 Jun 2015 01:13:34 -0700 From: tip-bot for Masami Hiramatsu Message-ID: Cc: acme@redhat.com, tglx@linutronix.de, hpa@zytor.com, jolsa@redhat.com, peterz@infradead.org, masami.hiramatsu.pt@hitachi.com, naota@elisp.net, linux-kernel@vger.kernel.org, dsahern@gmail.com, namhyung@kernel.org, mingo@kernel.org Reply-To: acme@redhat.com, tglx@linutronix.de, hpa@zytor.com, jolsa@redhat.com, masami.hiramatsu.pt@hitachi.com, peterz@infradead.org, naota@elisp.net, linux-kernel@vger.kernel.org, namhyung@kernel.org, dsahern@gmail.com, mingo@kernel.org In-Reply-To: <20150613013116.24402.2923.stgit@localhost.localdomain> References: <20150613013116.24402.2923.stgit@localhost.localdomain> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] perf probe: List probes in stdout Git-Commit-ID: ba7ecb02e7b89b09d8cdf4c1514a386af8916c4b X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 4559 Lines: 147 Commit-ID: ba7ecb02e7b89b09d8cdf4c1514a386af8916c4b Gitweb: http://git.kernel.org/tip/ba7ecb02e7b89b09d8cdf4c1514a386af8916c4b Author: Masami Hiramatsu AuthorDate: Sat, 13 Jun 2015 10:31:16 +0900 Committer: Arnaldo Carvalho de Melo CommitDate: Tue, 16 Jun 2015 10:34:39 -0300 perf probe: List probes in stdout Since commit 5e17b28f1e24 ("perf probe: Add --quiet option to suppress output result message") have replaced printf with pr_info, perf probe -l outputs its result in stderr. However, that is not what the commit expected. E.g.: # perf probe -l > /dev/null probe:vfs_read (on vfs_read@ksrc/linux-3/fs/read_write.c) With this fix: # perf probe -l > list # cat list probe:vfs_read (on vfs_read@ksrc/linux-3/fs/read_write.c) Of course, --quiet(-q) still works on --add/--del. # perf probe -q vfs_write # perf probe -l probe:vfs_read (on vfs_read@ksrc/linux-3/fs/read_write.c) probe:vfs_write (on vfs_write@ksrc/linux-3/fs/read_write.c) ----- Reported-by: Naohiro Aota Signed-off-by: Masami Hiramatsu Tested-by: Arnaldo Carvalho de Melo Cc: David Ahern Cc: Jiri Olsa Cc: Namhyung Kim Cc: Naohiro Aota Cc: Peter Zijlstra Link: http://lkml.kernel.org/r/20150613013116.24402.2923.stgit@localhost.localdomain Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/probe-event.c | 49 ++++++++++++++++++++++++++++++------------- 1 file changed, 35 insertions(+), 14 deletions(-) diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c index daa24a2..c4ab588 100644 --- a/tools/perf/util/probe-event.c +++ b/tools/perf/util/probe-event.c @@ -2126,9 +2126,9 @@ kprobe_blacklist__find_by_address(struct list_head *blacklist, return NULL; } -/* Show an event */ -static int show_perf_probe_event(struct perf_probe_event *pev, - const char *module) +static int perf_probe_event__sprintf(struct perf_probe_event *pev, + const char *module, + struct strbuf *result) { int i, ret; char buf[128]; @@ -2141,27 +2141,47 @@ static int show_perf_probe_event(struct perf_probe_event *pev, ret = e_snprintf(buf, 128, "%s:%s", pev->group, pev->event); if (ret < 0) - return ret; + goto out; - pr_info(" %-20s (on %s", buf, place); + strbuf_addf(result, " %-20s (on %s", buf, place); if (module) - pr_info(" in %s", module); + strbuf_addf(result, " in %s", module); if (pev->nargs > 0) { - pr_info(" with"); + strbuf_addstr(result, " with"); for (i = 0; i < pev->nargs; i++) { ret = synthesize_perf_probe_arg(&pev->args[i], buf, 128); if (ret < 0) - break; - pr_info(" %s", buf); + goto out; + strbuf_addf(result, " %s", buf); } } - pr_info(")\n"); + strbuf_addch(result, ')'); +out: free(place); return ret; } +/* Show an event */ +static int show_perf_probe_event(struct perf_probe_event *pev, + const char *module, bool use_stdout) +{ + struct strbuf buf = STRBUF_INIT; + int ret; + + ret = perf_probe_event__sprintf(pev, module, &buf); + if (ret >= 0) { + if (use_stdout) + printf("%s\n", buf.buf); + else + pr_info("%s\n", buf.buf); + } + strbuf_release(&buf); + + return ret; +} + static bool filter_probe_trace_event(struct probe_trace_event *tev, struct strfilter *filter) { @@ -2200,9 +2220,10 @@ static int __show_perf_probe_events(int fd, bool is_kprobe, goto next; ret = convert_to_perf_probe_event(&tev, &pev, is_kprobe); - if (ret >= 0) - ret = show_perf_probe_event(&pev, - tev.point.module); + if (ret < 0) + goto next; + ret = show_perf_probe_event(&pev, tev.point.module, + true); } next: clear_perf_probe_event(&pev); @@ -2468,7 +2489,7 @@ static int __add_probe_trace_events(struct perf_probe_event *pev, group = pev->group; pev->event = tev->event; pev->group = tev->group; - show_perf_probe_event(pev, tev->point.module); + show_perf_probe_event(pev, tev->point.module, false); /* Trick here - restore current event/group */ pev->event = (char *)event; pev->group = (char *)group; -- 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/