perf symbols: Set module info when build-id event found
authorNamhyung Kim <namhyung@kernel.org>
Wed, 31 May 2017 12:01:04 +0000 (21:01 +0900)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Mon, 5 Jun 2017 17:17:58 +0000 (14:17 -0300)
Like machine__findnew_module_dso(), it should set necessary info for
kernel modules to find symbol info from the file.  Factor out
dso__set_module_info() to do it.

This is needed for dso__needs_decompress() to detect such DSOs.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: kernel-team@lge.com
Link: http://lkml.kernel.org/r/20170531120105.21731-2-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/dso.c
tools/perf/util/dso.h
tools/perf/util/header.c
tools/perf/util/machine.c

index a96a99d2369f800634025bcdfa9838d1d6bc9d97..b27d127cdf68f996ee4f96ce24aa51044e31bf9f 100644 (file)
@@ -335,6 +335,21 @@ int __kmod_path__parse(struct kmod_path *m, const char *path,
        return 0;
 }
 
+void dso__set_module_info(struct dso *dso, struct kmod_path *m,
+                         struct machine *machine)
+{
+       if (machine__is_host(machine))
+               dso->symtab_type = DSO_BINARY_TYPE__SYSTEM_PATH_KMODULE;
+       else
+               dso->symtab_type = DSO_BINARY_TYPE__GUEST_KMODULE;
+
+       /* _KMODULE_COMP should be next to _KMODULE */
+       if (m->kmod && m->comp)
+               dso->symtab_type++;
+
+       dso__set_short_name(dso, strdup(m->name), true);
+}
+
 /*
  * Global list of open DSOs and the counter.
  */
index 12350b17172730adf0dffdf324cb9e0b4a4be2ba..5fe2ab5877bd6c30fd66bb81596ac3e564d9ce04 100644 (file)
@@ -259,6 +259,9 @@ int __kmod_path__parse(struct kmod_path *m, const char *path,
 #define kmod_path__parse_name(__m, __p) __kmod_path__parse(__m, __p, true , false)
 #define kmod_path__parse_ext(__m, __p)  __kmod_path__parse(__m, __p, false, true)
 
+void dso__set_module_info(struct dso *dso, struct kmod_path *m,
+                         struct machine *machine);
+
 /*
  * The dso__data_* external interface provides following functions:
  *   dso__data_get_fd
index c40a4d8acf8b4167041c217ef4801ae7fe6abd43..5cac8d5e009a88ff096d9e2f8026e39e8567c595 100644 (file)
@@ -1473,7 +1473,7 @@ static int __event_process_build_id(struct build_id_event *bev,
                        struct kmod_path m = { .name = NULL, };
 
                        if (!kmod_path__parse_name(&m, filename) && m.kmod)
-                               dso__set_short_name(dso, strdup(m.name), true);
+                               dso__set_module_info(dso, &m, machine);
                        else
                                dso->kernel = dso_type;
 
index d97e014c3df395e51e61da31f9624e12927a43b2..d7f31cb0a4cbeb41e6c02d58323a8848ff82cfc4 100644 (file)
@@ -572,16 +572,7 @@ static struct dso *machine__findnew_module_dso(struct machine *machine,
                if (dso == NULL)
                        goto out_unlock;
 
-               if (machine__is_host(machine))
-                       dso->symtab_type = DSO_BINARY_TYPE__SYSTEM_PATH_KMODULE;
-               else
-                       dso->symtab_type = DSO_BINARY_TYPE__GUEST_KMODULE;
-
-               /* _KMODULE_COMP should be next to _KMODULE */
-               if (m->kmod && m->comp)
-                       dso->symtab_type++;
-
-               dso__set_short_name(dso, strdup(m->name), true);
+               dso__set_module_info(dso, m, machine);
                dso__set_long_name(dso, strdup(filename), true);
        }