aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/symbol.c
diff options
context:
space:
mode:
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 @@
6 6
7#include "debug.h" 7#include "debug.h"
8 8
9#include <asm/bug.h>
9#include <libelf.h> 10#include <libelf.h>
10#include <gelf.h> 11#include <gelf.h>
11#include <elf.h> 12#include <elf.h>
@@ -37,6 +38,11 @@ unsigned int symbol__priv_size;
37static int vmlinux_path__nr_entries; 38static int vmlinux_path__nr_entries;
38static char **vmlinux_path; 39static char **vmlinux_path;
39 40
41static struct symbol_conf symbol_conf__defaults = {
42 .use_modules = true,
43 .try_vmlinux_path = true,
44};
45
40static struct rb_root kernel_maps; 46static struct rb_root kernel_maps;
41 47
42static void dso__fixup_sym_end(struct dso *self) 48static void dso__fixup_sym_end(struct dso *self)
@@ -1166,7 +1172,9 @@ struct symbol *kernel_maps__find_symbol(u64 ip, struct map **mapp,
1166 if (map) { 1172 if (map) {
1167 ip = map->map_ip(map, ip); 1173 ip = map->map_ip(map, ip);
1168 return map__find_symbol(map, ip, filter); 1174 return map__find_symbol(map, ip, filter);
1169 } 1175 } else
1176 WARN_ONCE(RB_EMPTY_ROOT(&kernel_maps),
1177 "Empty kernel_maps, was symbol__init() called?\n");
1170 1178
1171 return NULL; 1179 return NULL;
1172} 1180}
@@ -1485,9 +1493,9 @@ size_t dsos__fprintf_buildid(FILE *fp)
1485 return ret; 1493 return ret;
1486} 1494}
1487 1495
1488static int kernel_maps__create_kernel_map(const char *vmlinux_name) 1496static int kernel_maps__create_kernel_map(const struct symbol_conf *conf)
1489{ 1497{
1490 struct dso *kernel = dso__new(vmlinux_name ?: "[kernel.kallsyms]"); 1498 struct dso *kernel = dso__new(conf->vmlinux_name ?: "[kernel.kallsyms]");
1491 1499
1492 if (kernel == NULL) 1500 if (kernel == NULL)
1493 return -1; 1501 return -1;
@@ -1577,18 +1585,21 @@ out_fail:
1577 return -1; 1585 return -1;
1578} 1586}
1579 1587
1580int kernel_maps__init(const char *vmlinux_name, bool try_vmlinux_path, 1588static int kernel_maps__init(const struct symbol_conf *conf)
1581 bool use_modules)
1582{ 1589{
1583 if (try_vmlinux_path && vmlinux_path__init() < 0) 1590 const struct symbol_conf *pconf = conf ?: &symbol_conf__defaults;
1591
1592 symbol__priv_size = pconf->priv_size;
1593
1594 if (pconf->try_vmlinux_path && vmlinux_path__init() < 0)
1584 return -1; 1595 return -1;
1585 1596
1586 if (kernel_maps__create_kernel_map(vmlinux_name) < 0) { 1597 if (kernel_maps__create_kernel_map(pconf) < 0) {
1587 vmlinux_path__exit(); 1598 vmlinux_path__exit();
1588 return -1; 1599 return -1;
1589 } 1600 }
1590 1601
1591 if (use_modules && kernel_maps__create_module_maps() < 0) 1602 if (pconf->use_modules && kernel_maps__create_module_maps() < 0)
1592 pr_debug("Failed to load list of modules in use, " 1603 pr_debug("Failed to load list of modules in use, "
1593 "continuing...\n"); 1604 "continuing...\n");
1594 /* 1605 /*
@@ -1598,8 +1609,8 @@ int kernel_maps__init(const char *vmlinux_name, bool try_vmlinux_path,
1598 return 0; 1609 return 0;
1599} 1610}
1600 1611
1601void symbol__init(unsigned int priv_size) 1612int symbol__init(struct symbol_conf *conf)
1602{ 1613{
1603 elf_version(EV_CURRENT); 1614 elf_version(EV_CURRENT);
1604 symbol__priv_size = priv_size; 1615 return kernel_maps__init(conf);
1605} 1616}