From b8b0d819858e1140e98ce858a0c839f3d03cb0f5 Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Thu, 15 Mar 2018 16:26:29 -0300 Subject: perf annotate: Introduce init_column_widths() method out of TUI code More non-TUI stuff goes to the UI-agnostic library Cc: Adrian Hunter Cc: Andi Kleen Cc: David Ahern Cc: Jin Yao Cc: Jiri Olsa Cc: Namhyung Kim Cc: Wang Nan Link: https://lkml.kernel.org/n/tip-hngv7rpqvtta69ouj7ne770q@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/annotate.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'tools/perf/util/annotate.c') diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index 8a2fda80a221..9c05b534f428 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c @@ -2084,6 +2084,23 @@ void annotation__set_offsets(struct annotation *notes, s64 size) } } +static inline int width_jumps(int n) +{ + if (n >= 100) + return 5; + if (n / 10) + return 2; + return 1; +} + +void annotation__init_column_widths(struct annotation *notes, struct symbol *sym) +{ + notes->widths.addr = notes->widths.target = + notes->widths.min_addr = hex_width(symbol__size(sym)); + notes->widths.max_addr = hex_width(sym->end); + notes->widths.jumps = width_jumps(notes->max_jump_sources); +} + void annotation__update_column_widths(struct annotation *notes) { if (notes->options->use_offset) -- cgit