aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf
diff options
context:
space:
mode:
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,