static int load_kernel(void)
{
- int err = -1;
+ int err;
kernel_dso = dso__new("[kernel]", 0);
if (!kernel_dso)
return -1;
- if (vmlinux)
- err = dso__load_vmlinux(kernel_dso, vmlinux);
-
- if (err)
- err = dso__load_kallsyms(kernel_dso);
-
+ err = dso__load_kernel(kernel_dso, vmlinux);
if (err) {
dso__delete(kernel_dso);
kernel_dso = NULL;
return p - ptr;
}
-int dso__load_kallsyms(struct dso *self)
+static int dso__load_kallsyms(struct dso *self)
{
struct rb_node *nd, *prevnd;
char *line = NULL;
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);
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)
{
elf_version(EV_CURRENT);
struct symbol *dso__find_symbol(struct dso *self, uint64_t ip);
-int dso__load_kallsyms(struct dso *self);
-int dso__load_vmlinux(struct dso *self, const char *vmlinux);
+int dso__load_kernel(struct dso *self, const char *vmlinux);
int dso__load(struct dso *self);
size_t dso__fprintf(struct dso *self, FILE *fp);