aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tools/perf/util/machine.c59
1 files changed, 21 insertions, 38 deletions
diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index dbb5f0367005..eb95b883fb44 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -460,14 +460,15 @@ int machine__process_lost_event(struct machine *machine __maybe_unused,
460 return 0; 460 return 0;
461} 461}
462 462
463static struct dso *machine__module_dso(struct machine *machine, const char *filename) 463static struct dso*
464machine__module_dso(struct machine *machine, struct kmod_path *m,
465 const char *filename)
464{ 466{
465 struct dso *dso; 467 struct dso *dso;
466 bool compressed;
467 468
468 dso = dsos__find(&machine->kernel_dsos, filename, false); 469 dso = dsos__find(&machine->kernel_dsos, m->name, true);
469 if (!dso) { 470 if (!dso) {
470 dso = dsos__addnew(&machine->kernel_dsos, filename); 471 dso = dsos__addnew(&machine->kernel_dsos, m->name);
471 if (dso == NULL) 472 if (dso == NULL)
472 return NULL; 473 return NULL;
473 474
@@ -477,8 +478,11 @@ static struct dso *machine__module_dso(struct machine *machine, const char *file
477 dso->symtab_type = DSO_BINARY_TYPE__GUEST_KMODULE; 478 dso->symtab_type = DSO_BINARY_TYPE__GUEST_KMODULE;
478 479
479 /* _KMODULE_COMP should be next to _KMODULE */ 480 /* _KMODULE_COMP should be next to _KMODULE */
480 if (is_kernel_module(filename, &compressed) && compressed) 481 if (m->kmod && m->comp)
481 dso->symtab_type++; 482 dso->symtab_type++;
483
484 dso__set_short_name(dso, strdup(m->name), true);
485 dso__set_long_name(dso, strdup(filename), true);
482 } 486 }
483 487
484 return dso; 488 return dso;
@@ -487,17 +491,25 @@ static struct dso *machine__module_dso(struct machine *machine, const char *file
487struct map *machine__new_module(struct machine *machine, u64 start, 491struct map *machine__new_module(struct machine *machine, u64 start,
488 const char *filename) 492 const char *filename)
489{ 493{
490 struct map *map; 494 struct map *map = NULL;
491 struct dso *dso = machine__module_dso(machine, filename); 495 struct dso *dso;
496 struct kmod_path m;
492 497
493 if (dso == NULL) 498 if (kmod_path__parse_name(&m, filename))
494 return NULL; 499 return NULL;
495 500
501 dso = machine__module_dso(machine, &m, filename);
502 if (dso == NULL)
503 goto out;
504
496 map = map__new2(start, dso, MAP__FUNCTION); 505 map = map__new2(start, dso, MAP__FUNCTION);
497 if (map == NULL) 506 if (map == NULL)
498 return NULL; 507 goto out;
499 508
500 map_groups__insert(&machine->kmaps, map); 509 map_groups__insert(&machine->kmaps, map);
510
511out:
512 free(m.name);
501 return map; 513 return map;
502} 514}
503 515
@@ -1058,40 +1070,11 @@ static int machine__process_kernel_mmap_event(struct machine *machine,
1058 strlen(kmmap_prefix) - 1) == 0; 1070 strlen(kmmap_prefix) - 1) == 0;
1059 if (event->mmap.filename[0] == '/' || 1071 if (event->mmap.filename[0] == '/' ||
1060 (!is_kernel_mmap && event->mmap.filename[0] == '[')) { 1072 (!is_kernel_mmap && event->mmap.filename[0] == '[')) {
1061
1062 char short_module_name[1024];
1063 char *name, *dot;
1064
1065 if (event->mmap.filename[0] == '/') {
1066 name = strrchr(event->mmap.filename, '/');
1067 if (name == NULL)
1068 goto out_problem;
1069
1070 ++name; /* skip / */
1071 dot = strrchr(name, '.');
1072 if (dot == NULL)
1073 goto out_problem;
1074 /* On some system, modules are compressed like .ko.gz */
1075 if (is_supported_compression(dot + 1))
1076 dot -= 3;
1077 if (!is_kmodule_extension(dot + 1))
1078 goto out_problem;
1079 snprintf(short_module_name, sizeof(short_module_name),
1080 "[%.*s]", (int)(dot - name), name);
1081 strxfrchar(short_module_name, '-', '_');
1082 } else
1083 strcpy(short_module_name, event->mmap.filename);
1084
1085 map = machine__new_module(machine, event->mmap.start, 1073 map = machine__new_module(machine, event->mmap.start,
1086 event->mmap.filename); 1074 event->mmap.filename);
1087 if (map == NULL) 1075 if (map == NULL)
1088 goto out_problem; 1076 goto out_problem;
1089 1077
1090 name = strdup(short_module_name);
1091 if (name == NULL)
1092 goto out_problem;
1093
1094 dso__set_short_name(map->dso, name, true);
1095 map->end = map->start + event->mmap.len; 1078 map->end = map->start + event->mmap.len;
1096 } else if (is_kernel_mmap) { 1079 } else if (is_kernel_mmap) {
1097 const char *symbol_name = (event->mmap.filename + 1080 const char *symbol_name = (event->mmap.filename +