diff options
| author | Jiri Olsa <jolsa@kernel.org> | 2016-06-20 17:58:15 -0400 |
|---|---|---|
| committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2016-06-22 08:56:34 -0400 |
| commit | 5b91a86f47669898d6f2fe625844ab65cf258c34 (patch) | |
| tree | 17af4b771a2f07b8fbea60e768d2174f4a447890 /tools/perf/ui | |
| parent | dabd201239b5a521c3a5406c86dd273f47f37f1a (diff) | |
perf hists browser: Introduce struct hist_browser title callback
We can now setup title callback for hist_browser, which will be useful
in following changes to create customized hist_browsers.
This also separates struct perf_evsel dependency out of hist_browser
basic code.
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1466459899-1166-5-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/ui')
| -rw-r--r-- | tools/perf/ui/browsers/hists.c | 21 | ||||
| -rw-r--r-- | tools/perf/ui/browsers/hists.h | 4 |
2 files changed, 17 insertions, 8 deletions
diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c index 539b69065d9d..a74cbd381607 100644 --- a/tools/perf/ui/browsers/hists.c +++ b/tools/perf/ui/browsers/hists.c | |||
| @@ -21,9 +21,8 @@ | |||
| 21 | 21 | ||
| 22 | extern void hist_browser__init_hpp(void); | 22 | extern void hist_browser__init_hpp(void); |
| 23 | 23 | ||
| 24 | static int hists__browser_title(struct hists *hists, | 24 | static int perf_evsel_browser_title(struct hist_browser *browser, |
| 25 | struct hist_browser_timer *hbt, | 25 | char *bf, size_t size); |
| 26 | char *bf, size_t size); | ||
| 27 | static void hist_browser__update_nr_entries(struct hist_browser *hb); | 26 | static void hist_browser__update_nr_entries(struct hist_browser *hb); |
| 28 | 27 | ||
| 29 | static struct rb_node *hists__filter_entries(struct rb_node *nd, | 28 | static struct rb_node *hists__filter_entries(struct rb_node *nd, |
| @@ -568,6 +567,11 @@ static void ui_browser__warn_lost_events(struct ui_browser *browser) | |||
| 568 | "Or reduce the sampling frequency."); | 567 | "Or reduce the sampling frequency."); |
| 569 | } | 568 | } |
| 570 | 569 | ||
| 570 | static int hist_browser__title(struct hist_browser *browser, char *bf, size_t size) | ||
| 571 | { | ||
| 572 | return browser->title ? browser->title(browser, bf, size) : 0; | ||
| 573 | } | ||
| 574 | |||
| 571 | int hist_browser__run(struct hist_browser *browser, const char *help) | 575 | int hist_browser__run(struct hist_browser *browser, const char *help) |
| 572 | { | 576 | { |
| 573 | int key; | 577 | int key; |
| @@ -578,7 +582,7 @@ int hist_browser__run(struct hist_browser *browser, const char *help) | |||
| 578 | browser->b.entries = &browser->hists->entries; | 582 | browser->b.entries = &browser->hists->entries; |
| 579 | browser->b.nr_entries = hist_browser__nr_entries(browser); | 583 | browser->b.nr_entries = hist_browser__nr_entries(browser); |
| 580 | 584 | ||
| 581 | hists__browser_title(browser->hists, hbt, title, sizeof(title)); | 585 | hist_browser__title(browser, title, sizeof(title)); |
| 582 | 586 | ||
| 583 | if (ui_browser__show(&browser->b, title, "%s", help) < 0) | 587 | if (ui_browser__show(&browser->b, title, "%s", help) < 0) |
| 584 | return -1; | 588 | return -1; |
| @@ -604,8 +608,7 @@ int hist_browser__run(struct hist_browser *browser, const char *help) | |||
| 604 | ui_browser__warn_lost_events(&browser->b); | 608 | ui_browser__warn_lost_events(&browser->b); |
| 605 | } | 609 | } |
| 606 | 610 | ||
| 607 | hists__browser_title(browser->hists, | 611 | hist_browser__title(browser, title, sizeof(title)); |
| 608 | hbt, title, sizeof(title)); | ||
| 609 | ui_browser__show_title(&browser->b, title); | 612 | ui_browser__show_title(&browser->b, title); |
| 610 | continue; | 613 | continue; |
| 611 | } | 614 | } |
| @@ -2054,6 +2057,7 @@ struct hist_browser *hist_browser__new(struct hists *hists, | |||
| 2054 | browser->show_headers = symbol_conf.show_hist_headers; | 2057 | browser->show_headers = symbol_conf.show_hist_headers; |
| 2055 | browser->hbt = hbt; | 2058 | browser->hbt = hbt; |
| 2056 | browser->env = env; | 2059 | browser->env = env; |
| 2060 | browser->title = perf_evsel_browser_title; | ||
| 2057 | } | 2061 | } |
| 2058 | 2062 | ||
| 2059 | return browser; | 2063 | return browser; |
| @@ -2080,10 +2084,11 @@ static inline bool is_report_browser(void *timer) | |||
| 2080 | return timer == NULL; | 2084 | return timer == NULL; |
| 2081 | } | 2085 | } |
| 2082 | 2086 | ||
| 2083 | static int hists__browser_title(struct hists *hists, | 2087 | static int perf_evsel_browser_title(struct hist_browser *browser, |
| 2084 | struct hist_browser_timer *hbt, | ||
| 2085 | char *bf, size_t size) | 2088 | char *bf, size_t size) |
| 2086 | { | 2089 | { |
| 2090 | struct hist_browser_timer *hbt = browser->hbt; | ||
| 2091 | struct hists *hists = browser->hists; | ||
| 2087 | char unit; | 2092 | char unit; |
| 2088 | int printed; | 2093 | int printed; |
| 2089 | const struct dso *dso = hists->dso_filter; | 2094 | const struct dso *dso = hists->dso_filter; |
diff --git a/tools/perf/ui/browsers/hists.h b/tools/perf/ui/browsers/hists.h index 57b7764800b7..cf9d04928ccc 100644 --- a/tools/perf/ui/browsers/hists.h +++ b/tools/perf/ui/browsers/hists.h | |||
| @@ -18,6 +18,10 @@ struct hist_browser { | |||
| 18 | u64 nr_non_filtered_entries; | 18 | u64 nr_non_filtered_entries; |
| 19 | u64 nr_hierarchy_entries; | 19 | u64 nr_hierarchy_entries; |
| 20 | u64 nr_callchain_rows; | 20 | u64 nr_callchain_rows; |
| 21 | |||
| 22 | /* Get title string. */ | ||
| 23 | int (*title)(struct hist_browser *browser, | ||
| 24 | char *bf, size_t size); | ||
| 21 | }; | 25 | }; |
| 22 | 26 | ||
| 23 | struct hist_browser *hist_browser__new(struct hists *hists, | 27 | struct hist_browser *hist_browser__new(struct hists *hists, |
