aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2011-02-05 15:51:38 -0500
committerArnaldo Carvalho de Melo <acme@redhat.com>2011-02-06 10:40:31 -0500
commitf1e2701de02cff6d988b1dd49960620d5720cb89 (patch)
treed8d0c92eca89d01dd2b8d25554244aa3cc4eec10 /tools/perf
parentd040bd363824f9f0ad6610b91ee6c65f292c066c (diff)
perf annotate: Separate objdump parsing from actual screen rendering
Because in 'perf top' we'll need to parse just once and then, as samples come, render multiple times with evolving counter values. Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Ingo Molnar <mingo@elte.hu> Cc: Mike Galbraith <efault@gmx.de> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Stephane Eranian <eranian@google.com> Cc: Tom Zanussi <tzanussi@gmail.com> LKML-Reference: <new-submission> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf')
-rw-r--r--tools/perf/util/annotate.c62
-rw-r--r--tools/perf/util/annotate.h4
2 files changed, 47 insertions, 19 deletions
diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
index 072bc8d91aa1..10cdbad76058 100644
--- a/tools/perf/util/annotate.c
+++ b/tools/perf/util/annotate.c
@@ -421,21 +421,16 @@ static void symbol__annotate_hits(struct symbol *sym, int evidx)
421 printf("%*s: %" PRIu64 "\n", BITS_PER_LONG / 2, "h->sum", h->sum); 421 printf("%*s: %" PRIu64 "\n", BITS_PER_LONG / 2, "h->sum", h->sum);
422} 422}
423 423
424int symbol__tty_annotate(struct symbol *sym, struct map *map, int evidx, 424void symbol__annotate_printf(struct symbol *sym, struct map *map,
425 bool print_lines, bool full_paths, int min_pcnt, 425 struct list_head *head, int evidx, bool full_paths,
426 int max_lines) 426 int min_pcnt, int max_lines)
427{ 427{
428 struct dso *dso = map->dso; 428 struct dso *dso = map->dso;
429 const char *filename = dso->long_name, *d_filename; 429 const char *filename = dso->long_name, *d_filename;
430 struct rb_root source_line = RB_ROOT; 430 struct objdump_line *pos;
431 struct objdump_line *pos, *n;
432 LIST_HEAD(head);
433 int printed = 2; 431 int printed = 2;
434 u64 len; 432 u64 len;
435 433
436 if (symbol__annotate(sym, map, &head, 0) < 0)
437 return -1;
438
439 if (full_paths) 434 if (full_paths)
440 d_filename = filename; 435 d_filename = filename;
441 else 436 else
@@ -443,28 +438,57 @@ int symbol__tty_annotate(struct symbol *sym, struct map *map, int evidx,
443 438
444 len = sym->end - sym->start; 439 len = sym->end - sym->start;
445 440
446 if (print_lines) {
447 symbol__get_source_line(sym, map, evidx, &source_line,
448 len, filename);
449 print_summary(&source_line, filename);
450 }
451
452 printf(" Percent | Source code & Disassembly of %s\n", d_filename); 441 printf(" Percent | Source code & Disassembly of %s\n", d_filename);
453 printf("------------------------------------------------\n"); 442 printf("------------------------------------------------\n");
454 443
455 if (verbose) 444 if (verbose)
456 symbol__annotate_hits(sym, evidx); 445 symbol__annotate_hits(sym, evidx);
457 446
458 list_for_each_entry_safe(pos, n, &head, node) { 447 list_for_each_entry(pos, head, node) {
459 objdump_line__print(pos, &head, sym, evidx, len, min_pcnt); 448 objdump_line__print(pos, head, sym, evidx, len, min_pcnt);
460 list_del(&pos->node);
461 objdump_line__free(pos);
462 if (max_lines && ++printed >= max_lines) 449 if (max_lines && ++printed >= max_lines)
463 break; 450 break;
451
452 }
453}
454
455void objdump_line_list__purge(struct list_head *head)
456{
457 struct objdump_line *pos, *n;
458
459 list_for_each_entry_safe(pos, n, head, node) {
460 list_del(&pos->node);
461 objdump_line__free(pos);
462 }
463}
464
465int symbol__tty_annotate(struct symbol *sym, struct map *map, int evidx,
466 bool print_lines, bool full_paths, int min_pcnt,
467 int max_lines)
468{
469 struct dso *dso = map->dso;
470 const char *filename = dso->long_name;
471 struct rb_root source_line = RB_ROOT;
472 LIST_HEAD(head);
473 u64 len;
474
475 if (symbol__annotate(sym, map, &head, 0) < 0)
476 return -1;
477
478 len = sym->end - sym->start;
479
480 if (print_lines) {
481 symbol__get_source_line(sym, map, evidx, &source_line,
482 len, filename);
483 print_summary(&source_line, filename);
464 } 484 }
465 485
486 symbol__annotate_printf(sym, map, &head, evidx, full_paths,
487 min_pcnt, max_lines);
466 if (print_lines) 488 if (print_lines)
467 symbol__free_source_line(sym, len); 489 symbol__free_source_line(sym, len);
468 490
491 objdump_line_list__purge(&head);
492
469 return 0; 493 return 0;
470} 494}
diff --git a/tools/perf/util/annotate.h b/tools/perf/util/annotate.h
index 6b707324e66f..53dd92de2615 100644
--- a/tools/perf/util/annotate.h
+++ b/tools/perf/util/annotate.h
@@ -67,6 +67,10 @@ int symbol__alloc_hist(struct symbol *sym, int nevents);
67 67
68int symbol__annotate(struct symbol *sym, struct map *map, 68int symbol__annotate(struct symbol *sym, struct map *map,
69 struct list_head *head, size_t privsize); 69 struct list_head *head, size_t privsize);
70void symbol__annotate_printf(struct symbol *sym, struct map *map,
71 struct list_head *head, int evidx, bool full_paths,
72 int min_pcnt, int max_lines);
73void objdump_line_list__purge(struct list_head *head);
70 74
71int symbol__tty_annotate(struct symbol *sym, struct map *map, int evidx, 75int symbol__tty_annotate(struct symbol *sym, struct map *map, int evidx,
72 bool print_lines, bool full_paths, int min_pcnt, 76 bool print_lines, bool full_paths, int min_pcnt,