aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tools/perf/util/machine.c65
1 files changed, 41 insertions, 24 deletions
diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index eb95b883fb44..6ca61a3427a6 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -851,6 +851,39 @@ static char *get_kernel_version(const char *root_dir)
851 return strdup(name); 851 return strdup(name);
852} 852}
853 853
854static bool is_kmod_dso(struct dso *dso)
855{
856 return dso->symtab_type == DSO_BINARY_TYPE__SYSTEM_PATH_KMODULE ||
857 dso->symtab_type == DSO_BINARY_TYPE__GUEST_KMODULE;
858}
859
860static int map_groups__set_module_path(struct map_groups *mg, const char *path,
861 struct kmod_path *m)
862{
863 struct map *map;
864 char *long_name;
865
866 map = map_groups__find_by_name(mg, MAP__FUNCTION, m->name);
867 if (map == NULL)
868 return 0;
869
870 long_name = strdup(path);
871 if (long_name == NULL)
872 return -ENOMEM;
873
874 dso__set_long_name(map->dso, long_name, true);
875 dso__kernel_module_get_build_id(map->dso, "");
876
877 /*
878 * Full name could reveal us kmod compression, so
879 * we need to update the symtab_type if needed.
880 */
881 if (m->comp && is_kmod_dso(map->dso))
882 map->dso->symtab_type++;
883
884 return 0;
885}
886
854static int map_groups__set_modules_path_dir(struct map_groups *mg, 887static int map_groups__set_modules_path_dir(struct map_groups *mg,
855 const char *dir_name, int depth) 888 const char *dir_name, int depth)
856{ 889{
@@ -889,35 +922,19 @@ static int map_groups__set_modules_path_dir(struct map_groups *mg,
889 if (ret < 0) 922 if (ret < 0)
890 goto out; 923 goto out;
891 } else { 924 } else {
892 char *dot = strrchr(dent->d_name, '.'), 925 struct kmod_path m;
893 dso_name[PATH_MAX];
894 struct map *map;
895 char *long_name;
896 926
897 if (dot == NULL) 927 ret = kmod_path__parse_name(&m, dent->d_name);
898 continue; 928 if (ret)
929 goto out;
899 930
900 /* On some system, modules are compressed like .ko.gz */ 931 if (m.kmod)
901 if (is_supported_compression(dot + 1) && 932 ret = map_groups__set_module_path(mg, path, &m);
902 is_kmodule_extension(dot - 2))
903 dot -= 3;
904 933
905 snprintf(dso_name, sizeof(dso_name), "[%.*s]", 934 free(m.name);
906 (int)(dot - dent->d_name), dent->d_name);
907 935
908 strxfrchar(dso_name, '-', '_'); 936 if (ret)
909 map = map_groups__find_by_name(mg, MAP__FUNCTION,
910 dso_name);
911 if (map == NULL)
912 continue;
913
914 long_name = strdup(path);
915 if (long_name == NULL) {
916 ret = -1;
917 goto out; 937 goto out;
918 }
919 dso__set_long_name(map->dso, long_name, true);
920 dso__kernel_module_get_build_id(map->dso, "");
921 } 938 }
922 } 939 }
923 940