Skip to content

Commit

Permalink
perf symbols: Set module info when build-id event found
Browse files Browse the repository at this point in the history
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 <[email protected]>
Acked-by: Jiri Olsa <[email protected]>
Cc: Andi Kleen <[email protected]>
Cc: David Ahern <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: [email protected]
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
  • Loading branch information
namhyung authored and acmel committed Jun 5, 2017
1 parent 1deec1b commit 6b335e8
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 11 deletions.
15 changes: 15 additions & 0 deletions tools/perf/util/dso.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
3 changes: 3 additions & 0 deletions tools/perf/util/dso.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tools/perf/util/header.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
11 changes: 1 addition & 10 deletions tools/perf/util/machine.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down

0 comments on commit 6b335e8

Please sign in to comment.