perf probe: Accept filter argument for --list

Currently, perf-probe --list option ignores given event filter.
  ----
  # ./perf probe -l vfs\*
    probe:vfs_read       (on vfs_read@ksrc/linux-3/fs/read_write.c)
    probe_libc:malloc    (on __libc_malloc@malloc/malloc.c in /usr/lib64/libc-2.17.so)
  ----

This changes --list option to accept the event filter argument as below.
  ----
  # ./perf probe -l vfs\*
    probe:vfs_read       (on vfs_read@ksrc/linux-3/fs/read_write.c)
  # ./perf probe -l \*libc:\*
    probe_libc:malloc    (on __libc_malloc@malloc/malloc.c in /usr/lib64/libc-2.17.so)
  ----

Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Tested-by: Arnaldo 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: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/20150424094750.23967.53868.stgit@localhost.localdomain
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
Masami Hiramatsu 2015-04-24 18:47:50 +09:00 committed by Arnaldo Carvalho de Melo
parent 96b55e3923
commit b6a896438b
4 changed files with 73 additions and 32 deletions

View file

@ -2146,7 +2146,23 @@ static int show_perf_probe_event(struct perf_probe_event *pev,
return ret;
}
static int __show_perf_probe_events(int fd, bool is_kprobe)
static bool filter_probe_trace_event(struct probe_trace_event *tev,
struct strfilter *filter)
{
char tmp[128];
/* At first, check the event name itself */
if (strfilter__compare(filter, tev->event))
return true;
/* Next, check the combination of name and group */
if (e_snprintf(tmp, 128, "%s:%s", tev->group, tev->event) < 0)
return false;
return strfilter__compare(filter, tmp);
}
static int __show_perf_probe_events(int fd, bool is_kprobe,
struct strfilter *filter)
{
int ret = 0;
struct probe_trace_event tev;
@ -2164,12 +2180,15 @@ static int __show_perf_probe_events(int fd, bool is_kprobe)
strlist__for_each(ent, rawlist) {
ret = parse_probe_trace_command(ent->s, &tev);
if (ret >= 0) {
if (!filter_probe_trace_event(&tev, filter))
goto next;
ret = convert_to_perf_probe_event(&tev, &pev,
is_kprobe);
if (ret >= 0)
ret = show_perf_probe_event(&pev,
tev.point.module);
}
next:
clear_perf_probe_event(&pev);
clear_probe_trace_event(&tev);
if (ret < 0)
@ -2181,7 +2200,7 @@ static int __show_perf_probe_events(int fd, bool is_kprobe)
}
/* List up current perf-probe events */
int show_perf_probe_events(void)
int show_perf_probe_events(struct strfilter *filter)
{
int kp_fd, up_fd, ret;
@ -2193,7 +2212,7 @@ int show_perf_probe_events(void)
kp_fd = open_kprobe_events(false);
if (kp_fd >= 0) {
ret = __show_perf_probe_events(kp_fd, true);
ret = __show_perf_probe_events(kp_fd, true, filter);
close(kp_fd);
if (ret < 0)
goto out;
@ -2207,7 +2226,7 @@ int show_perf_probe_events(void)
}
if (up_fd >= 0) {
ret = __show_perf_probe_events(up_fd, false);
ret = __show_perf_probe_events(up_fd, false, filter);
close(up_fd);
}
out: