aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2012-04-19 12:15:24 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2012-04-19 12:15:24 -0400
commit61e04b332e9417720c331eb39c96a4ccb1aa0460 (patch)
treeb9968045de00bef1a6e8770a1d2053e1509a42be /tools
parentb793a40185b246c2690e06c6d86d12c35f24ab4c (diff)
perf annotate browser: Align jump labels
Find out at browser startup the max width and use it when rendering jump labels on the screen. Cc: David Ahern <dsahern@gmail.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Mike Galbraith <efault@gmx.de> Cc: Namhyung Kim <namhyung@gmail.com> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Stephane Eranian <eranian@google.com> Link: http://lkml.kernel.org/n/tip-7dxjiwqb77wz6f5lc05e0i0x@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/perf/ui/browsers/annotate.c17
-rw-r--r--tools/perf/util/util.c10
-rw-r--r--tools/perf/util/util.h2
3 files changed, 25 insertions, 4 deletions
diff --git a/tools/perf/ui/browsers/annotate.c b/tools/perf/ui/browsers/annotate.c
index a1e942bb903..c5ab21c50a7 100644
--- a/tools/perf/ui/browsers/annotate.c
+++ b/tools/perf/ui/browsers/annotate.c
@@ -31,6 +31,7 @@ struct annotate_browser {
31 bool hide_src_code; 31 bool hide_src_code;
32 bool use_offset; 32 bool use_offset;
33 bool searching_backwards; 33 bool searching_backwards;
34 u8 offset_width;
34 char search_bf[128]; 35 char search_bf[128];
35}; 36};
36 37
@@ -92,10 +93,17 @@ static void annotate_browser__write(struct ui_browser *self, void *entry, int ro
92 if (!ab->use_offset) 93 if (!ab->use_offset)
93 addr += ab->start; 94 addr += ab->start;
94 95
95 if (bdl->jump_target || !ab->use_offset) 96 if (!ab->use_offset) {
96 printed = scnprintf(bf, sizeof(bf), " %" PRIx64 ":", addr); 97 printed = scnprintf(bf, sizeof(bf), "%" PRIx64 ":", addr);
97 else 98 } else {
98 printed = scnprintf(bf, sizeof(bf), " "); 99 if (bdl->jump_target) {
100 printed = scnprintf(bf, sizeof(bf), "%*" PRIx64 ":",
101 ab->offset_width, addr);
102 } else {
103 printed = scnprintf(bf, sizeof(bf), "%*s ",
104 ab->offset_width, " ");
105 }
106 }
99 107
100 if (change_color) 108 if (change_color)
101 color = ui_browser__set_color(self, HE_COLORSET_ADDR); 109 color = ui_browser__set_color(self, HE_COLORSET_ADDR);
@@ -687,6 +695,7 @@ int symbol__tui_annotate(struct symbol *sym, struct map *map, int evidx,
687 695
688 annotate_browser__mark_jump_targets(&browser, size); 696 annotate_browser__mark_jump_targets(&browser, size);
689 697
698 browser.offset_width = hex_width(size);
690 browser.b.nr_entries = browser.nr_entries; 699 browser.b.nr_entries = browser.nr_entries;
691 browser.b.entries = &notes->src->source, 700 browser.b.entries = &notes->src->source,
692 browser.b.width += 18; /* Percentage */ 701 browser.b.width += 18; /* Percentage */
diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c
index 8109a907841..d03599fbe78 100644
--- a/tools/perf/util/util.c
+++ b/tools/perf/util/util.c
@@ -148,3 +148,13 @@ int readn(int fd, void *buf, size_t n)
148 148
149 return buf - buf_start; 149 return buf - buf_start;
150} 150}
151
152size_t hex_width(u64 v)
153{
154 size_t n = 1;
155
156 while ((v >>= 4))
157 ++n;
158
159 return n;
160}
diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h
index 0f99f394d8e..6121e24fefc 100644
--- a/tools/perf/util/util.h
+++ b/tools/perf/util/util.h
@@ -265,4 +265,6 @@ bool is_power_of_2(unsigned long n)
265 return (n != 0 && ((n & (n - 1)) == 0)); 265 return (n != 0 && ((n & (n - 1)) == 0));
266} 266}
267 267
268size_t hex_width(u64 v);
269
268#endif 270#endif