perf annotate: Move the column widths from the TUI to generic lib
tip-bot for Arnaldo Carvalho de Melo
merge botCommit-ID: 9761e86e36c0957e76c1b7c328953687a1a38655 Gitweb: https://git.kernel.org/tip/9761e86e36c0957e76c1b7c328953687a1a38655 Author: Arnaldo Carvalho de Melo <[email protected]> AuthorDate: Thu, 15 Mar 2018 16:18:21 -0300 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Tue, 20 Mar 2018 13:19:29 -0300
perf annotate: Move the column widths from the TUI to generic lib
This also will be used in other output formats, such as --stdio2.
Cc Adrian Hunter <[email protected]>
Cc Andi Kleen <[email protected]>
Cc David Ahern <[email protected]>
Cc Jin Yao <[email protected]>
Cc Jiri Olsa <[email protected]>
Cc Namhyung Kim <[email protected]>
Cc Wang Nan <[email protected]>
Signed-off-by Arnaldo Carvalho de Melo <[email protected]>
--- tools/perf/ui/browsers/annotate.c | 45 +++++++++++++++++---------------------- tools/perf/util/annotate.h | 7 ++++++ 2 files changed, 26 insertions(+), 26 deletions(-)
tools/perf/ui/browsers/annotate.c +19 -26
@@ -36,11 +36,6 @@ struct annotate_browser {struct annotation_line *selection;struct arch *arch;bool searching_backwards; -u8 addr_width; -u8 jumps_width; -u8 target_width; -u8 min_addr_width; -u8 max_addr_width;char search_bf[128 ]; };
@@ -194,10 +189,10 @@ static void annotate_browser__write(struct ui_browser *browser, void *entry, intelse if (al->offset ==-1 ) {if (al->line_nr && notes->options->show_linenr) printed =scnprintf (bf,sizeof (bf),"%-*d " , - ab->addr_width +1 , al->line_nr); + notes->widths.addr +1 , al->line_nr);else printed =scnprintf (bf,sizeof (bf),"%*s " , - ab->addr_width," " ); + notes->widths.addr," " );ui_browser__write_nstring (browser, bf, printed);ui_browser__write_nstring (browser, al->line, width - printed - pcnt_width - cycles_width +1 ); }else {
@@ -214,7 +209,7 @@ static void annotate_browser__write(struct ui_browser *browser, void *entry, intif (notes->options->show_nr_jumps) {int prev; printed =scnprintf (bf,sizeof (bf),"%*d " , - ab->jumps_width, + notes->widths.jumps, al->jump_sources); prev =ui_browser__set_jumps_percent_color (browser, al->jump_sources, current_entry);
@@ -223,10 +218,10 @@ static void annotate_browser__write(struct ui_browser *browser, void *entry, int } printed =scnprintf (bf,sizeof (bf),"%*" PRIx64": " , - ab->target_width, addr); + notes->widths.target, addr); }else { printed =scnprintf (bf,sizeof (bf),"%*s " , - ab->addr_width," " ); + notes->widths.addr," " ); } }
@@ -322,12 +317,12 @@ static void annotate_browser__draw_current_jump(struct ui_browser *browser)ui_browser__set_color (browser,HE_COLORSET_JUMP_ARROWS );__ui_browser__line_arrow (browser, - pcnt_width +2 + ab->addr_width + width, + pcnt_width +2 + notes->widths.addr + width, from, to);if (is_fused (ab, cursor)) {ui_browser__mark_fused (browser, - pcnt_width +3 + ab->addr_width + width, + pcnt_width +3 + notes->widths.addr + width, from -1 , to > from ? true : false); }
@@ -703,19 +698,17 @@ bool annotate_browser__continue_search_reverse(struct annotate_browser *browser,return __annotate_browser__search_reverse (browser); } -static void annotate_browser__update_addr_width (struct annotate_browser *browser) +static void annotation__update_column_widths (struct annotation *notes) { -struct annotation *notes =browser__annotation (&browser->b); -if (notes->options->use_offset) - browser->target_width = browser->min_addr_width; + notes->widths.target = notes->widths.min_addr;else - browser->target_width = browser->max_addr_width; + notes->widths.target = notes->widths.max_addr; - browser->addr_width = browser->target_width; + notes->widths.addr = notes->widths.target;if (notes->options->show_nr_jumps) - browser->addr_width += browser->jumps_width +1 ; + notes->widths.addr += notes->widths.jumps +1 ; } static int annotate_browser__run(struct annotate_browser *browser,
@@ -820,14 +813,14 @@ static int annotate_browser__run(struct annotate_browser *browser,continue ;case 'o' : notes->options->use_offset = !notes->options->use_offset; -annotate_browser__update_addr_width (browser); +annotation__update_column_widths (notes);continue ;case 'j' : notes->options->jump_arrows = !notes->options->jump_arrows;continue ;case 'J' : notes->options->show_nr_jumps = !notes->options->show_nr_jumps; -annotate_browser__update_addr_width (browser); +annotation__update_column_widths (notes);continue ;case '/' :if (annotate_browser__search (browser, delay_secs)) {
@@ -884,7 +877,7 @@ show_sup_ins: notes->options->show_nr_samples = false; else notes->options->show_total_period = true; -annotate_browser__update_addr_width (browser); +annotation__update_column_widths (notes);continue ;case K_LEFT :case K_ESC :
@@ -995,9 +988,9 @@ int symbol__tui_annotate(struct symbol *sym, struct map *map,annotation__mark_jump_targets (notes, sym);annotation__compute_ipc (notes, size); - browser.addr_width = browser.target_width = browser.min_addr_width =hex_width (size); - browser.max_addr_width =hex_width (sym->end); - browser.jumps_width =width_jumps (notes->max_jump_sources); + notes->widths.addr = notes->widths.target = notes->widths.min_addr =hex_width (size); + notes->widths.max_addr =hex_width (sym->end); + notes->widths.jumps =width_jumps (notes->max_jump_sources); notes->nr_events = nr_pcnt; browser.b.nr_entries = notes->nr_entries; browser.b.entries = ¬es->src->source,
@@ -1006,7 +999,7 @@ int symbol__tui_annotate(struct symbol *sym, struct map *map,if (notes->options->hide_src_code)ui_browser__init_asm_mode (&browser.b); -annotate_browser__update_addr_width (&browser); +annotation__update_column_widths (notes); ret =annotate_browser__run (&browser, evsel, hbt);
tools/perf/util/annotate.h +7 -0
@@ -178,6 +178,13 @@ struct annotation {int nr_entries;int nr_asm_entries;u16 max_line_len; +struct { +u8 addr; +u8 jumps; +u8 target; +u8 min_addr; +u8 max_addr; + } widths;bool have_cycles;struct annotated_source *src; };