diff options
Diffstat (limited to 'tools/perf/util/symbol.c')
-rw-r--r-- | tools/perf/util/symbol.c | 65 |
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 | ||
1355 | int dsos__load_kernel(const char *vmlinux, symbol_filter_t filter, | 1355 | int 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 | ||
1417 | out_delete_dso: | 1408 | out_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 | ||
1478 | int load_kernel(symbol_filter_t filter) | 1469 | struct 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 | |||
1491 | int 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 | ||
1492 | void symbol__init(unsigned int priv_size) | 1501 | void symbol__init(unsigned int priv_size) |