diff options
author | Namhyung Kim <namhyung@kernel.org> | 2014-07-31 01:47:38 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2014-08-12 11:03:06 -0400 |
commit | 5b5916696051b88e63f3726cc3db44bf9561bad9 (patch) | |
tree | 432d11af8cf78cf56bbda7f8ffa33085fc1101e1 /tools/perf/ui | |
parent | e0d66c74b09f5103eef441a98b68056c4dae4cac (diff) |
perf report: Honor column width setting
Set column width and do not change it if user gives -w/--column-widths
option. It'll truncate longer symbols than the width if exists.
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung.kim@lge.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1406785662-5534-5-git-send-email-namhyung@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 | 18 | ||||
-rw-r--r-- | tools/perf/ui/gtk/hists.c | 10 | ||||
-rw-r--r-- | tools/perf/ui/hist.c | 84 | ||||
-rw-r--r-- | tools/perf/ui/stdio/hist.c | 4 |
4 files changed, 77 insertions, 39 deletions
diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c index c1d8d3925fe1..e07d4e848d5c 100644 --- a/tools/perf/ui/browsers/hists.c +++ b/tools/perf/ui/browsers/hists.c | |||
@@ -678,12 +678,12 @@ static u64 __hpp_get_##_field(struct hist_entry *he) \ | |||
678 | } \ | 678 | } \ |
679 | \ | 679 | \ |
680 | static int \ | 680 | static int \ |
681 | hist_browser__hpp_color_##_type(struct perf_hpp_fmt *fmt __maybe_unused,\ | 681 | hist_browser__hpp_color_##_type(struct perf_hpp_fmt *fmt, \ |
682 | struct perf_hpp *hpp, \ | 682 | struct perf_hpp *hpp, \ |
683 | struct hist_entry *he) \ | 683 | struct hist_entry *he) \ |
684 | { \ | 684 | { \ |
685 | return __hpp__fmt(hpp, he, __hpp_get_##_field, " %*.2f%%", 6, \ | 685 | return hpp__fmt(fmt, hpp, he, __hpp_get_##_field, " %*.2f%%", \ |
686 | __hpp__slsmg_color_printf, true); \ | 686 | __hpp__slsmg_color_printf, true); \ |
687 | } | 687 | } |
688 | 688 | ||
689 | #define __HPP_COLOR_ACC_PERCENT_FN(_type, _field) \ | 689 | #define __HPP_COLOR_ACC_PERCENT_FN(_type, _field) \ |
@@ -693,19 +693,20 @@ static u64 __hpp_get_acc_##_field(struct hist_entry *he) \ | |||
693 | } \ | 693 | } \ |
694 | \ | 694 | \ |
695 | static int \ | 695 | static int \ |
696 | hist_browser__hpp_color_##_type(struct perf_hpp_fmt *fmt __maybe_unused,\ | 696 | hist_browser__hpp_color_##_type(struct perf_hpp_fmt *fmt, \ |
697 | struct perf_hpp *hpp, \ | 697 | struct perf_hpp *hpp, \ |
698 | struct hist_entry *he) \ | 698 | struct hist_entry *he) \ |
699 | { \ | 699 | { \ |
700 | if (!symbol_conf.cumulate_callchain) { \ | 700 | if (!symbol_conf.cumulate_callchain) { \ |
701 | int len = fmt->user_len ?: fmt->len; \ | ||
701 | int ret = scnprintf(hpp->buf, hpp->size, \ | 702 | int ret = scnprintf(hpp->buf, hpp->size, \ |
702 | "%*s", 8, "N/A"); \ | 703 | "%*s", len, "N/A"); \ |
703 | slsmg_printf("%s", hpp->buf); \ | 704 | slsmg_printf("%s", hpp->buf); \ |
704 | \ | 705 | \ |
705 | return ret; \ | 706 | return ret; \ |
706 | } \ | 707 | } \ |
707 | return __hpp__fmt(hpp, he, __hpp_get_acc_##_field, " %*.2f%%", \ | 708 | return hpp__fmt(fmt, hpp, he, __hpp_get_acc_##_field, \ |
708 | 6, __hpp__slsmg_color_printf, true); \ | 709 | " %*.2f%%", __hpp__slsmg_color_printf, true); \ |
709 | } | 710 | } |
710 | 711 | ||
711 | __HPP_COLOR_PERCENT_FN(overhead, period) | 712 | __HPP_COLOR_PERCENT_FN(overhead, period) |
@@ -1549,6 +1550,9 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events, | |||
1549 | 1550 | ||
1550 | memset(options, 0, sizeof(options)); | 1551 | memset(options, 0, sizeof(options)); |
1551 | 1552 | ||
1553 | if (symbol_conf.col_width_list_str) | ||
1554 | perf_hpp__set_user_width(symbol_conf.col_width_list_str); | ||
1555 | |||
1552 | while (1) { | 1556 | while (1) { |
1553 | const struct thread *thread = NULL; | 1557 | const struct thread *thread = NULL; |
1554 | const struct dso *dso = NULL; | 1558 | const struct dso *dso = NULL; |
diff --git a/tools/perf/ui/gtk/hists.c b/tools/perf/ui/gtk/hists.c index 91f6cd7d2312..897b2e140428 100644 --- a/tools/perf/ui/gtk/hists.c +++ b/tools/perf/ui/gtk/hists.c | |||
@@ -41,12 +41,12 @@ static u64 he_get_##_field(struct hist_entry *he) \ | |||
41 | return he->stat._field; \ | 41 | return he->stat._field; \ |
42 | } \ | 42 | } \ |
43 | \ | 43 | \ |
44 | static int perf_gtk__hpp_color_##_type(struct perf_hpp_fmt *fmt __maybe_unused, \ | 44 | static int perf_gtk__hpp_color_##_type(struct perf_hpp_fmt *fmt, \ |
45 | struct perf_hpp *hpp, \ | 45 | struct perf_hpp *hpp, \ |
46 | struct hist_entry *he) \ | 46 | struct hist_entry *he) \ |
47 | { \ | 47 | { \ |
48 | return __hpp__fmt(hpp, he, he_get_##_field, " %*.2f%%", 6, \ | 48 | return hpp__fmt(fmt, hpp, he, he_get_##_field, " %*.2f%%", \ |
49 | __percent_color_snprintf, true); \ | 49 | __percent_color_snprintf, true); \ |
50 | } | 50 | } |
51 | 51 | ||
52 | #define __HPP_COLOR_ACC_PERCENT_FN(_type, _field) \ | 52 | #define __HPP_COLOR_ACC_PERCENT_FN(_type, _field) \ |
@@ -59,8 +59,8 @@ static int perf_gtk__hpp_color_##_type(struct perf_hpp_fmt *fmt __maybe_unused, | |||
59 | struct perf_hpp *hpp, \ | 59 | struct perf_hpp *hpp, \ |
60 | struct hist_entry *he) \ | 60 | struct hist_entry *he) \ |
61 | { \ | 61 | { \ |
62 | return __hpp__fmt_acc(hpp, he, he_get_acc_##_field, " %*.2f%%", 6, \ | 62 | return hpp__fmt_acc(fmt, hpp, he, he_get_acc_##_field, " %*.2f%%", \ |
63 | __percent_color_snprintf, true); \ | 63 | __percent_color_snprintf, true); \ |
64 | } | 64 | } |
65 | 65 | ||
66 | __HPP_COLOR_PERCENT_FN(overhead, period) | 66 | __HPP_COLOR_PERCENT_FN(overhead, period) |
diff --git a/tools/perf/ui/hist.c b/tools/perf/ui/hist.c index e28ca972d046..b2d60a95f01d 100644 --- a/tools/perf/ui/hist.c +++ b/tools/perf/ui/hist.c | |||
@@ -15,9 +15,9 @@ | |||
15 | __ret; \ | 15 | __ret; \ |
16 | }) | 16 | }) |
17 | 17 | ||
18 | int __hpp__fmt(struct perf_hpp *hpp, struct hist_entry *he, | 18 | static int __hpp__fmt(struct perf_hpp *hpp, struct hist_entry *he, |
19 | hpp_field_fn get_field, const char *fmt, int len, | 19 | hpp_field_fn get_field, const char *fmt, int len, |
20 | hpp_snprint_fn print_fn, bool fmt_percent) | 20 | hpp_snprint_fn print_fn, bool fmt_percent) |
21 | { | 21 | { |
22 | int ret; | 22 | int ret; |
23 | struct hists *hists = he->hists; | 23 | struct hists *hists = he->hists; |
@@ -104,16 +104,35 @@ int __hpp__fmt(struct perf_hpp *hpp, struct hist_entry *he, | |||
104 | return ret; | 104 | return ret; |
105 | } | 105 | } |
106 | 106 | ||
107 | int __hpp__fmt_acc(struct perf_hpp *hpp, struct hist_entry *he, | 107 | int hpp__fmt(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp, |
108 | hpp_field_fn get_field, const char *fmt, int len, | 108 | struct hist_entry *he, hpp_field_fn get_field, |
109 | hpp_snprint_fn print_fn, bool fmt_percent) | 109 | const char *fmtstr, hpp_snprint_fn print_fn, bool fmt_percent) |
110 | { | ||
111 | int len = fmt->user_len ?: fmt->len; | ||
112 | |||
113 | if (symbol_conf.field_sep) { | ||
114 | return __hpp__fmt(hpp, he, get_field, fmtstr, 1, | ||
115 | print_fn, fmt_percent); | ||
116 | } | ||
117 | |||
118 | if (fmt_percent) | ||
119 | len -= 2; /* 2 for a space and a % sign */ | ||
120 | else | ||
121 | len -= 1; | ||
122 | |||
123 | return __hpp__fmt(hpp, he, get_field, fmtstr, len, print_fn, fmt_percent); | ||
124 | } | ||
125 | |||
126 | int hpp__fmt_acc(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp, | ||
127 | struct hist_entry *he, hpp_field_fn get_field, | ||
128 | const char *fmtstr, hpp_snprint_fn print_fn, bool fmt_percent) | ||
110 | { | 129 | { |
111 | if (!symbol_conf.cumulate_callchain) { | 130 | if (!symbol_conf.cumulate_callchain) { |
112 | return snprintf(hpp->buf, hpp->size, "%*s", | 131 | int len = fmt->user_len ?: fmt->len; |
113 | fmt_percent ? len + 2 : len + 1, "N/A"); | 132 | return snprintf(hpp->buf, hpp->size, " %*s", len - 1, "N/A"); |
114 | } | 133 | } |
115 | 134 | ||
116 | return __hpp__fmt(hpp, he, get_field, fmt, len, print_fn, fmt_percent); | 135 | return hpp__fmt(fmt, hpp, he, get_field, fmtstr, print_fn, fmt_percent); |
117 | } | 136 | } |
118 | 137 | ||
119 | static int field_cmp(u64 field_a, u64 field_b) | 138 | static int field_cmp(u64 field_a, u64 field_b) |
@@ -195,10 +214,10 @@ static int hpp__width_##_type(struct perf_hpp_fmt *fmt, \ | |||
195 | struct perf_hpp *hpp __maybe_unused, \ | 214 | struct perf_hpp *hpp __maybe_unused, \ |
196 | struct perf_evsel *evsel) \ | 215 | struct perf_evsel *evsel) \ |
197 | { \ | 216 | { \ |
198 | int len = fmt->len; \ | 217 | int len = fmt->user_len ?: fmt->len; \ |
199 | \ | 218 | \ |
200 | if (symbol_conf.event_group) \ | 219 | if (symbol_conf.event_group) \ |
201 | len = max(len, evsel->nr_members * len); \ | 220 | len = max(len, evsel->nr_members * fmt->len); \ |
202 | \ | 221 | \ |
203 | if (len < (int)strlen(_str)) \ | 222 | if (len < (int)strlen(_str)) \ |
204 | len = strlen(_str); \ | 223 | len = strlen(_str); \ |
@@ -253,18 +272,16 @@ static u64 he_get_##_field(struct hist_entry *he) \ | |||
253 | static int hpp__color_##_type(struct perf_hpp_fmt *fmt, \ | 272 | static int hpp__color_##_type(struct perf_hpp_fmt *fmt, \ |
254 | struct perf_hpp *hpp, struct hist_entry *he) \ | 273 | struct perf_hpp *hpp, struct hist_entry *he) \ |
255 | { \ | 274 | { \ |
256 | int len = fmt->len - 2; /* 2 for a space and a % sign */ \ | 275 | return hpp__fmt(fmt, hpp, he, he_get_##_field, " %*.2f%%", \ |
257 | return __hpp__fmt(hpp, he, he_get_##_field, " %*.2f%%", len, \ | 276 | hpp_color_scnprintf, true); \ |
258 | hpp_color_scnprintf, true); \ | ||
259 | } | 277 | } |
260 | 278 | ||
261 | #define __HPP_ENTRY_PERCENT_FN(_type, _field) \ | 279 | #define __HPP_ENTRY_PERCENT_FN(_type, _field) \ |
262 | static int hpp__entry_##_type(struct perf_hpp_fmt *fmt, \ | 280 | static int hpp__entry_##_type(struct perf_hpp_fmt *fmt, \ |
263 | struct perf_hpp *hpp, struct hist_entry *he) \ | 281 | struct perf_hpp *hpp, struct hist_entry *he) \ |
264 | { \ | 282 | { \ |
265 | int len = symbol_conf.field_sep ? 1 : fmt->len - 2; \ | 283 | return hpp__fmt(fmt, hpp, he, he_get_##_field, " %*.2f%%", \ |
266 | return __hpp__fmt(hpp, he, he_get_##_field, " %*.2f%%", len, \ | 284 | hpp_entry_scnprintf, true); \ |
267 | hpp_entry_scnprintf, true); \ | ||
268 | } | 285 | } |
269 | 286 | ||
270 | #define __HPP_SORT_FN(_type, _field) \ | 287 | #define __HPP_SORT_FN(_type, _field) \ |
@@ -282,18 +299,16 @@ static u64 he_get_acc_##_field(struct hist_entry *he) \ | |||
282 | static int hpp__color_##_type(struct perf_hpp_fmt *fmt, \ | 299 | static int hpp__color_##_type(struct perf_hpp_fmt *fmt, \ |
283 | struct perf_hpp *hpp, struct hist_entry *he) \ | 300 | struct perf_hpp *hpp, struct hist_entry *he) \ |
284 | { \ | 301 | { \ |
285 | int len = fmt->len - 2; /* 2 for a space and a % sign */ \ | 302 | return hpp__fmt_acc(fmt, hpp, he, he_get_acc_##_field, " %*.2f%%", \ |
286 | return __hpp__fmt_acc(hpp, he, he_get_acc_##_field, " %*.2f%%", len, \ | 303 | hpp_color_scnprintf, true); \ |
287 | hpp_color_scnprintf, true); \ | ||
288 | } | 304 | } |
289 | 305 | ||
290 | #define __HPP_ENTRY_ACC_PERCENT_FN(_type, _field) \ | 306 | #define __HPP_ENTRY_ACC_PERCENT_FN(_type, _field) \ |
291 | static int hpp__entry_##_type(struct perf_hpp_fmt *fmt, \ | 307 | static int hpp__entry_##_type(struct perf_hpp_fmt *fmt, \ |
292 | struct perf_hpp *hpp, struct hist_entry *he) \ | 308 | struct perf_hpp *hpp, struct hist_entry *he) \ |
293 | { \ | 309 | { \ |
294 | int len = symbol_conf.field_sep ? 1 : fmt->len - 2; \ | 310 | return hpp__fmt_acc(fmt, hpp, he, he_get_##_field, " %*.2f%%", \ |
295 | return __hpp__fmt_acc(hpp, he, he_get_##_field, " %*.2f%%", len, \ | 311 | hpp_entry_scnprintf, true); \ |
296 | hpp_entry_scnprintf, true); \ | ||
297 | } | 312 | } |
298 | 313 | ||
299 | #define __HPP_SORT_ACC_FN(_type, _field) \ | 314 | #define __HPP_SORT_ACC_FN(_type, _field) \ |
@@ -311,9 +326,8 @@ static u64 he_get_raw_##_field(struct hist_entry *he) \ | |||
311 | static int hpp__entry_##_type(struct perf_hpp_fmt *fmt, \ | 326 | static int hpp__entry_##_type(struct perf_hpp_fmt *fmt, \ |
312 | struct perf_hpp *hpp, struct hist_entry *he) \ | 327 | struct perf_hpp *hpp, struct hist_entry *he) \ |
313 | { \ | 328 | { \ |
314 | int len = symbol_conf.field_sep ? 1 : fmt->len - 1; \ | 329 | return hpp__fmt(fmt, hpp, he, he_get_raw_##_field, " %*"PRIu64, \ |
315 | return __hpp__fmt(hpp, he, he_get_raw_##_field, " %*"PRIu64, len, \ | 330 | hpp_entry_scnprintf, false); \ |
316 | hpp_entry_scnprintf, false); \ | ||
317 | } | 331 | } |
318 | 332 | ||
319 | #define __HPP_SORT_RAW_FN(_type, _field) \ | 333 | #define __HPP_SORT_RAW_FN(_type, _field) \ |
@@ -666,3 +680,21 @@ void perf_hpp__reset_width(struct perf_hpp_fmt *fmt, struct hists *hists) | |||
666 | break; | 680 | break; |
667 | } | 681 | } |
668 | } | 682 | } |
683 | |||
684 | void perf_hpp__set_user_width(const char *width_list_str) | ||
685 | { | ||
686 | struct perf_hpp_fmt *fmt; | ||
687 | const char *ptr = width_list_str; | ||
688 | |||
689 | perf_hpp__for_each_format(fmt) { | ||
690 | char *p; | ||
691 | |||
692 | int len = strtol(ptr, &p, 10); | ||
693 | fmt->user_len = len; | ||
694 | |||
695 | if (*p == ',') | ||
696 | ptr = p + 1; | ||
697 | else | ||
698 | break; | ||
699 | } | ||
700 | } | ||
diff --git a/tools/perf/ui/stdio/hist.c b/tools/perf/ui/stdio/hist.c index 40af0acb4fe9..15b451acbde6 100644 --- a/tools/perf/ui/stdio/hist.c +++ b/tools/perf/ui/stdio/hist.c | |||
@@ -395,10 +395,12 @@ size_t hists__fprintf(struct hists *hists, bool show_header, int max_rows, | |||
395 | 395 | ||
396 | init_rem_hits(); | 396 | init_rem_hits(); |
397 | 397 | ||
398 | |||
399 | perf_hpp__for_each_format(fmt) | 398 | perf_hpp__for_each_format(fmt) |
400 | perf_hpp__reset_width(fmt, hists); | 399 | perf_hpp__reset_width(fmt, hists); |
401 | 400 | ||
401 | if (symbol_conf.col_width_list_str) | ||
402 | perf_hpp__set_user_width(symbol_conf.col_width_list_str); | ||
403 | |||
402 | if (!show_header) | 404 | if (!show_header) |
403 | goto print_entries; | 405 | goto print_entries; |
404 | 406 | ||