diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2009-05-26 11:21:34 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-05-26 11:36:13 -0400 |
commit | abd54f68629fa73ed4fa040d433196211a9bbed2 (patch) | |
tree | b2aaf0d240f2520861ddc36511e745f0fe7c7e47 /Documentation/perf_counter/builtin-report.c | |
parent | 59d81029b6804c3d5895d07cad77d7dfddc6b5b2 (diff) |
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) | |||
360 | char *line = NULL; | 360 | char *line = NULL; |
361 | size_t n; | 361 | size_t n; |
362 | 362 | ||
363 | if (getline(&line, &n, file) < 0 || !line) | ||
364 | goto out_delete_dso; | ||
365 | |||
366 | unsigned long long previous_start; | ||
367 | char c, previous_symbf[4096]; | ||
368 | if (sscanf(line, "%llx %c %s", &previous_start, &c, previous_symbf) != 3) | ||
369 | goto out_delete_line; | ||
370 | |||
371 | while (!feof(file)) { | 363 | while (!feof(file)) { |
372 | unsigned long long start; | 364 | unsigned long long start; |
373 | char symbf[4096]; | 365 | char c, symbf[4096]; |
374 | 366 | ||
375 | if (getline(&line, &n, file) < 0) | 367 | if (getline(&line, &n, file) < 0) |
376 | break; | 368 | break; |
@@ -379,21 +371,35 @@ static int load_kallsyms(void) | |||
379 | goto out_delete_dso; | 371 | goto out_delete_dso; |
380 | 372 | ||
381 | if (sscanf(line, "%llx %c %s", &start, &c, symbf) == 3) { | 373 | if (sscanf(line, "%llx %c %s", &start, &c, symbf) == 3) { |
382 | if (start > previous_start) { | 374 | /* |
383 | struct symbol *sym = symbol__new(previous_start, | 375 | * Well fix up the end later, when we have all sorted. |
384 | start - previous_start, | 376 | */ |
385 | previous_symbf); | 377 | struct symbol *sym = symbol__new(start, 0xdead, symbf); |
386 | 378 | ||
387 | if (sym == NULL) | 379 | if (sym == NULL) |
388 | goto out_delete_dso; | 380 | goto out_delete_dso; |
389 | 381 | ||
390 | dso__insert_symbol(kernel_dso, sym); | 382 | dso__insert_symbol(kernel_dso, sym); |
391 | previous_start = start; | ||
392 | strcpy(previous_symbf, symbf); | ||
393 | } | ||
394 | } | 383 | } |
395 | } | 384 | } |
396 | 385 | ||
386 | /* | ||
387 | * Now that we have all sorted out, just set the ->end of all | ||
388 | * symbols | ||
389 | */ | ||
390 | struct rb_node *nd, *prevnd = rb_first(&kernel_dso->syms); | ||
391 | |||
392 | if (prevnd == NULL) | ||
393 | goto out_delete_line; | ||
394 | |||
395 | for (nd = rb_next(prevnd); nd; nd = rb_next(nd)) { | ||
396 | struct symbol *prev = rb_entry(prevnd, struct symbol, rb_node), | ||
397 | *curr = rb_entry(nd, struct symbol, rb_node); | ||
398 | |||
399 | prev->end = curr->start - 1; | ||
400 | prevnd = nd; | ||
401 | } | ||
402 | |||
397 | dsos__add(kernel_dso); | 403 | dsos__add(kernel_dso); |
398 | free(line); | 404 | free(line); |
399 | fclose(file); | 405 | fclose(file); |