Show available functions in given module or kernel.
--filter=FILTER::
- (Only for --vars) Set filter for variables. FILTER is a combination of
- glob pattern, see FILTER PATTERN for details.
- Default FILTER is "!__k???tab_* & !__crc_*".
- If several filters are specified, only the last filter is valid.
+ (Only for --vars and --funcs) Set filter. FILTER is a combination of glob
+ pattern, see FILTER PATTERN for detail.
+ Default FILTER is "!__k???tab_* & !__crc_*" for --vars, and "!_*"
+ for --funcs.
+ If several filters are specified, only the last filter is used.
-f::
--force::
#include "util/probe-event.h"
#define DEFAULT_VAR_FILTER "!__k???tab_* & !__crc_*"
+#define DEFAULT_FUNC_FILTER "!_*"
#define MAX_PATH_LEN 256
/* Session management structure */
return ret;
}
+#endif
static int opt_set_filter(const struct option *opt __used,
const char *str, int unset __used)
return 0;
}
-#endif
static const char * const probe_usage[] = {
"perf probe [<options>] 'PROBEDEF' ['PROBEDEF' ...]",
"Show accessible variables on PROBEDEF", opt_show_vars),
OPT_BOOLEAN('\0', "externs", ¶ms.show_ext_vars,
"Show external variables too (with --vars only)"),
- OPT_CALLBACK('\0', "filter", NULL,
- "[!]FILTER", "Set a variable filter (with --vars only)\n"
- "\t\t\t(default: \"" DEFAULT_VAR_FILTER "\")",
- opt_set_filter),
OPT_STRING('k', "vmlinux", &symbol_conf.vmlinux_name,
"file", "vmlinux pathname"),
OPT_STRING('s', "source", &symbol_conf.source_prefix,
"Set how many probe points can be found for a probe."),
OPT_BOOLEAN('F', "funcs", ¶ms.show_funcs,
"Show potential probe-able functions."),
+ OPT_CALLBACK('\0', "filter", NULL,
+ "[!]FILTER", "Set a filter (with --vars/funcs only)\n"
+ "\t\t\t(default: \"" DEFAULT_VAR_FILTER "\" for --vars,\n"
+ "\t\t\t \"" DEFAULT_FUNC_FILTER "\" for --funcs)",
+ opt_set_filter),
OPT_END()
};
pr_err(" Error: Don't use --funcs with --vars.\n");
usage_with_options(probe_usage, options);
}
- ret = show_available_funcs(params.target_module);
+ if (!params.filter)
+ params.filter = strfilter__new(DEFAULT_FUNC_FILTER,
+ NULL);
+ ret = show_available_funcs(params.target_module,
+ params.filter);
+ strfilter__delete(params.filter);
if (ret < 0)
pr_err(" Error: Failed to show functions."
" (%d)\n", ret);
return ret;
}
+/* TODO: don't use a global variable for filter ... */
+static struct strfilter *available_func_filter;
/*
- * If a symbol corresponds to a function with global binding return 0.
- * For all others return 1.
+ * If a symbol corresponds to a function with global binding and
+ * matches filter return 0. For all others return 1.
*/
-static int filter_non_global_functions(struct map *map __unused,
- struct symbol *sym)
+static int filter_available_functions(struct map *map __unused,
+ struct symbol *sym)
{
- if (sym->binding != STB_GLOBAL)
- return 1;
-
- return 0;
+ if (sym->binding == STB_GLOBAL &&
+ strfilter__compare(available_func_filter, sym->name))
+ return 0;
+ return 1;
}
-int show_available_funcs(const char *module)
+int show_available_funcs(const char *module, struct strfilter *_filter)
{
struct map *map;
int ret;
pr_err("Failed to find %s map.\n", (module) ? : "kernel");
return -EINVAL;
}
- if (map__load(map, filter_non_global_functions)) {
+ available_func_filter = _filter;
+ if (map__load(map, filter_available_functions)) {
pr_err("Failed to load map.\n");
return -EINVAL;
}