diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2009-12-11 15:50:22 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-12-12 01:42:11 -0500 |
commit | 79406cd789f745ac6aa9d597895f904a98a14007 (patch) | |
tree | 99281664ea6e0fd5bd0a6f762feed4f716b356cd /tools/perf/util/symbol.h | |
parent | 22ccec57f8732de22fd87bce43e8edcb71453c72 (diff) |
perf symbols: Allow lookups by symbol name too
Configurable via symbol_conf.sort_by_name, so that the cost of an
extra rb_node on all 'struct symbol' instances is not paid by tools
that only want to decode addresses.
How to use it:
symbol_conf.sort_by_name = true;
symbol_init(&symbol_conf);
struct map *map = map_groups__find_by_name(kmaps, MAP__VARIABLE, "[kernel.kallsyms]");
if (map == NULL) {
pr_err("couldn't find map!\n");
kernel_maps__fprintf(stdout);
} else {
struct symbol *sym = map__find_symbol_by_name(map, sym_filter, NULL);
if (sym == NULL)
pr_err("couldn't find symbol %s!\n", sym_filter);
else
pr_info("symbol %s: %#Lx-%#Lx \n", sym_filter, sym->start, sym->end);
}
Looking over the vmlinux/kallsyms is common enough that I'll add a
variable to the upcoming struct perf_session to avoid the need to
use map_groups__find_by_name to get the main vmlinux/kallsyms map.
The above example looks on the 'variable' symtab, but it is just
like that for the functions one.
Also the sort operation is done when we first use
map__find_symbol_by_name, in a lazy way.
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Frédéric Weisbecker <fweisbec@gmail.com>
Cc: Masami Hiramatsu <mhiramat@redhat.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Paul Mackerras <paulus@samba.org>
LKML-Reference: <1260564622-12392-1-git-send-email-acme@infradead.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'tools/perf/util/symbol.h')
-rw-r--r-- | tools/perf/util/symbol.h | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h index 6e1da1ea6311..51c401307bf1 100644 --- a/tools/perf/util/symbol.h +++ b/tools/perf/util/symbol.h | |||
@@ -52,7 +52,8 @@ struct symbol { | |||
52 | struct symbol_conf { | 52 | struct symbol_conf { |
53 | unsigned short priv_size; | 53 | unsigned short priv_size; |
54 | bool try_vmlinux_path, | 54 | bool try_vmlinux_path, |
55 | use_modules; | 55 | use_modules, |
56 | sort_by_name; | ||
56 | const char *vmlinux_name; | 57 | const char *vmlinux_name; |
57 | }; | 58 | }; |
58 | 59 | ||
@@ -74,6 +75,7 @@ struct addr_location { | |||
74 | struct dso { | 75 | struct dso { |
75 | struct list_head node; | 76 | struct list_head node; |
76 | struct rb_root symbols[MAP__NR_TYPES]; | 77 | struct rb_root symbols[MAP__NR_TYPES]; |
78 | struct rb_root symbol_names[MAP__NR_TYPES]; | ||
77 | struct symbol *(*find_symbol)(struct dso *self, | 79 | struct symbol *(*find_symbol)(struct dso *self, |
78 | enum map_type type, u64 addr); | 80 | enum map_type type, u64 addr); |
79 | u8 adjust_symbols:1; | 81 | u8 adjust_symbols:1; |
@@ -81,6 +83,7 @@ struct dso { | |||
81 | u8 has_build_id:1; | 83 | u8 has_build_id:1; |
82 | u8 kernel:1; | 84 | u8 kernel:1; |
83 | unsigned char origin; | 85 | unsigned char origin; |
86 | u8 sorted_by_name; | ||
84 | u8 loaded; | 87 | u8 loaded; |
85 | u8 build_id[BUILD_ID_SIZE]; | 88 | u8 build_id[BUILD_ID_SIZE]; |
86 | u16 long_name_len; | 89 | u16 long_name_len; |
@@ -93,6 +96,9 @@ struct dso *dso__new(const char *name); | |||
93 | void dso__delete(struct dso *self); | 96 | void dso__delete(struct dso *self); |
94 | 97 | ||
95 | bool dso__loaded(const struct dso *self, enum map_type type); | 98 | bool dso__loaded(const struct dso *self, enum map_type type); |
99 | bool dso__sorted_by_name(const struct dso *self, enum map_type type); | ||
100 | |||
101 | void dso__sort_by_name(struct dso *self, enum map_type type); | ||
96 | 102 | ||
97 | struct dso *dsos__findnew(const char *name); | 103 | struct dso *dsos__findnew(const char *name); |
98 | int dso__load(struct dso *self, struct map *map, symbol_filter_t filter); | 104 | int dso__load(struct dso *self, struct map *map, symbol_filter_t filter); |
@@ -103,6 +109,8 @@ size_t dso__fprintf_buildid(struct dso *self, FILE *fp); | |||
103 | size_t dso__fprintf(struct dso *self, enum map_type type, FILE *fp); | 109 | size_t dso__fprintf(struct dso *self, enum map_type type, FILE *fp); |
104 | char dso__symtab_origin(const struct dso *self); | 110 | char dso__symtab_origin(const struct dso *self); |
105 | void dso__set_build_id(struct dso *self, void *build_id); | 111 | void dso__set_build_id(struct dso *self, void *build_id); |
112 | struct symbol *dso__find_symbol_by_name(struct dso *self, enum map_type type, | ||
113 | const char *name); | ||
106 | 114 | ||
107 | int filename__read_build_id(const char *filename, void *bf, size_t size); | 115 | int filename__read_build_id(const char *filename, void *bf, size_t size); |
108 | int sysfs__read_build_id(const char *filename, void *bf, size_t size); | 116 | int sysfs__read_build_id(const char *filename, void *bf, size_t size); |