perf hists: Add support for header span
authorJiri Olsa <jolsa@kernel.org>
Sun, 7 Aug 2016 15:28:30 +0000 (17:28 +0200)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Tue, 23 Aug 2016 18:37:33 +0000 (15:37 -0300)
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>
tools/perf/builtin-diff.c
tools/perf/ui/browsers/hists.c
tools/perf/ui/gtk/hists.c
tools/perf/ui/hist.c
tools/perf/ui/stdio/hist.c
tools/perf/util/hist.h
tools/perf/util/sort.c

index 75da965df343c5e0dada434a09a8f1de9be161ed..9ff0db4e2d0cd1bcc35d2ea137871093ebfcb405 100644 (file)
@@ -1034,7 +1034,8 @@ static int hpp__entry_global(struct perf_hpp_fmt *_fmt, struct perf_hpp *hpp,
 
 static int hpp__header(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp,
                       struct hists *hists __maybe_unused,
-                      int line __maybe_unused)
+                      int line __maybe_unused,
+                      int *span __maybe_unused)
 {
        struct diff_hpp_fmt *dfmt =
                container_of(fmt, struct diff_hpp_fmt, fmt);
index 4a7aac8ed5ee90794a3554a83d49eaeddec68a05..22e48a3ebe2983cafb4b150f0dee1a73659df50b 100644 (file)
@@ -1514,6 +1514,7 @@ hists_browser__scnprintf_headers(struct hist_browser *browser, char *buf,
        struct perf_hpp_fmt *fmt;
        size_t ret = 0;
        int column = 0;
+       int span = 0;
 
        if (symbol_conf.use_callchain) {
                ret = scnprintf(buf, size, "  ");
@@ -1525,10 +1526,13 @@ hists_browser__scnprintf_headers(struct hist_browser *browser, char *buf,
                if (perf_hpp__should_skip(fmt, hists)  || column++ < browser->b.horiz_scroll)
                        continue;
 
-               ret = fmt->header(fmt, &dummy_hpp, hists, line);
+               ret = fmt->header(fmt, &dummy_hpp, hists, line, &span);
                if (advance_hpp_check(&dummy_hpp, ret))
                        break;
 
+               if (span)
+                       continue;
+
                ret = scnprintf(dummy_hpp.buf, dummy_hpp.size, "  ");
                if (advance_hpp_check(&dummy_hpp, ret))
                        break;
@@ -1562,7 +1566,7 @@ static int hists_browser__scnprintf_hierarchy_headers(struct hist_browser *brows
                if (column++ < browser->b.horiz_scroll)
                        continue;
 
-               ret = fmt->header(fmt, &dummy_hpp, hists, 0);
+               ret = fmt->header(fmt, &dummy_hpp, hists, 0, NULL);
                if (advance_hpp_check(&dummy_hpp, ret))
                        break;
 
@@ -1599,7 +1603,7 @@ static int hists_browser__scnprintf_hierarchy_headers(struct hist_browser *brows
                        }
                        first_col = false;
 
-                       ret = fmt->header(fmt, &dummy_hpp, hists, 0);
+                       ret = fmt->header(fmt, &dummy_hpp, hists, 0, NULL);
                        dummy_hpp.buf[ret] = '\0';
 
                        start = trim(dummy_hpp.buf);
index 79cb5c4d5e2e664d435eae191a39a7ef26048e8c..a4f02de7c1b54d426bb1b3f50b7fc2ba39ae5fa8 100644 (file)
@@ -549,7 +549,7 @@ static void perf_gtk__show_hierarchy(GtkWidget *window, struct hists *hists,
                                strcat(buf, "+");
                        first_col = false;
 
-                       fmt->header(fmt, &hpp, hists, 0);
+                       fmt->header(fmt, &hpp, hists, 0, NULL);
                        strcat(buf, ltrim(rtrim(hpp.buf)));
                }
        }
index 30457c65980cfe4929c05534d132876f6bfa7d9e..b47fafc8ee2aab20878cba272666fd878fd18458 100644 (file)
@@ -230,7 +230,8 @@ static int hpp__width_fn(struct perf_hpp_fmt *fmt,
 }
 
 static int hpp__header_fn(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp,
-                         struct hists *hists, int line __maybe_unused)
+                         struct hists *hists, int line __maybe_unused,
+                         int *span __maybe_unused)
 {
        int len = hpp__width_fn(fmt, hpp, hists);
        return scnprintf(hpp->buf, hpp->size, "%*s", len, fmt->name);
index 9b807cbb56b156701057553306a25f3fb44697fb..9b65f4a6b35a4b24877fac72e24e23a27ba10ae0 100644 (file)
@@ -549,7 +549,7 @@ static int print_hierarchy_header(struct hists *hists, struct perf_hpp *hpp,
                                    struct perf_hpp_list_node, list);
 
        perf_hpp_list__for_each_format(&fmt_node->hpp, fmt) {
-               fmt->header(fmt, hpp, hists, 0);
+               fmt->header(fmt, hpp, hists, 0, NULL);
                fprintf(fp, "%s%s", hpp->buf, sep ?: "  ");
        }
 
@@ -569,7 +569,7 @@ static int print_hierarchy_header(struct hists *hists, struct perf_hpp *hpp,
                                header_width += fprintf(fp, "+");
                        first_col = false;
 
-                       fmt->header(fmt, hpp, hists, 0);
+                       fmt->header(fmt, hpp, hists, 0, NULL);
 
                        header_width += fprintf(fp, "%s", trim(hpp->buf));
                }
@@ -645,18 +645,21 @@ static void fprintf_line(struct hists *hists, struct perf_hpp *hpp,
        struct perf_hpp_fmt *fmt;
        const char *sep = symbol_conf.field_sep;
        bool first = true;
+       int span = 0;
 
        hists__for_each_format(hists, fmt) {
                if (perf_hpp__should_skip(fmt, hists))
                        continue;
 
-               if (!first)
+               if (!first && !span)
                        fprintf(fp, "%s", sep ?: "  ");
                else
                        first = false;
 
-               fmt->header(fmt, hpp, hists, line);
-               fprintf(fp, "%s", hpp->buf);
+               fmt->header(fmt, hpp, hists, line, &span);
+
+               if (!span)
+                       fprintf(fp, "%s", hpp->buf);
        }
 }
 
index 71a44c1c44de469b269adce757930b098a741beb..a002c93fe422ff61ec1cfce66e46a2972812f3f8 100644 (file)
@@ -230,7 +230,7 @@ struct perf_hpp {
 struct perf_hpp_fmt {
        const char *name;
        int (*header)(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp,
-                     struct hists *hists, int line);
+                     struct hists *hists, int line, int *span);
        int (*width)(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp,
                     struct hists *hists);
        int (*color)(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp,
index a556de751018ad471986f007ae6224023db547f6..5ae3d32a21d66d6ebbefed0ff5ed896a70d232e0 100644 (file)
@@ -1492,7 +1492,8 @@ void perf_hpp__reset_sort_width(struct perf_hpp_fmt *fmt, struct hists *hists)
 }
 
 static int __sort__hpp_header(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp,
-                             struct hists *hists, int line __maybe_unused)
+                             struct hists *hists, int line __maybe_unused,
+                             int *span __maybe_unused)
 {
        struct hpp_sort_entry *hse;
        size_t len = fmt->user_len;
@@ -1798,7 +1799,8 @@ static void update_dynamic_len(struct hpp_dynamic_entry *hde,
 
 static int __sort__hde_header(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp,
                              struct hists *hists __maybe_unused,
-                             int line __maybe_unused)
+                             int line __maybe_unused,
+                             int *span __maybe_unused)
 {
        struct hpp_dynamic_entry *hde;
        size_t len = fmt->user_len;
This page took 0.029558 seconds and 5 git commands to generate.