diff options
author | Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com> | 2011-01-20 09:15:39 -0500 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2011-01-28 06:20:01 -0500 |
commit | bd09d7b5efeb13965b6725b4a3e9944908bca9d2 (patch) | |
tree | d2cd48d6c60288a0cf7d4d7bfe8fdcfed31221d7 /tools/perf/util/probe-event.c | |
parent | 68baa431ec2f14ba7510d4e79bceb6ceaf0d3b74 (diff) |
perf probe: Add variable filter support
Add filters support for available variable list.
Default filter is "!__k???tab_*&!__crc_*" for filtering out
automatically generated symbols.
The format of filter rule is "[!]GLOBPATTERN", so you can use wild
cards. If the filter rule starts with '!', matched variables are filter
out.
e.g.:
# perf probe -V schedule --externs --filter=cpu*
Available variables at schedule
@<schedule+0>
cpumask_var_t cpu_callout_mask
cpumask_var_t cpu_core_map
cpumask_var_t cpu_isolated_map
cpumask_var_t cpu_sibling_map
int cpu_number
long unsigned int* cpu_bit_bitmap
...
Cc: 2nddept-manager@sdl.hitachi.co.jp
Cc: Chase Douglas <chase.douglas@canonical.com>
Cc: Franck Bui-Huu <fbuihuu@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
LKML-Reference: <20110120141539.25915.43401.stgit@ltc236.sdl.hitachi.co.jp>
Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
[ committer note: Removed the elf.h include as it was fixed up in e80711c]
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 | 66 |
1 files changed, 40 insertions, 26 deletions
diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c index 859d377a3df3..077e0518f0f7 100644 --- a/tools/perf/util/probe-event.c +++ b/tools/perf/util/probe-event.c | |||
@@ -451,12 +451,14 @@ end: | |||
451 | } | 451 | } |
452 | 452 | ||
453 | static int show_available_vars_at(int fd, struct perf_probe_event *pev, | 453 | static int show_available_vars_at(int fd, struct perf_probe_event *pev, |
454 | int max_vls, bool externs) | 454 | int max_vls, struct strfilter *_filter, |
455 | bool externs) | ||
455 | { | 456 | { |
456 | char *buf; | 457 | char *buf; |
457 | int ret, i; | 458 | int ret, i, nvars; |
458 | struct str_node *node; | 459 | struct str_node *node; |
459 | struct variable_list *vls = NULL, *vl; | 460 | struct variable_list *vls = NULL, *vl; |
461 | const char *var; | ||
460 | 462 | ||
461 | buf = synthesize_perf_probe_point(&pev->point); | 463 | buf = synthesize_perf_probe_point(&pev->point); |
462 | if (!buf) | 464 | if (!buf) |
@@ -464,36 +466,45 @@ static int show_available_vars_at(int fd, struct perf_probe_event *pev, | |||
464 | pr_debug("Searching variables at %s\n", buf); | 466 | pr_debug("Searching variables at %s\n", buf); |
465 | 467 | ||
466 | ret = find_available_vars_at(fd, pev, &vls, max_vls, externs); | 468 | ret = find_available_vars_at(fd, pev, &vls, max_vls, externs); |
467 | if (ret > 0) { | 469 | if (ret <= 0) { |
468 | /* Some variables were found */ | 470 | pr_err("Failed to find variables at %s (%d)\n", buf, ret); |
469 | fprintf(stdout, "Available variables at %s\n", buf); | 471 | goto end; |
470 | for (i = 0; i < ret; i++) { | 472 | } |
471 | vl = &vls[i]; | 473 | /* Some variables are found */ |
472 | /* | 474 | fprintf(stdout, "Available variables at %s\n", buf); |
473 | * A probe point might be converted to | 475 | for (i = 0; i < ret; i++) { |
474 | * several trace points. | 476 | vl = &vls[i]; |
475 | */ | 477 | /* |
476 | fprintf(stdout, "\t@<%s+%lu>\n", vl->point.symbol, | 478 | * A probe point might be converted to |
477 | vl->point.offset); | 479 | * several trace points. |
478 | free(vl->point.symbol); | 480 | */ |
479 | if (vl->vars) { | 481 | fprintf(stdout, "\t@<%s+%lu>\n", vl->point.symbol, |
480 | strlist__for_each(node, vl->vars) | 482 | vl->point.offset); |
483 | free(vl->point.symbol); | ||
484 | nvars = 0; | ||
485 | if (vl->vars) { | ||
486 | strlist__for_each(node, vl->vars) { | ||
487 | var = strchr(node->s, '\t') + 1; | ||
488 | if (strfilter__compare(_filter, var)) { | ||
481 | fprintf(stdout, "\t\t%s\n", node->s); | 489 | fprintf(stdout, "\t\t%s\n", node->s); |
482 | strlist__delete(vl->vars); | 490 | nvars++; |
483 | } else | 491 | } |
484 | fprintf(stdout, "(No variables)\n"); | 492 | } |
493 | strlist__delete(vl->vars); | ||
485 | } | 494 | } |
486 | free(vls); | 495 | if (nvars == 0) |
487 | } else | 496 | fprintf(stdout, "\t\t(No matched variables)\n"); |
488 | pr_err("Failed to find variables at %s (%d)\n", buf, ret); | 497 | } |
489 | 498 | free(vls); | |
499 | end: | ||
490 | free(buf); | 500 | free(buf); |
491 | return ret; | 501 | return ret; |
492 | } | 502 | } |
493 | 503 | ||
494 | /* Show available variables on given probe point */ | 504 | /* Show available variables on given probe point */ |
495 | int show_available_vars(struct perf_probe_event *pevs, int npevs, | 505 | int show_available_vars(struct perf_probe_event *pevs, int npevs, |
496 | int max_vls, const char *module, bool externs) | 506 | int max_vls, const char *module, |
507 | struct strfilter *_filter, bool externs) | ||
497 | { | 508 | { |
498 | int i, fd, ret = 0; | 509 | int i, fd, ret = 0; |
499 | 510 | ||
@@ -510,7 +521,8 @@ int show_available_vars(struct perf_probe_event *pevs, int npevs, | |||
510 | setup_pager(); | 521 | setup_pager(); |
511 | 522 | ||
512 | for (i = 0; i < npevs && ret >= 0; i++) | 523 | for (i = 0; i < npevs && ret >= 0; i++) |
513 | ret = show_available_vars_at(fd, &pevs[i], max_vls, externs); | 524 | ret = show_available_vars_at(fd, &pevs[i], max_vls, _filter, |
525 | externs); | ||
514 | 526 | ||
515 | close(fd); | 527 | close(fd); |
516 | return ret; | 528 | return ret; |
@@ -556,7 +568,9 @@ int show_line_range(struct line_range *lr __unused, const char *module __unused) | |||
556 | 568 | ||
557 | int show_available_vars(struct perf_probe_event *pevs __unused, | 569 | int show_available_vars(struct perf_probe_event *pevs __unused, |
558 | int npevs __unused, int max_vls __unused, | 570 | int npevs __unused, int max_vls __unused, |
559 | const char *module __unused, bool externs __unused) | 571 | const char *module __unused, |
572 | struct strfilter *filter __unused, | ||
573 | bool externs __unused) | ||
560 | { | 574 | { |
561 | pr_warning("Debuginfo-analysis is not supported.\n"); | 575 | pr_warning("Debuginfo-analysis is not supported.\n"); |
562 | return -ENOSYS; | 576 | return -ENOSYS; |