Skip to content

Commit 7d132ca

Browse files
committed
perf machine: Add a kallsyms loading constructor
To reduce the boilerplate for searching for functions in the running kernel and modules. Cc: Adrian Hunter <[email protected]> Cc: David Ahern <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Masami Hiramatsu <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Wang Nan <[email protected]> Link: http://lkml.kernel.org/n/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent d5f805c commit 7d132ca

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

tools/perf/util/machine.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,25 @@ struct machine *machine__new_host(void)
8787
return NULL;
8888
}
8989

90+
struct machine *machine__new_kallsyms(void)
91+
{
92+
struct machine *machine = machine__new_host();
93+
/*
94+
* FIXME:
95+
* 1) MAP__FUNCTION will go away when we stop loading separate maps for
96+
* functions and data objects.
97+
* 2) We should switch to machine__load_kallsyms(), i.e. not explicitely
98+
* ask for not using the kcore parsing code, once this one is fixed
99+
* to create a map per module.
100+
*/
101+
if (machine && __machine__load_kallsyms(machine, "/proc/kallsyms", MAP__FUNCTION, true) <= 0) {
102+
machine__delete(machine);
103+
machine = NULL;
104+
}
105+
106+
return machine;
107+
}
108+
90109
static void dsos__purge(struct dsos *dsos)
91110
{
92111
struct dso *pos, *n;

tools/perf/util/machine.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ char *machine__mmap_name(struct machine *machine, char *bf, size_t size);
129129
void machines__set_comm_exec(struct machines *machines, bool comm_exec);
130130

131131
struct machine *machine__new_host(void);
132+
struct machine *machine__new_kallsyms(void);
132133
int machine__init(struct machine *machine, const char *root_dir, pid_t pid);
133134
void machine__exit(struct machine *machine);
134135
void machine__delete_threads(struct machine *machine);

0 commit comments

Comments
 (0)