Commit ba7ecb02 authored by Masami Hiramatsu's avatar Masami Hiramatsu Committed by Arnaldo Carvalho de Melo

perf probe: List probes in stdout

Since commit 5e17b28f ("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: default avatarNaohiro Aota <naota@elisp.net>
Signed-off-by: default avatarMasami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Naohiro Aota <naota@elisp.net>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/20150613013116.24402.2923.stgit@localhost.localdomainSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent a35489a6
...@@ -2126,9 +2126,9 @@ kprobe_blacklist__find_by_address(struct list_head *blacklist, ...@@ -2126,9 +2126,9 @@ kprobe_blacklist__find_by_address(struct list_head *blacklist,
return NULL; return NULL;
} }
/* Show an event */ static int perf_probe_event__sprintf(struct perf_probe_event *pev,
static int show_perf_probe_event(struct perf_probe_event *pev, const char *module,
const char *module) struct strbuf *result)
{ {
int i, ret; int i, ret;
char buf[128]; char buf[128];
...@@ -2141,27 +2141,47 @@ static int show_perf_probe_event(struct perf_probe_event *pev, ...@@ -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); ret = e_snprintf(buf, 128, "%s:%s", pev->group, pev->event);
if (ret < 0) if (ret < 0)
return ret; goto out;
pr_info(" %-20s (on %s", buf, place); strbuf_addf(result, " %-20s (on %s", buf, place);
if (module) if (module)
pr_info(" in %s", module); strbuf_addf(result, " in %s", module);
if (pev->nargs > 0) { if (pev->nargs > 0) {
pr_info(" with"); strbuf_addstr(result, " with");
for (i = 0; i < pev->nargs; i++) { for (i = 0; i < pev->nargs; i++) {
ret = synthesize_perf_probe_arg(&pev->args[i], ret = synthesize_perf_probe_arg(&pev->args[i],
buf, 128); buf, 128);
if (ret < 0) if (ret < 0)
break; goto out;
pr_info(" %s", buf); strbuf_addf(result, " %s", buf);
} }
} }
pr_info(")\n"); strbuf_addch(result, ')');
out:
free(place); free(place);
return ret; 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, static bool filter_probe_trace_event(struct probe_trace_event *tev,
struct strfilter *filter) struct strfilter *filter)
{ {
...@@ -2200,9 +2220,10 @@ static int __show_perf_probe_events(int fd, bool is_kprobe, ...@@ -2200,9 +2220,10 @@ static int __show_perf_probe_events(int fd, bool is_kprobe,
goto next; goto next;
ret = convert_to_perf_probe_event(&tev, &pev, ret = convert_to_perf_probe_event(&tev, &pev,
is_kprobe); is_kprobe);
if (ret >= 0) if (ret < 0)
ret = show_perf_probe_event(&pev, goto next;
tev.point.module); ret = show_perf_probe_event(&pev, tev.point.module,
true);
} }
next: next:
clear_perf_probe_event(&pev); clear_perf_probe_event(&pev);
...@@ -2468,7 +2489,7 @@ static int __add_probe_trace_events(struct perf_probe_event *pev, ...@@ -2468,7 +2489,7 @@ static int __add_probe_trace_events(struct perf_probe_event *pev,
group = pev->group; group = pev->group;
pev->event = tev->event; pev->event = tev->event;
pev->group = tev->group; 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 */ /* Trick here - restore current event/group */
pev->event = (char *)event; pev->event = (char *)event;
pev->group = (char *)group; pev->group = (char *)group;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment