aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/perf/Documentation/perf-probe.txt9
-rw-r--r--tools/perf/builtin-probe.c19
-rw-r--r--tools/perf/util/probe-event.c23
-rw-r--r--tools/perf/util/probe-event.h2
4 files changed, 32 insertions, 21 deletions
diff --git a/tools/perf/Documentation/perf-probe.txt b/tools/perf/Documentation/perf-probe.txt
index 32fb18f1695d..81c3220e04f3 100644
--- a/tools/perf/Documentation/perf-probe.txt
+++ b/tools/perf/Documentation/perf-probe.txt
@@ -78,10 +78,11 @@ OPTIONS
78 Show available functions in given module or kernel. 78 Show available functions in given module or kernel.
79 79
80--filter=FILTER:: 80--filter=FILTER::
81 (Only for --vars) Set filter for variables. FILTER is a combination of 81 (Only for --vars and --funcs) Set filter. FILTER is a combination of glob
82 glob pattern, see FILTER PATTERN for details. 82 pattern, see FILTER PATTERN for detail.
83 Default FILTER is "!__k???tab_* & !__crc_*". 83 Default FILTER is "!__k???tab_* & !__crc_*" for --vars, and "!_*"
84 If several filters are specified, only the last filter is valid. 84 for --funcs.
85 If several filters are specified, only the last filter is used.
85 86
86-f:: 87-f::
87--force:: 88--force::
diff --git a/tools/perf/builtin-probe.c b/tools/perf/builtin-probe.c
index abb423e164c8..fcde0031085f 100644
--- a/tools/perf/builtin-probe.c
+++ b/tools/perf/builtin-probe.c
@@ -45,6 +45,7 @@
45#include "util/probe-event.h" 45#include "util/probe-event.h"
46 46
47#define DEFAULT_VAR_FILTER "!__k???tab_* & !__crc_*" 47#define DEFAULT_VAR_FILTER "!__k???tab_* & !__crc_*"
48#define DEFAULT_FUNC_FILTER "!_*"
48#define MAX_PATH_LEN 256 49#define MAX_PATH_LEN 256
49 50
50/* Session management structure */ 51/* Session management structure */
@@ -159,6 +160,7 @@ static int opt_show_vars(const struct option *opt __used,
159 160
160 return ret; 161 return ret;
161} 162}
163#endif
162 164
163static int opt_set_filter(const struct option *opt __used, 165static int opt_set_filter(const struct option *opt __used,
164 const char *str, int unset __used) 166 const char *str, int unset __used)
@@ -180,7 +182,6 @@ static int opt_set_filter(const struct option *opt __used,
180 182
181 return 0; 183 return 0;
182} 184}
183#endif
184 185
185static const char * const probe_usage[] = { 186static const char * const probe_usage[] = {
186 "perf probe [<options>] 'PROBEDEF' ['PROBEDEF' ...]", 187 "perf probe [<options>] 'PROBEDEF' ['PROBEDEF' ...]",
@@ -236,10 +237,6 @@ static const struct option options[] = {
236 "Show accessible variables on PROBEDEF", opt_show_vars), 237 "Show accessible variables on PROBEDEF", opt_show_vars),
237 OPT_BOOLEAN('\0', "externs", &params.show_ext_vars, 238 OPT_BOOLEAN('\0', "externs", &params.show_ext_vars,
238 "Show external variables too (with --vars only)"), 239 "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),
243 OPT_STRING('k', "vmlinux", &symbol_conf.vmlinux_name, 240 OPT_STRING('k', "vmlinux", &symbol_conf.vmlinux_name,
244 "file", "vmlinux pathname"), 241 "file", "vmlinux pathname"),
245 OPT_STRING('s', "source", &symbol_conf.source_prefix, 242 OPT_STRING('s', "source", &symbol_conf.source_prefix,
@@ -252,6 +249,11 @@ static const struct option options[] = {
252 "Set how many probe points can be found for a probe."), 249 "Set how many probe points can be found for a probe."),
253 OPT_BOOLEAN('F', "funcs", &params.show_funcs, 250 OPT_BOOLEAN('F', "funcs", &params.show_funcs,
254 "Show potential probe-able functions."), 251 "Show potential probe-able functions."),
252 OPT_CALLBACK('\0', "filter", NULL,
253 "[!]FILTER", "Set a filter (with --vars/funcs only)\n"
254 "\t\t\t(default: \"" DEFAULT_VAR_FILTER "\" for --vars,\n"
255 "\t\t\t \"" DEFAULT_FUNC_FILTER "\" for --funcs)",
256 opt_set_filter),
255 OPT_END() 257 OPT_END()
256}; 258};
257 259
@@ -322,7 +324,12 @@ int cmd_probe(int argc, const char **argv, const char *prefix __used)
322 pr_err(" Error: Don't use --funcs with --vars.\n"); 324 pr_err(" Error: Don't use --funcs with --vars.\n");
323 usage_with_options(probe_usage, options); 325 usage_with_options(probe_usage, options);
324 } 326 }
325 ret = show_available_funcs(params.target_module); 327 if (!params.filter)
328 params.filter = strfilter__new(DEFAULT_FUNC_FILTER,
329 NULL);
330 ret = show_available_funcs(params.target_module,
331 params.filter);
332 strfilter__delete(params.filter);
326 if (ret < 0) 333 if (ret < 0)
327 pr_err(" Error: Failed to show functions." 334 pr_err(" Error: Failed to show functions."
328 " (%d)\n", ret); 335 " (%d)\n", ret);
diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index 077e0518f0f7..9d237e3cff5d 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -1951,21 +1951,23 @@ int del_perf_probe_events(struct strlist *dellist)
1951 1951
1952 return ret; 1952 return ret;
1953} 1953}
1954/* TODO: don't use a global variable for filter ... */
1955static struct strfilter *available_func_filter;
1954 1956
1955/* 1957/*
1956 * If a symbol corresponds to a function with global binding return 0. 1958 * If a symbol corresponds to a function with global binding and
1957 * For all others return 1. 1959 * matches filter return 0. For all others return 1.
1958 */ 1960 */
1959static int filter_non_global_functions(struct map *map __unused, 1961static int filter_available_functions(struct map *map __unused,
1960 struct symbol *sym) 1962 struct symbol *sym)
1961{ 1963{
1962 if (sym->binding != STB_GLOBAL) 1964 if (sym->binding == STB_GLOBAL &&
1963 return 1; 1965 strfilter__compare(available_func_filter, sym->name))
1964 1966 return 0;
1965 return 0; 1967 return 1;
1966} 1968}
1967 1969
1968int show_available_funcs(const char *module) 1970int show_available_funcs(const char *module, struct strfilter *_filter)
1969{ 1971{
1970 struct map *map; 1972 struct map *map;
1971 int ret; 1973 int ret;
@@ -1981,7 +1983,8 @@ int show_available_funcs(const char *module)
1981 pr_err("Failed to find %s map.\n", (module) ? : "kernel"); 1983 pr_err("Failed to find %s map.\n", (module) ? : "kernel");
1982 return -EINVAL; 1984 return -EINVAL;
1983 } 1985 }
1984 if (map__load(map, filter_non_global_functions)) { 1986 available_func_filter = _filter;
1987 if (map__load(map, filter_available_functions)) {
1985 pr_err("Failed to load map.\n"); 1988 pr_err("Failed to load map.\n");
1986 return -EINVAL; 1989 return -EINVAL;
1987 } 1990 }
diff --git a/tools/perf/util/probe-event.h b/tools/perf/util/probe-event.h
index 4e80b2bbc516..3434fc9d79d5 100644
--- a/tools/perf/util/probe-event.h
+++ b/tools/perf/util/probe-event.h
@@ -128,7 +128,7 @@ extern int show_line_range(struct line_range *lr, const char *module);
128extern int show_available_vars(struct perf_probe_event *pevs, int npevs, 128extern int show_available_vars(struct perf_probe_event *pevs, int npevs,
129 int max_probe_points, const char *module, 129 int max_probe_points, const char *module,
130 struct strfilter *filter, bool externs); 130 struct strfilter *filter, bool externs);
131extern int show_available_funcs(const char *module); 131extern int show_available_funcs(const char *module, struct strfilter *filter);
132 132
133 133
134/* Maximum index number of event-name postfix */ 134/* Maximum index number of event-name postfix */