aboutsummaryrefslogtreecommitdiff
path: root/tools/perf/util/symbol.c
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo2009-11-24 12:05:15 -0200
committerIngo Molnar2009-11-24 16:37:02 +0100
commitb32d133aec5dc882cf783a293f393bfb3f4379e1 (patch)
tree41fc56a4aaec8892a235ffd530b36278d147dc4e /tools/perf/util/symbol.c
parent7cc017edb9459193d3b581155a14029e4bef0c49 (diff)
perf symbols: Simplify symbol machinery setup
And also express its configuration toggles via a struct. Now all one has to do is to call symbol__init(NULL) if the defaults are OK, or pass a struct symbol_conf pointer with the desired configuration. If a tool uses kernel_maps__find_symbol() to look at the kernel and modules mappings for a symbol but didn't call symbol__init() first, that will generate a one time warning too, alerting the subcommand developer that symbol__init() must be called. 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: <1259071517-3242-2-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.c31
1 files changed, 21 insertions, 10 deletions
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index 44d81d5ae8cf..c4ca974b36e3 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -6,6 +6,7 @@
#include "debug.h"
+#include <asm/bug.h>
#include <libelf.h>
#include <gelf.h>
#include <elf.h>
@@ -37,6 +38,11 @@ unsigned int symbol__priv_size;
static int vmlinux_path__nr_entries;
static char **vmlinux_path;
+static struct symbol_conf symbol_conf__defaults = {
+ .use_modules = true,
+ .try_vmlinux_path = true,
+};
+
static struct rb_root kernel_maps;
static void dso__fixup_sym_end(struct dso *self)
@@ -1166,7 +1172,9 @@ struct symbol *kernel_maps__find_symbol(u64 ip, struct map **mapp,
if (map) {
ip = map->map_ip(map, ip);
return map__find_symbol(map, ip, filter);
- }
+ } else
+ WARN_ONCE(RB_EMPTY_ROOT(&kernel_maps),
+ "Empty kernel_maps, was symbol__init() called?\n");
return NULL;
}
@@ -1485,9 +1493,9 @@ size_t dsos__fprintf_buildid(FILE *fp)
return ret;
}
-static int kernel_maps__create_kernel_map(const char *vmlinux_name)
+static int kernel_maps__create_kernel_map(const struct symbol_conf *conf)
{
- struct dso *kernel = dso__new(vmlinux_name ?: "[kernel.kallsyms]");
+ struct dso *kernel = dso__new(conf->vmlinux_name ?: "[kernel.kallsyms]");
if (kernel == NULL)
return -1;
@@ -1577,18 +1585,21 @@ out_fail:
return -1;
}
-int kernel_maps__init(const char *vmlinux_name, bool try_vmlinux_path,
- bool use_modules)
+static int kernel_maps__init(const struct symbol_conf *conf)
{
- if (try_vmlinux_path && vmlinux_path__init() < 0)
+ const struct symbol_conf *pconf = conf ?: &symbol_conf__defaults;
+
+ symbol__priv_size = pconf->priv_size;
+
+ if (pconf->try_vmlinux_path && vmlinux_path__init() < 0)
return -1;
- if (kernel_maps__create_kernel_map(vmlinux_name) < 0) {
+ if (kernel_maps__create_kernel_map(pconf) < 0) {
vmlinux_path__exit();
return -1;
}
- if (use_modules && kernel_maps__create_module_maps() < 0)
+ if (pconf->use_modules && kernel_maps__create_module_maps() < 0)
pr_debug("Failed to load list of modules in use, "
"continuing...\n");
/*
@@ -1598,8 +1609,8 @@ int kernel_maps__init(const char *vmlinux_name, bool try_vmlinux_path,
return 0;
}
-void symbol__init(unsigned int priv_size)
+int symbol__init(struct symbol_conf *conf)
{
elf_version(EV_CURRENT);
- symbol__priv_size = priv_size;
+ return kernel_maps__init(conf);
}