perf hists: Fix width computation for srcline sort entry
authorJiri Olsa <jolsa@kernel.org>
Mon, 19 Sep 2016 13:10:10 +0000 (15:10 +0200)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Tue, 20 Sep 2016 15:28:28 +0000 (12:28 -0300)
Adding header size to width computation for srcline sort entry,
because it's possible to get empty data with ':0' which set width
of 2 which is lower than width needed to display column header.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Don Zickus <dzickus@redhat.com>
Cc: Joe Mario <jmario@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1474290610-23241-62-git-send-email-jolsa@kernel.org
[ Added declaration to sort.h ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/hist.c
tools/perf/util/sort.h

index 37a08f20730af9b5eb6af41e84a5525b050030a6..b02992efb51383c06ce507adcba261100e101dd8 100644 (file)
@@ -177,8 +177,10 @@ void hists__calc_col_len(struct hists *hists, struct hist_entry *h)
        hists__new_col_len(hists, HISTC_LOCAL_WEIGHT, 12);
        hists__new_col_len(hists, HISTC_GLOBAL_WEIGHT, 12);
 
-       if (h->srcline)
-               hists__new_col_len(hists, HISTC_SRCLINE, strlen(h->srcline));
+       if (h->srcline) {
+               len = MAX(strlen(h->srcline), strlen(sort_srcline.se_header));
+               hists__new_col_len(hists, HISTC_SRCLINE, len);
+       }
 
        if (h->srcfile)
                hists__new_col_len(hists, HISTC_SRCFILE, strlen(h->srcfile));
index 28c0524c87026a213f6f2af95cc71bb6d30f251d..9505483cb95cbaf40a9082b46371a2e0287f91b9 100644 (file)
@@ -40,6 +40,7 @@ extern struct sort_entry sort_dso_from;
 extern struct sort_entry sort_dso_to;
 extern struct sort_entry sort_sym_from;
 extern struct sort_entry sort_sym_to;
+extern struct sort_entry sort_srcline;
 extern enum sort_type sort__first_dimension;
 extern const char default_mem_sort_order[];