perf_counter tools: Make symbol loading consistently return number of loaded symbols
authorMike Galbraith <efault@gmx.de>
Thu, 2 Jul 2009 06:05:58 +0000 (08:05 +0200)
committerIngo Molnar <mingo@elte.hu>
Thu, 2 Jul 2009 06:42:20 +0000 (08:42 +0200)
perf_counter tools: Make symbol loading consistently return number of loaded symbols.

Signed-off-by: Mike 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: Ingo Molnar <mingo@elte.hu>
tools/perf/builtin-annotate.c
tools/perf/builtin-report.c
tools/perf/builtin-top.c
tools/perf/util/symbol.c

index 132de8b28dbb066fdbf33edb7eb05a3ec97c8698..3becc8a35bee1737bf9d3343ab5d11d2c9ccc53a 100644 (file)
@@ -172,7 +172,7 @@ static int load_kernel(void)
                return -1;
 
        err = dso__load_kernel(kernel_dso, vmlinux, NULL, verbose);
-       if (err) {
+       if (err <= 0) {
                dso__delete(kernel_dso);
                kernel_dso = NULL;
        } else
index be1b7584796dd53668815d21568fb63c4957a681..58d1612894ffad3c8cd68a8ea01e6ffaf81f9730 100644 (file)
@@ -189,7 +189,7 @@ static int load_kernel(void)
                return -1;
 
        err = dso__load_kernel(kernel_dso, vmlinux, NULL, verbose);
-       if (err) {
+       if (err <= 0) {
                dso__delete(kernel_dso);
                kernel_dso = NULL;
        } else
index cdc74cfb15178fc7f0b1147f3cfaaece066077f0..97fde1d84365540cffce7738ea17ef8f2121f2d7 100644 (file)
@@ -364,7 +364,7 @@ static int parse_symbols(void)
        if (kernel_dso == NULL)
                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;
 
        node = rb_first(&kernel_dso->syms);
index 78c2efde01b7bee7a52665969cf0fcb87917b481..c077b6a146904de76604b30210d8d262f9ef9452 100644 (file)
@@ -146,6 +146,7 @@ static int dso__load_kallsyms(struct dso *self, symbol_filter_t filter, int verb
        char *line = NULL;
        size_t n;
        FILE *file = fopen("/proc/kallsyms", "r");
+       int count = 0;
 
        if (file == NULL)
                goto out_failure;
@@ -188,8 +189,10 @@ static int dso__load_kallsyms(struct dso *self, symbol_filter_t filter, int verb
 
                if (filter && filter(self, sym))
                        symbol__delete(sym, self->sym_priv_size);
-               else
+               else {
                        dso__insert_symbol(self, sym);
+                       count++;
+               }
        }
 
        /*
@@ -212,7 +215,7 @@ static int dso__load_kallsyms(struct dso *self, symbol_filter_t filter, int verb
        free(line);
        fclose(file);
 
-       return 0;
+       return count;
 
 out_delete_line:
        free(line);
@@ -639,7 +642,7 @@ int dso__load_kernel(struct dso *self, const char *vmlinux,
        if (vmlinux)
                err = dso__load_vmlinux(self, vmlinux, filter, verbose);
 
-       if (err < 0)
+       if (err <= 0)
                err = dso__load_kallsyms(self, filter, verbose);
 
        return err;