diff options
author | Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com> | 2010-10-21 06:13:23 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2010-10-21 13:59:06 -0400 |
commit | cf6eb489e5c04c8f8d5fd7bf90b8346c987688bc (patch) | |
tree | 3da471c3ae3f99cdcbec26cc95412a4b44506f3c /tools/perf/util/probe-event.c | |
parent | 632941c4f8fbd5b90dcb1672cd0422dfd7332bc9 (diff) |
perf probe: Show accessible local variables
Add -V (--vars) option for listing accessible local variables at given probe
point. This will help finding which local variables are available for event
arguments.
e.g.)
# perf probe -V call_timer_fn:23
Available variables at call_timer_fn:23
@<run_timer_softirq+345>
function_type* fn
int preempt_count
long unsigned int data
struct list_head work_list
struct list_head* head
struct timer_list* timer
struct tvec_base* base
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
LKML-Reference: <20101021101323.3542.40282.stgit@ltc236.sdl.hitachi.co.jp>
Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/probe-event.c')
-rw-r--r-- | tools/perf/util/probe-event.c | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c index fcc16e4349df..288ebe8279d2 100644 --- a/tools/perf/util/probe-event.c +++ b/tools/perf/util/probe-event.c | |||
@@ -378,6 +378,72 @@ end: | |||
378 | return ret; | 378 | return ret; |
379 | } | 379 | } |
380 | 380 | ||
381 | static int show_available_vars_at(int fd, struct perf_probe_event *pev, | ||
382 | int max_vls) | ||
383 | { | ||
384 | char *buf; | ||
385 | int ret, i; | ||
386 | struct str_node *node; | ||
387 | struct variable_list *vls = NULL, *vl; | ||
388 | |||
389 | buf = synthesize_perf_probe_point(&pev->point); | ||
390 | if (!buf) | ||
391 | return -EINVAL; | ||
392 | pr_debug("Searching variables at %s\n", buf); | ||
393 | |||
394 | ret = find_available_vars_at(fd, pev, &vls, max_vls); | ||
395 | if (ret > 0) { | ||
396 | /* Some variables were found */ | ||
397 | fprintf(stdout, "Available variables at %s\n", buf); | ||
398 | for (i = 0; i < ret; i++) { | ||
399 | vl = &vls[i]; | ||
400 | /* | ||
401 | * A probe point might be converted to | ||
402 | * several trace points. | ||
403 | */ | ||
404 | fprintf(stdout, "\t@<%s+%lu>\n", vl->point.symbol, | ||
405 | vl->point.offset); | ||
406 | free(vl->point.symbol); | ||
407 | if (vl->vars) { | ||
408 | strlist__for_each(node, vl->vars) | ||
409 | fprintf(stdout, "\t\t%s\n", node->s); | ||
410 | strlist__delete(vl->vars); | ||
411 | } else | ||
412 | fprintf(stdout, "(No variables)\n"); | ||
413 | } | ||
414 | free(vls); | ||
415 | } else | ||
416 | pr_err("Failed to find variables at %s (%d)\n", buf, ret); | ||
417 | |||
418 | free(buf); | ||
419 | return ret; | ||
420 | } | ||
421 | |||
422 | /* Show available variables on given probe point */ | ||
423 | int show_available_vars(struct perf_probe_event *pevs, int npevs, | ||
424 | int max_vls) | ||
425 | { | ||
426 | int i, fd, ret = 0; | ||
427 | |||
428 | ret = init_vmlinux(); | ||
429 | if (ret < 0) | ||
430 | return ret; | ||
431 | |||
432 | fd = open_vmlinux(); | ||
433 | if (fd < 0) { | ||
434 | pr_warning("Failed to open debuginfo file.\n"); | ||
435 | return fd; | ||
436 | } | ||
437 | |||
438 | setup_pager(); | ||
439 | |||
440 | for (i = 0; i < npevs && ret >= 0; i++) | ||
441 | ret = show_available_vars_at(fd, &pevs[i], max_vls); | ||
442 | |||
443 | close(fd); | ||
444 | return ret; | ||
445 | } | ||
446 | |||
381 | #else /* !DWARF_SUPPORT */ | 447 | #else /* !DWARF_SUPPORT */ |
382 | 448 | ||
383 | static int kprobe_convert_to_perf_probe(struct probe_trace_point *tp, | 449 | static int kprobe_convert_to_perf_probe(struct probe_trace_point *tp, |
@@ -409,6 +475,12 @@ int show_line_range(struct line_range *lr __unused) | |||
409 | return -ENOSYS; | 475 | return -ENOSYS; |
410 | } | 476 | } |
411 | 477 | ||
478 | int show_available_vars(struct perf_probe_event *pevs __unused, | ||
479 | int npevs __unused, int max_probe_points __unused) | ||
480 | { | ||
481 | pr_warning("Debuginfo-analysis is not supported.\n"); | ||
482 | return -ENOSYS; | ||
483 | } | ||
412 | #endif | 484 | #endif |
413 | 485 | ||
414 | int parse_line_range_desc(const char *arg, struct line_range *lr) | 486 | int parse_line_range_desc(const char *arg, struct line_range *lr) |