aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/symbol.c
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2009-11-18 17:20:53 -0500
committerIngo Molnar <mingo@elte.hu>2009-11-19 02:28:13 -0500
commit2446042c93bfc6eeebfc89e88fdef2435d2bb5c4 (patch)
tree3b442923926652127331449cf9a2da811a8fca4a /tools/perf/util/symbol.c
parentf1617b40596cb341ee6602a9d969c5e4cebe9260 (diff)
perf symbols: Capture the running kernel buildid too
[root@doppio linux-2.6-tip]# perf record -a -f sleep 3s ; perf buildid-list | grep vmlinux [ perf record: Woken up 1 times to write data ] [ perf record: Captured and wrote 0.171 MB perf.data (~7489 samples) ] 18e7cc53db62a7d35e9d6f6c9ddc23017d38ee9a vmlinux [root@doppio linux-2.6-tip]# Several refactorings were needed so that we can have symmetry between dsos__load_modules() and dsos__load_kernel(), i.e. those functions will respectively create and add to the dsos list the loaded modules and kernel, with its buildids, but not load its symbols. That is something the subcomands that need will have to call dso__load_kernel_sym(), just like we do with modules with dsos__load_module_sym()/dso__load_module_sym(). Next csets will actually use this info to stop producing bogus results using mismatched vmlinux and .ko files. Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Roland McGrath <roland@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: <1258582853-8579-4-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.c65
1 files changed, 37 insertions, 28 deletions
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index 7b4cedeb3020..4d75e745288f 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -1352,17 +1352,11 @@ static int dso__load_vmlinux(struct dso *self, struct map *map,
1352 return err; 1352 return err;
1353} 1353}
1354 1354
1355int dsos__load_kernel(const char *vmlinux, symbol_filter_t filter, 1355int dso__load_kernel_sym(struct dso *self, symbol_filter_t filter, int use_modules)
1356 int use_modules)
1357{ 1356{
1358 int err = -1; 1357 int err = -1;
1359 struct dso *dso = dso__new(vmlinux);
1360 1358
1361 if (dso == NULL) 1359 kernel_map = map__new2(0, self);
1362 return -1;
1363
1364 dso->short_name = "[kernel]";
1365 kernel_map = map__new2(0, dso);
1366 if (kernel_map == NULL) 1360 if (kernel_map == NULL)
1367 goto out_delete_dso; 1361 goto out_delete_dso;
1368 1362
@@ -1374,39 +1368,36 @@ int dsos__load_kernel(const char *vmlinux, symbol_filter_t filter,
1374 use_modules = 0; 1368 use_modules = 0;
1375 } 1369 }
1376 1370
1377 if (vmlinux) { 1371 err = dso__load_vmlinux(self, kernel_map, self->name, filter);
1378 err = dso__load_vmlinux(dso, kernel_map, vmlinux, filter); 1372 if (err > 0 && use_modules) {
1379 if (err > 0 && use_modules) { 1373 int syms = dsos__load_modules_sym(filter);
1380 int syms = dsos__load_modules_sym(filter);
1381 1374
1382 if (syms < 0) 1375 if (syms < 0)
1383 pr_warning("Failed to read module symbols!" 1376 pr_warning("Failed to read module symbols!"
1384 " Continuing...\n"); 1377 " Continuing...\n");
1385 else 1378 else
1386 err += syms; 1379 err += syms;
1387 }
1388 } 1380 }
1389 1381
1390 if (err <= 0) 1382 if (err <= 0)
1391 err = kernel_maps__load_kallsyms(filter, use_modules); 1383 err = kernel_maps__load_kallsyms(filter, use_modules);
1392 1384
1393 if (err > 0) { 1385 if (err > 0) {
1394 struct rb_node *node = rb_first(&dso->syms); 1386 struct rb_node *node = rb_first(&self->syms);
1395 struct symbol *sym = rb_entry(node, struct symbol, rb_node); 1387 struct symbol *sym = rb_entry(node, struct symbol, rb_node);
1396 1388
1397 kernel_map->start = sym->start; 1389 kernel_map->start = sym->start;
1398 node = rb_last(&dso->syms); 1390 node = rb_last(&self->syms);
1399 sym = rb_entry(node, struct symbol, rb_node); 1391 sym = rb_entry(node, struct symbol, rb_node);
1400 kernel_map->end = sym->end; 1392 kernel_map->end = sym->end;
1401 1393
1402 dso->origin = DSO__ORIG_KERNEL; 1394 self->origin = DSO__ORIG_KERNEL;
1403 kernel_maps__insert(kernel_map); 1395 kernel_maps__insert(kernel_map);
1404 /* 1396 /*
1405 * Now that we have all sorted out, just set the ->end of all 1397 * Now that we have all sorted out, just set the ->end of all
1406 * maps: 1398 * maps:
1407 */ 1399 */
1408 kernel_maps__fixup_end(); 1400 kernel_maps__fixup_end();
1409 dsos__add(dso);
1410 1401
1411 if (verbose) 1402 if (verbose)
1412 kernel_maps__fprintf(stderr); 1403 kernel_maps__fprintf(stderr);
@@ -1415,7 +1406,7 @@ int dsos__load_kernel(const char *vmlinux, symbol_filter_t filter,
1415 return err; 1406 return err;
1416 1407
1417out_delete_dso: 1408out_delete_dso:
1418 dso__delete(dso); 1409 dso__delete(self);
1419 return -1; 1410 return -1;
1420} 1411}
1421 1412
@@ -1475,18 +1466,36 @@ size_t dsos__fprintf_buildid(FILE *fp)
1475 return ret; 1466 return ret;
1476} 1467}
1477 1468
1478int load_kernel(symbol_filter_t filter) 1469struct dso *dsos__load_kernel(void)
1479{ 1470{
1480 if (dsos__load_kernel(vmlinux_name, filter, modules) <= 0) 1471 struct dso *kernel = dso__new(vmlinux_name);
1481 return -1;
1482 1472
1473 if (kernel == NULL)
1474 return NULL;
1475
1476 kernel->short_name = "[kernel]";
1483 vdso = dso__new("[vdso]"); 1477 vdso = dso__new("[vdso]");
1484 if (!vdso) 1478 if (!vdso)
1485 return -1; 1479 return NULL;
1480
1481 if (sysfs__read_build_id("/sys/kernel/notes", kernel->build_id,
1482 sizeof(kernel->build_id)) == 0)
1483 kernel->has_build_id = true;
1486 1484
1485 dsos__add(kernel);
1487 dsos__add(vdso); 1486 dsos__add(vdso);
1488 1487
1489 return 0; 1488 return kernel;
1489}
1490
1491int load_kernel(symbol_filter_t filter)
1492{
1493 struct dso *kernel = dsos__load_kernel();
1494
1495 if (kernel == NULL)
1496 return -1;
1497
1498 return dso__load_kernel_sym(kernel, filter, modules);
1490} 1499}
1491 1500
1492void symbol__init(unsigned int priv_size) 1501void symbol__init(unsigned int priv_size)