diff options
Diffstat (limited to 'tools/perf')
-rw-r--r-- | tools/perf/ui/browsers/hists.c | 62 | ||||
-rw-r--r-- | tools/perf/ui/gtk/hists.c | 2 | ||||
-rw-r--r-- | tools/perf/ui/hist.c | 28 | ||||
-rw-r--r-- | tools/perf/util/hist.h | 4 |
4 files changed, 34 insertions, 62 deletions
diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c index 847de116b9ec..37c5188fd68a 100644 --- a/tools/perf/ui/browsers/hists.c +++ b/tools/perf/ui/browsers/hists.c | |||
@@ -616,35 +616,6 @@ struct hpp_arg { | |||
616 | bool current_entry; | 616 | bool current_entry; |
617 | }; | 617 | }; |
618 | 618 | ||
619 | static int __hpp__overhead_callback(struct perf_hpp *hpp, bool front) | ||
620 | { | ||
621 | struct hpp_arg *arg = hpp->ptr; | ||
622 | |||
623 | if (arg->current_entry && arg->b->navkeypressed) | ||
624 | ui_browser__set_color(arg->b, HE_COLORSET_SELECTED); | ||
625 | else | ||
626 | ui_browser__set_color(arg->b, HE_COLORSET_NORMAL); | ||
627 | |||
628 | if (front) { | ||
629 | if (!symbol_conf.use_callchain) | ||
630 | return 0; | ||
631 | |||
632 | slsmg_printf("%c ", arg->folded_sign); | ||
633 | return 2; | ||
634 | } | ||
635 | |||
636 | return 0; | ||
637 | } | ||
638 | |||
639 | static int __hpp__color_callback(struct perf_hpp *hpp, bool front __maybe_unused) | ||
640 | { | ||
641 | struct hpp_arg *arg = hpp->ptr; | ||
642 | |||
643 | if (!arg->current_entry || !arg->b->navkeypressed) | ||
644 | ui_browser__set_color(arg->b, HE_COLORSET_NORMAL); | ||
645 | return 0; | ||
646 | } | ||
647 | |||
648 | static int __hpp__slsmg_color_printf(struct perf_hpp *hpp, const char *fmt, ...) | 619 | static int __hpp__slsmg_color_printf(struct perf_hpp *hpp, const char *fmt, ...) |
649 | { | 620 | { |
650 | struct hpp_arg *arg = hpp->ptr; | 621 | struct hpp_arg *arg = hpp->ptr; |
@@ -665,7 +636,7 @@ static int __hpp__slsmg_color_printf(struct perf_hpp *hpp, const char *fmt, ...) | |||
665 | return ret; | 636 | return ret; |
666 | } | 637 | } |
667 | 638 | ||
668 | #define __HPP_COLOR_PERCENT_FN(_type, _field, _cb) \ | 639 | #define __HPP_COLOR_PERCENT_FN(_type, _field) \ |
669 | static u64 __hpp_get_##_field(struct hist_entry *he) \ | 640 | static u64 __hpp_get_##_field(struct hist_entry *he) \ |
670 | { \ | 641 | { \ |
671 | return he->stat._field; \ | 642 | return he->stat._field; \ |
@@ -676,15 +647,15 @@ hist_browser__hpp_color_##_type(struct perf_hpp_fmt *fmt __maybe_unused,\ | |||
676 | struct perf_hpp *hpp, \ | 647 | struct perf_hpp *hpp, \ |
677 | struct hist_entry *he) \ | 648 | struct hist_entry *he) \ |
678 | { \ | 649 | { \ |
679 | return __hpp__fmt(hpp, he, __hpp_get_##_field, _cb, " %6.2f%%", \ | 650 | return __hpp__fmt(hpp, he, __hpp_get_##_field, " %6.2f%%", \ |
680 | __hpp__slsmg_color_printf, true); \ | 651 | __hpp__slsmg_color_printf, true); \ |
681 | } | 652 | } |
682 | 653 | ||
683 | __HPP_COLOR_PERCENT_FN(overhead, period, __hpp__overhead_callback) | 654 | __HPP_COLOR_PERCENT_FN(overhead, period) |
684 | __HPP_COLOR_PERCENT_FN(overhead_sys, period_sys, __hpp__color_callback) | 655 | __HPP_COLOR_PERCENT_FN(overhead_sys, period_sys) |
685 | __HPP_COLOR_PERCENT_FN(overhead_us, period_us, __hpp__color_callback) | 656 | __HPP_COLOR_PERCENT_FN(overhead_us, period_us) |
686 | __HPP_COLOR_PERCENT_FN(overhead_guest_sys, period_guest_sys, __hpp__color_callback) | 657 | __HPP_COLOR_PERCENT_FN(overhead_guest_sys, period_guest_sys) |
687 | __HPP_COLOR_PERCENT_FN(overhead_guest_us, period_guest_us, __hpp__color_callback) | 658 | __HPP_COLOR_PERCENT_FN(overhead_guest_us, period_guest_us) |
688 | 659 | ||
689 | #undef __HPP_COLOR_PERCENT_FN | 660 | #undef __HPP_COLOR_PERCENT_FN |
690 | 661 | ||
@@ -729,7 +700,7 @@ static int hist_browser__show_entry(struct hist_browser *browser, | |||
729 | 700 | ||
730 | if (row_offset == 0) { | 701 | if (row_offset == 0) { |
731 | struct hpp_arg arg = { | 702 | struct hpp_arg arg = { |
732 | .b = &browser->b, | 703 | .b = &browser->b, |
733 | .folded_sign = folded_sign, | 704 | .folded_sign = folded_sign, |
734 | .current_entry = current_entry, | 705 | .current_entry = current_entry, |
735 | }; | 706 | }; |
@@ -742,11 +713,24 @@ static int hist_browser__show_entry(struct hist_browser *browser, | |||
742 | ui_browser__gotorc(&browser->b, row, 0); | 713 | ui_browser__gotorc(&browser->b, row, 0); |
743 | 714 | ||
744 | perf_hpp__for_each_format(fmt) { | 715 | perf_hpp__for_each_format(fmt) { |
745 | if (!first) { | 716 | if (current_entry && browser->b.navkeypressed) { |
717 | ui_browser__set_color(&browser->b, | ||
718 | HE_COLORSET_SELECTED); | ||
719 | } else { | ||
720 | ui_browser__set_color(&browser->b, | ||
721 | HE_COLORSET_NORMAL); | ||
722 | } | ||
723 | |||
724 | if (first) { | ||
725 | if (symbol_conf.use_callchain) { | ||
726 | slsmg_printf("%c ", folded_sign); | ||
727 | width -= 2; | ||
728 | } | ||
729 | first = false; | ||
730 | } else { | ||
746 | slsmg_printf(" "); | 731 | slsmg_printf(" "); |
747 | width -= 2; | 732 | width -= 2; |
748 | } | 733 | } |
749 | first = false; | ||
750 | 734 | ||
751 | if (fmt->color) { | 735 | if (fmt->color) { |
752 | width -= fmt->color(fmt, &hpp, entry); | 736 | width -= fmt->color(fmt, &hpp, entry); |
diff --git a/tools/perf/ui/gtk/hists.c b/tools/perf/ui/gtk/hists.c index d5c336e1bb14..2237245bfac0 100644 --- a/tools/perf/ui/gtk/hists.c +++ b/tools/perf/ui/gtk/hists.c | |||
@@ -43,7 +43,7 @@ static int perf_gtk__hpp_color_##_type(struct perf_hpp_fmt *fmt __maybe_unused, | |||
43 | struct perf_hpp *hpp, \ | 43 | struct perf_hpp *hpp, \ |
44 | struct hist_entry *he) \ | 44 | struct hist_entry *he) \ |
45 | { \ | 45 | { \ |
46 | return __hpp__fmt(hpp, he, he_get_##_field, NULL, " %6.2f%%", \ | 46 | return __hpp__fmt(hpp, he, he_get_##_field, " %6.2f%%", \ |
47 | __percent_color_snprintf, true); \ | 47 | __percent_color_snprintf, true); \ |
48 | } | 48 | } |
49 | 49 | ||
diff --git a/tools/perf/ui/hist.c b/tools/perf/ui/hist.c index 400437ee60b1..e7ac794382c1 100644 --- a/tools/perf/ui/hist.c +++ b/tools/perf/ui/hist.c | |||
@@ -16,20 +16,15 @@ | |||
16 | }) | 16 | }) |
17 | 17 | ||
18 | int __hpp__fmt(struct perf_hpp *hpp, struct hist_entry *he, | 18 | int __hpp__fmt(struct perf_hpp *hpp, struct hist_entry *he, |
19 | hpp_field_fn get_field, hpp_callback_fn callback, | 19 | hpp_field_fn get_field, const char *fmt, |
20 | const char *fmt, hpp_snprint_fn print_fn, bool fmt_percent) | 20 | hpp_snprint_fn print_fn, bool fmt_percent) |
21 | { | 21 | { |
22 | int ret = 0; | 22 | int ret; |
23 | struct hists *hists = he->hists; | 23 | struct hists *hists = he->hists; |
24 | struct perf_evsel *evsel = hists_to_evsel(hists); | 24 | struct perf_evsel *evsel = hists_to_evsel(hists); |
25 | char *buf = hpp->buf; | 25 | char *buf = hpp->buf; |
26 | size_t size = hpp->size; | 26 | size_t size = hpp->size; |
27 | 27 | ||
28 | if (callback) { | ||
29 | ret = callback(hpp, true); | ||
30 | advance_hpp(hpp, ret); | ||
31 | } | ||
32 | |||
33 | if (fmt_percent) { | 28 | if (fmt_percent) { |
34 | double percent = 0.0; | 29 | double percent = 0.0; |
35 | u64 total = hists__total_period(hists); | 30 | u64 total = hists__total_period(hists); |
@@ -37,9 +32,9 @@ int __hpp__fmt(struct perf_hpp *hpp, struct hist_entry *he, | |||
37 | if (total) | 32 | if (total) |
38 | percent = 100.0 * get_field(he) / total; | 33 | percent = 100.0 * get_field(he) / total; |
39 | 34 | ||
40 | ret += hpp__call_print_fn(hpp, print_fn, fmt, percent); | 35 | ret = hpp__call_print_fn(hpp, print_fn, fmt, percent); |
41 | } else | 36 | } else |
42 | ret += hpp__call_print_fn(hpp, print_fn, fmt, get_field(he)); | 37 | ret = hpp__call_print_fn(hpp, print_fn, fmt, get_field(he)); |
43 | 38 | ||
44 | if (perf_evsel__is_group_event(evsel)) { | 39 | if (perf_evsel__is_group_event(evsel)) { |
45 | int prev_idx, idx_delta; | 40 | int prev_idx, idx_delta; |
@@ -99,13 +94,6 @@ int __hpp__fmt(struct perf_hpp *hpp, struct hist_entry *he, | |||
99 | } | 94 | } |
100 | } | 95 | } |
101 | 96 | ||
102 | if (callback) { | ||
103 | int __ret = callback(hpp, false); | ||
104 | |||
105 | advance_hpp(hpp, __ret); | ||
106 | ret += __ret; | ||
107 | } | ||
108 | |||
109 | /* | 97 | /* |
110 | * Restore original buf and size as it's where caller expects | 98 | * Restore original buf and size as it's where caller expects |
111 | * the result will be saved. | 99 | * the result will be saved. |
@@ -235,7 +223,7 @@ static u64 he_get_##_field(struct hist_entry *he) \ | |||
235 | static int hpp__color_##_type(struct perf_hpp_fmt *fmt __maybe_unused, \ | 223 | static int hpp__color_##_type(struct perf_hpp_fmt *fmt __maybe_unused, \ |
236 | struct perf_hpp *hpp, struct hist_entry *he) \ | 224 | struct perf_hpp *hpp, struct hist_entry *he) \ |
237 | { \ | 225 | { \ |
238 | return __hpp__fmt(hpp, he, he_get_##_field, NULL, " %6.2f%%", \ | 226 | return __hpp__fmt(hpp, he, he_get_##_field, " %6.2f%%", \ |
239 | hpp_color_scnprintf, true); \ | 227 | hpp_color_scnprintf, true); \ |
240 | } | 228 | } |
241 | 229 | ||
@@ -244,7 +232,7 @@ static int hpp__entry_##_type(struct perf_hpp_fmt *_fmt __maybe_unused, \ | |||
244 | struct perf_hpp *hpp, struct hist_entry *he) \ | 232 | struct perf_hpp *hpp, struct hist_entry *he) \ |
245 | { \ | 233 | { \ |
246 | const char *fmt = symbol_conf.field_sep ? " %.2f" : " %6.2f%%"; \ | 234 | const char *fmt = symbol_conf.field_sep ? " %.2f" : " %6.2f%%"; \ |
247 | return __hpp__fmt(hpp, he, he_get_##_field, NULL, fmt, \ | 235 | return __hpp__fmt(hpp, he, he_get_##_field, fmt, \ |
248 | hpp_entry_scnprintf, true); \ | 236 | hpp_entry_scnprintf, true); \ |
249 | } | 237 | } |
250 | 238 | ||
@@ -264,7 +252,7 @@ static int hpp__entry_##_type(struct perf_hpp_fmt *_fmt __maybe_unused, \ | |||
264 | struct perf_hpp *hpp, struct hist_entry *he) \ | 252 | struct perf_hpp *hpp, struct hist_entry *he) \ |
265 | { \ | 253 | { \ |
266 | const char *fmt = symbol_conf.field_sep ? " %"PRIu64 : " %11"PRIu64; \ | 254 | const char *fmt = symbol_conf.field_sep ? " %"PRIu64 : " %11"PRIu64; \ |
267 | return __hpp__fmt(hpp, he, he_get_raw_##_field, NULL, fmt, \ | 255 | return __hpp__fmt(hpp, he, he_get_raw_##_field, fmt, \ |
268 | hpp_entry_scnprintf, false); \ | 256 | hpp_entry_scnprintf, false); \ |
269 | } | 257 | } |
270 | 258 | ||
diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h index e76d3232672c..76bb72e4302b 100644 --- a/tools/perf/util/hist.h +++ b/tools/perf/util/hist.h | |||
@@ -203,8 +203,8 @@ typedef int (*hpp_callback_fn)(struct perf_hpp *hpp, bool front); | |||
203 | typedef int (*hpp_snprint_fn)(struct perf_hpp *hpp, const char *fmt, ...); | 203 | typedef int (*hpp_snprint_fn)(struct perf_hpp *hpp, const char *fmt, ...); |
204 | 204 | ||
205 | int __hpp__fmt(struct perf_hpp *hpp, struct hist_entry *he, | 205 | int __hpp__fmt(struct perf_hpp *hpp, struct hist_entry *he, |
206 | hpp_field_fn get_field, hpp_callback_fn callback, | 206 | hpp_field_fn get_field, const char *fmt, |
207 | const char *fmt, hpp_snprint_fn print_fn, bool fmt_percent); | 207 | hpp_snprint_fn print_fn, bool fmt_percent); |
208 | 208 | ||
209 | static inline void advance_hpp(struct perf_hpp *hpp, int inc) | 209 | static inline void advance_hpp(struct perf_hpp *hpp, int inc) |
210 | { | 210 | { |