aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJiri Olsa <jolsa@kernel.org>2016-06-14 14:19:20 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2016-06-15 09:50:04 -0400
commitda1b0407c866e7a8679cd3b64b35d83825c58a14 (patch)
treeb61bfc866505fb302348f9c39c2a14e3bfa93727
parent053721736011ee52e83b8e8794d922d1c511a4d3 (diff)
perf hists: Replace perf_evsel arg perf_hpp_fmt's width callback
Replacing perf_evsel arg perf_hpp_fmt's width callback with hists object. This will be helpful in future for non evsel related hist browsers. 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/1465928361-2442-11-git-send-email-jolsa@kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r--tools/perf/builtin-diff.c2
-rw-r--r--tools/perf/ui/browsers/hists.c2
-rw-r--r--tools/perf/ui/hist.c9
-rw-r--r--tools/perf/ui/stdio/hist.c6
-rw-r--r--tools/perf/util/hist.c2
-rw-r--r--tools/perf/util/hist.h2
-rw-r--r--tools/perf/util/sort.c6
7 files changed, 15 insertions, 14 deletions
diff --git a/tools/perf/builtin-diff.c b/tools/perf/builtin-diff.c
index b75ea770d443..7f628f9c2fb4 100644
--- a/tools/perf/builtin-diff.c
+++ b/tools/perf/builtin-diff.c
@@ -1056,7 +1056,7 @@ static int hpp__header(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp,
1056 1056
1057static int hpp__width(struct perf_hpp_fmt *fmt, 1057static int hpp__width(struct perf_hpp_fmt *fmt,
1058 struct perf_hpp *hpp __maybe_unused, 1058 struct perf_hpp *hpp __maybe_unused,
1059 struct perf_evsel *evsel __maybe_unused) 1059 struct hists *hists __maybe_unused)
1060{ 1060{
1061 struct diff_hpp_fmt *dfmt = 1061 struct diff_hpp_fmt *dfmt =
1062 container_of(fmt, struct diff_hpp_fmt, fmt); 1062 container_of(fmt, struct diff_hpp_fmt, fmt);
diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c
index c20425d7d9ae..b1b60544a545 100644
--- a/tools/perf/ui/browsers/hists.c
+++ b/tools/perf/ui/browsers/hists.c
@@ -1470,7 +1470,7 @@ static int hist_browser__show_no_entry(struct hist_browser *browser,
1470 column++ < browser->b.horiz_scroll) 1470 column++ < browser->b.horiz_scroll)
1471 continue; 1471 continue;
1472 1472
1473 ret = fmt->width(fmt, NULL, hists_to_evsel(browser->hists)); 1473 ret = fmt->width(fmt, NULL, browser->hists);
1474 1474
1475 if (first) { 1475 if (first) {
1476 /* for folded sign */ 1476 /* for folded sign */
diff --git a/tools/perf/ui/hist.c b/tools/perf/ui/hist.c
index 0b232d61310c..6940745aa77c 100644
--- a/tools/perf/ui/hist.c
+++ b/tools/perf/ui/hist.c
@@ -215,9 +215,10 @@ static int __hpp__sort_acc(struct hist_entry *a, struct hist_entry *b,
215 215
216static int hpp__width_fn(struct perf_hpp_fmt *fmt, 216static int hpp__width_fn(struct perf_hpp_fmt *fmt,
217 struct perf_hpp *hpp __maybe_unused, 217 struct perf_hpp *hpp __maybe_unused,
218 struct perf_evsel *evsel) 218 struct hists *hists)
219{ 219{
220 int len = fmt->user_len ?: fmt->len; 220 int len = fmt->user_len ?: fmt->len;
221 struct perf_evsel *evsel = hists_to_evsel(hists);
221 222
222 if (symbol_conf.event_group) 223 if (symbol_conf.event_group)
223 len = max(len, evsel->nr_members * fmt->len); 224 len = max(len, evsel->nr_members * fmt->len);
@@ -231,7 +232,7 @@ static int hpp__width_fn(struct perf_hpp_fmt *fmt,
231static int hpp__header_fn(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp, 232static int hpp__header_fn(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp,
232 struct hists *hists) 233 struct hists *hists)
233{ 234{
234 int len = hpp__width_fn(fmt, hpp, hists_to_evsel(hists)); 235 int len = hpp__width_fn(fmt, hpp, hists);
235 return scnprintf(hpp->buf, hpp->size, "%*s", len, fmt->name); 236 return scnprintf(hpp->buf, hpp->size, "%*s", len, fmt->name);
236} 237}
237 238
@@ -632,7 +633,7 @@ unsigned int hists__sort_list_width(struct hists *hists)
632 else 633 else
633 ret += 2; 634 ret += 2;
634 635
635 ret += fmt->width(fmt, &dummy_hpp, hists_to_evsel(hists)); 636 ret += fmt->width(fmt, &dummy_hpp, hists);
636 } 637 }
637 638
638 if (verbose && hists__has(hists, sym)) /* Addr + origin */ 639 if (verbose && hists__has(hists, sym)) /* Addr + origin */
@@ -657,7 +658,7 @@ unsigned int hists__overhead_width(struct hists *hists)
657 else 658 else
658 ret += 2; 659 ret += 2;
659 660
660 ret += fmt->width(fmt, &dummy_hpp, hists_to_evsel(hists)); 661 ret += fmt->width(fmt, &dummy_hpp, hists);
661 } 662 }
662 663
663 return ret; 664 return ret;
diff --git a/tools/perf/ui/stdio/hist.c b/tools/perf/ui/stdio/hist.c
index d0534fac46ae..f04a63112079 100644
--- a/tools/perf/ui/stdio/hist.c
+++ b/tools/perf/ui/stdio/hist.c
@@ -590,7 +590,7 @@ static int print_hierarchy_header(struct hists *hists, struct perf_hpp *hpp,
590 fprintf(fp, "%s", sep ?: ".."); 590 fprintf(fp, "%s", sep ?: "..");
591 first_col = false; 591 first_col = false;
592 592
593 width = fmt->width(fmt, hpp, hists_to_evsel(hists)); 593 width = fmt->width(fmt, hpp, hists);
594 fprintf(fp, "%.*s", width, dots); 594 fprintf(fp, "%.*s", width, dots);
595 } 595 }
596 596
@@ -607,7 +607,7 @@ static int print_hierarchy_header(struct hists *hists, struct perf_hpp *hpp,
607 width++; /* for '+' sign between column header */ 607 width++; /* for '+' sign between column header */
608 first_col = false; 608 first_col = false;
609 609
610 width += fmt->width(fmt, hpp, hists_to_evsel(hists)); 610 width += fmt->width(fmt, hpp, hists);
611 } 611 }
612 612
613 if (width > header_width) 613 if (width > header_width)
@@ -682,7 +682,7 @@ hists__fprintf_standard_headers(struct hists *hists,
682 else 682 else
683 first = false; 683 first = false;
684 684
685 width = fmt->width(fmt, hpp, hists_to_evsel(hists)); 685 width = fmt->width(fmt, hpp, hists);
686 for (i = 0; i < width; i++) 686 for (i = 0; i < width; i++)
687 fprintf(fp, "."); 687 fprintf(fp, ".");
688 } 688 }
diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c
index d1f19e0012d4..2515cfdb7365 100644
--- a/tools/perf/util/hist.c
+++ b/tools/perf/util/hist.c
@@ -1081,7 +1081,7 @@ int hist_entry__snprintf_alignment(struct hist_entry *he, struct perf_hpp *hpp,
1081 struct perf_hpp_fmt *fmt, int printed) 1081 struct perf_hpp_fmt *fmt, int printed)
1082{ 1082{
1083 if (!list_is_last(&fmt->list, &he->hists->hpp_list->fields)) { 1083 if (!list_is_last(&fmt->list, &he->hists->hpp_list->fields)) {
1084 const int width = fmt->width(fmt, hpp, hists_to_evsel(he->hists)); 1084 const int width = fmt->width(fmt, hpp, he->hists);
1085 if (printed < width) { 1085 if (printed < width) {
1086 advance_hpp(hpp, printed); 1086 advance_hpp(hpp, printed);
1087 printed = scnprintf(hpp->buf, hpp->size, "%-*s", width - printed, " "); 1087 printed = scnprintf(hpp->buf, hpp->size, "%-*s", width - printed, " ");
diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h
index aae932f9eb87..a19112872ff9 100644
--- a/tools/perf/util/hist.h
+++ b/tools/perf/util/hist.h
@@ -217,7 +217,7 @@ struct perf_hpp_fmt {
217 int (*header)(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp, 217 int (*header)(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp,
218 struct hists *hists); 218 struct hists *hists);
219 int (*width)(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp, 219 int (*width)(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp,
220 struct perf_evsel *evsel); 220 struct hists *hists);
221 int (*color)(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp, 221 int (*color)(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp,
222 struct hist_entry *he); 222 struct hist_entry *he);
223 int (*entry)(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp, 223 int (*entry)(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp,
diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
index 3e52c77981e3..896d34ebcc1e 100644
--- a/tools/perf/util/sort.c
+++ b/tools/perf/util/sort.c
@@ -1503,7 +1503,7 @@ static int __sort__hpp_header(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp,
1503 1503
1504static int __sort__hpp_width(struct perf_hpp_fmt *fmt, 1504static int __sort__hpp_width(struct perf_hpp_fmt *fmt,
1505 struct perf_hpp *hpp __maybe_unused, 1505 struct perf_hpp *hpp __maybe_unused,
1506 struct perf_evsel *evsel) 1506 struct hists *hists)
1507{ 1507{
1508 struct hpp_sort_entry *hse; 1508 struct hpp_sort_entry *hse;
1509 size_t len = fmt->user_len; 1509 size_t len = fmt->user_len;
@@ -1511,7 +1511,7 @@ static int __sort__hpp_width(struct perf_hpp_fmt *fmt,
1511 hse = container_of(fmt, struct hpp_sort_entry, hpp); 1511 hse = container_of(fmt, struct hpp_sort_entry, hpp);
1512 1512
1513 if (!len) 1513 if (!len)
1514 len = hists__col_len(evsel__hists(evsel), hse->se->se_width_idx); 1514 len = hists__col_len(hists, hse->se->se_width_idx);
1515 1515
1516 return len; 1516 return len;
1517} 1517}
@@ -1808,7 +1808,7 @@ static int __sort__hde_header(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp,
1808 1808
1809static int __sort__hde_width(struct perf_hpp_fmt *fmt, 1809static int __sort__hde_width(struct perf_hpp_fmt *fmt,
1810 struct perf_hpp *hpp __maybe_unused, 1810 struct perf_hpp *hpp __maybe_unused,
1811 struct perf_evsel *evsel __maybe_unused) 1811 struct hists *hists __maybe_unused)
1812{ 1812{
1813 struct hpp_dynamic_entry *hde; 1813 struct hpp_dynamic_entry *hde;
1814 size_t len = fmt->user_len; 1814 size_t len = fmt->user_len;