diff options
author | Jiri Olsa <jolsa@kernel.org> | 2015-02-12 16:20:01 -0500 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2015-03-23 10:43:25 -0400 |
commit | bb58a8a459c322196613ad4af8801de41469cebb (patch) | |
tree | 03f17d60b1d7e5d2f42883388ba2655acb1c5bc5 /tools/perf/util/machine.c | |
parent | 963a70b8a2d65538f7d58b2b84a2ae10a3ecb6ea (diff) |
perf tools: Use kmod_path__parse in map_groups__set_modules_path_dir
Replacing the file name parsing with kmod_path__parse
and moving the dso update into new separate function.
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-q0ed76ajcyoaofotntrg5sla@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/machine.c')
-rw-r--r-- | tools/perf/util/machine.c | 65 |
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 | ||
854 | static 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 | |||
860 | static 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 | |||
854 | static int map_groups__set_modules_path_dir(struct map_groups *mg, | 887 | static 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 | ||