aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNamhyung Kim <namhyung@kernel.org>2017-05-31 08:01:04 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2017-06-05 13:17:58 -0400
commit6b335e8f545591c07df0f34231bd7ff7506c98c1 (patch)
tree07d0ed62b940d1da53b409f0da6a33653d7daa5b
parent1deec1bd96ccd8beb04d2112a6d12fe20505c3a6 (diff)
perf symbols: Set module info when build-id event found
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>
-rw-r--r--tools/perf/util/dso.c15
-rw-r--r--tools/perf/util/dso.h3
-rw-r--r--tools/perf/util/header.c2
-rw-r--r--tools/perf/util/machine.c11
4 files changed, 20 insertions, 11 deletions
diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c
index a96a99d2369f..b27d127cdf68 100644
--- a/tools/perf/util/dso.c
+++ b/tools/perf/util/dso.c
@@ -335,6 +335,21 @@ int __kmod_path__parse(struct kmod_path *m, const char *path,
335 return 0; 335 return 0;
336} 336}
337 337
338void dso__set_module_info(struct dso *dso, struct kmod_path *m,
339 struct machine *machine)
340{
341 if (machine__is_host(machine))
342 dso->symtab_type = DSO_BINARY_TYPE__SYSTEM_PATH_KMODULE;
343 else
344 dso->symtab_type = DSO_BINARY_TYPE__GUEST_KMODULE;
345
346 /* _KMODULE_COMP should be next to _KMODULE */
347 if (m->kmod && m->comp)
348 dso->symtab_type++;
349
350 dso__set_short_name(dso, strdup(m->name), true);
351}
352
338/* 353/*
339 * Global list of open DSOs and the counter. 354 * Global list of open DSOs and the counter.
340 */ 355 */
diff --git a/tools/perf/util/dso.h b/tools/perf/util/dso.h
index 12350b171727..5fe2ab5877bd 100644
--- a/tools/perf/util/dso.h
+++ b/tools/perf/util/dso.h
@@ -259,6 +259,9 @@ int __kmod_path__parse(struct kmod_path *m, const char *path,
259#define kmod_path__parse_name(__m, __p) __kmod_path__parse(__m, __p, true , false) 259#define kmod_path__parse_name(__m, __p) __kmod_path__parse(__m, __p, true , false)
260#define kmod_path__parse_ext(__m, __p) __kmod_path__parse(__m, __p, false, true) 260#define kmod_path__parse_ext(__m, __p) __kmod_path__parse(__m, __p, false, true)
261 261
262void dso__set_module_info(struct dso *dso, struct kmod_path *m,
263 struct machine *machine);
264
262/* 265/*
263 * The dso__data_* external interface provides following functions: 266 * The dso__data_* external interface provides following functions:
264 * dso__data_get_fd 267 * dso__data_get_fd
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
index c40a4d8acf8b..5cac8d5e009a 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -1473,7 +1473,7 @@ static int __event_process_build_id(struct build_id_event *bev,
1473 struct kmod_path m = { .name = NULL, }; 1473 struct kmod_path m = { .name = NULL, };
1474 1474
1475 if (!kmod_path__parse_name(&m, filename) && m.kmod) 1475 if (!kmod_path__parse_name(&m, filename) && m.kmod)
1476 dso__set_short_name(dso, strdup(m.name), true); 1476 dso__set_module_info(dso, &m, machine);
1477 else 1477 else
1478 dso->kernel = dso_type; 1478 dso->kernel = dso_type;
1479 1479
diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index d97e014c3df3..d7f31cb0a4cb 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -572,16 +572,7 @@ static struct dso *machine__findnew_module_dso(struct machine *machine,
572 if (dso == NULL) 572 if (dso == NULL)
573 goto out_unlock; 573 goto out_unlock;
574 574
575 if (machine__is_host(machine)) 575 dso__set_module_info(dso, m, machine);
576 dso->symtab_type = DSO_BINARY_TYPE__SYSTEM_PATH_KMODULE;
577 else
578 dso->symtab_type = DSO_BINARY_TYPE__GUEST_KMODULE;
579
580 /* _KMODULE_COMP should be next to _KMODULE */
581 if (m->kmod && m->comp)
582 dso->symtab_type++;
583
584 dso__set_short_name(dso, strdup(m->name), true);
585 dso__set_long_name(dso, strdup(filename), true); 576 dso__set_long_name(dso, strdup(filename), true);
586 } 577 }
587 578