aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/symbol.c
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2009-12-15 17:04:39 -0500
committerIngo Molnar <mingo@elte.hu>2009-12-16 02:53:48 -0500
commit75be6cf48738aec68aac49b428423569492cfba3 (patch)
treed7f5ceb028361e8b725ba6f3b8219e66c7b89790 /tools/perf/util/symbol.c
parent7ef17aafc98406d01ebbf7fe98ef1332b70d20bb (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/symbol.c')
-rw-r--r--tools/perf/util/symbol.c38
1 files changed, 15 insertions, 23 deletions
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);
33static struct map *map__new2(u64 start, struct dso *dso, enum map_type type); 33static struct map *map__new2(u64 start, struct dso *dso, enum map_type type);
34static int dso__load_kernel_sym(struct dso *self, struct map *map, 34static 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);
36unsigned int symbol__priv_size;
37static int vmlinux_path__nr_entries; 36static int vmlinux_path__nr_entries;
38static char **vmlinux_path; 37static char **vmlinux_path;
39 38
40static struct symbol_conf symbol_conf__defaults = { 39struct 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)
130static struct symbol *symbol__new(u64 start, u64 len, const char *name) 129static 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
151static void symbol__delete(struct symbol *self) 150static 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
156static size_t symbol__fprintf(struct symbol *self, FILE *fp) 155static 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
1743int symbol__init(struct symbol_conf *conf) 1742int 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
1759int perf_session__create_kernel_maps(struct perf_session *self, 1755int 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 /*