Commit a827c875 authored by Arnaldo Carvalho de Melo's avatar Arnaldo Carvalho de Melo Committed by Ingo Molnar

perf_counter tools: Consolidate dso methods to load kernel symbols

Now one has just to use dso__load_kernel() optionally passing a vmlinux
filename.

Will make things easier for perf top that will want to pass a callback
to filter some symbols.
Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
parent 0085c954
...@@ -118,18 +118,13 @@ static void dsos__fprintf(FILE *fp) ...@@ -118,18 +118,13 @@ static void dsos__fprintf(FILE *fp)
static int load_kernel(void) static int load_kernel(void)
{ {
int err = -1; int err;
kernel_dso = dso__new("[kernel]", 0); kernel_dso = dso__new("[kernel]", 0);
if (!kernel_dso) if (!kernel_dso)
return -1; return -1;
if (vmlinux) err = dso__load_kernel(kernel_dso, vmlinux);
err = dso__load_vmlinux(kernel_dso, vmlinux);
if (err)
err = dso__load_kallsyms(kernel_dso);
if (err) { if (err) {
dso__delete(kernel_dso); dso__delete(kernel_dso);
kernel_dso = NULL; kernel_dso = NULL;
......
...@@ -155,7 +155,7 @@ static int hex2long(char *ptr, unsigned long *long_val) ...@@ -155,7 +155,7 @@ static int hex2long(char *ptr, unsigned long *long_val)
return p - ptr; return p - ptr;
} }
int dso__load_kallsyms(struct dso *self) static int dso__load_kallsyms(struct dso *self)
{ {
struct rb_node *nd, *prevnd; struct rb_node *nd, *prevnd;
char *line = NULL; char *line = NULL;
...@@ -410,7 +410,7 @@ int dso__load(struct dso *self) ...@@ -410,7 +410,7 @@ int dso__load(struct dso *self)
return ret; return ret;
} }
int dso__load_vmlinux(struct dso *self, const char *vmlinux) static int dso__load_vmlinux(struct dso *self, const char *vmlinux)
{ {
int err, fd = open(vmlinux, O_RDONLY); int err, fd = open(vmlinux, O_RDONLY);
...@@ -423,6 +423,19 @@ int dso__load_vmlinux(struct dso *self, const char *vmlinux) ...@@ -423,6 +423,19 @@ int dso__load_vmlinux(struct dso *self, const char *vmlinux)
return err; return err;
} }
int dso__load_kernel(struct dso *self, const char *vmlinux)
{
int err = -1;
if (vmlinux)
err = dso__load_vmlinux(self, vmlinux);
if (err)
err = dso__load_kallsyms(self);
return err;
}
void symbol__init(void) void symbol__init(void)
{ {
elf_version(EV_CURRENT); elf_version(EV_CURRENT);
......
...@@ -29,8 +29,7 @@ static inline void *dso__sym_priv(struct dso *self, struct symbol *sym) ...@@ -29,8 +29,7 @@ static inline void *dso__sym_priv(struct dso *self, struct symbol *sym)
struct symbol *dso__find_symbol(struct dso *self, uint64_t ip); struct symbol *dso__find_symbol(struct dso *self, uint64_t ip);
int dso__load_kallsyms(struct dso *self); int dso__load_kernel(struct dso *self, const char *vmlinux);
int dso__load_vmlinux(struct dso *self, const char *vmlinux);
int dso__load(struct dso *self); int dso__load(struct dso *self);
size_t dso__fprintf(struct dso *self, FILE *fp); size_t dso__fprintf(struct dso *self, FILE *fp);
......
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