Commit 9974f496 authored by Mike Galbraith's avatar Mike Galbraith Committed by Ingo Molnar

perf_counter tools: Make symbol loading consistently return number of loaded symbols

perf_counter tools: Make symbol loading consistently return number of loaded symbols.
Signed-off-by: default avatarMike Galbraith <efault@gmx.de>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
LKML-Reference: <1246514758.13293.42.camel@marge.simson.net>
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
parent a92bef0f
...@@ -172,7 +172,7 @@ static int load_kernel(void) ...@@ -172,7 +172,7 @@ static int load_kernel(void)
return -1; return -1;
err = dso__load_kernel(kernel_dso, vmlinux, NULL, verbose); err = dso__load_kernel(kernel_dso, vmlinux, NULL, verbose);
if (err) { if (err <= 0) {
dso__delete(kernel_dso); dso__delete(kernel_dso);
kernel_dso = NULL; kernel_dso = NULL;
} else } else
......
...@@ -189,7 +189,7 @@ static int load_kernel(void) ...@@ -189,7 +189,7 @@ static int load_kernel(void)
return -1; return -1;
err = dso__load_kernel(kernel_dso, vmlinux, NULL, verbose); err = dso__load_kernel(kernel_dso, vmlinux, NULL, verbose);
if (err) { if (err <= 0) {
dso__delete(kernel_dso); dso__delete(kernel_dso);
kernel_dso = NULL; kernel_dso = NULL;
} else } else
......
...@@ -364,7 +364,7 @@ static int parse_symbols(void) ...@@ -364,7 +364,7 @@ static int parse_symbols(void)
if (kernel_dso == NULL) if (kernel_dso == NULL)
return -1; return -1;
if (dso__load_kernel(kernel_dso, NULL, symbol_filter, 1) != 0) if (dso__load_kernel(kernel_dso, NULL, symbol_filter, 1) <= 0)
goto out_delete_dso; goto out_delete_dso;
node = rb_first(&kernel_dso->syms); node = rb_first(&kernel_dso->syms);
......
...@@ -146,6 +146,7 @@ static int dso__load_kallsyms(struct dso *self, symbol_filter_t filter, int verb ...@@ -146,6 +146,7 @@ static int dso__load_kallsyms(struct dso *self, symbol_filter_t filter, int verb
char *line = NULL; char *line = NULL;
size_t n; size_t n;
FILE *file = fopen("/proc/kallsyms", "r"); FILE *file = fopen("/proc/kallsyms", "r");
int count = 0;
if (file == NULL) if (file == NULL)
goto out_failure; goto out_failure;
...@@ -188,8 +189,10 @@ static int dso__load_kallsyms(struct dso *self, symbol_filter_t filter, int verb ...@@ -188,8 +189,10 @@ static int dso__load_kallsyms(struct dso *self, symbol_filter_t filter, int verb
if (filter && filter(self, sym)) if (filter && filter(self, sym))
symbol__delete(sym, self->sym_priv_size); symbol__delete(sym, self->sym_priv_size);
else else {
dso__insert_symbol(self, sym); dso__insert_symbol(self, sym);
count++;
}
} }
/* /*
...@@ -212,7 +215,7 @@ static int dso__load_kallsyms(struct dso *self, symbol_filter_t filter, int verb ...@@ -212,7 +215,7 @@ static int dso__load_kallsyms(struct dso *self, symbol_filter_t filter, int verb
free(line); free(line);
fclose(file); fclose(file);
return 0; return count;
out_delete_line: out_delete_line:
free(line); free(line);
...@@ -639,7 +642,7 @@ int dso__load_kernel(struct dso *self, const char *vmlinux, ...@@ -639,7 +642,7 @@ int dso__load_kernel(struct dso *self, const char *vmlinux,
if (vmlinux) if (vmlinux)
err = dso__load_vmlinux(self, vmlinux, filter, verbose); err = dso__load_vmlinux(self, vmlinux, filter, verbose);
if (err < 0) if (err <= 0)
err = dso__load_kallsyms(self, filter, verbose); err = dso__load_kallsyms(self, filter, verbose);
return err; return err;
......
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