struct sym_ext *ext;
};
-static struct symbol_conf symbol_conf = {
- .priv_size = sizeof(struct sym_priv),
- .try_vmlinux_path = true,
-};
-
static const char *sym_hist_filter;
static int symbol_filter(struct map *map __used, struct symbol *sym)
static int __cmd_annotate(void)
{
- struct perf_session *session = perf_session__new(input_name, O_RDONLY,
- force, &symbol_conf);
int ret;
+ struct perf_session *session;
+ session = perf_session__new(input_name, O_RDONLY, force);
if (session == NULL)
return -ENOMEM;
int cmd_annotate(int argc, const char **argv, const char *prefix __used)
{
- if (symbol__init(&symbol_conf) < 0)
+ symbol_conf.priv_size = sizeof(struct sym_priv);
+ symbol_conf.try_vmlinux_path = true;
+
+ if (symbol__init() < 0)
return -1;
argc = parse_options(argc, argv, options, annotate_usage, 0);
static int __cmd_buildid_list(void)
{
int err = -1;
- struct perf_session *session = perf_session__new(input_name, O_RDONLY,
- force, NULL);
+ struct perf_session *session;
+
+ session = perf_session__new(input_name, O_RDONLY, force);
if (session == NULL)
return -1;
static int force;
static bool show_percent;
-struct symbol_conf symbol_conf;
-
static int perf_session__add_hist_entry(struct perf_session *self,
struct addr_location *al, u64 count)
{
int ret, i;
struct perf_session *session[2];
- session[0] = perf_session__new(input_old, O_RDONLY, force, &symbol_conf);
- session[1] = perf_session__new(input_new, O_RDONLY, force, &symbol_conf);
+ session[0] = perf_session__new(input_old, O_RDONLY, force);
+ session[1] = perf_session__new(input_new, O_RDONLY, force);
if (session[0] == NULL || session[1] == NULL)
return -ENOMEM;
int cmd_diff(int argc, const char **argv, const char *prefix __used)
{
- if (symbol__init(&symbol_conf) < 0)
+ if (symbol__init() < 0)
return -1;
setup_sorting(diff_usage, options);
static int __cmd_kmem(void)
{
int err;
- struct perf_session *session = perf_session__new(input_name, O_RDONLY,
- 0, NULL);
+ struct perf_session *session = perf_session__new(input_name, O_RDONLY, 0);
if (session == NULL)
return -ENOMEM;
int cmd_kmem(int argc, const char **argv, const char *prefix __used)
{
- symbol__init(0);
+ symbol__init();
argc = parse_options(argc, argv, kmem_options, kmem_usage, 0);
int nr_probe;
struct probe_point probes[MAX_PROBES];
struct strlist *dellist;
- struct symbol_conf conf;
struct perf_session *psession;
struct map *kmap;
} session;
OPT_BOOLEAN('v', "verbose", &verbose,
"be more verbose (show parsed arguments, etc)"),
#ifndef NO_LIBDWARF
- OPT_STRING('k', "vmlinux", &session.conf.vmlinux_name,
+ OPT_STRING('k', "vmlinux", &symbol_conf.vmlinux_name,
"file", "vmlinux pathname"),
#endif
OPT_BOOLEAN('l', "list", &session.list_events,
}
/* Initialize symbol maps for vmlinux */
- session.conf.sort_by_name = true;
- if (session.conf.vmlinux_name == NULL)
- session.conf.try_vmlinux_path = true;
- if (symbol__init(&session.conf) < 0)
+ symbol_conf.sort_by_name = true;
+ if (symbol_conf.vmlinux_name == NULL)
+ symbol_conf.try_vmlinux_path = true;
+ if (symbol__init() < 0)
die("Failed to init symbol map.");
- session.psession = perf_session__new(NULL, O_WRONLY, false,
- &session.conf);
+ session.psession = perf_session__new(NULL, O_WRONLY, false);
if (session.psession == NULL)
die("Failed to init perf_session.");
session.kmap = map_groups__find_by_name(&session.psession->kmaps,
exit(-1);
}
- session = perf_session__new(output_name, O_WRONLY, force, NULL);
+ session = perf_session__new(output_name, O_WRONLY, force);
if (session == NULL) {
pr_err("Not enough memory for reading perf file header\n");
return -1;
{
int counter;
- symbol__init(0);
+ symbol__init();
argc = parse_options(argc, argv, options, record_usage,
PARSE_OPT_STOP_AT_NON_OPTION);
static char callchain_default_opt[] = "fractal,0.5";
-static struct symbol_conf symbol_conf;
-
-
static size_t
callchain__fprintf_left_margin(FILE *fp, int left_margin)
{
int ret;
struct perf_session *session;
- session = perf_session__new(input_name, O_RDONLY, force, &symbol_conf);
+ session = perf_session__new(input_name, O_RDONLY, force);
if (session == NULL)
return -ENOMEM;
int cmd_report(int argc, const char **argv, const char *prefix __used)
{
- if (symbol__init(&symbol_conf) < 0)
+ if (symbol__init() < 0)
return -1;
argc = parse_options(argc, argv, options, report_usage, 0);
static int read_events(void)
{
int err;
- struct perf_session *session = perf_session__new(input_name, O_RDONLY,
- 0, NULL);
+ struct perf_session *session = perf_session__new(input_name, O_RDONLY, 0);
if (session == NULL)
return -ENOMEM;
if (!strcmp(argv[0], "trace"))
return cmd_trace(argc, argv, prefix);
- symbol__init(0);
+ symbol__init();
if (!strncmp(argv[0], "rec", 3)) {
return __cmd_record(argc, argv);
} else if (!strncmp(argv[0], "lat", 3)) {
static int __cmd_timechart(void)
{
- struct perf_session *session = perf_session__new(input_name, O_RDONLY,
- 0, NULL);
+ struct perf_session *session = perf_session__new(input_name, O_RDONLY, 0);
int ret;
if (session == NULL)
int cmd_timechart(int argc, const char **argv, const char *prefix __used)
{
- symbol__init(0);
+ symbol__init();
argc = parse_options(argc, argv, options, timechart_usage,
PARSE_OPT_STOP_AT_NON_OPTION);
static bool hide_kernel_symbols = false;
static bool hide_user_symbols = false;
static struct winsize winsize;
-static struct symbol_conf symbol_conf;
/*
* Source
* FIXME: perf_session__new should allow passing a O_MMAP, so that all this
* mmap reading, etc is encapsulated in it. Use O_WRONLY for now.
*/
- struct perf_session *session = perf_session__new(NULL, O_WRONLY, false,
- &symbol_conf);
+ struct perf_session *session = perf_session__new(NULL, O_WRONLY, false);
if (session == NULL)
return -ENOMEM;
(nr_counters + 1) * sizeof(unsigned long));
if (symbol_conf.vmlinux_name == NULL)
symbol_conf.try_vmlinux_path = true;
- if (symbol__init(&symbol_conf) < 0)
+ if (symbol__init() < 0)
return -1;
if (delay_secs < 1)
exit(-1);
}
- symbol__init(0);
+ symbol__init();
setup_scripting();
setup_pager();
- session = perf_session__new(input_name, O_RDONLY, 0, NULL);
+ session = perf_session__new(input_name, O_RDONLY, 0);
if (session == NULL)
return -ENOMEM;
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);
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)
struct ip_callchain;
struct thread;
struct symbol;
-struct symbol_conf;
struct perf_session {
struct perf_header header;
int fd;
int cwdlen;
char *cwd;
- bool use_modules;
bool use_callchain;
char filename[0];
};
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,
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,
};
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;
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)
module = strchr(pos->name, '\t');
if (module) {
- if (!session->use_modules)
+ if (!symbol_conf.use_modules)
goto discard_symbol;
*module++ = '\0';
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);
/*
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 {
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;