Commit bb58a8a4 authored by Jiri Olsa's avatar Jiri Olsa Committed by Arnaldo Carvalho de Melo

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: default avatarJiri Olsa <jolsa@kernel.org>
Acked-by: default avatarNamhyung 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.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 963a70b8
...@@ -851,6 +851,39 @@ static char *get_kernel_version(const char *root_dir) ...@@ -851,6 +851,39 @@ static char *get_kernel_version(const char *root_dir)
return strdup(name); return strdup(name);
} }
static bool is_kmod_dso(struct dso *dso)
{
return dso->symtab_type == DSO_BINARY_TYPE__SYSTEM_PATH_KMODULE ||
dso->symtab_type == DSO_BINARY_TYPE__GUEST_KMODULE;
}
static int map_groups__set_module_path(struct map_groups *mg, const char *path,
struct kmod_path *m)
{
struct map *map;
char *long_name;
map = map_groups__find_by_name(mg, MAP__FUNCTION, m->name);
if (map == NULL)
return 0;
long_name = strdup(path);
if (long_name == NULL)
return -ENOMEM;
dso__set_long_name(map->dso, long_name, true);
dso__kernel_module_get_build_id(map->dso, "");
/*
* Full name could reveal us kmod compression, so
* we need to update the symtab_type if needed.
*/
if (m->comp && is_kmod_dso(map->dso))
map->dso->symtab_type++;
return 0;
}
static int map_groups__set_modules_path_dir(struct map_groups *mg, static int map_groups__set_modules_path_dir(struct map_groups *mg,
const char *dir_name, int depth) const char *dir_name, int depth)
{ {
...@@ -889,36 +922,20 @@ static int map_groups__set_modules_path_dir(struct map_groups *mg, ...@@ -889,36 +922,20 @@ static int map_groups__set_modules_path_dir(struct map_groups *mg,
if (ret < 0) if (ret < 0)
goto out; goto out;
} else { } else {
char *dot = strrchr(dent->d_name, '.'), struct kmod_path m;
dso_name[PATH_MAX];
struct map *map;
char *long_name;
if (dot == NULL)
continue;
/* On some system, modules are compressed like .ko.gz */ ret = kmod_path__parse_name(&m, dent->d_name);
if (is_supported_compression(dot + 1) && if (ret)
is_kmodule_extension(dot - 2)) goto out;
dot -= 3;
snprintf(dso_name, sizeof(dso_name), "[%.*s]", if (m.kmod)
(int)(dot - dent->d_name), dent->d_name); ret = map_groups__set_module_path(mg, path, &m);
strxfrchar(dso_name, '-', '_'); free(m.name);
map = map_groups__find_by_name(mg, MAP__FUNCTION,
dso_name);
if (map == NULL)
continue;
long_name = strdup(path); if (ret)
if (long_name == NULL) {
ret = -1;
goto out; goto out;
} }
dso__set_long_name(map->dso, long_name, true);
dso__kernel_module_get_build_id(map->dso, "");
}
} }
out: out:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment