diff options
Diffstat (limited to 'tools/perf/util/symbol.c')
-rw-r--r-- | tools/perf/util/symbol.c | 38 |
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); | |||
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 | /* |