diff options
Diffstat (limited to 'tools/perf/ui/browsers/annotate.c')
-rw-r--r-- | tools/perf/ui/browsers/annotate.c | 76 |
1 files changed, 61 insertions, 15 deletions
diff --git a/tools/perf/ui/browsers/annotate.c b/tools/perf/ui/browsers/annotate.c index 3b4f1c10ff57..1d00e5ec7906 100644 --- a/tools/perf/ui/browsers/annotate.c +++ b/tools/perf/ui/browsers/annotate.c | |||
@@ -15,6 +15,7 @@ | |||
15 | #include <linux/kernel.h> | 15 | #include <linux/kernel.h> |
16 | #include <linux/string.h> | 16 | #include <linux/string.h> |
17 | #include <sys/ttydefaults.h> | 17 | #include <sys/ttydefaults.h> |
18 | #include <asm/bug.h> | ||
18 | 19 | ||
19 | struct disasm_line_samples { | 20 | struct disasm_line_samples { |
20 | double percent; | 21 | double percent; |
@@ -115,7 +116,7 @@ static void annotate_browser__write(struct ui_browser *browser, void *entry, int | |||
115 | if (!browser->navkeypressed) | 116 | if (!browser->navkeypressed) |
116 | ops.width += 1; | 117 | ops.width += 1; |
117 | 118 | ||
118 | annotation_line__write(al, notes, &ops); | 119 | annotation_line__write(al, notes, &ops, ab->opts); |
119 | 120 | ||
120 | if (ops.current_entry) | 121 | if (ops.current_entry) |
121 | ab->selection = al; | 122 | ab->selection = al; |
@@ -227,10 +228,10 @@ static int disasm__cmp(struct annotation_line *a, struct annotation_line *b) | |||
227 | { | 228 | { |
228 | int i; | 229 | int i; |
229 | 230 | ||
230 | for (i = 0; i < a->samples_nr; i++) { | 231 | for (i = 0; i < a->data_nr; i++) { |
231 | if (a->samples[i].percent == b->samples[i].percent) | 232 | if (a->data[i].percent == b->data[i].percent) |
232 | continue; | 233 | continue; |
233 | return a->samples[i].percent < b->samples[i].percent; | 234 | return a->data[i].percent < b->data[i].percent; |
234 | } | 235 | } |
235 | return 0; | 236 | return 0; |
236 | } | 237 | } |
@@ -314,11 +315,14 @@ static void annotate_browser__calc_percent(struct annotate_browser *browser, | |||
314 | continue; | 315 | continue; |
315 | } | 316 | } |
316 | 317 | ||
317 | for (i = 0; i < pos->al.samples_nr; i++) { | 318 | for (i = 0; i < pos->al.data_nr; i++) { |
318 | struct annotation_data *sample = &pos->al.samples[i]; | 319 | double percent; |
319 | 320 | ||
320 | if (max_percent < sample->percent) | 321 | percent = annotation_data__percent(&pos->al.data[i], |
321 | max_percent = sample->percent; | 322 | browser->opts->percent_type); |
323 | |||
324 | if (max_percent < percent) | ||
325 | max_percent = percent; | ||
322 | } | 326 | } |
323 | 327 | ||
324 | if (max_percent < 0.01 && pos->al.ipc == 0) { | 328 | if (max_percent < 0.01 && pos->al.ipc == 0) { |
@@ -380,9 +384,10 @@ static void ui_browser__init_asm_mode(struct ui_browser *browser) | |||
380 | #define SYM_TITLE_MAX_SIZE (PATH_MAX + 64) | 384 | #define SYM_TITLE_MAX_SIZE (PATH_MAX + 64) |
381 | 385 | ||
382 | static int sym_title(struct symbol *sym, struct map *map, char *title, | 386 | static int sym_title(struct symbol *sym, struct map *map, char *title, |
383 | size_t sz) | 387 | size_t sz, int percent_type) |
384 | { | 388 | { |
385 | return snprintf(title, sz, "%s %s", sym->name, map->dso->long_name); | 389 | return snprintf(title, sz, "%s %s [Percent: %s]", sym->name, map->dso->long_name, |
390 | percent_type_str(percent_type)); | ||
386 | } | 391 | } |
387 | 392 | ||
388 | /* | 393 | /* |
@@ -420,7 +425,7 @@ static bool annotate_browser__callq(struct annotate_browser *browser, | |||
420 | 425 | ||
421 | pthread_mutex_unlock(¬es->lock); | 426 | pthread_mutex_unlock(¬es->lock); |
422 | symbol__tui_annotate(dl->ops.target.sym, ms->map, evsel, hbt, browser->opts); | 427 | symbol__tui_annotate(dl->ops.target.sym, ms->map, evsel, hbt, browser->opts); |
423 | sym_title(ms->sym, ms->map, title, sizeof(title)); | 428 | sym_title(ms->sym, ms->map, title, sizeof(title), browser->opts->percent_type); |
424 | ui_browser__show_title(&browser->b, title); | 429 | ui_browser__show_title(&browser->b, title); |
425 | return true; | 430 | return true; |
426 | } | 431 | } |
@@ -595,6 +600,7 @@ bool annotate_browser__continue_search_reverse(struct annotate_browser *browser, | |||
595 | 600 | ||
596 | static int annotate_browser__show(struct ui_browser *browser, char *title, const char *help) | 601 | static int annotate_browser__show(struct ui_browser *browser, char *title, const char *help) |
597 | { | 602 | { |
603 | struct annotate_browser *ab = container_of(browser, struct annotate_browser, b); | ||
598 | struct map_symbol *ms = browser->priv; | 604 | struct map_symbol *ms = browser->priv; |
599 | struct symbol *sym = ms->sym; | 605 | struct symbol *sym = ms->sym; |
600 | char symbol_dso[SYM_TITLE_MAX_SIZE]; | 606 | char symbol_dso[SYM_TITLE_MAX_SIZE]; |
@@ -602,7 +608,7 @@ static int annotate_browser__show(struct ui_browser *browser, char *title, const | |||
602 | if (ui_browser__show(browser, title, help) < 0) | 608 | if (ui_browser__show(browser, title, help) < 0) |
603 | return -1; | 609 | return -1; |
604 | 610 | ||
605 | sym_title(sym, ms->map, symbol_dso, sizeof(symbol_dso)); | 611 | sym_title(sym, ms->map, symbol_dso, sizeof(symbol_dso), ab->opts->percent_type); |
606 | 612 | ||
607 | ui_browser__gotorc_title(browser, 0, 0); | 613 | ui_browser__gotorc_title(browser, 0, 0); |
608 | ui_browser__set_color(browser, HE_COLORSET_ROOT); | 614 | ui_browser__set_color(browser, HE_COLORSET_ROOT); |
@@ -610,6 +616,39 @@ static int annotate_browser__show(struct ui_browser *browser, char *title, const | |||
610 | return 0; | 616 | return 0; |
611 | } | 617 | } |
612 | 618 | ||
619 | static void | ||
620 | switch_percent_type(struct annotation_options *opts, bool base) | ||
621 | { | ||
622 | switch (opts->percent_type) { | ||
623 | case PERCENT_HITS_LOCAL: | ||
624 | if (base) | ||
625 | opts->percent_type = PERCENT_PERIOD_LOCAL; | ||
626 | else | ||
627 | opts->percent_type = PERCENT_HITS_GLOBAL; | ||
628 | break; | ||
629 | case PERCENT_HITS_GLOBAL: | ||
630 | if (base) | ||
631 | opts->percent_type = PERCENT_PERIOD_GLOBAL; | ||
632 | else | ||
633 | opts->percent_type = PERCENT_HITS_LOCAL; | ||
634 | break; | ||
635 | case PERCENT_PERIOD_LOCAL: | ||
636 | if (base) | ||
637 | opts->percent_type = PERCENT_HITS_LOCAL; | ||
638 | else | ||
639 | opts->percent_type = PERCENT_PERIOD_GLOBAL; | ||
640 | break; | ||
641 | case PERCENT_PERIOD_GLOBAL: | ||
642 | if (base) | ||
643 | opts->percent_type = PERCENT_HITS_GLOBAL; | ||
644 | else | ||
645 | opts->percent_type = PERCENT_PERIOD_LOCAL; | ||
646 | break; | ||
647 | default: | ||
648 | WARN_ON(1); | ||
649 | } | ||
650 | } | ||
651 | |||
613 | static int annotate_browser__run(struct annotate_browser *browser, | 652 | static int annotate_browser__run(struct annotate_browser *browser, |
614 | struct perf_evsel *evsel, | 653 | struct perf_evsel *evsel, |
615 | struct hist_browser_timer *hbt) | 654 | struct hist_browser_timer *hbt) |
@@ -624,8 +663,7 @@ static int annotate_browser__run(struct annotate_browser *browser, | |||
624 | char title[256]; | 663 | char title[256]; |
625 | int key; | 664 | int key; |
626 | 665 | ||
627 | annotation__scnprintf_samples_period(notes, title, sizeof(title), evsel); | 666 | hists__scnprintf_title(hists, title, sizeof(title)); |
628 | |||
629 | if (annotate_browser__show(&browser->b, title, help) < 0) | 667 | if (annotate_browser__show(&browser->b, title, help) < 0) |
630 | return -1; | 668 | return -1; |
631 | 669 | ||
@@ -701,6 +739,8 @@ static int annotate_browser__run(struct annotate_browser *browser, | |||
701 | "k Toggle line numbers\n" | 739 | "k Toggle line numbers\n" |
702 | "P Print to [symbol_name].annotation file.\n" | 740 | "P Print to [symbol_name].annotation file.\n" |
703 | "r Run available scripts\n" | 741 | "r Run available scripts\n" |
742 | "p Toggle percent type [local/global]\n" | ||
743 | "b Toggle percent base [period/hits]\n" | ||
704 | "? Search string backwards\n"); | 744 | "? Search string backwards\n"); |
705 | continue; | 745 | continue; |
706 | case 'r': | 746 | case 'r': |
@@ -781,7 +821,7 @@ show_sup_ins: | |||
781 | continue; | 821 | continue; |
782 | } | 822 | } |
783 | case 'P': | 823 | case 'P': |
784 | map_symbol__annotation_dump(ms, evsel); | 824 | map_symbol__annotation_dump(ms, evsel, browser->opts); |
785 | continue; | 825 | continue; |
786 | case 't': | 826 | case 't': |
787 | if (notes->options->show_total_period) { | 827 | if (notes->options->show_total_period) { |
@@ -800,6 +840,12 @@ show_sup_ins: | |||
800 | notes->options->show_minmax_cycle = true; | 840 | notes->options->show_minmax_cycle = true; |
801 | annotation__update_column_widths(notes); | 841 | annotation__update_column_widths(notes); |
802 | continue; | 842 | continue; |
843 | case 'p': | ||
844 | case 'b': | ||
845 | switch_percent_type(browser->opts, key == 'b'); | ||
846 | hists__scnprintf_title(hists, title, sizeof(title)); | ||
847 | annotate_browser__show(&browser->b, title, help); | ||
848 | continue; | ||
803 | case K_LEFT: | 849 | case K_LEFT: |
804 | case K_ESC: | 850 | case K_ESC: |
805 | case 'q': | 851 | case 'q': |