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.c529
1 files changed, 339 insertions, 190 deletions
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index ab92763edb03..323c0aea0a91 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -1,6 +1,5 @@
1#include "util.h" 1#include "util.h"
2#include "../perf.h" 2#include "../perf.h"
3#include "session.h"
4#include "sort.h" 3#include "sort.h"
5#include "string.h" 4#include "string.h"
6#include "symbol.h" 5#include "symbol.h"
@@ -22,6 +21,7 @@
22enum dso_origin { 21enum dso_origin {
23 DSO__ORIG_KERNEL = 0, 22 DSO__ORIG_KERNEL = 0,
24 DSO__ORIG_JAVA_JIT, 23 DSO__ORIG_JAVA_JIT,
24 DSO__ORIG_BUILD_ID_CACHE,
25 DSO__ORIG_FEDORA, 25 DSO__ORIG_FEDORA,
26 DSO__ORIG_UBUNTU, 26 DSO__ORIG_UBUNTU,
27 DSO__ORIG_BUILDID, 27 DSO__ORIG_BUILDID,
@@ -33,7 +33,7 @@ enum dso_origin {
33static void dsos__add(struct list_head *head, struct dso *dso); 33static void dsos__add(struct list_head *head, struct dso *dso);
34static struct map *map__new2(u64 start, struct dso *dso, enum map_type type); 34static struct map *map__new2(u64 start, struct dso *dso, enum map_type type);
35static int dso__load_kernel_sym(struct dso *self, struct map *map, 35static int dso__load_kernel_sym(struct dso *self, struct map *map,
36 struct perf_session *session, symbol_filter_t filter); 36 symbol_filter_t filter);
37static int vmlinux_path__nr_entries; 37static int vmlinux_path__nr_entries;
38static char **vmlinux_path; 38static char **vmlinux_path;
39 39
@@ -53,17 +53,12 @@ bool dso__sorted_by_name(const struct dso *self, enum map_type type)
53 return self->sorted_by_name & (1 << type); 53 return self->sorted_by_name & (1 << type);
54} 54}
55 55
56static void dso__set_loaded(struct dso *self, enum map_type type)
57{
58 self->loaded |= (1 << type);
59}
60
61static void dso__set_sorted_by_name(struct dso *self, enum map_type type) 56static void dso__set_sorted_by_name(struct dso *self, enum map_type type)
62{ 57{
63 self->sorted_by_name |= (1 << type); 58 self->sorted_by_name |= (1 << type);
64} 59}
65 60
66static bool symbol_type__is_a(char symbol_type, enum map_type map_type) 61bool symbol_type__is_a(char symbol_type, enum map_type map_type)
67{ 62{
68 switch (map_type) { 63 switch (map_type) {
69 case MAP__FUNCTION: 64 case MAP__FUNCTION:
@@ -142,14 +137,14 @@ static struct symbol *symbol__new(u64 start, u64 len, const char *name)
142 self->start = start; 137 self->start = start;
143 self->end = len ? start + len - 1 : start; 138 self->end = len ? start + len - 1 : start;
144 139
145 pr_debug3("%s: %s %#Lx-%#Lx\n", __func__, name, start, self->end); 140 pr_debug4("%s: %s %#Lx-%#Lx\n", __func__, name, start, self->end);
146 141
147 memcpy(self->name, name, namelen); 142 memcpy(self->name, name, namelen);
148 143
149 return self; 144 return self;
150} 145}
151 146
152static void symbol__delete(struct symbol *self) 147void symbol__delete(struct symbol *self)
153{ 148{
154 free(((void *)self) - symbol_conf.priv_size); 149 free(((void *)self) - symbol_conf.priv_size);
155} 150}
@@ -160,7 +155,7 @@ static size_t symbol__fprintf(struct symbol *self, FILE *fp)
160 self->start, self->end, self->name); 155 self->start, self->end, self->name);
161} 156}
162 157
163static void dso__set_long_name(struct dso *self, char *name) 158void dso__set_long_name(struct dso *self, char *name)
164{ 159{
165 if (name == NULL) 160 if (name == NULL)
166 return; 161 return;
@@ -175,7 +170,7 @@ static void dso__set_basename(struct dso *self)
175 170
176struct dso *dso__new(const char *name) 171struct dso *dso__new(const char *name)
177{ 172{
178 struct dso *self = malloc(sizeof(*self) + strlen(name) + 1); 173 struct dso *self = zalloc(sizeof(*self) + strlen(name) + 1);
179 174
180 if (self != NULL) { 175 if (self != NULL) {
181 int i; 176 int i;
@@ -344,10 +339,10 @@ void dso__sort_by_name(struct dso *self, enum map_type type)
344 &self->symbols[type]); 339 &self->symbols[type]);
345} 340}
346 341
347int build_id__sprintf(u8 *self, int len, char *bf) 342int build_id__sprintf(const u8 *self, int len, char *bf)
348{ 343{
349 char *bid = bf; 344 char *bid = bf;
350 u8 *raw = self; 345 const u8 *raw = self;
351 int i; 346 int i;
352 347
353 for (i = 0; i < len; ++i) { 348 for (i = 0; i < len; ++i) {
@@ -372,6 +367,10 @@ size_t dso__fprintf(struct dso *self, enum map_type type, FILE *fp)
372 struct rb_node *nd; 367 struct rb_node *nd;
373 size_t ret = fprintf(fp, "dso: %s (", self->short_name); 368 size_t ret = fprintf(fp, "dso: %s (", self->short_name);
374 369
370 if (self->short_name != self->long_name)
371 ret += fprintf(fp, "%s, ", self->long_name);
372 ret += fprintf(fp, "%s, %sloaded, ", map_type__name[type],
373 self->loaded ? "" : "NOT ");
375 ret += dso__fprintf_buildid(self, fp); 374 ret += dso__fprintf_buildid(self, fp);
376 ret += fprintf(fp, ")\n"); 375 ret += fprintf(fp, ")\n");
377 for (nd = rb_first(&self->symbols[type]); nd; nd = rb_next(nd)) { 376 for (nd = rb_first(&self->symbols[type]); nd; nd = rb_next(nd)) {
@@ -382,24 +381,20 @@ size_t dso__fprintf(struct dso *self, enum map_type type, FILE *fp)
382 return ret; 381 return ret;
383} 382}
384 383
385/* 384int kallsyms__parse(const char *filename, void *arg,
386 * Loads the function entries in /proc/kallsyms into kernel_map->dso, 385 int (*process_symbol)(void *arg, const char *name,
387 * so that we can in the next step set the symbol ->end address and then 386 char type, u64 start))
388 * call kernel_maps__split_kallsyms.
389 */
390static int dso__load_all_kallsyms(struct dso *self, struct map *map)
391{ 387{
392 char *line = NULL; 388 char *line = NULL;
393 size_t n; 389 size_t n;
394 struct rb_root *root = &self->symbols[map->type]; 390 int err = 0;
395 FILE *file = fopen("/proc/kallsyms", "r"); 391 FILE *file = fopen(filename, "r");
396 392
397 if (file == NULL) 393 if (file == NULL)
398 goto out_failure; 394 goto out_failure;
399 395
400 while (!feof(file)) { 396 while (!feof(file)) {
401 u64 start; 397 u64 start;
402 struct symbol *sym;
403 int line_len, len; 398 int line_len, len;
404 char symbol_type; 399 char symbol_type;
405 char *symbol_name; 400 char *symbol_name;
@@ -420,43 +415,72 @@ static int dso__load_all_kallsyms(struct dso *self, struct map *map)
420 continue; 415 continue;
421 416
422 symbol_type = toupper(line[len]); 417 symbol_type = toupper(line[len]);
423 if (!symbol_type__is_a(symbol_type, map->type))
424 continue;
425
426 symbol_name = line + len + 2; 418 symbol_name = line + len + 2;
427 /*
428 * Will fix up the end later, when we have all symbols sorted.
429 */
430 sym = symbol__new(start, 0, symbol_name);
431 419
432 if (sym == NULL) 420 err = process_symbol(arg, symbol_name, symbol_type, start);
433 goto out_delete_line; 421 if (err)
434 /* 422 break;
435 * We will pass the symbols to the filter later, in
436 * map__split_kallsyms, when we have split the maps per module
437 */
438 symbols__insert(root, sym);
439 } 423 }
440 424
441 free(line); 425 free(line);
442 fclose(file); 426 fclose(file);
427 return err;
443 428
444 return 0;
445
446out_delete_line:
447 free(line);
448out_failure: 429out_failure:
449 return -1; 430 return -1;
450} 431}
451 432
433struct process_kallsyms_args {
434 struct map *map;
435 struct dso *dso;
436};
437
438static int map__process_kallsym_symbol(void *arg, const char *name,
439 char type, u64 start)
440{
441 struct symbol *sym;
442 struct process_kallsyms_args *a = arg;
443 struct rb_root *root = &a->dso->symbols[a->map->type];
444
445 if (!symbol_type__is_a(type, a->map->type))
446 return 0;
447
448 /*
449 * Will fix up the end later, when we have all symbols sorted.
450 */
451 sym = symbol__new(start, 0, name);
452
453 if (sym == NULL)
454 return -ENOMEM;
455 /*
456 * We will pass the symbols to the filter later, in
457 * map__split_kallsyms, when we have split the maps per module
458 */
459 symbols__insert(root, sym);
460 return 0;
461}
462
463/*
464 * Loads the function entries in /proc/kallsyms into kernel_map->dso,
465 * so that we can in the next step set the symbol ->end address and then
466 * call kernel_maps__split_kallsyms.
467 */
468static int dso__load_all_kallsyms(struct dso *self, const char *filename,
469 struct map *map)
470{
471 struct process_kallsyms_args args = { .map = map, .dso = self, };
472 return kallsyms__parse(filename, &args, map__process_kallsym_symbol);
473}
474
452/* 475/*
453 * Split the symbols into maps, making sure there are no overlaps, i.e. the 476 * Split the symbols into maps, making sure there are no overlaps, i.e. the
454 * kernel range is broken in several maps, named [kernel].N, as we don't have 477 * kernel range is broken in several maps, named [kernel].N, as we don't have
455 * the original ELF section names vmlinux have. 478 * the original ELF section names vmlinux have.
456 */ 479 */
457static int dso__split_kallsyms(struct dso *self, struct map *map, 480static int dso__split_kallsyms(struct dso *self, struct map *map,
458 struct perf_session *session, symbol_filter_t filter) 481 symbol_filter_t filter)
459{ 482{
483 struct map_groups *kmaps = map__kmap(map)->kmaps;
460 struct map *curr_map = map; 484 struct map *curr_map = map;
461 struct symbol *pos; 485 struct symbol *pos;
462 int count = 0; 486 int count = 0;
@@ -477,13 +501,17 @@ static int dso__split_kallsyms(struct dso *self, struct map *map,
477 501
478 *module++ = '\0'; 502 *module++ = '\0';
479 503
480 if (strcmp(self->name, module)) { 504 if (strcmp(curr_map->dso->short_name, module)) {
481 curr_map = map_groups__find_by_name(&session->kmaps, map->type, module); 505 curr_map = map_groups__find_by_name(kmaps, map->type, module);
482 if (curr_map == NULL) { 506 if (curr_map == NULL) {
483 pr_debug("/proc/{kallsyms,modules} " 507 pr_debug("/proc/{kallsyms,modules} "
484 "inconsistency!\n"); 508 "inconsistency while looking "
509 "for \"%s\" module!\n", module);
485 return -1; 510 return -1;
486 } 511 }
512
513 if (curr_map->dso->loaded)
514 goto discard_symbol;
487 } 515 }
488 /* 516 /*
489 * So that we look just like we get from .ko files, 517 * So that we look just like we get from .ko files,
@@ -503,13 +531,13 @@ static int dso__split_kallsyms(struct dso *self, struct map *map,
503 return -1; 531 return -1;
504 532
505 curr_map = map__new2(pos->start, dso, map->type); 533 curr_map = map__new2(pos->start, dso, map->type);
506 if (map == NULL) { 534 if (curr_map == NULL) {
507 dso__delete(dso); 535 dso__delete(dso);
508 return -1; 536 return -1;
509 } 537 }
510 538
511 curr_map->map_ip = curr_map->unmap_ip = identity__map_ip; 539 curr_map->map_ip = curr_map->unmap_ip = identity__map_ip;
512 map_groups__insert(&session->kmaps, curr_map); 540 map_groups__insert(kmaps, curr_map);
513 ++kernel_range; 541 ++kernel_range;
514 } 542 }
515 543
@@ -528,17 +556,16 @@ discard_symbol: rb_erase(&pos->rb_node, root);
528 return count; 556 return count;
529} 557}
530 558
531 559int dso__load_kallsyms(struct dso *self, const char *filename,
532static int dso__load_kallsyms(struct dso *self, struct map *map, 560 struct map *map, symbol_filter_t filter)
533 struct perf_session *session, symbol_filter_t filter)
534{ 561{
535 if (dso__load_all_kallsyms(self, map) < 0) 562 if (dso__load_all_kallsyms(self, filename, map) < 0)
536 return -1; 563 return -1;
537 564
538 symbols__fixup_end(&self->symbols[map->type]); 565 symbols__fixup_end(&self->symbols[map->type]);
539 self->origin = DSO__ORIG_KERNEL; 566 self->origin = DSO__ORIG_KERNEL;
540 567
541 return dso__split_kallsyms(self, map, session, filter); 568 return dso__split_kallsyms(self, map, filter);
542} 569}
543 570
544static int dso__load_perf_map(struct dso *self, struct map *map, 571static int dso__load_perf_map(struct dso *self, struct map *map,
@@ -864,10 +891,10 @@ static bool elf_sec__is_a(GElf_Shdr *self, Elf_Data *secstrs, enum map_type type
864 } 891 }
865} 892}
866 893
867static int dso__load_sym(struct dso *self, struct map *map, 894static int dso__load_sym(struct dso *self, struct map *map, const char *name,
868 struct perf_session *session, const char *name, int fd, 895 int fd, symbol_filter_t filter, int kmodule)
869 symbol_filter_t filter, int kernel, int kmodule)
870{ 896{
897 struct kmap *kmap = self->kernel ? map__kmap(map) : NULL;
871 struct map *curr_map = map; 898 struct map *curr_map = map;
872 struct dso *curr_dso = self; 899 struct dso *curr_dso = self;
873 size_t dso_name_len = strlen(self->short_name); 900 size_t dso_name_len = strlen(self->short_name);
@@ -924,7 +951,7 @@ static int dso__load_sym(struct dso *self, struct map *map,
924 nr_syms = shdr.sh_size / shdr.sh_entsize; 951 nr_syms = shdr.sh_size / shdr.sh_entsize;
925 952
926 memset(&sym, 0, sizeof(sym)); 953 memset(&sym, 0, sizeof(sym));
927 if (!kernel) { 954 if (!self->kernel) {
928 self->adjust_symbols = (ehdr.e_type == ET_EXEC || 955 self->adjust_symbols = (ehdr.e_type == ET_EXEC ||
929 elf_section_by_name(elf, &ehdr, &shdr, 956 elf_section_by_name(elf, &ehdr, &shdr,
930 ".gnu.prelink_undo", 957 ".gnu.prelink_undo",
@@ -933,11 +960,15 @@ static int dso__load_sym(struct dso *self, struct map *map,
933 960
934 elf_symtab__for_each_symbol(syms, nr_syms, idx, sym) { 961 elf_symtab__for_each_symbol(syms, nr_syms, idx, sym) {
935 struct symbol *f; 962 struct symbol *f;
936 const char *elf_name; 963 const char *elf_name = elf_sym__name(&sym, symstrs);
937 char *demangled = NULL; 964 char *demangled = NULL;
938 int is_label = elf_sym__is_label(&sym); 965 int is_label = elf_sym__is_label(&sym);
939 const char *section_name; 966 const char *section_name;
940 967
968 if (kmap && kmap->ref_reloc_sym && kmap->ref_reloc_sym->name &&
969 strcmp(elf_name, kmap->ref_reloc_sym->name) == 0)
970 kmap->ref_reloc_sym->unrelocated_addr = sym.st_value;
971
941 if (!is_label && !elf_sym__is_a(&sym, map->type)) 972 if (!is_label && !elf_sym__is_a(&sym, map->type))
942 continue; 973 continue;
943 974
@@ -950,10 +981,9 @@ static int dso__load_sym(struct dso *self, struct map *map,
950 if (is_label && !elf_sec__is_a(&shdr, secstrs, map->type)) 981 if (is_label && !elf_sec__is_a(&shdr, secstrs, map->type))
951 continue; 982 continue;
952 983
953 elf_name = elf_sym__name(&sym, symstrs);
954 section_name = elf_sec__name(&shdr, secstrs); 984 section_name = elf_sec__name(&shdr, secstrs);
955 985
956 if (kernel || kmodule) { 986 if (self->kernel || kmodule) {
957 char dso_name[PATH_MAX]; 987 char dso_name[PATH_MAX];
958 988
959 if (strcmp(section_name, 989 if (strcmp(section_name,
@@ -969,7 +999,7 @@ static int dso__load_sym(struct dso *self, struct map *map,
969 snprintf(dso_name, sizeof(dso_name), 999 snprintf(dso_name, sizeof(dso_name),
970 "%s%s", self->short_name, section_name); 1000 "%s%s", self->short_name, section_name);
971 1001
972 curr_map = map_groups__find_by_name(&session->kmaps, map->type, dso_name); 1002 curr_map = map_groups__find_by_name(kmap->kmaps, map->type, dso_name);
973 if (curr_map == NULL) { 1003 if (curr_map == NULL) {
974 u64 start = sym.st_value; 1004 u64 start = sym.st_value;
975 1005
@@ -980,7 +1010,7 @@ static int dso__load_sym(struct dso *self, struct map *map,
980 if (curr_dso == NULL) 1010 if (curr_dso == NULL)
981 goto out_elf_end; 1011 goto out_elf_end;
982 curr_map = map__new2(start, curr_dso, 1012 curr_map = map__new2(start, curr_dso,
983 MAP__FUNCTION); 1013 map->type);
984 if (curr_map == NULL) { 1014 if (curr_map == NULL) {
985 dso__delete(curr_dso); 1015 dso__delete(curr_dso);
986 goto out_elf_end; 1016 goto out_elf_end;
@@ -988,8 +1018,9 @@ static int dso__load_sym(struct dso *self, struct map *map,
988 curr_map->map_ip = identity__map_ip; 1018 curr_map->map_ip = identity__map_ip;
989 curr_map->unmap_ip = identity__map_ip; 1019 curr_map->unmap_ip = identity__map_ip;
990 curr_dso->origin = DSO__ORIG_KERNEL; 1020 curr_dso->origin = DSO__ORIG_KERNEL;
991 map_groups__insert(&session->kmaps, curr_map); 1021 map_groups__insert(kmap->kmaps, curr_map);
992 dsos__add(&dsos__kernel, curr_dso); 1022 dsos__add(&dsos__kernel, curr_dso);
1023 dso__set_loaded(curr_dso, map->type);
993 } else 1024 } else
994 curr_dso = curr_map->dso; 1025 curr_dso = curr_map->dso;
995 1026
@@ -997,9 +1028,10 @@ static int dso__load_sym(struct dso *self, struct map *map,
997 } 1028 }
998 1029
999 if (curr_dso->adjust_symbols) { 1030 if (curr_dso->adjust_symbols) {
1000 pr_debug2("adjusting symbol: st_value: %Lx sh_addr: " 1031 pr_debug4("%s: adjusting symbol: st_value: %#Lx "
1001 "%Lx sh_offset: %Lx\n", (u64)sym.st_value, 1032 "sh_addr: %#Lx sh_offset: %#Lx\n", __func__,
1002 (u64)shdr.sh_addr, (u64)shdr.sh_offset); 1033 (u64)sym.st_value, (u64)shdr.sh_addr,
1034 (u64)shdr.sh_offset);
1003 sym.st_value -= shdr.sh_addr - shdr.sh_offset; 1035 sym.st_value -= shdr.sh_addr - shdr.sh_offset;
1004 } 1036 }
1005 /* 1037 /*
@@ -1027,8 +1059,16 @@ new_symbol:
1027 /* 1059 /*
1028 * For misannotated, zeroed, ASM function sizes. 1060 * For misannotated, zeroed, ASM function sizes.
1029 */ 1061 */
1030 if (nr > 0) 1062 if (nr > 0) {
1031 symbols__fixup_end(&self->symbols[map->type]); 1063 symbols__fixup_end(&self->symbols[map->type]);
1064 if (kmap) {
1065 /*
1066 * We need to fixup this here too because we create new
1067 * maps here, for things like vsyscall sections.
1068 */
1069 __map_groups__fixup_end(kmap->kmaps, map->type);
1070 }
1071 }
1032 err = nr; 1072 err = nr;
1033out_elf_end: 1073out_elf_end:
1034 elf_end(elf); 1074 elf_end(elf);
@@ -1041,25 +1081,28 @@ static bool dso__build_id_equal(const struct dso *self, u8 *build_id)
1041 return memcmp(self->build_id, build_id, sizeof(self->build_id)) == 0; 1081 return memcmp(self->build_id, build_id, sizeof(self->build_id)) == 0;
1042} 1082}
1043 1083
1044static bool __dsos__read_build_ids(struct list_head *head) 1084static bool __dsos__read_build_ids(struct list_head *head, bool with_hits)
1045{ 1085{
1046 bool have_build_id = false; 1086 bool have_build_id = false;
1047 struct dso *pos; 1087 struct dso *pos;
1048 1088
1049 list_for_each_entry(pos, head, node) 1089 list_for_each_entry(pos, head, node) {
1090 if (with_hits && !pos->hit)
1091 continue;
1050 if (filename__read_build_id(pos->long_name, pos->build_id, 1092 if (filename__read_build_id(pos->long_name, pos->build_id,
1051 sizeof(pos->build_id)) > 0) { 1093 sizeof(pos->build_id)) > 0) {
1052 have_build_id = true; 1094 have_build_id = true;
1053 pos->has_build_id = true; 1095 pos->has_build_id = true;
1054 } 1096 }
1097 }
1055 1098
1056 return have_build_id; 1099 return have_build_id;
1057} 1100}
1058 1101
1059bool dsos__read_build_ids(void) 1102bool dsos__read_build_ids(bool with_hits)
1060{ 1103{
1061 bool kbuildids = __dsos__read_build_ids(&dsos__kernel), 1104 bool kbuildids = __dsos__read_build_ids(&dsos__kernel, with_hits),
1062 ubuildids = __dsos__read_build_ids(&dsos__user); 1105 ubuildids = __dsos__read_build_ids(&dsos__user, with_hits);
1063 return kbuildids || ubuildids; 1106 return kbuildids || ubuildids;
1064} 1107}
1065 1108
@@ -1191,6 +1234,7 @@ char dso__symtab_origin(const struct dso *self)
1191 static const char origin[] = { 1234 static const char origin[] = {
1192 [DSO__ORIG_KERNEL] = 'k', 1235 [DSO__ORIG_KERNEL] = 'k',
1193 [DSO__ORIG_JAVA_JIT] = 'j', 1236 [DSO__ORIG_JAVA_JIT] = 'j',
1237 [DSO__ORIG_BUILD_ID_CACHE] = 'B',
1194 [DSO__ORIG_FEDORA] = 'f', 1238 [DSO__ORIG_FEDORA] = 'f',
1195 [DSO__ORIG_UBUNTU] = 'u', 1239 [DSO__ORIG_UBUNTU] = 'u',
1196 [DSO__ORIG_BUILDID] = 'b', 1240 [DSO__ORIG_BUILDID] = 'b',
@@ -1203,19 +1247,19 @@ char dso__symtab_origin(const struct dso *self)
1203 return origin[self->origin]; 1247 return origin[self->origin];
1204} 1248}
1205 1249
1206int dso__load(struct dso *self, struct map *map, struct perf_session *session, 1250int dso__load(struct dso *self, struct map *map, symbol_filter_t filter)
1207 symbol_filter_t filter)
1208{ 1251{
1209 int size = PATH_MAX; 1252 int size = PATH_MAX;
1210 char *name; 1253 char *name;
1211 u8 build_id[BUILD_ID_SIZE]; 1254 u8 build_id[BUILD_ID_SIZE];
1255 char build_id_hex[BUILD_ID_SIZE * 2 + 1];
1212 int ret = -1; 1256 int ret = -1;
1213 int fd; 1257 int fd;
1214 1258
1215 dso__set_loaded(self, map->type); 1259 dso__set_loaded(self, map->type);
1216 1260
1217 if (self->kernel) 1261 if (self->kernel)
1218 return dso__load_kernel_sym(self, map, session, filter); 1262 return dso__load_kernel_sym(self, map, filter);
1219 1263
1220 name = malloc(size); 1264 name = malloc(size);
1221 if (!name) 1265 if (!name)
@@ -1230,8 +1274,16 @@ int dso__load(struct dso *self, struct map *map, struct perf_session *session,
1230 return ret; 1274 return ret;
1231 } 1275 }
1232 1276
1233 self->origin = DSO__ORIG_FEDORA - 1; 1277 self->origin = DSO__ORIG_BUILD_ID_CACHE;
1234 1278
1279 if (self->has_build_id) {
1280 build_id__sprintf(self->build_id, sizeof(self->build_id),
1281 build_id_hex);
1282 snprintf(name, size, "%s/%s/.build-id/%.2s/%s",
1283 getenv("HOME"), DEBUG_CACHE_DIR,
1284 build_id_hex, build_id_hex + 2);
1285 goto open_file;
1286 }
1235more: 1287more:
1236 do { 1288 do {
1237 self->origin++; 1289 self->origin++;
@@ -1247,8 +1299,6 @@ more:
1247 case DSO__ORIG_BUILDID: 1299 case DSO__ORIG_BUILDID:
1248 if (filename__read_build_id(self->long_name, build_id, 1300 if (filename__read_build_id(self->long_name, build_id,
1249 sizeof(build_id))) { 1301 sizeof(build_id))) {
1250 char build_id_hex[BUILD_ID_SIZE * 2 + 1];
1251
1252 build_id__sprintf(build_id, sizeof(build_id), 1302 build_id__sprintf(build_id, sizeof(build_id),
1253 build_id_hex); 1303 build_id_hex);
1254 snprintf(name, size, 1304 snprintf(name, size,
@@ -1276,11 +1326,11 @@ compare_build_id:
1276 if (!dso__build_id_equal(self, build_id)) 1326 if (!dso__build_id_equal(self, build_id))
1277 goto more; 1327 goto more;
1278 } 1328 }
1279 1329open_file:
1280 fd = open(name, O_RDONLY); 1330 fd = open(name, O_RDONLY);
1281 } while (fd < 0); 1331 } while (fd < 0);
1282 1332
1283 ret = dso__load_sym(self, map, NULL, name, fd, filter, 0, 0); 1333 ret = dso__load_sym(self, map, name, fd, filter, 0);
1284 close(fd); 1334 close(fd);
1285 1335
1286 /* 1336 /*
@@ -1309,14 +1359,34 @@ struct map *map_groups__find_by_name(struct map_groups *self,
1309 for (nd = rb_first(&self->maps[type]); nd; nd = rb_next(nd)) { 1359 for (nd = rb_first(&self->maps[type]); nd; nd = rb_next(nd)) {
1310 struct map *map = rb_entry(nd, struct map, rb_node); 1360 struct map *map = rb_entry(nd, struct map, rb_node);
1311 1361
1312 if (map->dso && strcmp(map->dso->name, name) == 0) 1362 if (map->dso && strcmp(map->dso->short_name, name) == 0)
1313 return map; 1363 return map;
1314 } 1364 }
1315 1365
1316 return NULL; 1366 return NULL;
1317} 1367}
1318 1368
1319static int perf_session__set_modules_path_dir(struct perf_session *self, char *dirname) 1369static int dso__kernel_module_get_build_id(struct dso *self)
1370{
1371 char filename[PATH_MAX];
1372 /*
1373 * kernel module short names are of the form "[module]" and
1374 * we need just "module" here.
1375 */
1376 const char *name = self->short_name + 1;
1377
1378 snprintf(filename, sizeof(filename),
1379 "/sys/module/%.*s/notes/.note.gnu.build-id",
1380 (int)strlen(name - 1), name);
1381
1382 if (sysfs__read_build_id(filename, self->build_id,
1383 sizeof(self->build_id)) == 0)
1384 self->has_build_id = true;
1385
1386 return 0;
1387}
1388
1389static int map_groups__set_modules_path_dir(struct map_groups *self, char *dirname)
1320{ 1390{
1321 struct dirent *dent; 1391 struct dirent *dent;
1322 DIR *dir = opendir(dirname); 1392 DIR *dir = opendir(dirname);
@@ -1336,7 +1406,7 @@ static int perf_session__set_modules_path_dir(struct perf_session *self, char *d
1336 1406
1337 snprintf(path, sizeof(path), "%s/%s", 1407 snprintf(path, sizeof(path), "%s/%s",
1338 dirname, dent->d_name); 1408 dirname, dent->d_name);
1339 if (perf_session__set_modules_path_dir(self, path) < 0) 1409 if (map_groups__set_modules_path_dir(self, path) < 0)
1340 goto failure; 1410 goto failure;
1341 } else { 1411 } else {
1342 char *dot = strrchr(dent->d_name, '.'), 1412 char *dot = strrchr(dent->d_name, '.'),
@@ -1350,7 +1420,7 @@ static int perf_session__set_modules_path_dir(struct perf_session *self, char *d
1350 (int)(dot - dent->d_name), dent->d_name); 1420 (int)(dot - dent->d_name), dent->d_name);
1351 1421
1352 strxfrchar(dso_name, '-', '_'); 1422 strxfrchar(dso_name, '-', '_');
1353 map = map_groups__find_by_name(&self->kmaps, MAP__FUNCTION, dso_name); 1423 map = map_groups__find_by_name(self, MAP__FUNCTION, dso_name);
1354 if (map == NULL) 1424 if (map == NULL)
1355 continue; 1425 continue;
1356 1426
@@ -1361,6 +1431,7 @@ static int perf_session__set_modules_path_dir(struct perf_session *self, char *d
1361 if (long_name == NULL) 1431 if (long_name == NULL)
1362 goto failure; 1432 goto failure;
1363 dso__set_long_name(map->dso, long_name); 1433 dso__set_long_name(map->dso, long_name);
1434 dso__kernel_module_get_build_id(map->dso);
1364 } 1435 }
1365 } 1436 }
1366 1437
@@ -1370,7 +1441,7 @@ failure:
1370 return -1; 1441 return -1;
1371} 1442}
1372 1443
1373static int perf_session__set_modules_path(struct perf_session *self) 1444static int map_groups__set_modules_path(struct map_groups *self)
1374{ 1445{
1375 struct utsname uts; 1446 struct utsname uts;
1376 char modules_path[PATH_MAX]; 1447 char modules_path[PATH_MAX];
@@ -1381,7 +1452,7 @@ static int perf_session__set_modules_path(struct perf_session *self)
1381 snprintf(modules_path, sizeof(modules_path), "/lib/modules/%s/kernel", 1452 snprintf(modules_path, sizeof(modules_path), "/lib/modules/%s/kernel",
1382 uts.release); 1453 uts.release);
1383 1454
1384 return perf_session__set_modules_path_dir(self, modules_path); 1455 return map_groups__set_modules_path_dir(self, modules_path);
1385} 1456}
1386 1457
1387/* 1458/*
@@ -1391,8 +1462,8 @@ static int perf_session__set_modules_path(struct perf_session *self)
1391 */ 1462 */
1392static struct map *map__new2(u64 start, struct dso *dso, enum map_type type) 1463static struct map *map__new2(u64 start, struct dso *dso, enum map_type type)
1393{ 1464{
1394 struct map *self = malloc(sizeof(*self)); 1465 struct map *self = zalloc(sizeof(*self) +
1395 1466 (dso->kernel ? sizeof(struct kmap) : 0));
1396 if (self != NULL) { 1467 if (self != NULL) {
1397 /* 1468 /*
1398 * ->end will be filled after we load all the symbols 1469 * ->end will be filled after we load all the symbols
@@ -1403,7 +1474,25 @@ static struct map *map__new2(u64 start, struct dso *dso, enum map_type type)
1403 return self; 1474 return self;
1404} 1475}
1405 1476
1406static int perf_session__create_module_maps(struct perf_session *self) 1477struct map *map_groups__new_module(struct map_groups *self, u64 start,
1478 const char *filename)
1479{
1480 struct map *map;
1481 struct dso *dso = __dsos__findnew(&dsos__kernel, filename);
1482
1483 if (dso == NULL)
1484 return NULL;
1485
1486 map = map__new2(start, dso, MAP__FUNCTION);
1487 if (map == NULL)
1488 return NULL;
1489
1490 dso->origin = DSO__ORIG_KMODULE;
1491 map_groups__insert(self, map);
1492 return map;
1493}
1494
1495static int map_groups__create_modules(struct map_groups *self)
1407{ 1496{
1408 char *line = NULL; 1497 char *line = NULL;
1409 size_t n; 1498 size_t n;
@@ -1416,7 +1505,6 @@ static int perf_session__create_module_maps(struct perf_session *self)
1416 while (!feof(file)) { 1505 while (!feof(file)) {
1417 char name[PATH_MAX]; 1506 char name[PATH_MAX];
1418 u64 start; 1507 u64 start;
1419 struct dso *dso;
1420 char *sep; 1508 char *sep;
1421 int line_len; 1509 int line_len;
1422 1510
@@ -1442,32 +1530,16 @@ static int perf_session__create_module_maps(struct perf_session *self)
1442 *sep = '\0'; 1530 *sep = '\0';
1443 1531
1444 snprintf(name, sizeof(name), "[%s]", line); 1532 snprintf(name, sizeof(name), "[%s]", line);
1445 dso = dso__new(name); 1533 map = map_groups__new_module(self, start, name);
1446 1534 if (map == NULL)
1447 if (dso == NULL)
1448 goto out_delete_line;
1449
1450 map = map__new2(start, dso, MAP__FUNCTION);
1451 if (map == NULL) {
1452 dso__delete(dso);
1453 goto out_delete_line; 1535 goto out_delete_line;
1454 } 1536 dso__kernel_module_get_build_id(map->dso);
1455
1456 snprintf(name, sizeof(name),
1457 "/sys/module/%s/notes/.note.gnu.build-id", line);
1458 if (sysfs__read_build_id(name, dso->build_id,
1459 sizeof(dso->build_id)) == 0)
1460 dso->has_build_id = true;
1461
1462 dso->origin = DSO__ORIG_KMODULE;
1463 map_groups__insert(&self->kmaps, map);
1464 dsos__add(&dsos__kernel, dso);
1465 } 1537 }
1466 1538
1467 free(line); 1539 free(line);
1468 fclose(file); 1540 fclose(file);
1469 1541
1470 return perf_session__set_modules_path(self); 1542 return map_groups__set_modules_path(self);
1471 1543
1472out_delete_line: 1544out_delete_line:
1473 free(line); 1545 free(line);
@@ -1476,7 +1548,6 @@ out_failure:
1476} 1548}
1477 1549
1478static int dso__load_vmlinux(struct dso *self, struct map *map, 1550static int dso__load_vmlinux(struct dso *self, struct map *map,
1479 struct perf_session *session,
1480 const char *vmlinux, symbol_filter_t filter) 1551 const char *vmlinux, symbol_filter_t filter)
1481{ 1552{
1482 int err = -1, fd; 1553 int err = -1, fd;
@@ -1510,51 +1581,124 @@ static int dso__load_vmlinux(struct dso *self, struct map *map,
1510 return -1; 1581 return -1;
1511 1582
1512 dso__set_loaded(self, map->type); 1583 dso__set_loaded(self, map->type);
1513 err = dso__load_sym(self, map, session, self->long_name, fd, filter, 1, 0); 1584 err = dso__load_sym(self, map, vmlinux, fd, filter, 0);
1514 close(fd); 1585 close(fd);
1515 1586
1587 if (err > 0)
1588 pr_debug("Using %s for symbols\n", vmlinux);
1589
1590 return err;
1591}
1592
1593int dso__load_vmlinux_path(struct dso *self, struct map *map,
1594 symbol_filter_t filter)
1595{
1596 int i, err = 0;
1597
1598 pr_debug("Looking at the vmlinux_path (%d entries long)\n",
1599 vmlinux_path__nr_entries);
1600
1601 for (i = 0; i < vmlinux_path__nr_entries; ++i) {
1602 err = dso__load_vmlinux(self, map, vmlinux_path[i], filter);
1603 if (err > 0) {
1604 dso__set_long_name(self, strdup(vmlinux_path[i]));
1605 break;
1606 }
1607 }
1608
1516 return err; 1609 return err;
1517} 1610}
1518 1611
1519static int dso__load_kernel_sym(struct dso *self, struct map *map, 1612static int dso__load_kernel_sym(struct dso *self, struct map *map,
1520 struct perf_session *session, symbol_filter_t filter) 1613 symbol_filter_t filter)
1521{ 1614{
1522 int err; 1615 int err;
1523 bool is_kallsyms; 1616 const char *kallsyms_filename = NULL;
1617 char *kallsyms_allocated_filename = NULL;
1618 /*
1619 * Step 1: if the user specified a vmlinux filename, use it and only
1620 * it, reporting errors to the user if it cannot be used.
1621 *
1622 * For instance, try to analyse an ARM perf.data file _without_ a
1623 * build-id, or if the user specifies the wrong path to the right
1624 * vmlinux file, obviously we can't fallback to another vmlinux (a
1625 * x86_86 one, on the machine where analysis is being performed, say),
1626 * or worse, /proc/kallsyms.
1627 *
1628 * If the specified file _has_ a build-id and there is a build-id
1629 * section in the perf.data file, we will still do the expected
1630 * validation in dso__load_vmlinux and will bail out if they don't
1631 * match.
1632 */
1633 if (symbol_conf.vmlinux_name != NULL) {
1634 err = dso__load_vmlinux(self, map,
1635 symbol_conf.vmlinux_name, filter);
1636 goto out_try_fixup;
1637 }
1524 1638
1525 if (vmlinux_path != NULL) { 1639 if (vmlinux_path != NULL) {
1526 int i; 1640 err = dso__load_vmlinux_path(self, map, filter);
1527 pr_debug("Looking at the vmlinux_path (%d entries long)\n", 1641 if (err > 0)
1528 vmlinux_path__nr_entries); 1642 goto out_fixup;
1529 for (i = 0; i < vmlinux_path__nr_entries; ++i) { 1643 }
1530 err = dso__load_vmlinux(self, map, session, 1644
1531 vmlinux_path[i], filter); 1645 /*
1532 if (err > 0) { 1646 * Say the kernel DSO was created when processing the build-id header table,
1533 pr_debug("Using %s for symbols\n", 1647 * we have a build-id, so check if it is the same as the running kernel,
1534 vmlinux_path[i]); 1648 * using it if it is.
1535 dso__set_long_name(self, 1649 */
1536 strdup(vmlinux_path[i])); 1650 if (self->has_build_id) {
1537 goto out_fixup; 1651 u8 kallsyms_build_id[BUILD_ID_SIZE];
1652 char sbuild_id[BUILD_ID_SIZE * 2 + 1];
1653
1654 if (sysfs__read_build_id("/sys/kernel/notes", kallsyms_build_id,
1655 sizeof(kallsyms_build_id)) == 0) {
1656 if (dso__build_id_equal(self, kallsyms_build_id)) {
1657 kallsyms_filename = "/proc/kallsyms";
1658 goto do_kallsyms;
1538 } 1659 }
1539 } 1660 }
1540 } 1661 /*
1662 * Now look if we have it on the build-id cache in
1663 * $HOME/.debug/[kernel.kallsyms].
1664 */
1665 build_id__sprintf(self->build_id, sizeof(self->build_id),
1666 sbuild_id);
1541 1667
1542 is_kallsyms = self->long_name[0] == '['; 1668 if (asprintf(&kallsyms_allocated_filename,
1543 if (is_kallsyms) 1669 "%s/.debug/[kernel.kallsyms]/%s",
1544 goto do_kallsyms; 1670 getenv("HOME"), sbuild_id) == -1) {
1671 pr_err("Not enough memory for kallsyms file lookup\n");
1672 return -1;
1673 }
1545 1674
1546 err = dso__load_vmlinux(self, map, session, self->long_name, filter); 1675 kallsyms_filename = kallsyms_allocated_filename;
1547 if (err <= 0) { 1676
1548 pr_info("The file %s cannot be used, " 1677 if (access(kallsyms_filename, F_OK)) {
1549 "trying to use /proc/kallsyms...", self->long_name); 1678 pr_err("No kallsyms or vmlinux with build-id %s "
1550do_kallsyms: 1679 "was found\n", sbuild_id);
1551 err = dso__load_kallsyms(self, map, session, filter); 1680 free(kallsyms_allocated_filename);
1552 if (err > 0 && !is_kallsyms) 1681 return -1;
1553 dso__set_long_name(self, strdup("[kernel.kallsyms]")); 1682 }
1683 } else {
1684 /*
1685 * Last resort, if we don't have a build-id and couldn't find
1686 * any vmlinux file, try the running kernel kallsyms table.
1687 */
1688 kallsyms_filename = "/proc/kallsyms";
1554 } 1689 }
1555 1690
1691do_kallsyms:
1692 err = dso__load_kallsyms(self, kallsyms_filename, map, filter);
1693 if (err > 0)
1694 pr_debug("Using %s for symbols\n", kallsyms_filename);
1695 free(kallsyms_allocated_filename);
1696
1697out_try_fixup:
1556 if (err > 0) { 1698 if (err > 0) {
1557out_fixup: 1699out_fixup:
1700 if (kallsyms_filename != NULL)
1701 dso__set_long_name(self, strdup("[kernel.kallsyms]"));
1558 map__fixup_start(map); 1702 map__fixup_start(map);
1559 map__fixup_end(map); 1703 map__fixup_end(map);
1560 } 1704 }
@@ -1564,7 +1708,6 @@ out_fixup:
1564 1708
1565LIST_HEAD(dsos__user); 1709LIST_HEAD(dsos__user);
1566LIST_HEAD(dsos__kernel); 1710LIST_HEAD(dsos__kernel);
1567struct dso *vdso;
1568 1711
1569static void dsos__add(struct list_head *head, struct dso *dso) 1712static void dsos__add(struct list_head *head, struct dso *dso)
1570{ 1713{
@@ -1576,19 +1719,19 @@ static struct dso *dsos__find(struct list_head *head, const char *name)
1576 struct dso *pos; 1719 struct dso *pos;
1577 1720
1578 list_for_each_entry(pos, head, node) 1721 list_for_each_entry(pos, head, node)
1579 if (strcmp(pos->name, name) == 0) 1722 if (strcmp(pos->long_name, name) == 0)
1580 return pos; 1723 return pos;
1581 return NULL; 1724 return NULL;
1582} 1725}
1583 1726
1584struct dso *dsos__findnew(const char *name) 1727struct dso *__dsos__findnew(struct list_head *head, const char *name)
1585{ 1728{
1586 struct dso *dso = dsos__find(&dsos__user, name); 1729 struct dso *dso = dsos__find(head, name);
1587 1730
1588 if (!dso) { 1731 if (!dso) {
1589 dso = dso__new(name); 1732 dso = dso__new(name);
1590 if (dso != NULL) { 1733 if (dso != NULL) {
1591 dsos__add(&dsos__user, dso); 1734 dsos__add(head, dso);
1592 dso__set_basename(dso); 1735 dso__set_basename(dso);
1593 } 1736 }
1594 } 1737 }
@@ -1613,75 +1756,78 @@ void dsos__fprintf(FILE *fp)
1613 __dsos__fprintf(&dsos__user, fp); 1756 __dsos__fprintf(&dsos__user, fp);
1614} 1757}
1615 1758
1616static size_t __dsos__fprintf_buildid(struct list_head *head, FILE *fp) 1759static size_t __dsos__fprintf_buildid(struct list_head *head, FILE *fp,
1760 bool with_hits)
1617{ 1761{
1618 struct dso *pos; 1762 struct dso *pos;
1619 size_t ret = 0; 1763 size_t ret = 0;
1620 1764
1621 list_for_each_entry(pos, head, node) { 1765 list_for_each_entry(pos, head, node) {
1766 if (with_hits && !pos->hit)
1767 continue;
1622 ret += dso__fprintf_buildid(pos, fp); 1768 ret += dso__fprintf_buildid(pos, fp);
1623 ret += fprintf(fp, " %s\n", pos->long_name); 1769 ret += fprintf(fp, " %s\n", pos->long_name);
1624 } 1770 }
1625 return ret; 1771 return ret;
1626} 1772}
1627 1773
1628size_t dsos__fprintf_buildid(FILE *fp) 1774size_t dsos__fprintf_buildid(FILE *fp, bool with_hits)
1629{ 1775{
1630 return (__dsos__fprintf_buildid(&dsos__kernel, fp) + 1776 return (__dsos__fprintf_buildid(&dsos__kernel, fp, with_hits) +
1631 __dsos__fprintf_buildid(&dsos__user, fp)); 1777 __dsos__fprintf_buildid(&dsos__user, fp, with_hits));
1632} 1778}
1633 1779
1634static struct dso *dsos__create_kernel( const char *vmlinux) 1780struct dso *dso__new_kernel(const char *name)
1635{ 1781{
1636 struct dso *kernel = dso__new(vmlinux ?: "[kernel.kallsyms]"); 1782 struct dso *self = dso__new(name ?: "[kernel.kallsyms]");
1637 1783
1638 if (kernel == NULL) 1784 if (self != NULL) {
1639 return NULL; 1785 self->short_name = "[kernel]";
1786 self->kernel = 1;
1787 }
1640 1788
1641 kernel->short_name = "[kernel]"; 1789 return self;
1642 kernel->kernel = 1; 1790}
1643 1791
1644 vdso = dso__new("[vdso]"); 1792void dso__read_running_kernel_build_id(struct dso *self)
1645 if (vdso == NULL) 1793{
1646 goto out_delete_kernel_dso; 1794 if (sysfs__read_build_id("/sys/kernel/notes", self->build_id,
1647 dso__set_loaded(vdso, MAP__FUNCTION); 1795 sizeof(self->build_id)) == 0)
1796 self->has_build_id = true;
1797}
1648 1798
1649 if (sysfs__read_build_id("/sys/kernel/notes", kernel->build_id, 1799static struct dso *dsos__create_kernel(const char *vmlinux)
1650 sizeof(kernel->build_id)) == 0) 1800{
1651 kernel->has_build_id = true; 1801 struct dso *kernel = dso__new_kernel(vmlinux);
1652 1802
1653 dsos__add(&dsos__kernel, kernel); 1803 if (kernel != NULL) {
1654 dsos__add(&dsos__user, vdso); 1804 dso__read_running_kernel_build_id(kernel);
1805 dsos__add(&dsos__kernel, kernel);
1806 }
1655 1807
1656 return kernel; 1808 return kernel;
1657
1658out_delete_kernel_dso:
1659 dso__delete(kernel);
1660 return NULL;
1661} 1809}
1662 1810
1663static int map_groups__create_kernel_maps(struct map_groups *self, const char *vmlinux) 1811int __map_groups__create_kernel_maps(struct map_groups *self,
1812 struct map *vmlinux_maps[MAP__NR_TYPES],
1813 struct dso *kernel)
1664{ 1814{
1665 struct map *functions, *variables; 1815 enum map_type type;
1666 struct dso *kernel = dsos__create_kernel(vmlinux);
1667 1816
1668 if (kernel == NULL) 1817 for (type = 0; type < MAP__NR_TYPES; ++type) {
1669 return -1; 1818 struct kmap *kmap;
1670 1819
1671 functions = map__new2(0, kernel, MAP__FUNCTION); 1820 vmlinux_maps[type] = map__new2(0, kernel, type);
1672 if (functions == NULL) 1821 if (vmlinux_maps[type] == NULL)
1673 return -1; 1822 return -1;
1674 1823
1675 variables = map__new2(0, kernel, MAP__VARIABLE); 1824 vmlinux_maps[type]->map_ip =
1676 if (variables == NULL) { 1825 vmlinux_maps[type]->unmap_ip = identity__map_ip;
1677 map__delete(functions);
1678 return -1;
1679 }
1680 1826
1681 functions->map_ip = functions->unmap_ip = 1827 kmap = map__kmap(vmlinux_maps[type]);
1682 variables->map_ip = variables->unmap_ip = identity__map_ip; 1828 kmap->kmaps = self;
1683 map_groups__insert(self, functions); 1829 map_groups__insert(self, vmlinux_maps[type]);
1684 map_groups__insert(self, variables); 1830 }
1685 1831
1686 return 0; 1832 return 0;
1687} 1833}
@@ -1791,19 +1937,22 @@ out_free_comm_list:
1791 return -1; 1937 return -1;
1792} 1938}
1793 1939
1794int perf_session__create_kernel_maps(struct perf_session *self) 1940int map_groups__create_kernel_maps(struct map_groups *self,
1941 struct map *vmlinux_maps[MAP__NR_TYPES])
1795{ 1942{
1796 if (map_groups__create_kernel_maps(&self->kmaps, 1943 struct dso *kernel = dsos__create_kernel(symbol_conf.vmlinux_name);
1797 symbol_conf.vmlinux_name) < 0) 1944
1945 if (kernel == NULL)
1946 return -1;
1947
1948 if (__map_groups__create_kernel_maps(self, vmlinux_maps, kernel) < 0)
1798 return -1; 1949 return -1;
1799 1950
1800 if (symbol_conf.use_modules && 1951 if (symbol_conf.use_modules && map_groups__create_modules(self) < 0)
1801 perf_session__create_module_maps(self) < 0) 1952 pr_debug("Problems creating module maps, continuing anyway...\n");
1802 pr_debug("Failed to load list of modules for session %s, "
1803 "continuing...\n", self->filename);
1804 /* 1953 /*
1805 * Now that we have all the maps created, just set the ->end of them: 1954 * Now that we have all the maps created, just set the ->end of them:
1806 */ 1955 */
1807 map_groups__fixup_end(&self->kmaps); 1956 map_groups__fixup_end(self);
1808 return 0; 1957 return 0;
1809} 1958}