Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 234359
b: refs/heads/master
c: e80711c
h: refs/heads/master
i:
  234357: 0039f51
  234355: b27d45f
  234351: c9ea4f1
v: v3
  • Loading branch information
Masami Hiramatsu authored and Arnaldo Carvalho de Melo committed Jan 24, 2011
1 parent d4a170b commit 56bf440
Show file tree
Hide file tree
Showing 5 changed files with 100 additions and 4 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 5069ed86be3c2f28bcdf7fae1374ec0c325aafba
refs/heads/master: e80711ca8512c8586da0c3e18e2f1caf73c88731
4 changes: 4 additions & 0 deletions trunk/tools/perf/Documentation/perf-probe.txt
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ OPTIONS
(Only for --vars) Show external defined variables in addition to local
variables.

-F::
--funcs::
Show available functions in given module or kernel.

-f::
--force::
Forcibly add events with existing name.
Expand Down
29 changes: 28 additions & 1 deletion trunk/tools/perf/builtin-probe.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ static struct {
bool show_lines;
bool show_vars;
bool show_ext_vars;
bool show_funcs;
bool mod_events;
int nevents;
struct perf_probe_event events[MAX_PROBES];
Expand Down Expand Up @@ -221,6 +222,8 @@ static const struct option options[] = {
OPT__DRY_RUN(&probe_event_dry_run),
OPT_INTEGER('\0', "max-probes", &params.max_probe_points,
"Set how many probe points can be found for a probe."),
OPT_BOOLEAN('F', "funcs", &params.show_funcs,
"Show potential probe-able functions."),
OPT_END()
};

Expand All @@ -246,7 +249,7 @@ int cmd_probe(int argc, const char **argv, const char *prefix __used)
params.max_probe_points = MAX_PROBES;

if ((!params.nevents && !params.dellist && !params.list_events &&
!params.show_lines))
!params.show_lines && !params.show_funcs))
usage_with_options(probe_usage, options);

/*
Expand All @@ -267,12 +270,36 @@ int cmd_probe(int argc, const char **argv, const char *prefix __used)
pr_err(" Error: Don't use --list with --vars.\n");
usage_with_options(probe_usage, options);
}
if (params.show_funcs) {
pr_err(" Error: Don't use --list with --funcs.\n");
usage_with_options(probe_usage, options);
}
ret = show_perf_probe_events();
if (ret < 0)
pr_err(" Error: Failed to show event list. (%d)\n",
ret);
return ret;
}
if (params.show_funcs) {
if (params.nevents != 0 || params.dellist) {
pr_err(" Error: Don't use --funcs with"
" --add/--del.\n");
usage_with_options(probe_usage, options);
}
if (params.show_lines) {
pr_err(" Error: Don't use --funcs with --line.\n");
usage_with_options(probe_usage, options);
}
if (params.show_vars) {
pr_err(" Error: Don't use --funcs with --vars.\n");
usage_with_options(probe_usage, options);
}
ret = show_available_funcs(params.target_module);
if (ret < 0)
pr_err(" Error: Failed to show functions."
" (%d)\n", ret);
return ret;
}

#ifdef DWARF_SUPPORT
if (params.show_lines) {
Expand Down
68 changes: 66 additions & 2 deletions trunk/tools/perf/util/probe-event.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include <string.h>
#include <stdarg.h>
#include <limits.h>
#include <elf.h>

#undef _GNU_SOURCE
#include "util.h"
Expand Down Expand Up @@ -111,7 +112,25 @@ static struct symbol *__find_kernel_function_by_name(const char *name,
NULL);
}

const char *kernel_get_module_path(const char *module)
static struct map *kernel_get_module_map(const char *module)
{
struct rb_node *nd;
struct map_groups *grp = &machine.kmaps;

if (!module)
module = "kernel";

for (nd = rb_first(&grp->maps[MAP__FUNCTION]); nd; nd = rb_next(nd)) {
struct map *pos = rb_entry(nd, struct map, rb_node);
if (strncmp(pos->dso->short_name + 1, module,
pos->dso->short_name_len - 2) == 0) {
return pos;
}
}
return NULL;
}

static struct dso *kernel_get_module_dso(const char *module)
{
struct dso *dso;
struct map *map;
Expand Down Expand Up @@ -141,7 +160,13 @@ const char *kernel_get_module_path(const char *module)
}
}
found:
return dso->long_name;
return dso;
}

const char *kernel_get_module_path(const char *module)
{
struct dso *dso = kernel_get_module_dso(module);
return (dso) ? dso->long_name : NULL;
}

#ifdef DWARF_SUPPORT
Expand Down Expand Up @@ -1913,3 +1938,42 @@ int del_perf_probe_events(struct strlist *dellist)
return ret;
}

/*
* If a symbol corresponds to a function with global binding return 0.
* For all others return 1.
*/
static int filter_non_global_functions(struct map *map __unused,
struct symbol *sym)
{
if (sym->binding != STB_GLOBAL)
return 1;

return 0;
}

int show_available_funcs(const char *module)
{
struct map *map;
int ret;

setup_pager();

ret = init_vmlinux();
if (ret < 0)
return ret;

map = kernel_get_module_map(module);
if (!map) {
pr_err("Failed to find %s map.\n", (module) ? : "kernel");
return -EINVAL;
}
if (map__load(map, filter_non_global_functions)) {
pr_err("Failed to load map.\n");
return -EINVAL;
}
if (!dso__sorted_by_name(map->dso, map->type))
dso__sort_by_name(map->dso, map->type);

dso__fprintf_symbols_by_name(map->dso, map->type, stdout);
return 0;
}
1 change: 1 addition & 0 deletions trunk/tools/perf/util/probe-event.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ extern int show_line_range(struct line_range *lr, const char *module);
extern int show_available_vars(struct perf_probe_event *pevs, int npevs,
int max_probe_points, const char *module,
bool externs);
extern int show_available_funcs(const char *module);


/* Maximum index number of event-name postfix */
Expand Down

0 comments on commit 56bf440

Please sign in to comment.