perf probe: Show trace event definition

Add --definition/-D option for showing the trace-event definition in
stdout. This can be useful in debugging or combined with a shell script.

e.g.
  ----
  # perf probe --definition 'do_sys_open $params'
  p:probe/do_sys_open _text+2261728 dfd=%di:s32 filename=%si:u64 flags=%dx:s32 mode=%cx:u16
  ----

Suggested-and-Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/147214226712.23638.2240534040014013658.stgit@devbox
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
Masami Hiramatsu
2016-08-26 01:24:27 +09:00
committed by Arnaldo Carvalho de Melo
parent 893c5c798b
commit 1c20b1d154
4 changed files with 73 additions and 7 deletions

View File

@@ -3207,6 +3207,52 @@ int convert_perf_probe_events(struct perf_probe_event *pevs, int npevs)
return 0;
}
static int show_probe_trace_event(struct probe_trace_event *tev)
{
char *buf = synthesize_probe_trace_command(tev);
if (!buf) {
pr_debug("Failed to synthesize probe trace event.\n");
return -EINVAL;
}
/* Showing definition always go stdout */
printf("%s\n", buf);
free(buf);
return 0;
}
int show_probe_trace_events(struct perf_probe_event *pevs, int npevs)
{
struct strlist *namelist = strlist__new(NULL, NULL);
struct probe_trace_event *tev;
struct perf_probe_event *pev;
int i, j, ret = 0;
if (!namelist)
return -ENOMEM;
for (j = 0; j < npevs && !ret; j++) {
pev = &pevs[j];
for (i = 0; i < pev->ntevs && !ret; i++) {
tev = &pev->tevs[i];
/* Skip if the symbol is out of .text or blacklisted */
if (!tev->point.symbol && !pev->uprobes)
continue;
/* Set new name for tev (and update namelist) */
ret = probe_trace_event__set_name(tev, pev,
namelist, true);
if (!ret)
ret = show_probe_trace_event(tev);
}
}
strlist__delete(namelist);
return ret;
}
int apply_perf_probe_events(struct perf_probe_event *pevs, int npevs)
{
int i, ret = 0;