aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJiri Olsa <jolsa@kernel.org>2016-08-07 11:28:30 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2016-08-23 14:37:33 -0400
commit29659ab4e7d02c08d8f2d08db0b0f708bd8b6771 (patch)
tree797ba34474ca75fdbc80c7512f94b54411469f0f
parentf3705b062eafc2867eb0e9ee3502bd59564f103c (diff)
perf hists: Add support for header span
Add span argument for header callback function. The handling of this argument is completely in the hands of the callback. The only thing the caller ensures is it's zeroed on the beginning. Omitting span skipping in hierarchy headers and gtk code. The c2c code use this to span header lines based on the entries span configuration. 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/1470583710-1649-6-git-send-email-jolsa@kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r--tools/perf/builtin-diff.c3
-rw-r--r--tools/perf/ui/browsers/hists.c10
-rw-r--r--tools/perf/ui/gtk/hists.c2
-rw-r--r--tools/perf/ui/hist.c3
-rw-r--r--tools/perf/ui/stdio/hist.c13
-rw-r--r--tools/perf/util/hist.h2
-rw-r--r--tools/perf/util/sort.c6
7 files changed, 25 insertions, 14 deletions
diff --git a/tools/perf/builtin-diff.c b/tools/perf/builtin-diff.c
index 75da965df343..9ff0db4e2d0c 100644
--- a/tools/perf/builtin-diff.c
+++ b/tools/perf/builtin-diff.c
@@ -1034,7 +1034,8 @@ static int hpp__entry_global(struct perf_hpp_fmt *_fmt, struct perf_hpp *hpp,
1034 1034
1035static int hpp__header(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp, 1035static int hpp__header(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp,
1036 struct hists *hists __maybe_unused, 1036 struct hists *hists __maybe_unused,
1037 int line __maybe_unused) 1037 int line __maybe_unused,
1038 int *span __maybe_unused)
1038{ 1039{
1039 struct diff_hpp_fmt *dfmt = 1040 struct diff_hpp_fmt *dfmt =
1040 container_of(fmt, struct diff_hpp_fmt, fmt); 1041 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 4a7aac8ed5ee..22e48a3ebe29 100644
--- a/tools/perf/ui/browsers/hists.c
+++ b/tools/perf/ui/browsers/hists.c
@@ -1514,6 +1514,7 @@ hists_browser__scnprintf_headers(struct hist_browser *browser, char *buf,
1514 struct perf_hpp_fmt *fmt; 1514 struct perf_hpp_fmt *fmt;
1515 size_t ret = 0; 1515 size_t ret = 0;
1516 int column = 0; 1516 int column = 0;
1517 int span = 0;
1517 1518
1518 if (symbol_conf.use_callchain) { 1519 if (symbol_conf.use_callchain) {
1519 ret = scnprintf(buf, size, " "); 1520 ret = scnprintf(buf, size, " ");
@@ -1525,10 +1526,13 @@ hists_browser__scnprintf_headers(struct hist_browser *browser, char *buf,
1525 if (perf_hpp__should_skip(fmt, hists) || column++ < browser->b.horiz_scroll) 1526 if (perf_hpp__should_skip(fmt, hists) || column++ < browser->b.horiz_scroll)
1526 continue; 1527 continue;
1527 1528
1528 ret = fmt->header(fmt, &dummy_hpp, hists, line); 1529 ret = fmt->header(fmt, &dummy_hpp, hists, line, &span);
1529 if (advance_hpp_check(&dummy_hpp, ret)) 1530 if (advance_hpp_check(&dummy_hpp, ret))
1530 break; 1531 break;
1531 1532
1533 if (span)
1534 continue;
1535
1532 ret = scnprintf(dummy_hpp.buf, dummy_hpp.size, " "); 1536 ret = scnprintf(dummy_hpp.buf, dummy_hpp.size, " ");
1533 if (advance_hpp_check(&dummy_hpp, ret)) 1537 if (advance_hpp_check(&dummy_hpp, ret))
1534 break; 1538 break;
@@ -1562,7 +1566,7 @@ static int hists_browser__scnprintf_hierarchy_headers(struct hist_browser *brows
1562 if (column++ < browser->b.horiz_scroll) 1566 if (column++ < browser->b.horiz_scroll)
1563 continue; 1567 continue;
1564 1568
1565 ret = fmt->header(fmt, &dummy_hpp, hists, 0); 1569 ret = fmt->header(fmt, &dummy_hpp, hists, 0, NULL);
1566 if (advance_hpp_check(&dummy_hpp, ret)) 1570 if (advance_hpp_check(&dummy_hpp, ret))
1567 break; 1571 break;
1568 1572
@@ -1599,7 +1603,7 @@ static int hists_browser__scnprintf_hierarchy_headers(struct hist_browser *brows
1599 } 1603 }
1600 first_col = false; 1604 first_col = false;
1601 1605
1602 ret = fmt->header(fmt, &dummy_hpp, hists, 0); 1606 ret = fmt->header(fmt, &dummy_hpp, hists, 0, NULL);
1603 dummy_hpp.buf[ret] = '\0'; 1607 dummy_hpp.buf[ret] = '\0';
1604 1608
1605 start = trim(dummy_hpp.buf); 1609 start = trim(dummy_hpp.buf);
diff --git a/tools/perf/ui/gtk/hists.c b/tools/perf/ui/gtk/hists.c
index 79cb5c4d5e2e..a4f02de7c1b5 100644
--- a/tools/perf/ui/gtk/hists.c
+++ b/tools/perf/ui/gtk/hists.c
@@ -549,7 +549,7 @@ static void perf_gtk__show_hierarchy(GtkWidget *window, struct hists *hists,
549 strcat(buf, "+"); 549 strcat(buf, "+");
550 first_col = false; 550 first_col = false;
551 551
552 fmt->header(fmt, &hpp, hists, 0); 552 fmt->header(fmt, &hpp, hists, 0, NULL);
553 strcat(buf, ltrim(rtrim(hpp.buf))); 553 strcat(buf, ltrim(rtrim(hpp.buf)));
554 } 554 }
555 } 555 }
diff --git a/tools/perf/ui/hist.c b/tools/perf/ui/hist.c
index 30457c65980c..b47fafc8ee2a 100644
--- a/tools/perf/ui/hist.c
+++ b/tools/perf/ui/hist.c
@@ -230,7 +230,8 @@ static int hpp__width_fn(struct perf_hpp_fmt *fmt,
230} 230}
231 231
232static 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,
233 struct hists *hists, int line __maybe_unused) 233 struct hists *hists, int line __maybe_unused,
234 int *span __maybe_unused)
234{ 235{
235 int len = hpp__width_fn(fmt, hpp, hists); 236 int len = hpp__width_fn(fmt, hpp, hists);
236 return scnprintf(hpp->buf, hpp->size, "%*s", len, fmt->name); 237 return scnprintf(hpp->buf, hpp->size, "%*s", len, fmt->name);
diff --git a/tools/perf/ui/stdio/hist.c b/tools/perf/ui/stdio/hist.c
index 9b807cbb56b1..9b65f4a6b35a 100644
--- a/tools/perf/ui/stdio/hist.c
+++ b/tools/perf/ui/stdio/hist.c
@@ -549,7 +549,7 @@ static int print_hierarchy_header(struct hists *hists, struct perf_hpp *hpp,
549 struct perf_hpp_list_node, list); 549 struct perf_hpp_list_node, list);
550 550
551 perf_hpp_list__for_each_format(&fmt_node->hpp, fmt) { 551 perf_hpp_list__for_each_format(&fmt_node->hpp, fmt) {
552 fmt->header(fmt, hpp, hists, 0); 552 fmt->header(fmt, hpp, hists, 0, NULL);
553 fprintf(fp, "%s%s", hpp->buf, sep ?: " "); 553 fprintf(fp, "%s%s", hpp->buf, sep ?: " ");
554 } 554 }
555 555
@@ -569,7 +569,7 @@ static int print_hierarchy_header(struct hists *hists, struct perf_hpp *hpp,
569 header_width += fprintf(fp, "+"); 569 header_width += fprintf(fp, "+");
570 first_col = false; 570 first_col = false;
571 571
572 fmt->header(fmt, hpp, hists, 0); 572 fmt->header(fmt, hpp, hists, 0, NULL);
573 573
574 header_width += fprintf(fp, "%s", trim(hpp->buf)); 574 header_width += fprintf(fp, "%s", trim(hpp->buf));
575 } 575 }
@@ -645,18 +645,21 @@ static void fprintf_line(struct hists *hists, struct perf_hpp *hpp,
645 struct perf_hpp_fmt *fmt; 645 struct perf_hpp_fmt *fmt;
646 const char *sep = symbol_conf.field_sep; 646 const char *sep = symbol_conf.field_sep;
647 bool first = true; 647 bool first = true;
648 int span = 0;
648 649
649 hists__for_each_format(hists, fmt) { 650 hists__for_each_format(hists, fmt) {
650 if (perf_hpp__should_skip(fmt, hists)) 651 if (perf_hpp__should_skip(fmt, hists))
651 continue; 652 continue;
652 653
653 if (!first) 654 if (!first && !span)
654 fprintf(fp, "%s", sep ?: " "); 655 fprintf(fp, "%s", sep ?: " ");
655 else 656 else
656 first = false; 657 first = false;
657 658
658 fmt->header(fmt, hpp, hists, line); 659 fmt->header(fmt, hpp, hists, line, &span);
659 fprintf(fp, "%s", hpp->buf); 660
661 if (!span)
662 fprintf(fp, "%s", hpp->buf);
660 } 663 }
661} 664}
662 665
diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h
index 71a44c1c44de..a002c93fe422 100644
--- a/tools/perf/util/hist.h
+++ b/tools/perf/util/hist.h
@@ -230,7 +230,7 @@ struct perf_hpp {
230struct perf_hpp_fmt { 230struct perf_hpp_fmt {
231 const char *name; 231 const char *name;
232 int (*header)(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp, 232 int (*header)(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp,
233 struct hists *hists, int line); 233 struct hists *hists, int line, int *span);
234 int (*width)(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp, 234 int (*width)(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp,
235 struct hists *hists); 235 struct hists *hists);
236 int (*color)(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp, 236 int (*color)(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp,
diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
index a556de751018..5ae3d32a21d6 100644
--- a/tools/perf/util/sort.c
+++ b/tools/perf/util/sort.c
@@ -1492,7 +1492,8 @@ void perf_hpp__reset_sort_width(struct perf_hpp_fmt *fmt, struct hists *hists)
1492} 1492}
1493 1493
1494static int __sort__hpp_header(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp, 1494static int __sort__hpp_header(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp,
1495 struct hists *hists, int line __maybe_unused) 1495 struct hists *hists, int line __maybe_unused,
1496 int *span __maybe_unused)
1496{ 1497{
1497 struct hpp_sort_entry *hse; 1498 struct hpp_sort_entry *hse;
1498 size_t len = fmt->user_len; 1499 size_t len = fmt->user_len;
@@ -1798,7 +1799,8 @@ static void update_dynamic_len(struct hpp_dynamic_entry *hde,
1798 1799
1799static int __sort__hde_header(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp, 1800static int __sort__hde_header(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp,
1800 struct hists *hists __maybe_unused, 1801 struct hists *hists __maybe_unused,
1801 int line __maybe_unused) 1802 int line __maybe_unused,
1803 int *span __maybe_unused)
1802{ 1804{
1803 struct hpp_dynamic_entry *hde; 1805 struct hpp_dynamic_entry *hde;
1804 size_t len = fmt->user_len; 1806 size_t len = fmt->user_len;