diff options
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: return -1; } -struct perf_session *perf_session__new(const char *filename, int mode, - bool force, struct symbol_conf *conf) +struct perf_session *perf_session__new(const char *filename, int mode, bool force) { size_t len = filename ? strlen(filename) + 1 : 0; struct perf_session *self = zalloc(sizeof(*self) + len); @@ -69,7 +68,7 @@ struct perf_session *perf_session__new(const char *filename, int mode, self->cwdlen = 0; map_groups__init(&self->kmaps); - if (perf_session__create_kernel_maps(self, conf) < 0) + if (perf_session__create_kernel_maps(self) < 0) goto out_delete; 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 @@ struct ip_callchain; struct thread; struct symbol; -struct symbol_conf; struct perf_session { struct perf_header header; @@ -26,7 +25,6 @@ struct perf_session { int fd; int cwdlen; char *cwd; - bool use_modules; bool use_callchain; char filename[0]; }; @@ -48,8 +46,7 @@ struct perf_event_ops { bool full_paths; }; -struct perf_session *perf_session__new(const char *filename, int mode, - bool force, struct symbol_conf *conf); +struct perf_session *perf_session__new(const char *filename, int mode, bool force); void perf_session__delete(struct perf_session *self); 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); static struct map *map__new2(u64 start, struct dso *dso, enum map_type type); static int dso__load_kernel_sym(struct dso *self, struct map *map, struct perf_session *session, symbol_filter_t filter); -unsigned int symbol__priv_size; static int vmlinux_path__nr_entries; static char **vmlinux_path; -static struct symbol_conf symbol_conf__defaults = { +struct symbol_conf symbol_conf = { .use_modules = true, .try_vmlinux_path = true, }; @@ -130,13 +129,13 @@ static void map_groups__fixup_end(struct map_groups *self) static struct symbol *symbol__new(u64 start, u64 len, const char *name) { size_t namelen = strlen(name) + 1; - struct symbol *self = zalloc(symbol__priv_size + + struct symbol *self = zalloc(symbol_conf.priv_size + sizeof(*self) + namelen); if (self == NULL) return NULL; - if (symbol__priv_size) - self = ((void *)self) + symbol__priv_size; + if (symbol_conf.priv_size) + self = ((void *)self) + symbol_conf.priv_size; self->start = start; self->end = len ? start + len - 1 : start; @@ -150,7 +149,7 @@ static struct symbol *symbol__new(u64 start, u64 len, const char *name) static void symbol__delete(struct symbol *self) { - free(((void *)self) - symbol__priv_size); + free(((void *)self) - symbol_conf.priv_size); } 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, module = strchr(pos->name, '\t'); if (module) { - if (!session->use_modules) + if (!symbol_conf.use_modules) goto discard_symbol; *module++ = '\0'; @@ -1740,34 +1739,27 @@ out_fail: return -1; } -int symbol__init(struct symbol_conf *conf) +int symbol__init(void) { - const struct symbol_conf *pconf = conf ?: &symbol_conf__defaults; - elf_version(EV_CURRENT); - symbol__priv_size = pconf->priv_size; - if (pconf->sort_by_name) - symbol__priv_size += (sizeof(struct symbol_name_rb_node) - - sizeof(struct symbol)); + if (symbol_conf.sort_by_name) + symbol_conf.priv_size += (sizeof(struct symbol_name_rb_node) - + sizeof(struct symbol)); - if (pconf->try_vmlinux_path && vmlinux_path__init() < 0) + if (symbol_conf.try_vmlinux_path && vmlinux_path__init() < 0) return -1; return 0; } -int perf_session__create_kernel_maps(struct perf_session *self, - struct symbol_conf *conf) +int perf_session__create_kernel_maps(struct perf_session *self) { - const struct symbol_conf *pconf = conf ?: &symbol_conf__defaults; - if (map_groups__create_kernel_maps(&self->kmaps, - pconf->vmlinux_name) < 0) + symbol_conf.vmlinux_name) < 0) return -1; - self->use_modules = pconf->use_modules; - - if (pconf->use_modules && perf_session__create_module_maps(self) < 0) + if (symbol_conf.use_modules && + perf_session__create_module_maps(self) < 0) pr_debug("Failed to load list of modules for session %s, " "continuing...\n", self->filename); /* 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 { const char *vmlinux_name; }; -extern unsigned int symbol__priv_size; +extern struct symbol_conf symbol_conf; static inline void *symbol__priv(struct symbol *self) { - return ((void *)self) - symbol__priv_size; + return ((void *)self) - symbol_conf.priv_size; } struct addr_location { @@ -119,9 +119,8 @@ int sysfs__read_build_id(const char *filename, void *bf, size_t size); bool dsos__read_build_ids(void); int build_id__sprintf(u8 *self, int len, char *bf); -int symbol__init(struct symbol_conf *conf); -int perf_session__create_kernel_maps(struct perf_session *self, - struct symbol_conf *conf); +int symbol__init(void); +int perf_session__create_kernel_maps(struct perf_session *self); extern struct list_head dsos__user, dsos__kernel; extern struct dso *vdso; |