diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2009-05-26 12:21:34 -0300 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-05-26 17:36:13 +0200 |
commit | abd54f68629fa73ed4fa040d433196211a9bbed2 (patch) | |
tree | b2aaf0d240f2520861ddc36511e745f0fe7c7e47 /Documentation/perf_counter/builtin-report.c | |
parent | 59d81029b6804c3d5895d07cad77d7dfddc6b5b2 (diff) | |
download | lwn-abd54f68629fa73ed4fa040d433196211a9bbed2.tar.gz lwn-abd54f68629fa73ed4fa040d433196211a9bbed2.zip |
perf: Don't assume /proc/kallsyms is ordered
perf: Don't assume /proc/kallsyms is ordered
Since we _are_ ordering it by the symbol start, just traverse the
freshly built rbtree setting the prev->end members to curr->start - 1.
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: Marcelo Tosatti <mtosatti@redhat.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: John Kacur <jkacur@redhat.com>
LKML-Reference: <20090526152134.GF4424@ghostprotocols.net>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'Documentation/perf_counter/builtin-report.c')
-rw-r--r-- | Documentation/perf_counter/builtin-report.c | 44 |
1 files changed, 25 insertions, 19 deletions
diff --git a/Documentation/perf_counter/builtin-report.c b/Documentation/perf_counter/builtin-report.c index b19b893d4ff5..e17819001dd5 100644 --- a/Documentation/perf_counter/builtin-report.c +++ b/Documentation/perf_counter/builtin-report.c @@ -360,17 +360,9 @@ static int load_kallsyms(void) char *line = NULL; size_t n; - if (getline(&line, &n, file) < 0 || !line) - goto out_delete_dso; - - unsigned long long previous_start; - char c, previous_symbf[4096]; - if (sscanf(line, "%llx %c %s", &previous_start, &c, previous_symbf) != 3) - goto out_delete_line; - while (!feof(file)) { unsigned long long start; - char symbf[4096]; + char c, symbf[4096]; if (getline(&line, &n, file) < 0) break; @@ -379,21 +371,35 @@ static int load_kallsyms(void) goto out_delete_dso; if (sscanf(line, "%llx %c %s", &start, &c, symbf) == 3) { - if (start > previous_start) { - struct symbol *sym = symbol__new(previous_start, - start - previous_start, - previous_symbf); + /* + * Well fix up the end later, when we have all sorted. + */ + struct symbol *sym = symbol__new(start, 0xdead, symbf); - if (sym == NULL) - goto out_delete_dso; + if (sym == NULL) + goto out_delete_dso; - dso__insert_symbol(kernel_dso, sym); - previous_start = start; - strcpy(previous_symbf, symbf); - } + dso__insert_symbol(kernel_dso, sym); } } + /* + * Now that we have all sorted out, just set the ->end of all + * symbols + */ + struct rb_node *nd, *prevnd = rb_first(&kernel_dso->syms); + + if (prevnd == NULL) + goto out_delete_line; + + for (nd = rb_next(prevnd); nd; nd = rb_next(nd)) { + struct symbol *prev = rb_entry(prevnd, struct symbol, rb_node), + *curr = rb_entry(nd, struct symbol, rb_node); + + prev->end = curr->start - 1; + prevnd = nd; + } + dsos__add(kernel_dso); free(line); fclose(file); |