aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/ui/browsers/annotate.c
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2012-04-02 11:59:01 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2012-04-07 15:09:05 -0400
commit058b4cc9af574c072988a38a7a5ee93df881e5aa (patch)
treeb43317d17d667aa54b20e0b363f1d2fb288e07e7 /tools/perf/util/ui/browsers/annotate.c
parent087091652bf8b351432a3f3fb50996ee3582d5e4 (diff)
perf annotate: Allow printing objdump line addr in different color
And by default use "magenta" for it. Both the --stdio and --tui routines follow the same semantics. 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-ede5zkaf7oorwvbqjezb4yg4@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/ui/browsers/annotate.c')
-rw-r--r--tools/perf/util/ui/browsers/annotate.c26
1 files changed, 21 insertions, 5 deletions
diff --git a/tools/perf/util/ui/browsers/annotate.c b/tools/perf/util/ui/browsers/annotate.c
index 57a4c6ef3fd2..7ac7dd04d5c6 100644
--- a/tools/perf/util/ui/browsers/annotate.c
+++ b/tools/perf/util/ui/browsers/annotate.c
@@ -16,6 +16,7 @@ struct annotate_browser {
16 struct rb_root entries; 16 struct rb_root entries;
17 struct rb_node *curr_hot; 17 struct rb_node *curr_hot;
18 struct objdump_line *selection; 18 struct objdump_line *selection;
19 u64 start;
19 int nr_asm_entries; 20 int nr_asm_entries;
20 int nr_entries; 21 int nr_entries;
21 bool hide_src_code; 22 bool hide_src_code;
@@ -51,6 +52,9 @@ static void annotate_browser__write(struct ui_browser *self, void *entry, int ro
51 struct annotate_browser *ab = container_of(self, struct annotate_browser, b); 52 struct annotate_browser *ab = container_of(self, struct annotate_browser, b);
52 struct objdump_line *ol = list_entry(entry, struct objdump_line, node); 53 struct objdump_line *ol = list_entry(entry, struct objdump_line, node);
53 bool current_entry = ui_browser__is_current_entry(self, row); 54 bool current_entry = ui_browser__is_current_entry(self, row);
55 bool change_color = (!ab->hide_src_code &&
56 (!current_entry || (self->use_navkeypressed &&
57 !self->navkeypressed)));
54 int width = self->width; 58 int width = self->width;
55 59
56 if (ol->offset != -1) { 60 if (ol->offset != -1) {
@@ -69,15 +73,26 @@ static void annotate_browser__write(struct ui_browser *self, void *entry, int ro
69 if (!self->navkeypressed) 73 if (!self->navkeypressed)
70 width += 1; 74 width += 1;
71 75
72 if (!ab->hide_src_code && ol->offset != -1) 76 if (ol->offset != -1 && change_color)
73 if (!current_entry || (self->use_navkeypressed && 77 ui_browser__set_color(self, HE_COLORSET_CODE);
74 !self->navkeypressed))
75 ui_browser__set_color(self, HE_COLORSET_CODE);
76 78
77 if (!*ol->line) 79 if (!*ol->line)
78 slsmg_write_nstring(" ", width - 18); 80 slsmg_write_nstring(" ", width - 18);
79 else 81 else if (ol->offset == -1)
80 slsmg_write_nstring(ol->line, width - 18); 82 slsmg_write_nstring(ol->line, width - 18);
83 else {
84 char bf[64];
85 u64 addr = ab->start + ol->offset;
86 int printed = scnprintf(bf, sizeof(bf), " %" PRIx64 ":", addr);
87 int color = -1;
88
89 if (change_color)
90 color = ui_browser__set_color(self, HE_COLORSET_ADDR);
91 slsmg_write_nstring(bf, printed);
92 if (change_color)
93 ui_browser__set_color(self, color);
94 slsmg_write_nstring(ol->line, width - 18 - printed);
95 }
81 96
82 if (current_entry) 97 if (current_entry)
83 ab->selection = ol; 98 ab->selection = ol;
@@ -406,6 +421,7 @@ int symbol__tui_annotate(struct symbol *sym, struct map *map, int evidx,
406 ui_helpline__push("Press <- or ESC to exit"); 421 ui_helpline__push("Press <- or ESC to exit");
407 422
408 notes = symbol__annotation(sym); 423 notes = symbol__annotation(sym);
424 browser.start = map__rip_2objdump(map, sym->start);
409 425
410 list_for_each_entry(pos, &notes->src->source, node) { 426 list_for_each_entry(pos, &notes->src->source, node) {
411 struct objdump_line_rb_node *rbpos; 427 struct objdump_line_rb_node *rbpos;