aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/symbol.c
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2010-04-29 14:25:23 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2010-04-29 14:25:23 -0400
commit5c0541d53ef3897494768decb09eb8f1087953a5 (patch)
tree38b8eab8e45a2d2265db64b131320e6baa43b984 /tools/perf/util/symbol.c
parent18acde52b83bd1c8e1d007db519f46d344aa13ed (diff)
perf symbols: Add machine helper routines
Created when writing the first 'perf test' regression testing routine. Cc: Frédéric Weisbecker <fweisbec@gmail.com> Cc: Mike Galbraith <efault@gmx.de> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> LKML-Reference: <new-submission> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/symbol.c')
-rw-r--r--tools/perf/util/symbol.c77
1 files changed, 57 insertions, 20 deletions
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index caa890f8e2c0..4c0146a49063 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -1983,23 +1983,23 @@ void dso__read_running_kernel_build_id(struct dso *self, struct machine *machine
1983 self->has_build_id = true; 1983 self->has_build_id = true;
1984} 1984}
1985 1985
1986static struct dso *dsos__create_kernel(struct machine *machine) 1986static struct dso *machine__create_kernel(struct machine *self)
1987{ 1987{
1988 const char *vmlinux_name = NULL; 1988 const char *vmlinux_name = NULL;
1989 struct dso *kernel; 1989 struct dso *kernel;
1990 1990
1991 if (machine__is_host(machine)) { 1991 if (machine__is_host(self)) {
1992 vmlinux_name = symbol_conf.vmlinux_name; 1992 vmlinux_name = symbol_conf.vmlinux_name;
1993 kernel = dso__new_kernel(vmlinux_name); 1993 kernel = dso__new_kernel(vmlinux_name);
1994 } else { 1994 } else {
1995 if (machine__is_default_guest(machine)) 1995 if (machine__is_default_guest(self))
1996 vmlinux_name = symbol_conf.default_guest_vmlinux_name; 1996 vmlinux_name = symbol_conf.default_guest_vmlinux_name;
1997 kernel = dso__new_guest_kernel(machine, vmlinux_name); 1997 kernel = dso__new_guest_kernel(self, vmlinux_name);
1998 } 1998 }
1999 1999
2000 if (kernel != NULL) { 2000 if (kernel != NULL) {
2001 dso__read_running_kernel_build_id(kernel, machine); 2001 dso__read_running_kernel_build_id(kernel, self);
2002 dsos__add(&machine->kernel_dsos, kernel); 2002 dsos__add(&self->kernel_dsos, kernel);
2003 } 2003 }
2004 return kernel; 2004 return kernel;
2005} 2005}
@@ -2026,6 +2026,23 @@ int __machine__create_kernel_maps(struct machine *self, struct dso *kernel)
2026 return 0; 2026 return 0;
2027} 2027}
2028 2028
2029int machine__create_kernel_maps(struct machine *self)
2030{
2031 struct dso *kernel = machine__create_kernel(self);
2032
2033 if (kernel == NULL ||
2034 __machine__create_kernel_maps(self, kernel) < 0)
2035 return -1;
2036
2037 if (symbol_conf.use_modules && machine__create_modules(self) < 0)
2038 pr_debug("Problems creating module maps, continuing anyway...\n");
2039 /*
2040 * Now that we have all the maps created, just set the ->end of them:
2041 */
2042 map_groups__fixup_end(&self->kmaps);
2043 return 0;
2044}
2045
2029static void vmlinux_path__exit(void) 2046static void vmlinux_path__exit(void)
2030{ 2047{
2031 while (--vmlinux_path__nr_entries >= 0) { 2048 while (--vmlinux_path__nr_entries >= 0) {
@@ -2144,25 +2161,12 @@ out_free_comm_list:
2144 2161
2145int machines__create_kernel_maps(struct rb_root *self, pid_t pid) 2162int machines__create_kernel_maps(struct rb_root *self, pid_t pid)
2146{ 2163{
2147 struct dso *kernel;
2148 struct machine *machine = machines__findnew(self, pid); 2164 struct machine *machine = machines__findnew(self, pid);
2149 2165
2150 if (machine == NULL) 2166 if (machine == NULL)
2151 return -1; 2167 return -1;
2152 kernel = dsos__create_kernel(machine);
2153 if (kernel == NULL)
2154 return -1;
2155
2156 if (__machine__create_kernel_maps(machine, kernel) < 0)
2157 return -1;
2158 2168
2159 if (symbol_conf.use_modules && machine__create_modules(machine) < 0) 2169 return machine__create_kernel_maps(machine);
2160 pr_debug("Problems creating module maps, continuing anyway...\n");
2161 /*
2162 * Now that we have all the maps created, just set the ->end of them:
2163 */
2164 map_groups__fixup_end(&machine->kmaps);
2165 return 0;
2166} 2170}
2167 2171
2168static int hex(char ch) 2172static int hex(char ch)
@@ -2248,3 +2252,36 @@ failure:
2248 2252
2249 return ret; 2253 return ret;
2250} 2254}
2255
2256int machine__load_kallsyms(struct machine *self, const char *filename,
2257 enum map_type type, symbol_filter_t filter)
2258{
2259 struct map *map = self->vmlinux_maps[type];
2260 int ret = dso__load_kallsyms(map->dso, filename, map, filter);
2261
2262 if (ret > 0) {
2263 dso__set_loaded(map->dso, type);
2264 /*
2265 * Since /proc/kallsyms will have multiple sessions for the
2266 * kernel, with modules between them, fixup the end of all
2267 * sections.
2268 */
2269 __map_groups__fixup_end(&self->kmaps, type);
2270 }
2271
2272 return ret;
2273}
2274
2275int machine__load_vmlinux_path(struct machine *self, enum map_type type,
2276 symbol_filter_t filter)
2277{
2278 struct map *map = self->vmlinux_maps[type];
2279 int ret = dso__load_vmlinux_path(map->dso, map, filter);
2280
2281 if (ret > 0) {
2282 dso__set_loaded(map->dso, type);
2283 map__reloc_vmlinux(map);
2284 }
2285
2286 return ret;
2287}