diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2009-12-15 17:04:39 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-12-16 02:53:48 -0500 |
commit | 75be6cf48738aec68aac49b428423569492cfba3 (patch) | |
tree | d7f5ceb028361e8b725ba6f3b8219e66c7b89790 /tools/perf/util | |
parent | 7ef17aafc98406d01ebbf7fe98ef1332b70d20bb (diff) |
perf symbols: Make symbol_conf global
This simplifies a lot of functions, less stuff to be done by
tool writers.
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Frédéric Weisbecker <fweisbec@gmail.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Paul Mackerras <paulus@samba.org>
LKML-Reference: <1260914682-29652-1-git-send-email-acme@infradead.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'tools/perf/util')
-rw-r--r-- | tools/perf/util/session.c | 5 | ||||
-rw-r--r-- | tools/perf/util/session.h | 5 | ||||
-rw-r--r-- | tools/perf/util/symbol.c | 38 | ||||
-rw-r--r-- | tools/perf/util/symbol.h | 9 |
4 files changed, 22 insertions, 35 deletions
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c index ecd54bedfb1c..bceaa09f55a1 100644 --- a/tools/perf/util/session.c +++ b/tools/perf/util/session.c | |||
@@ -49,8 +49,7 @@ out_close: | |||
49 | return -1; | 49 | return -1; |
50 | } | 50 | } |
51 | 51 | ||
52 | struct perf_session *perf_session__new(const char *filename, int mode, | 52 | struct perf_session *perf_session__new(const char *filename, int mode, bool force) |
53 | bool force, struct symbol_conf *conf) | ||
54 | { | 53 | { |
55 | size_t len = filename ? strlen(filename) + 1 : 0; | 54 | size_t len = filename ? strlen(filename) + 1 : 0; |
56 | struct perf_session *self = zalloc(sizeof(*self) + len); | 55 | struct perf_session *self = zalloc(sizeof(*self) + len); |
@@ -69,7 +68,7 @@ struct perf_session *perf_session__new(const char *filename, int mode, | |||
69 | self->cwdlen = 0; | 68 | self->cwdlen = 0; |
70 | map_groups__init(&self->kmaps); | 69 | map_groups__init(&self->kmaps); |
71 | 70 | ||
72 | if (perf_session__create_kernel_maps(self, conf) < 0) | 71 | if (perf_session__create_kernel_maps(self) < 0) |
73 | goto out_delete; | 72 | goto out_delete; |
74 | 73 | ||
75 | if (mode == O_RDONLY && perf_session__open(self, force) < 0) | 74 | if (mode == O_RDONLY && perf_session__open(self, force) < 0) |
diff --git a/tools/perf/util/session.h b/tools/perf/util/session.h index bdfc4b8eee7a..faf18a8e0311 100644 --- a/tools/perf/util/session.h +++ b/tools/perf/util/session.h | |||
@@ -10,7 +10,6 @@ | |||
10 | struct ip_callchain; | 10 | struct ip_callchain; |
11 | struct thread; | 11 | struct thread; |
12 | struct symbol; | 12 | struct symbol; |
13 | struct symbol_conf; | ||
14 | 13 | ||
15 | struct perf_session { | 14 | struct perf_session { |
16 | struct perf_header header; | 15 | struct perf_header header; |
@@ -26,7 +25,6 @@ struct perf_session { | |||
26 | int fd; | 25 | int fd; |
27 | int cwdlen; | 26 | int cwdlen; |
28 | char *cwd; | 27 | char *cwd; |
29 | bool use_modules; | ||
30 | bool use_callchain; | 28 | bool use_callchain; |
31 | char filename[0]; | 29 | char filename[0]; |
32 | }; | 30 | }; |
@@ -48,8 +46,7 @@ struct perf_event_ops { | |||
48 | bool full_paths; | 46 | bool full_paths; |
49 | }; | 47 | }; |
50 | 48 | ||
51 | struct perf_session *perf_session__new(const char *filename, int mode, | 49 | struct perf_session *perf_session__new(const char *filename, int mode, bool force); |
52 | bool force, struct symbol_conf *conf); | ||
53 | void perf_session__delete(struct perf_session *self); | 50 | void perf_session__delete(struct perf_session *self); |
54 | 51 | ||
55 | int perf_session__process_events(struct perf_session *self, | 52 | int perf_session__process_events(struct perf_session *self, |
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c index 185b9eec192b..17ce01269a91 100644 --- a/tools/perf/util/symbol.c +++ b/tools/perf/util/symbol.c | |||
@@ -33,11 +33,10 @@ static void dsos__add(struct list_head *head, struct dso *dso); | |||
33 | static struct map *map__new2(u64 start, struct dso *dso, enum map_type type); | 33 | static struct map *map__new2(u64 start, struct dso *dso, enum map_type type); |
34 | static int dso__load_kernel_sym(struct dso *self, struct map *map, | 34 | static int dso__load_kernel_sym(struct dso *self, struct map *map, |
35 | struct perf_session *session, symbol_filter_t filter); | 35 | struct perf_session *session, symbol_filter_t filter); |
36 | unsigned int symbol__priv_size; | ||
37 | static int vmlinux_path__nr_entries; | 36 | static int vmlinux_path__nr_entries; |
38 | static char **vmlinux_path; | 37 | static char **vmlinux_path; |
39 | 38 | ||
40 | static struct symbol_conf symbol_conf__defaults = { | 39 | struct symbol_conf symbol_conf = { |
41 | .use_modules = true, | 40 | .use_modules = true, |
42 | .try_vmlinux_path = true, | 41 | .try_vmlinux_path = true, |
43 | }; | 42 | }; |
@@ -130,13 +129,13 @@ static void map_groups__fixup_end(struct map_groups *self) | |||
130 | static struct symbol *symbol__new(u64 start, u64 len, const char *name) | 129 | static struct symbol *symbol__new(u64 start, u64 len, const char *name) |
131 | { | 130 | { |
132 | size_t namelen = strlen(name) + 1; | 131 | size_t namelen = strlen(name) + 1; |
133 | struct symbol *self = zalloc(symbol__priv_size + | 132 | struct symbol *self = zalloc(symbol_conf.priv_size + |
134 | sizeof(*self) + namelen); | 133 | sizeof(*self) + namelen); |
135 | if (self == NULL) | 134 | if (self == NULL) |
136 | return NULL; | 135 | return NULL; |
137 | 136 | ||
138 | if (symbol__priv_size) | 137 | if (symbol_conf.priv_size) |
139 | self = ((void *)self) + symbol__priv_size; | 138 | self = ((void *)self) + symbol_conf.priv_size; |
140 | 139 | ||
141 | self->start = start; | 140 | self->start = start; |
142 | self->end = len ? start + len - 1 : start; | 141 | self->end = len ? start + len - 1 : start; |
@@ -150,7 +149,7 @@ static struct symbol *symbol__new(u64 start, u64 len, const char *name) | |||
150 | 149 | ||
151 | static void symbol__delete(struct symbol *self) | 150 | static void symbol__delete(struct symbol *self) |
152 | { | 151 | { |
153 | free(((void *)self) - symbol__priv_size); | 152 | free(((void *)self) - symbol_conf.priv_size); |
154 | } | 153 | } |
155 | 154 | ||
156 | static size_t symbol__fprintf(struct symbol *self, FILE *fp) | 155 | static size_t symbol__fprintf(struct symbol *self, FILE *fp) |
@@ -471,7 +470,7 @@ static int dso__split_kallsyms(struct dso *self, struct map *map, | |||
471 | 470 | ||
472 | module = strchr(pos->name, '\t'); | 471 | module = strchr(pos->name, '\t'); |
473 | if (module) { | 472 | if (module) { |
474 | if (!session->use_modules) | 473 | if (!symbol_conf.use_modules) |
475 | goto discard_symbol; | 474 | goto discard_symbol; |
476 | 475 | ||
477 | *module++ = '\0'; | 476 | *module++ = '\0'; |
@@ -1740,34 +1739,27 @@ out_fail: | |||
1740 | return -1; | 1739 | return -1; |
1741 | } | 1740 | } |
1742 | 1741 | ||
1743 | int symbol__init(struct symbol_conf *conf) | 1742 | int symbol__init(void) |
1744 | { | 1743 | { |
1745 | const struct symbol_conf *pconf = conf ?: &symbol_conf__defaults; | ||
1746 | |||
1747 | elf_version(EV_CURRENT); | 1744 | elf_version(EV_CURRENT); |
1748 | symbol__priv_size = pconf->priv_size; | 1745 | if (symbol_conf.sort_by_name) |
1749 | if (pconf->sort_by_name) | 1746 | symbol_conf.priv_size += (sizeof(struct symbol_name_rb_node) - |
1750 | symbol__priv_size += (sizeof(struct symbol_name_rb_node) - | 1747 | sizeof(struct symbol)); |
1751 | sizeof(struct symbol)); | ||
1752 | 1748 | ||
1753 | if (pconf->try_vmlinux_path && vmlinux_path__init() < 0) | 1749 | if (symbol_conf.try_vmlinux_path && vmlinux_path__init() < 0) |
1754 | return -1; | 1750 | return -1; |
1755 | 1751 | ||
1756 | return 0; | 1752 | return 0; |
1757 | } | 1753 | } |
1758 | 1754 | ||
1759 | int perf_session__create_kernel_maps(struct perf_session *self, | 1755 | int perf_session__create_kernel_maps(struct perf_session *self) |
1760 | struct symbol_conf *conf) | ||
1761 | { | 1756 | { |
1762 | const struct symbol_conf *pconf = conf ?: &symbol_conf__defaults; | ||
1763 | |||
1764 | if (map_groups__create_kernel_maps(&self->kmaps, | 1757 | if (map_groups__create_kernel_maps(&self->kmaps, |
1765 | pconf->vmlinux_name) < 0) | 1758 | symbol_conf.vmlinux_name) < 0) |
1766 | return -1; | 1759 | return -1; |
1767 | 1760 | ||
1768 | self->use_modules = pconf->use_modules; | 1761 | if (symbol_conf.use_modules && |
1769 | 1762 | perf_session__create_module_maps(self) < 0) | |
1770 | if (pconf->use_modules && perf_session__create_module_maps(self) < 0) | ||
1771 | pr_debug("Failed to load list of modules for session %s, " | 1763 | pr_debug("Failed to load list of modules for session %s, " |
1772 | "continuing...\n", self->filename); | 1764 | "continuing...\n", self->filename); |
1773 | /* | 1765 | /* |
diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h index 941ef331790e..766294735f93 100644 --- a/tools/perf/util/symbol.h +++ b/tools/perf/util/symbol.h | |||
@@ -57,11 +57,11 @@ struct symbol_conf { | |||
57 | const char *vmlinux_name; | 57 | const char *vmlinux_name; |
58 | }; | 58 | }; |
59 | 59 | ||
60 | extern unsigned int symbol__priv_size; | 60 | extern struct symbol_conf symbol_conf; |
61 | 61 | ||
62 | static inline void *symbol__priv(struct symbol *self) | 62 | static inline void *symbol__priv(struct symbol *self) |
63 | { | 63 | { |
64 | return ((void *)self) - symbol__priv_size; | 64 | return ((void *)self) - symbol_conf.priv_size; |
65 | } | 65 | } |
66 | 66 | ||
67 | struct addr_location { | 67 | struct addr_location { |
@@ -119,9 +119,8 @@ int sysfs__read_build_id(const char *filename, void *bf, size_t size); | |||
119 | bool dsos__read_build_ids(void); | 119 | bool dsos__read_build_ids(void); |
120 | int build_id__sprintf(u8 *self, int len, char *bf); | 120 | int build_id__sprintf(u8 *self, int len, char *bf); |
121 | 121 | ||
122 | int symbol__init(struct symbol_conf *conf); | 122 | int symbol__init(void); |
123 | int perf_session__create_kernel_maps(struct perf_session *self, | 123 | int perf_session__create_kernel_maps(struct perf_session *self); |
124 | struct symbol_conf *conf); | ||
125 | 124 | ||
126 | extern struct list_head dsos__user, dsos__kernel; | 125 | extern struct list_head dsos__user, dsos__kernel; |
127 | extern struct dso *vdso; | 126 | extern struct dso *vdso; |