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/builtin-probe.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/builtin-probe.c')
-rw-r--r-- | tools/perf/builtin-probe.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/tools/perf/builtin-probe.c b/tools/perf/builtin-probe.c index 6cf708aba7c9..abb423e164c8 100644 --- a/tools/perf/builtin-probe.c +++ b/tools/perf/builtin-probe.c | |||
@@ -36,6 +36,7 @@ | |||
36 | #include "builtin.h" | 36 | #include "builtin.h" |
37 | #include "util/util.h" | 37 | #include "util/util.h" |
38 | #include "util/strlist.h" | 38 | #include "util/strlist.h" |
39 | #include "util/strfilter.h" | ||
39 | #include "util/symbol.h" | 40 | #include "util/symbol.h" |
40 | #include "util/debug.h" | 41 | #include "util/debug.h" |
41 | #include "util/debugfs.h" | 42 | #include "util/debugfs.h" |
@@ -43,6 +44,7 @@ | |||
43 | #include "util/probe-finder.h" | 44 | #include "util/probe-finder.h" |
44 | #include "util/probe-event.h" | 45 | #include "util/probe-event.h" |
45 | 46 | ||
47 | #define DEFAULT_VAR_FILTER "!__k???tab_* & !__crc_*" | ||
46 | #define MAX_PATH_LEN 256 | 48 | #define MAX_PATH_LEN 256 |
47 | 49 | ||
48 | /* Session management structure */ | 50 | /* Session management structure */ |
@@ -60,6 +62,7 @@ static struct { | |||
60 | struct line_range line_range; | 62 | struct line_range line_range; |
61 | const char *target_module; | 63 | const char *target_module; |
62 | int max_probe_points; | 64 | int max_probe_points; |
65 | struct strfilter *filter; | ||
63 | } params; | 66 | } params; |
64 | 67 | ||
65 | /* Parse an event definition. Note that any error must die. */ | 68 | /* Parse an event definition. Note that any error must die. */ |
@@ -156,6 +159,27 @@ static int opt_show_vars(const struct option *opt __used, | |||
156 | 159 | ||
157 | return ret; | 160 | return ret; |
158 | } | 161 | } |
162 | |||
163 | static int opt_set_filter(const struct option *opt __used, | ||
164 | const char *str, int unset __used) | ||
165 | { | ||
166 | const char *err; | ||
167 | |||
168 | if (str) { | ||
169 | pr_debug2("Set filter: %s\n", str); | ||
170 | if (params.filter) | ||
171 | strfilter__delete(params.filter); | ||
172 | params.filter = strfilter__new(str, &err); | ||
173 | if (!params.filter) { | ||
174 | pr_err("Filter parse error at %ld.\n", err - str + 1); | ||
175 | pr_err("Source: \"%s\"\n", str); | ||
176 | pr_err(" %*c\n", (int)(err - str + 1), '^'); | ||
177 | return -EINVAL; | ||
178 | } | ||
179 | } | ||
180 | |||
181 | return 0; | ||
182 | } | ||
159 | #endif | 183 | #endif |
160 | 184 | ||
161 | static const char * const probe_usage[] = { | 185 | static const char * const probe_usage[] = { |
@@ -212,6 +236,10 @@ static const struct option options[] = { | |||
212 | "Show accessible variables on PROBEDEF", opt_show_vars), | 236 | "Show accessible variables on PROBEDEF", opt_show_vars), |
213 | OPT_BOOLEAN('\0', "externs", ¶ms.show_ext_vars, | 237 | OPT_BOOLEAN('\0', "externs", ¶ms.show_ext_vars, |
214 | "Show external variables too (with --vars only)"), | 238 | "Show external variables too (with --vars only)"), |
239 | OPT_CALLBACK('\0', "filter", NULL, | ||
240 | "[!]FILTER", "Set a variable filter (with --vars only)\n" | ||
241 | "\t\t\t(default: \"" DEFAULT_VAR_FILTER "\")", | ||
242 | opt_set_filter), | ||
215 | OPT_STRING('k', "vmlinux", &symbol_conf.vmlinux_name, | 243 | OPT_STRING('k', "vmlinux", &symbol_conf.vmlinux_name, |
216 | "file", "vmlinux pathname"), | 244 | "file", "vmlinux pathname"), |
217 | OPT_STRING('s', "source", &symbol_conf.source_prefix, | 245 | OPT_STRING('s', "source", &symbol_conf.source_prefix, |
@@ -324,10 +352,16 @@ int cmd_probe(int argc, const char **argv, const char *prefix __used) | |||
324 | " --add/--del.\n"); | 352 | " --add/--del.\n"); |
325 | usage_with_options(probe_usage, options); | 353 | usage_with_options(probe_usage, options); |
326 | } | 354 | } |
355 | if (!params.filter) | ||
356 | params.filter = strfilter__new(DEFAULT_VAR_FILTER, | ||
357 | NULL); | ||
358 | |||
327 | ret = show_available_vars(params.events, params.nevents, | 359 | ret = show_available_vars(params.events, params.nevents, |
328 | params.max_probe_points, | 360 | params.max_probe_points, |
329 | params.target_module, | 361 | params.target_module, |
362 | params.filter, | ||
330 | params.show_ext_vars); | 363 | params.show_ext_vars); |
364 | strfilter__delete(params.filter); | ||
331 | if (ret < 0) | 365 | if (ret < 0) |
332 | pr_err(" Error: Failed to show vars. (%d)\n", ret); | 366 | pr_err(" Error: Failed to show vars. (%d)\n", ret); |
333 | return ret; | 367 | return ret; |