perf tools: Add support for multiline headers and spans
Jiri Olsa
reviewercover perf tools: Add support for multiline headers and spans
hi,
the c2c output readability heavily depends on headers being displayed on multiple lines and allowing span of some headers over multiple columns, like:
# Total %All Total ----- Core Load Hit ----- -- LLC Load Hit -- ----- LLC Load Hitm -----
# Index Cacheline records Ld Miss %hitm Loads FB L1 L2 Llc Rmt Total Lcl Rmt
# ..... .................... ....... ....... ....... ....... ....... ....... ....... ........ ........ ....... ....... .......
#
0 0x7fbe65acee00 203 2.37% 3.34% 162 26 72 0 20 2 39 11 28I haven't found use for this under current perf code, so there's no actual current user in perf code of those features.
Also available in:
git://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf.git
perf/fixes
thanks,
jirka
---
Jiri Olsa (5):
perf tools: Introduce nr_header_lines into struct perf_hpp_list perf tools: Add line argument into perf_hpp_fmt's header callback perf tools tui: Display multiple header lines
perf tools stdio: Display multiple header lines
perf tools: Add support for header span
tools/perf/builtin-diff.c | 4 +++- tools/perf/ui/browsers/hists.c | 48 +++++++++++++++++++++++++++++++++++------------- tools/perf/ui/gtk/hists.c | 2 +- tools/perf/ui/hist.c | 4 +++- tools/perf/ui/stdio/hist.c | 45 ++++++++++++++++++++++++++++++++------------- tools/perf/util/hist.h | 3 ++- tools/perf/util/sort.c | 7 +++++-- 7 files changed, 81 insertions(+), 32 deletions(-)
Jiri Olsa
reviewerPATCH 1/5 perf tools: Introduce nr_header_lines into struct perf_hpp_list
Currently we support just single line for header, this is first step to allow more.
Store the number of header lines in perf_hpp_list, which encompasses all the display/sort entries and is thus suitable to hold this value.
--- tools/perf/ui/browsers/hists.c | 15 ++++++++++++--- tools/perf/ui/hist.c | 1 + tools/perf/util/hist.h | 1 + 3 files changed, 14 insertions(+), 3 deletions(-)
tools/perf/ui/browsers/hists.c +12 -3
@@ -69,8 +69,11 @@ static u32 hist_browser__nr_entries(struct hist_browser *hb)static void hist_browser__update_rows (struct hist_browser *hb) {struct ui_browser *browser = &hb->b; -u16 header_offset = hb->show_headers ?1 :0 , index_row; +struct hists *hists = hb->hists; +struct perf_hpp_list *hpp_list = hists->hpp_list; +u16 header_offset, index_row; + header_offset = hb->show_headers ? hpp_list->nr_header_lines :0 ; browser->rows = browser->height - header_offset;/* * Verify if we were at the last line and that line isn't
@@ -99,8 +102,11 @@ static void hist_browser__refresh_dimensions(struct ui_browser *browser)static void hist_browser__gotorc (struct hist_browser *browser,int row,int column) { -u16 header_offset = browser->show_headers ?1 :0 ; +struct hists *hists = browser->hists; +struct perf_hpp_list *hpp_list = hists->hpp_list; +u16 header_offset; + header_offset = browser->show_headers ? hpp_list->nr_header_lines :0 ;ui_browser__gotorc (&browser->b, row + header_offset, column); }
@@ -1656,10 +1662,13 @@ static unsigned int hist_browser__refresh(struct ui_browser *browser)u16 header_offset =0 ;struct rb_node *nd; struct hist_browser *hb = container_of(browser, struct hist_browser, b); +struct hists *hists = hb->hists;if (hb->show_headers) { +struct perf_hpp_list *hpp_list = hists->hpp_list; +hist_browser__show_headers (hb); - header_offset =1 ; + header_offset = hpp_list->nr_header_lines; }ui_browser__hists_init_top (browser);
tools/perf/ui/hist.c +1 -0
@@ -441,6 +441,7 @@ struct perf_hpp_fmt perf_hpp__format[] = {struct perf_hpp_list perf_hpp_list = { .fields =LIST_HEAD_INIT (perf_hpp_list.fields), .sorts =LIST_HEAD_INIT (perf_hpp_list.sorts), + .nr_header_lines =1 , };#undef HPP__COLOR_PRINT_FNS
tools/perf/util/hist.h +1 -0
@@ -259,6 +259,7 @@ struct perf_hpp_list {struct list_head fields;struct list_head sorts; +int nr_header_lines;int need_collapse;int parent;int sym;
Signature · 1 line
2.4.11
tip-bot for Jiri Olsa
merge bot[tip:perf/core] perf hists: Introduce nr_header_lines into struct perf_hpp_list
perf hists: Introduce nr_header_lines into struct perf_hpp_list
Commit-ID: f8e6710de859e1ac3a5df294bddeca19f60cec9a Gitweb: http://git.kernel.org/tip/f8e6710de859e1ac3a5df294bddeca19f60cec9a Author: Jiri Olsa <[email protected]> AuthorDate: Sun, 7 Aug 2016 17:28:26 +0200 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Tue, 23 Aug 2016 15:37:33 -0300
perf hists: Introduce nr_header_lines into struct perf_hpp_list
Currently we support just single line headers, this is first step to allow more.
Store the number of header lines in perf_hpp_list, which encompasses all the display/sort entries and is thus suitable to hold this value.
--- tools/perf/ui/browsers/hists.c | 15 ++++++++++++--- tools/perf/ui/hist.c | 1 + tools/perf/util/hist.h | 1 + 3 files changed, 14 insertions(+), 3 deletions(-)
tools/perf/ui/browsers/hists.c +12 -3
@@ -69,8 +69,11 @@ static u32 hist_browser__nr_entries(struct hist_browser *hb)static void hist_browser__update_rows (struct hist_browser *hb) {struct ui_browser *browser = &hb->b; -u16 header_offset = hb->show_headers ?1 :0 , index_row; +struct hists *hists = hb->hists; +struct perf_hpp_list *hpp_list = hists->hpp_list; +u16 header_offset, index_row; + header_offset = hb->show_headers ? hpp_list->nr_header_lines :0 ; browser->rows = browser->height - header_offset;/* * Verify if we were at the last line and that line isn't
@@ -99,8 +102,11 @@ static void hist_browser__refresh_dimensions(struct ui_browser *browser)static void hist_browser__gotorc (struct hist_browser *browser,int row,int column) { -u16 header_offset = browser->show_headers ?1 :0 ; +struct hists *hists = browser->hists; +struct perf_hpp_list *hpp_list = hists->hpp_list; +u16 header_offset; + header_offset = browser->show_headers ? hpp_list->nr_header_lines :0 ;ui_browser__gotorc (&browser->b, row + header_offset, column); }
@@ -1656,10 +1662,13 @@ static unsigned int hist_browser__refresh(struct ui_browser *browser)u16 header_offset =0 ;struct rb_node *nd; struct hist_browser *hb = container_of(browser, struct hist_browser, b); +struct hists *hists = hb->hists;if (hb->show_headers) { +struct perf_hpp_list *hpp_list = hists->hpp_list; +hist_browser__show_headers (hb); - header_offset =1 ; + header_offset = hpp_list->nr_header_lines; }ui_browser__hists_init_top (browser);
tools/perf/ui/hist.c +1 -0
@@ -441,6 +441,7 @@ struct perf_hpp_fmt perf_hpp__format[] = {struct perf_hpp_list perf_hpp_list = { .fields =LIST_HEAD_INIT (perf_hpp_list.fields), .sorts =LIST_HEAD_INIT (perf_hpp_list.sorts), + .nr_header_lines =1 , };#undef HPP__COLOR_PRINT_FNS
tools/perf/util/hist.h +1 -0
@@ -259,6 +259,7 @@ struct perf_hpp_list {struct list_head fields;struct list_head sorts; +int nr_header_lines;int need_collapse;int parent;int sym;
Jiri Olsa
reviewerPATCH 2/5 perf tools: Add line argument into perf_hpp_fmt's header callback
In reply to Jiri OlsaAdding line argument into perf_hpp_fmt's header
callback to be able to request specific header
line.
--- tools/perf/builtin-diff.c | 3 ++- tools/perf/ui/browsers/hists.c | 6 +++--- tools/perf/ui/gtk/hists.c | 2 +- tools/perf/ui/hist.c | 2 +- tools/perf/ui/stdio/hist.c | 6 +++--- tools/perf/util/hist.h | 2 +- tools/perf/util/sort.c | 5 +++-- 7 files changed, 14 insertions(+), 12 deletions(-)
tools/perf/builtin-diff.c +2 -1
@@ -1033,7 +1033,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 ) +struct hists *hists__maybe_unused , +int line__maybe_unused ) {struct diff_hpp_fmt *dfmt = container_of(fmt, struct diff_hpp_fmt, fmt);
tools/perf/ui/browsers/hists.c +3 -3
@@ -1523,7 +1523,7 @@ static int hists_browser__scnprintf_headers(struct hist_browser *browser, char *if (perf_hpp__should_skip (fmt, hists) || column++ < browser->b.horiz_scroll)continue ; - ret = fmt->header (fmt, &dummy_hpp, hists); + ret = fmt->header (fmt, &dummy_hpp, hists,0 );if (advance_hpp_check (&dummy_hpp, ret))break ;
@@ -1560,7 +1560,7 @@ static int hists_browser__scnprintf_hierarchy_headers(struct hist_browser *browsif (column++ < browser->b.horiz_scroll)continue ; - ret = fmt->header (fmt, &dummy_hpp, hists); + ret = fmt->header (fmt, &dummy_hpp, hists,0 );if (advance_hpp_check (&dummy_hpp, ret))break ;
@@ -1597,7 +1597,7 @@ static int hists_browser__scnprintf_hierarchy_headers(struct hist_browser *brows } first_col = false; - ret = fmt->header (fmt, &dummy_hpp, hists); + ret = fmt->header (fmt, &dummy_hpp, hists,0 ); dummy_hpp.buf[ret] ='\0' ; start =trim (dummy_hpp.buf);
tools/perf/ui/gtk/hists.c +1 -1
@@ -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); + fmt->header (fmt, &hpp, hists,0 );strcat (buf,ltrim (rtrim (hpp.buf))); } }
tools/perf/ui/hist.c +1 -1
@@ -230,7 +230,7 @@ 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) +struct hists *hists,int line__maybe_unused ) {int len =hpp__width_fn (fmt, hpp, hists);return scnprintf (hpp->buf, hpp->size,"%*s" , len, fmt->name);
tools/perf/ui/stdio/hist.c +3 -3
@@ -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); + fmt->header (fmt, hpp, hists,0 );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); + fmt->header (fmt, hpp, hists,0 ); header_width +=fprintf (fp,"%s" ,trim (hpp->buf)); }
@@ -658,7 +658,7 @@ hists__fprintf_standard_headers(struct hists *hists,else first = false; - fmt->header (fmt, hpp, hists); + fmt->header (fmt, hpp, hists,0 );fprintf (fp,"%s" , hpp->buf); }
tools/perf/util/hist.h +1 -1
@@ -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); +struct hists *hists,int line);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,
tools/perf/util/sort.c +3 -2
@@ -1488,7 +1488,7 @@ 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) +struct hists *hists,int line__maybe_unused ) {struct hpp_sort_entry *hse;size_t len = fmt->user_len;
@@ -1793,7 +1793,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 ) +struct hists *hists__maybe_unused , +int line__maybe_unused ) {struct hpp_dynamic_entry *hde;size_t len = fmt->user_len;
Signature · 1 line
2.4.11
tip-bot for Jiri Olsa
merge bot[tip:perf/core] perf hists: Add line argument into perf_hpp_fmt's header callback
perf hists: Add line argument into perf_hpp_fmt's header callback
Commit-ID: 74bb43f29ec80bc998804fa7399930d86c4bae67 Gitweb: http://git.kernel.org/tip/74bb43f29ec80bc998804fa7399930d86c4bae67 Author: Jiri Olsa <[email protected]> AuthorDate: Sun, 7 Aug 2016 17:28:27 +0200 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Tue, 23 Aug 2016 15:37:33 -0300
perf hists: Add line argument into perf_hpp_fmt's header callback
Adding line argument into perf_hpp_fmt's header callback to be able to request specific header line.
--- tools/perf/builtin-diff.c | 3 ++- tools/perf/ui/browsers/hists.c | 6 +++--- tools/perf/ui/gtk/hists.c | 2 +- tools/perf/ui/hist.c | 2 +- tools/perf/ui/stdio/hist.c | 6 +++--- tools/perf/util/hist.h | 2 +- tools/perf/util/sort.c | 5 +++-- 7 files changed, 14 insertions(+), 12 deletions(-)
tools/perf/builtin-diff.c +2 -1
@@ -1033,7 +1033,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 ) +struct hists *hists__maybe_unused , +int line__maybe_unused ) {struct diff_hpp_fmt *dfmt = container_of(fmt, struct diff_hpp_fmt, fmt);
tools/perf/ui/browsers/hists.c +3 -3
@@ -1523,7 +1523,7 @@ static int hists_browser__scnprintf_headers(struct hist_browser *browser, char *if (perf_hpp__should_skip (fmt, hists) || column++ < browser->b.horiz_scroll)continue ; - ret = fmt->header (fmt, &dummy_hpp, hists); + ret = fmt->header (fmt, &dummy_hpp, hists,0 );if (advance_hpp_check (&dummy_hpp, ret))break ;
@@ -1560,7 +1560,7 @@ static int hists_browser__scnprintf_hierarchy_headers(struct hist_browser *browsif (column++ < browser->b.horiz_scroll)continue ; - ret = fmt->header (fmt, &dummy_hpp, hists); + ret = fmt->header (fmt, &dummy_hpp, hists,0 );if (advance_hpp_check (&dummy_hpp, ret))break ;
@@ -1597,7 +1597,7 @@ static int hists_browser__scnprintf_hierarchy_headers(struct hist_browser *brows } first_col = false; - ret = fmt->header (fmt, &dummy_hpp, hists); + ret = fmt->header (fmt, &dummy_hpp, hists,0 ); dummy_hpp.buf[ret] ='\0' ; start =trim (dummy_hpp.buf);
tools/perf/ui/gtk/hists.c +1 -1
@@ -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); + fmt->header (fmt, &hpp, hists,0 );strcat (buf,ltrim (rtrim (hpp.buf))); } }
tools/perf/ui/hist.c +1 -1
@@ -230,7 +230,7 @@ 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) +struct hists *hists,int line__maybe_unused ) {int len =hpp__width_fn (fmt, hpp, hists);return scnprintf (hpp->buf, hpp->size,"%*s" , len, fmt->name);
tools/perf/ui/stdio/hist.c +3 -3
@@ -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); + fmt->header (fmt, hpp, hists,0 );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); + fmt->header (fmt, hpp, hists,0 ); header_width +=fprintf (fp,"%s" ,trim (hpp->buf)); }
@@ -658,7 +658,7 @@ hists__fprintf_standard_headers(struct hists *hists,else first = false; - fmt->header (fmt, hpp, hists); + fmt->header (fmt, hpp, hists,0 );fprintf (fp,"%s" , hpp->buf); }
tools/perf/util/hist.h +1 -1
@@ -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); +struct hists *hists,int line);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,
tools/perf/util/sort.c +3 -2
@@ -1492,7 +1492,7 @@ 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) +struct hists *hists,int line__maybe_unused ) {struct hpp_sort_entry *hse;size_t len = fmt->user_len;
@@ -1797,7 +1797,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 ) +struct hists *hists__maybe_unused , +int line__maybe_unused ) {struct hpp_dynamic_entry *hde;size_t len = fmt->user_len;
Jiri Olsa
reviewerPATCH 3/5 perf tools tui: Display multiple header lines
In reply to Jiri OlsaDisplay multiple header lines in TUI browser, if it's configured within struct perf_hpp_list::nr_header_lines.
--- tools/perf/ui/browsers/hists.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-)
tools/perf/ui/browsers/hists.c +17 -8
@@ -1502,7 +1502,9 @@ static int advance_hpp_check(struct perf_hpp *hpp, int inc)return hpp->size <=0 ; } -static int hists_browser__scnprintf_headers (struct hist_browser *browser,char *buf,size_t size) +static int +hists_browser__scnprintf_headers (struct hist_browser *browser,char *buf, +size_t size,int line) {struct hists *hists = browser->hists;struct perf_hpp dummy_hpp = {
@@ -1523,7 +1525,7 @@ static int hists_browser__scnprintf_headers(struct hist_browser *browser, char *if (perf_hpp__should_skip (fmt, hists) || column++ < browser->b.horiz_scroll)continue ; - ret = fmt->header (fmt, &dummy_hpp, hists,0 ); + ret = fmt->header (fmt, &dummy_hpp, hists, line);if (advance_hpp_check (&dummy_hpp, ret))break ;
@@ -1628,14 +1630,21 @@ static void hists_browser__hierarchy_headers(struct hist_browser *browser)static void hists_browser__headers (struct hist_browser *browser) { -char headers[1024 ]; +struct hists *hists = browser->hists; +struct perf_hpp_list *hpp_list = hists->hpp_list; -hists_browser__scnprintf_headers (browser, headers, -sizeof (headers)); +int line; -ui_browser__gotorc (&browser->b,0 ,0 ); -ui_browser__set_color (&browser->b,HE_COLORSET_ROOT ); -ui_browser__write_nstring (&browser->b, headers, browser->b.width +1 ); +for (line =0 ; line < hpp_list->nr_header_lines; line++) { +char headers[1024 ]; + +hists_browser__scnprintf_headers (browser, headers, +sizeof (headers), line); + +ui_browser__gotorc (&browser->b, line,0 ); +ui_browser__set_color (&browser->b,HE_COLORSET_ROOT ); +ui_browser__write_nstring (&browser->b, headers, browser->b.width +1 ); + } }static void hist_browser__show_headers (struct hist_browser *browser)
Signature · 1 line
2.4.11
tip-bot for Jiri Olsa
merge bot[tip:perf/core] perf tools tui: Display multiple header lines
perf tools tui: Display multiple header lines
Commit-ID: 69705b35859195b5640861fff91cc936d1baf4eb Gitweb: http://git.kernel.org/tip/69705b35859195b5640861fff91cc936d1baf4eb Author: Jiri Olsa <[email protected]> AuthorDate: Sun, 7 Aug 2016 17:28:28 +0200 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Tue, 23 Aug 2016 15:37:33 -0300
perf tools tui: Display multiple header lines
Display multiple header lines in TUI browser, if it's configured within struct perf_hpp_list::nr_header_lines.
--- tools/perf/ui/browsers/hists.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-)
tools/perf/ui/browsers/hists.c +17 -8
@@ -1502,7 +1502,9 @@ static int advance_hpp_check(struct perf_hpp *hpp, int inc)return hpp->size <=0 ; } -static int hists_browser__scnprintf_headers (struct hist_browser *browser,char *buf,size_t size) +static int +hists_browser__scnprintf_headers (struct hist_browser *browser,char *buf, +size_t size,int line) {struct hists *hists = browser->hists;struct perf_hpp dummy_hpp = {
@@ -1523,7 +1525,7 @@ static int hists_browser__scnprintf_headers(struct hist_browser *browser, char *if (perf_hpp__should_skip (fmt, hists) || column++ < browser->b.horiz_scroll)continue ; - ret = fmt->header (fmt, &dummy_hpp, hists,0 ); + ret = fmt->header (fmt, &dummy_hpp, hists, line);if (advance_hpp_check (&dummy_hpp, ret))break ;
@@ -1628,14 +1630,21 @@ static void hists_browser__hierarchy_headers(struct hist_browser *browser)static void hists_browser__headers (struct hist_browser *browser) { -char headers[1024 ]; +struct hists *hists = browser->hists; +struct perf_hpp_list *hpp_list = hists->hpp_list; -hists_browser__scnprintf_headers (browser, headers, -sizeof (headers)); +int line; -ui_browser__gotorc (&browser->b,0 ,0 ); -ui_browser__set_color (&browser->b,HE_COLORSET_ROOT ); -ui_browser__write_nstring (&browser->b, headers, browser->b.width +1 ); +for (line =0 ; line < hpp_list->nr_header_lines; line++) { +char headers[1024 ]; + +hists_browser__scnprintf_headers (browser, headers, +sizeof (headers), line); + +ui_browser__gotorc (&browser->b, line,0 ); +ui_browser__set_color (&browser->b,HE_COLORSET_ROOT ); +ui_browser__write_nstring (&browser->b, headers, browser->b.width +1 ); + } }static void hist_browser__show_headers (struct hist_browser *browser)
Jiri Olsa
reviewerPATCH 4/5 perf tools stdio: Display multiple header lines
In reply to Jiri OlsaDisplay multiple header lines in stdio output , if it's configured within struct perf_hpp_list::nr_header_lines.
--- tools/perf/ui/stdio/hist.c | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-)
tools/perf/ui/stdio/hist.c +25 -9
@@ -639,13 +639,10 @@ hists__fprintf_hierarchy_headers(struct hists *hists,return print_hierarchy_header (hists, hpp, symbol_conf.field_sep, fp); } -static int -hists__fprintf_standard_headers (struct hists *hists, -struct perf_hpp *hpp, -FILE *fp) +static void fprintf_line (struct hists *hists,struct perf_hpp *hpp, +int line,FILE *fp) {struct perf_hpp_fmt *fmt; -unsigned int width;const char *sep = symbol_conf.field_sep;bool first = true;
@@ -658,14 +655,33 @@ hists__fprintf_standard_headers(struct hists *hists,else first = false; - fmt->header (fmt, hpp, hists,0 ); + fmt->header (fmt, hpp, hists, line);fprintf (fp,"%s" , hpp->buf); } +} -fprintf (fp,"\n" ); +static int +hists__fprintf_standard_headers (struct hists *hists, +struct perf_hpp *hpp, +FILE *fp) +{ +struct perf_hpp_list *hpp_list = hists->hpp_list; +struct perf_hpp_fmt *fmt; +unsigned int width; +const char *sep = symbol_conf.field_sep; +bool first = true; +int line; + +for (line =0 ; line < hpp_list->nr_header_lines; line++) { +/* first # is displayed one level up */ +if (line) +fprintf (fp,"# " ); +fprintf_line (hists, hpp, line, fp); +fprintf (fp,"\n" ); + }if (sep) -return 1 ; +return hpp_list->nr_header_lines; first = true;
@@ -689,7 +705,7 @@ hists__fprintf_standard_headers(struct hists *hists,fprintf (fp,"\n" );fprintf (fp,"#\n" ); -return 3 ; +return hpp_list->nr_header_lines +2 ; }static int hists__fprintf_headers (struct hists *hists,FILE *fp)
Signature · 1 line
2.4.11
tip-bot for Jiri Olsa
merge bot[tip:perf/core] perf tools stdio: Display multiple header lines
perf tools stdio: Display multiple header lines
Commit-ID: f3705b062eafc2867eb0e9ee3502bd59564f103c Gitweb: http://git.kernel.org/tip/f3705b062eafc2867eb0e9ee3502bd59564f103c Author: Jiri Olsa <[email protected]> AuthorDate: Sun, 7 Aug 2016 17:28:29 +0200 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Tue, 23 Aug 2016 15:37:33 -0300
perf tools stdio: Display multiple header lines
Display multiple header lines in stdio output , if it's configured within struct perf_hpp_list::nr_header_lines.
--- tools/perf/ui/stdio/hist.c | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-)
tools/perf/ui/stdio/hist.c +25 -9
@@ -639,13 +639,10 @@ hists__fprintf_hierarchy_headers(struct hists *hists,return print_hierarchy_header (hists, hpp, symbol_conf.field_sep, fp); } -static int -hists__fprintf_standard_headers (struct hists *hists, -struct perf_hpp *hpp, -FILE *fp) +static void fprintf_line (struct hists *hists,struct perf_hpp *hpp, +int line,FILE *fp) {struct perf_hpp_fmt *fmt; -unsigned int width;const char *sep = symbol_conf.field_sep;bool first = true;
@@ -658,14 +655,33 @@ hists__fprintf_standard_headers(struct hists *hists,else first = false; - fmt->header (fmt, hpp, hists,0 ); + fmt->header (fmt, hpp, hists, line);fprintf (fp,"%s" , hpp->buf); } +} -fprintf (fp,"\n" ); +static int +hists__fprintf_standard_headers (struct hists *hists, +struct perf_hpp *hpp, +FILE *fp) +{ +struct perf_hpp_list *hpp_list = hists->hpp_list; +struct perf_hpp_fmt *fmt; +unsigned int width; +const char *sep = symbol_conf.field_sep; +bool first = true; +int line; + +for (line =0 ; line < hpp_list->nr_header_lines; line++) { +/* first # is displayed one level up */ +if (line) +fprintf (fp,"# " ); +fprintf_line (hists, hpp, line, fp); +fprintf (fp,"\n" ); + }if (sep) -return 1 ; +return hpp_list->nr_header_lines; first = true;
@@ -689,7 +705,7 @@ hists__fprintf_standard_headers(struct hists *hists,fprintf (fp,"\n" );fprintf (fp,"#\n" ); -return 3 ; +return hpp_list->nr_header_lines +2 ; }static int hists__fprintf_headers (struct hists *hists,FILE *fp)
Jiri Olsa
reviewerPATCH 5/5 perf tools: Add support for header span
In reply to Jiri OlsaAdd 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.
--- tools/perf/builtin-diff.c | 3 ++- tools/perf/ui/browsers/hists.c | 10 +++++++--- tools/perf/ui/gtk/hists.c | 2 +- tools/perf/ui/hist.c | 3 ++- tools/perf/ui/stdio/hist.c | 13 ++++++++----- tools/perf/util/hist.h | 2 +- tools/perf/util/sort.c | 6 ++++-- 7 files changed, 25 insertions(+), 14 deletions(-)
tools/perf/builtin-diff.c +2 -1
@@ -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);
tools/perf/ui/browsers/hists.c +7 -3
@@ -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 *browsif (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);
tools/perf/ui/gtk/hists.c +1 -1
@@ -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))); } }
tools/perf/ui/hist.c +2 -1
@@ -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);
tools/perf/ui/stdio/hist.c +8 -5
@@ -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); } }
tools/perf/util/hist.h +1 -1
@@ -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,
tools/perf/util/sort.c +4 -2
@@ -1488,7 +1488,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;
@@ -1794,7 +1795,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;
Signature · 1 line
2.4.11
tip-bot for Jiri Olsa
merge bot[tip:perf/core] perf hists: Add support for header span
perf hists: Add support for header span
Commit-ID: 29659ab4e7d02c08d8f2d08db0b0f708bd8b6771 Gitweb: http://git.kernel.org/tip/29659ab4e7d02c08d8f2d08db0b0f708bd8b6771 Author: Jiri Olsa <[email protected]> AuthorDate: Sun, 7 Aug 2016 17:28:30 +0200 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Tue, 23 Aug 2016 15:37:33 -0300
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.
--- tools/perf/builtin-diff.c | 3 ++- tools/perf/ui/browsers/hists.c | 10 +++++++--- tools/perf/ui/gtk/hists.c | 2 +- tools/perf/ui/hist.c | 3 ++- tools/perf/ui/stdio/hist.c | 13 ++++++++----- tools/perf/util/hist.h | 2 +- tools/perf/util/sort.c | 6 ++++-- 7 files changed, 25 insertions(+), 14 deletions(-)
tools/perf/builtin-diff.c +2 -1
@@ -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);
tools/perf/ui/browsers/hists.c +7 -3
@@ -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 *browsif (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);
tools/perf/ui/gtk/hists.c +1 -1
@@ -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))); } }
tools/perf/ui/hist.c +2 -1
@@ -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);
tools/perf/ui/stdio/hist.c +8 -5
@@ -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); } }
tools/perf/util/hist.h +1 -1
@@ -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,
tools/perf/util/sort.c +4 -2
@@ -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;